Ruby: internal/vm.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

vm.h
Go to the documentation of this file.
1#ifndef INTERNAL_VM_H /*-*-C-*-vi:se ft=c:*/
2#define INTERNAL_VM_H
12#include "ruby/internal/stdbool.h" /* for bool */
13#include "internal/serial.h" /* for rb_serial_t */
14#include "internal/static_assert.h" /* for STATIC_ASSERT */
15#include "ruby/ruby.h" /* for ID */
16#include "ruby/st.h" /* for st_table */
17
18#ifdef rb_funcallv
19# undef rb_funcallv
20#endif
21
22#ifdef rb_method_basic_definition_p
23# undef rb_method_basic_definition_p
24#endif
25
26struct rb_callable_method_entry_struct; /* in method.h */
27struct rb_method_definition_struct; /* in method.h */
28struct rb_execution_context_struct; /* in vm_core.h */
29struct rb_control_frame_struct; /* in vm_core.h */
30struct rb_callinfo; /* in vm_core.h */
31
32 enum method_missing_reason {
33 MISSING_NOENTRY = 0x00,
34 MISSING_PRIVATE = 0x01,
35 MISSING_PROTECTED = 0x02,
36 MISSING_FCALL = 0x04,
37 MISSING_VCALL = 0x08,
38 MISSING_SUPER = 0x10,
39 MISSING_MISSING = 0x20,
40 MISSING_NONE = 0x40
41};
42
43/* vm_insnhelper.h */
44 rb_serial_t rb_next_class_serial(void);
45
46/* vm.c */
47 VALUE rb_obj_is_thread(VALUE obj);
48void rb_vm_mark(void *ptr);
49void rb_vm_each_stack_value(void *ptr, void (*cb)(VALUE, void*), void *ctx);
50 PUREFUNC(VALUE rb_vm_top_self(void));
51void rb_vm_inc_const_missing_count(void);
52const void **rb_vm_get_insns_address_table(void);
53 VALUE rb_source_location(int *pline);
54const char *rb_source_location_cstr(int *pline);
55 MJIT_STATIC void rb_vm_pop_cfunc_frame(void);
56int rb_vm_add_root_module(VALUE module);
57void rb_vm_check_redefinition_by_prepend(VALUE klass);
58int rb_vm_check_optimizable_mid(VALUE mid);
59 VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);
60 MJIT_STATIC VALUE ruby_vm_special_exception_copy(VALUE);
61 PUREFUNC(st_table *rb_vm_fstring_table(void));
62
63 MJIT_SYMBOL_EXPORT_BEGIN
64 VALUE vm_exec(struct rb_execution_context_struct *, bool); /* used in JIT-ed code */
65 MJIT_SYMBOL_EXPORT_END
66
67/* vm_eval.c */
68 VALUE rb_current_realfilepath(void);
69 VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE);
70 typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
71 VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
72 rb_check_funcall_hook *hook, VALUE arg);
73 VALUE rb_check_funcall_with_hook_kw(VALUE recv, ID mid, int argc, const VALUE *argv,
74 rb_check_funcall_hook *hook, VALUE arg, int kw_splat);
75const char *rb_type_str(enum ruby_value_type type);
76 VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE);
77 VALUE rb_check_funcall_basic_kw(VALUE, ID, VALUE, int, const VALUE*, int);
78 VALUE rb_yield_1(VALUE val);
79 VALUE rb_yield_force_blockarg(VALUE values);
80 VALUE rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv,
81 rb_block_call_func_t bl_proc, int min_argc, int max_argc,
82 VALUE data2);
83void rb_check_stack_overflow(void);
84
85/* vm_insnhelper.c */
86 VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
87 VALUE rb_eql_opt(VALUE obj1, VALUE obj2);
88
89struct rb_iseq_struct;
90 MJIT_SYMBOL_EXPORT_BEGIN
91const struct rb_callcache *rb_vm_search_method_slowpath(const struct rb_callinfo *ci, VALUE klass);
92 MJIT_SYMBOL_EXPORT_END
93
94/* vm_method.c */
95struct rb_execution_context_struct;
96 MJIT_SYMBOL_EXPORT_BEGIN
97int rb_ec_obj_respond_to(struct rb_execution_context_struct *ec, VALUE obj, ID id, int priv);
98 MJIT_SYMBOL_EXPORT_END
99
100/* vm_dump.c */
101void rb_print_backtrace(void);
102
103/* vm_backtrace.c */
104 VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval);
105 VALUE rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval);
106 VALUE rb_vm_backtrace(int argc, const VALUE * argv, struct rb_execution_context_struct * ec);
107 VALUE rb_vm_backtrace_locations(int argc, const VALUE * argv, struct rb_execution_context_struct * ec);
108 VALUE rb_make_backtrace(void);
109void rb_backtrace_print_as_bugreport(void);
110int rb_backtrace_p(VALUE obj);
111 VALUE rb_backtrace_to_str_ary(VALUE obj);
112 VALUE rb_backtrace_to_location_ary(VALUE obj);
113void rb_backtrace_each(VALUE (*iter)(VALUE recv, VALUE str), VALUE output);
114
115 MJIT_SYMBOL_EXPORT_BEGIN
116 VALUE rb_ec_backtrace_object(const struct rb_execution_context_struct *ec);
117void rb_backtrace_use_iseq_first_lineno_for_last_location(VALUE self);
118 MJIT_SYMBOL_EXPORT_END
119
120#define RUBY_DTRACE_CREATE_HOOK(name, arg) \
121 RUBY_DTRACE_HOOK(name##_CREATE, arg)
122#define RUBY_DTRACE_HOOK(name, arg) \
123do { \
124 if (UNLIKELY(RUBY_DTRACE_##name##_ENABLED())) { \
125 int dtrace_line; \
126 const char *dtrace_file = rb_source_location_cstr(&dtrace_line); \
127 if (!dtrace_file) dtrace_file = ""; \
128 RUBY_DTRACE_##name(arg, dtrace_file, dtrace_line); \
129 } \
130} while (0)
131#endif /* INTERNAL_VM_H */
PUREFUNC
#define PUREFUNC(x)
Definition: attributes.h:54
ptr
struct RIMemo * ptr
Definition: debug.c:88
MJIT_SYMBOL_EXPORT_END
#define MJIT_SYMBOL_EXPORT_END
Definition: dllexport.h:63
MJIT_STATIC
#define MJIT_STATIC
Definition: dllexport.h:71
MJIT_SYMBOL_EXPORT_BEGIN
#define MJIT_SYMBOL_EXPORT_BEGIN
Definition: dllexport.h:62
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
rb_print_backtrace
void rb_print_backtrace(void)
Definition: vm_dump.c:753
rb_backtrace_to_str_ary
VALUE rb_backtrace_to_str_ary(VALUE obj)
Definition: vm_backtrace.c:809
rb_backtrace_each
void rb_backtrace_each(VALUE(*iter)(VALUE recv, VALUE str), VALUE output)
Definition: vm_backtrace.c:1039
rb_vm_backtrace_locations
VALUE rb_vm_backtrace_locations(int argc, const VALUE *argv, struct rb_execution_context_struct *ec)
Definition: vm_backtrace.c:1167
rb_yield_1
VALUE rb_yield_1(VALUE val)
Definition: vm_eval.c:1335
rb_check_funcall_basic_kw
VALUE rb_check_funcall_basic_kw(VALUE, ID, VALUE, int, const VALUE *, int)
Calls a method only if it is the basic method of ancestor otherwise returns Qundef;.
Definition: vm_eval.c:1111
rb_check_block_call
VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE)
Definition: vm_eval.c:1625
rb_vm_get_insns_address_table
const void ** rb_vm_get_insns_address_table(void)
Definition: vm_exec.c:153
rb_ec_obj_respond_to
int rb_ec_obj_respond_to(struct rb_execution_context_struct *ec, VALUE obj, ID id, int priv)
Definition: vm_method.c:2552
rb_check_funcall_hook
void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE)
Definition: vm.h:70
rb_vm_add_root_module
int rb_vm_add_root_module(VALUE module)
Definition: vm.c:2622
rb_vm_backtrace
VALUE rb_vm_backtrace(int argc, const VALUE *argv, struct rb_execution_context_struct *ec)
Definition: vm_backtrace.c:1162
rb_backtrace_print_as_bugreport
void rb_backtrace_print_as_bugreport(void)
Definition: vm_backtrace.c:994
rb_vm_top_self
VALUE rb_vm_top_self(void)
Definition: vm.c:3752
rb_type_str
const char * rb_type_str(enum ruby_value_type type)
Definition: vm_eval.c:686
rb_vm_check_optimizable_mid
int rb_vm_check_optimizable_mid(VALUE mid)
Definition: vm.c:1823
rb_vm_each_stack_value
void rb_vm_each_stack_value(void *ptr, void(*cb)(VALUE, void *), void *ctx)
Definition: vm.c:2501
rb_eql_opt
VALUE rb_eql_opt(VALUE obj1, VALUE obj2)
Definition: vm_insnhelper.c:2016
rb_vm_fstring_table
st_table * rb_vm_fstring_table(void)
Definition: vm.c:3787
ruby_vm_special_exception_copy
VALUE ruby_vm_special_exception_copy(VALUE)
Definition: vm_insnhelper.c:48
rb_obj_is_thread
VALUE rb_obj_is_thread(VALUE obj)
Definition: vm.c:3003
rb_vm_mark
void rb_vm_mark(void *ptr)
Definition: vm.c:2538
rb_backtrace_p
int rb_backtrace_p(VALUE obj)
Definition: vm_backtrace.c:471
rb_yield_refine_block
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements)
Definition: vm_eval.c:1980
rb_equal_opt
VALUE rb_equal_opt(VALUE obj1, VALUE obj2)
Definition: vm_insnhelper.c:2010
rb_backtrace_to_location_ary
VALUE rb_backtrace_to_location_ary(VALUE obj)
Definition: vm_backtrace.c:864
rb_vm_check_redefinition_by_prepend
void rb_vm_check_redefinition_by_prepend(VALUE klass)
Definition: vm.c:1873
rb_next_class_serial
rb_serial_t rb_next_class_serial(void)
Definition: vm.c:366
rb_vm_thread_backtrace
VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval)
Definition: vm_backtrace.c:1151
rb_yield_force_blockarg
VALUE rb_yield_force_blockarg(VALUE values)
Definition: vm_eval.c:1413
rb_check_funcall_default
VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE)
Definition: vm_eval.c:647
rb_check_funcall_with_hook_kw
VALUE rb_check_funcall_with_hook_kw(VALUE recv, ID mid, int argc, const VALUE *argv, rb_check_funcall_hook *hook, VALUE arg, int kw_splat)
Definition: vm_eval.c:653
rb_check_funcall_with_hook
VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv, rb_check_funcall_hook *hook, VALUE arg)
Definition: vm_eval.c:679
rb_lambda_call
VALUE rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t bl_proc, int min_argc, int max_argc, VALUE data2)
Definition: vm_eval.c:1598
rb_check_stack_overflow
void rb_check_stack_overflow(void)
Definition: vm_eval.c:331
rb_backtrace_use_iseq_first_lineno_for_last_location
void rb_backtrace_use_iseq_first_lineno_for_last_location(VALUE self)
Definition: vm_backtrace.c:821
rb_vm_search_method_slowpath
const struct rb_callcache * rb_vm_search_method_slowpath(const struct rb_callinfo *ci, VALUE klass)
Definition: vm_insnhelper.c:1729
method_missing_reason
method_missing_reason
Definition: vm.h:32
MISSING_SUPER
@ MISSING_SUPER
Definition: vm.h:38
MISSING_VCALL
@ MISSING_VCALL
Definition: vm.h:37
MISSING_PRIVATE
@ MISSING_PRIVATE
Definition: vm.h:34
MISSING_PROTECTED
@ MISSING_PROTECTED
Definition: vm.h:35
MISSING_NOENTRY
@ MISSING_NOENTRY
Definition: vm.h:33
MISSING_NONE
@ MISSING_NONE
Definition: vm.h:40
MISSING_MISSING
@ MISSING_MISSING
Definition: vm.h:39
MISSING_FCALL
@ MISSING_FCALL
Definition: vm.h:36
rb_source_location_cstr
const char * rb_source_location_cstr(int *pline)
Definition: vm.c:1616
rb_source_location
VALUE rb_source_location(int *pline)
Definition: vm.c:1600
rb_vm_pop_cfunc_frame
void rb_vm_pop_cfunc_frame(void)
Definition: vm.c:625
rb_vm_thread_backtrace_locations
VALUE rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval)
Definition: vm_backtrace.c:1157
rb_make_backtrace
VALUE rb_make_backtrace(void)
Definition: vm_backtrace.c:1059
rb_current_realfilepath
VALUE rb_current_realfilepath(void)
Definition: vm_eval.c:2569
rb_ec_backtrace_object
VALUE rb_ec_backtrace_object(const struct rb_execution_context_struct *ec)
rb_vm_inc_const_missing_count
void rb_vm_inc_const_missing_count(void)
Definition: vm.c:425
rb_block_call_func_t
rb_block_call_func * rb_block_call_func_t
Definition: iterator.h:34
ruby::backward::cxxanyargs::type
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:56
ruby.h
argc
int argc
Definition: ruby.c:240
argv
char ** argv
Definition: ruby.c:241
serial.h
Internal header for rb_serial_t.
rb_serial_t
unsigned LONG_LONG rb_serial_t
Definition: serial.h:19
st.h
stdbool.h
C99 shim for <stdbool.h>
rb_callable_method_entry_struct
Definition: method.h:62
rb_callcache
Definition: vm_callinfo.h:274
rb_callcache::klass
const VALUE klass
Definition: vm_callinfo.h:278
rb_callinfo
Definition: vm_callinfo.h:61
rb_callinfo::mid
VALUE mid
Definition: vm_callinfo.h:64
rb_control_frame_struct
Definition: vm_core.h:769
rb_execution_context_struct
Definition: vm_core.h:854
rb_iseq_struct
Definition: vm_core.h:444
rb_method_definition_struct
Definition: method.h:172
st_table
Definition: st.h:79
VALUE
unsigned long VALUE
Definition: value.h:38
ID
unsigned long ID
Definition: value.h:39
ruby_value_type
ruby_value_type
C-level type of an object.
Definition: value_type.h:110
vm_exec
#define vm_exec
Definition: vm.c:11