Ruby: internal/vm.h Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

vm.h
1#ifndef INTERNAL_VM_H /*-*-C-*-vi:se ft=c:*/
2#define INTERNAL_VM_H
11#include "ruby/internal/stdbool.h" /* for bool */
12#include "internal/serial.h" /* for rb_serial_t */
13#include "internal/static_assert.h" /* for STATIC_ASSERT */
14#include "ruby/ruby.h" /* for ID */
15#include "ruby/st.h" /* for st_table */
16
17#ifdef rb_funcallv
18# undef rb_funcallv
19#endif
20
21#ifdef rb_method_basic_definition_p
22# undef rb_method_basic_definition_p
23#endif
24
25struct rb_callable_method_entry_struct; /* in method.h */
26struct rb_method_definition_struct; /* in method.h */
27struct rb_execution_context_struct; /* in vm_core.h */
28struct rb_control_frame_struct; /* in vm_core.h */
29struct rb_callinfo; /* in vm_core.h */
30
31enum method_missing_reason {
32 MISSING_NOENTRY = 0x00,
33 MISSING_PRIVATE = 0x01,
34 MISSING_PROTECTED = 0x02,
35 MISSING_FCALL = 0x04,
36 MISSING_VCALL = 0x08,
37 MISSING_SUPER = 0x10,
38 MISSING_MISSING = 0x20,
39 MISSING_NONE = 0x40
40};
41
42/* vm_insnhelper.h */
43 VALUE rb_vm_push_frame_fname(struct rb_execution_context_struct *ec, VALUE fname);
44
45/* vm.c */
46 VALUE rb_obj_is_thread(VALUE obj);
47void rb_vm_mark(void *ptr);
48void rb_vm_each_stack_value(void *ptr, void (*cb)(VALUE, void*), void *ctx);
49PUREFUNC(VALUE rb_vm_top_self(void));
50const void **rb_vm_get_insns_address_table(void);
51 VALUE rb_source_location(int *pline);
52const char *rb_source_location_cstr(int *pline);
53MJIT_STATIC void rb_vm_pop_cfunc_frame(void);
54int rb_vm_add_root_module(VALUE module);
55void rb_vm_check_redefinition_by_prepend(VALUE klass);
56int rb_vm_check_optimizable_mid(VALUE mid);
57 VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);
58MJIT_STATIC VALUE ruby_vm_special_exception_copy(VALUE);
59PUREFUNC(st_table *rb_vm_fstring_table(void));
60
61MJIT_SYMBOL_EXPORT_BEGIN
62 VALUE vm_exec(struct rb_execution_context_struct *, bool); /* used in JIT-ed code */
63MJIT_SYMBOL_EXPORT_END
64
65/* vm_eval.c */
66 VALUE rb_current_realfilepath(void);
67 VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE);
68typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
69 VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
70 rb_check_funcall_hook *hook, VALUE arg);
71 VALUE rb_check_funcall_with_hook_kw(VALUE recv, ID mid, int argc, const VALUE *argv,
72 rb_check_funcall_hook *hook, VALUE arg, int kw_splat);
73const char *rb_type_str(enum ruby_value_type type);
74 VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE);
75 VALUE rb_check_funcall_basic_kw(VALUE, ID, VALUE, int, const VALUE*, int);
76 VALUE rb_yield_1(VALUE val);
77 VALUE rb_yield_force_blockarg(VALUE values);
78 VALUE rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv,
79 rb_block_call_func_t bl_proc, int min_argc, int max_argc,
80 VALUE data2);
81void rb_check_stack_overflow(void);
82
83/* vm_insnhelper.c */
84 VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
85 VALUE rb_eql_opt(VALUE obj1, VALUE obj2);
86
87struct rb_iseq_struct;
88MJIT_SYMBOL_EXPORT_BEGIN
89const struct rb_callcache *rb_vm_search_method_slowpath(const struct rb_callinfo *ci, VALUE klass);
90MJIT_SYMBOL_EXPORT_END
91
92/* vm_method.c */
93struct rb_execution_context_struct;
94MJIT_SYMBOL_EXPORT_BEGIN
95int rb_ec_obj_respond_to(struct rb_execution_context_struct *ec, VALUE obj, ID id, int priv);
96MJIT_SYMBOL_EXPORT_END
97
98void rb_clear_constant_cache(void);
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);
114int rb_frame_info_p(VALUE obj);
115int rb_get_node_id_from_frame_info(VALUE obj);
116const struct rb_iseq_struct *rb_get_iseq_from_frame_info(VALUE obj);
117
118MJIT_SYMBOL_EXPORT_BEGIN
119 VALUE rb_ec_backtrace_object(const struct rb_execution_context_struct *ec);
120void rb_backtrace_use_iseq_first_lineno_for_last_location(VALUE self);
121MJIT_SYMBOL_EXPORT_END
122
123#define RUBY_DTRACE_CREATE_HOOK(name, arg) \
124 RUBY_DTRACE_HOOK(name##_CREATE, arg)
125#define RUBY_DTRACE_HOOK(name, arg) \
126do { \
127 if (UNLIKELY(RUBY_DTRACE_##name##_ENABLED())) { \
128 int dtrace_line; \
129 const char *dtrace_file = rb_source_location_cstr(&dtrace_line); \
130 if (!dtrace_file) dtrace_file = ""; \
131 RUBY_DTRACE_##name(arg, dtrace_file, dtrace_line); \
132 } \
133} while (0)
134#endif /* INTERNAL_VM_H */
rb_make_backtrace
VALUE rb_make_backtrace(void)
Creates the good old fashioned array-of-strings style backtrace info.
Definition vm_backtrace.c:1078
rb_block_call_func_t
rb_block_call_func * rb_block_call_func_t
Shorthand type that represents an iterator-written-in-C function pointer.
Definition iterator.h:88
ruby::backward::cxxanyargs::type
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition cxxanyargs.hpp:56
ruby.h
stdbool.h
C99 shim for <stdbool.h>
rb_callable_method_entry_struct
Definition method.h:62
rb_callcache
Definition vm_callinfo.h:275
rb_callinfo
Definition vm_callinfo.h:62
rb_control_frame_struct
Definition vm_core.h:818
rb_execution_context_struct
Definition vm_core.h:899
rb_iseq_struct
Definition vm_core.h:526
rb_method_definition_struct
Definition method.h:179
st_table
Definition st.h:79
ID
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40
ruby_value_type
ruby_value_type
C-level type of an object.
Definition value_type.h:112