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
40 MISSING_NONE = 0x40
41};
42
43/* vm_insnhelper.h */
45
46/* vm.c */
48void rb_vm_mark(void *ptr);
49void rb_vm_each_stack_value(void *ptr, void (*cb)(VALUE, void*), void *ctx);
52const void **rb_vm_get_insns_address_table(void);
53VALUE rb_source_location(int *pline);
54const char *rb_source_location_cstr(int *pline);
59VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);
62
64VALUE vm_exec(struct rb_execution_context_struct *, bool); /* used in JIT-ed code */
66
67/* vm_eval.c */
70typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
72 rb_check_funcall_hook *hook, VALUE arg);
74 rb_check_funcall_hook *hook, VALUE arg, int kw_splat);
75const char *rb_type_str(enum ruby_value_type type);
80VALUE 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);
84
85/* vm_insnhelper.c */
86VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
87VALUE rb_eql_opt(VALUE obj1, VALUE obj2);
88
89struct rb_iseq_struct;
91const struct rb_callcache *rb_vm_search_method_slowpath(const struct rb_callinfo *ci, VALUE klass);
93
94/* vm_method.c */
97int rb_ec_obj_respond_to(struct rb_execution_context_struct *ec, VALUE obj, ID id, int priv);
99
100/* vm_dump.c */
101void rb_print_backtrace(void);
102
103/* vm_backtrace.c */
104VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval);
110int rb_backtrace_p(VALUE obj);
113void rb_backtrace_each(VALUE (*iter)(VALUE recv, VALUE str), VALUE output);
114
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 */
#define PUREFUNC(x)
Definition: attributes.h:54
struct RIMemo * ptr
Definition: debug.c:88
#define MJIT_SYMBOL_EXPORT_END
Definition: dllexport.h:63
#define MJIT_STATIC
Definition: dllexport.h:71
#define MJIT_SYMBOL_EXPORT_BEGIN
Definition: dllexport.h:62
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
void rb_print_backtrace(void)
Definition: vm_dump.c:753
VALUE rb_backtrace_to_str_ary(VALUE obj)
Definition: vm_backtrace.c:809
void rb_backtrace_each(VALUE(*iter)(VALUE recv, VALUE str), VALUE output)
VALUE rb_vm_backtrace_locations(int argc, const VALUE *argv, struct rb_execution_context_struct *ec)
VALUE rb_yield_1(VALUE val)
Definition: vm_eval.c:1335
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
VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE)
Definition: vm_eval.c:1625
const void ** rb_vm_get_insns_address_table(void)
Definition: vm_exec.c:153
int rb_ec_obj_respond_to(struct rb_execution_context_struct *ec, VALUE obj, ID id, int priv)
Definition: vm_method.c:2552
void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE)
Definition: vm.h:70
int rb_vm_add_root_module(VALUE module)
Definition: vm.c:2622
VALUE rb_vm_backtrace(int argc, const VALUE *argv, struct rb_execution_context_struct *ec)
void rb_backtrace_print_as_bugreport(void)
Definition: vm_backtrace.c:994
VALUE rb_vm_top_self(void)
Definition: vm.c:3752
const char * rb_type_str(enum ruby_value_type type)
Definition: vm_eval.c:686
int rb_vm_check_optimizable_mid(VALUE mid)
Definition: vm.c:1823
void rb_vm_each_stack_value(void *ptr, void(*cb)(VALUE, void *), void *ctx)
Definition: vm.c:2501
VALUE rb_eql_opt(VALUE obj1, VALUE obj2)
st_table * rb_vm_fstring_table(void)
Definition: vm.c:3787
VALUE ruby_vm_special_exception_copy(VALUE)
Definition: vm_insnhelper.c:48
VALUE rb_obj_is_thread(VALUE obj)
Definition: vm.c:3003
void rb_vm_mark(void *ptr)
Definition: vm.c:2538
int rb_backtrace_p(VALUE obj)
Definition: vm_backtrace.c:471
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements)
Definition: vm_eval.c:1980
VALUE rb_equal_opt(VALUE obj1, VALUE obj2)
VALUE rb_backtrace_to_location_ary(VALUE obj)
Definition: vm_backtrace.c:864
void rb_vm_check_redefinition_by_prepend(VALUE klass)
Definition: vm.c:1873
rb_serial_t rb_next_class_serial(void)
Definition: vm.c:366
VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval)
VALUE rb_yield_force_blockarg(VALUE values)
Definition: vm_eval.c:1413
VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE)
Definition: vm_eval.c:647
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
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
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
void rb_check_stack_overflow(void)
Definition: vm_eval.c:331
void rb_backtrace_use_iseq_first_lineno_for_last_location(VALUE self)
Definition: vm_backtrace.c:821
const struct rb_callcache * rb_vm_search_method_slowpath(const struct rb_callinfo *ci, VALUE klass)
method_missing_reason
Definition: vm.h:32
@ MISSING_SUPER
Definition: vm.h:38
@ MISSING_VCALL
Definition: vm.h:37
@ MISSING_PRIVATE
Definition: vm.h:34
@ MISSING_PROTECTED
Definition: vm.h:35
@ MISSING_NOENTRY
Definition: vm.h:33
@ MISSING_NONE
Definition: vm.h:40
@ MISSING_MISSING
Definition: vm.h:39
@ MISSING_FCALL
Definition: vm.h:36
const char * rb_source_location_cstr(int *pline)
Definition: vm.c:1616
VALUE rb_source_location(int *pline)
Definition: vm.c:1600
void rb_vm_pop_cfunc_frame(void)
Definition: vm.c:625
VALUE rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval)
VALUE rb_make_backtrace(void)
VALUE rb_current_realfilepath(void)
Definition: vm_eval.c:2569
VALUE rb_ec_backtrace_object(const struct rb_execution_context_struct *ec)
void rb_vm_inc_const_missing_count(void)
Definition: vm.c:425
rb_block_call_func * rb_block_call_func_t
Definition: iterator.h:34
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:56
int argc
Definition: ruby.c:240
char ** argv
Definition: ruby.c:241
Internal header for rb_serial_t.
unsigned LONG_LONG rb_serial_t
Definition: serial.h:19
C99 shim for <stdbool.h>
Definition: method.h:62
const VALUE klass
Definition: vm_callinfo.h:278
Definition: st.h:79
unsigned long VALUE
Definition: value.h:38
unsigned long ID
Definition: value.h:39
ruby_value_type
C-level type of an object.
Definition: value_type.h:110
#define vm_exec
Definition: vm.c:11