Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

builtin.h
Go to the documentation of this file.
1 #ifndef BUILTIN_H_INCLUDED
2 #define BUILTIN_H_INCLUDED
3
4 // invoke
5
6 struct rb_builtin_function {
7 // for invocation
8 const void * const func_ptr;
9 const int argc;
10
11 // for load
12 const int index;
13 const char * const name;
14 };
15
16 #define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity) { \
17 .name = #_name, \
18 .func_ptr = (void *)_fname, \
19 .argc = _arity, \
20 .index = _i \
21 }
22
23 void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table);
24
25 #ifndef VM_CORE_H_EC_DEFINED
26 typedef struct rb_execution_context_struct rb_execution_context_t;
27 #endif
28
29 /* The following code is generated by the following Ruby script:
30
31 16.times{|i|
32 args = (i > 0 ? ', ' : '') + (0...i).map{"VALUE"}.join(', ')
33 puts "static inline void rb_builtin_function_check_arity#{i}(VALUE (*f)(rb_execution_context_t *ec, VALUE self#{args})){}"
34 }
35 */
36
37 static inline void rb_builtin_function_check_arity0(VALUE (*f)(rb_execution_context_t *ec, VALUE self)){}
38 static inline void rb_builtin_function_check_arity1(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE)){}
39 static inline void rb_builtin_function_check_arity2(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE)){}
40 static inline void rb_builtin_function_check_arity3(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE)){}
41 static inline void rb_builtin_function_check_arity4(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE)){}
42 static inline void rb_builtin_function_check_arity5(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE)){}
43 static inline void rb_builtin_function_check_arity6(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
44 static inline void rb_builtin_function_check_arity7(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
45 static inline void rb_builtin_function_check_arity8(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
46 static inline void rb_builtin_function_check_arity9(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
47 static inline void rb_builtin_function_check_arity10(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
48 static inline void rb_builtin_function_check_arity11(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
49 static inline void rb_builtin_function_check_arity12(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
50 static inline void rb_builtin_function_check_arity13(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
51 static inline void rb_builtin_function_check_arity14(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
52 static inline void rb_builtin_function_check_arity15(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
53
54 VALUE rb_vm_lvar_exposed(rb_execution_context_t *ec, int index);
55
56 // __builtin_inline!
57
58 PUREFUNC(static inline VALUE rb_vm_lvar(rb_execution_context_t *ec, int index));
59
60 static inline VALUE
61 rb_vm_lvar(rb_execution_context_t *ec, int index)
62 {
63 #if VM_CORE_H_EC_DEFINED
64 return ec->cfp->ep[index];
65 #else
66 return rb_vm_lvar_exposed(ec, index);
67 #endif
68 }
69
70 // dump/load
71
72 struct builtin_binary {
73 const char *feature; // feature name
74 const unsigned char *bin; // binary by ISeq#to_binary
75 size_t bin_size;
76 };
77
78 #endif // BUILTIN_H_INCLUDED
rb_builtin_function
Definition: builtin.h:6
VALUE
unsigned long VALUE
Definition: ruby.h:102
index
int index
Definition: rb_mjit_min_header-2.7.0.h:11246
builtin_binary::bin
const unsigned char * bin
Definition: builtin.h:74
rb_builtin_function::index
const int index
Definition: builtin.h:12
builtin_binary::bin_size
size_t bin_size
Definition: builtin.h:75
rb_execution_context_struct::cfp
rb_control_frame_t * cfp
Definition: vm_core.h:847
PUREFUNC
PUREFUNC(static inline VALUE rb_vm_lvar(rb_execution_context_t *ec, int index))
rb_vm_lvar_exposed
VALUE rb_vm_lvar_exposed(rb_execution_context_t *ec, int index)
Definition: rb_mjit_min_header-2.7.0.h:17141
builtin_binary
Definition: builtin.h:72
rb_builtin_function::func_ptr
const void *const func_ptr
Definition: builtin.h:8
builtin_binary::feature
const char * feature
Definition: builtin.h:73
f
#define f
rb_control_frame_struct::ep
const VALUE * ep
Definition: vm_core.h:765
rb_builtin_function::argc
const int argc
Definition: builtin.h:9
rb_load_with_builtin_functions
void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table)
Definition: builtin.c:39
rb_builtin_function::name
const char *const name
Definition: builtin.h:13
rb_execution_context_struct
Definition: vm_core.h:843