debase-ruby_core_source 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/addr2line.h +21 -0
  4. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/ccan/build_assert/build_assert.h +40 -0
  5. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/ccan/check_type/check_type.h +63 -0
  6. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/ccan/container_of/container_of.h +142 -0
  7. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/ccan/list/list.h +773 -0
  8. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/ccan/str/str.h +16 -0
  9. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/constant.h +50 -0
  10. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/dln.h +51 -0
  11. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/encindex.h +67 -0
  12. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/eval_intern.h +304 -0
  13. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/gc.h +114 -0
  14. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/id.h +211 -0
  15. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/id_table.h +30 -0
  16. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/insns.inc +110 -0
  17. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/insns_info.inc +776 -0
  18. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/internal.h +1406 -0
  19. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/iseq.h +249 -0
  20. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/known_errors.inc +746 -0
  21. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/method.h +213 -0
  22. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/node.h +520 -0
  23. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/node_name.inc +208 -0
  24. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/opt_sc.inc +758 -0
  25. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/optinsn.inc +83 -0
  26. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/optunifs.inc +127 -0
  27. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/parse.h +185 -0
  28. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/probes_helper.h +43 -0
  29. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/regenc.h +234 -0
  30. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/regint.h +987 -0
  31. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/regparse.h +367 -0
  32. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/revision.h +1 -0
  33. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/ruby_atomic.h +233 -0
  34. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/siphash.h +48 -0
  35. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/symbol.h +108 -0
  36. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/thread_pthread.h +54 -0
  37. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/thread_win32.h +36 -0
  38. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/timev.h +42 -0
  39. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/transcode_data.h +139 -0
  40. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/version.h +55 -0
  41. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/vm.inc +3411 -0
  42. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/vm_call_iseq_optimized.inc +212 -0
  43. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/vm_core.h +1240 -0
  44. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/vm_debug.h +37 -0
  45. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/vm_exec.h +182 -0
  46. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/vm_insnhelper.h +227 -0
  47. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/vm_opts.h +57 -0
  48. data/lib/debase/ruby_core_source/ruby-2.3.3-p222/vmtc.inc +108 -0
  49. data/lib/debase/ruby_core_source/version.rb +1 -1
  50. metadata +48 -2
@@ -0,0 +1,212 @@
1
+ #if 1 /* enable or disable this optimization */
2
+
3
+ /* DO NOT EDIT THIS FILE DIRECTLY
4
+ *
5
+ * This file is enerated by tool/mkcall_iseq.rb
6
+ */
7
+
8
+ static VALUE
9
+ vm_call_iseq_setup_normal_0start_0params_1locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
10
+ {
11
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 0, 1);
12
+ }
13
+
14
+ static VALUE
15
+ vm_call_iseq_setup_normal_0start_0params_2locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
16
+ {
17
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 0, 2);
18
+ }
19
+
20
+ static VALUE
21
+ vm_call_iseq_setup_normal_0start_0params_3locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
22
+ {
23
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 0, 3);
24
+ }
25
+
26
+ static VALUE
27
+ vm_call_iseq_setup_normal_0start_0params_4locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
28
+ {
29
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 0, 4);
30
+ }
31
+
32
+ static VALUE
33
+ vm_call_iseq_setup_normal_0start_0params_5locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
34
+ {
35
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 0, 5);
36
+ }
37
+
38
+ static VALUE
39
+ vm_call_iseq_setup_normal_0start_0params_6locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
40
+ {
41
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 0, 6);
42
+ }
43
+
44
+ static VALUE
45
+ vm_call_iseq_setup_normal_0start_1params_1locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
46
+ {
47
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 1, 1);
48
+ }
49
+
50
+ static VALUE
51
+ vm_call_iseq_setup_normal_0start_1params_2locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
52
+ {
53
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 1, 2);
54
+ }
55
+
56
+ static VALUE
57
+ vm_call_iseq_setup_normal_0start_1params_3locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
58
+ {
59
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 1, 3);
60
+ }
61
+
62
+ static VALUE
63
+ vm_call_iseq_setup_normal_0start_1params_4locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
64
+ {
65
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 1, 4);
66
+ }
67
+
68
+ static VALUE
69
+ vm_call_iseq_setup_normal_0start_1params_5locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
70
+ {
71
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 1, 5);
72
+ }
73
+
74
+ static VALUE
75
+ vm_call_iseq_setup_normal_0start_1params_6locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
76
+ {
77
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 1, 6);
78
+ }
79
+
80
+ static VALUE
81
+ vm_call_iseq_setup_normal_0start_2params_1locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
82
+ {
83
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 2, 1);
84
+ }
85
+
86
+ static VALUE
87
+ vm_call_iseq_setup_normal_0start_2params_2locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
88
+ {
89
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 2, 2);
90
+ }
91
+
92
+ static VALUE
93
+ vm_call_iseq_setup_normal_0start_2params_3locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
94
+ {
95
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 2, 3);
96
+ }
97
+
98
+ static VALUE
99
+ vm_call_iseq_setup_normal_0start_2params_4locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
100
+ {
101
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 2, 4);
102
+ }
103
+
104
+ static VALUE
105
+ vm_call_iseq_setup_normal_0start_2params_5locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
106
+ {
107
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 2, 5);
108
+ }
109
+
110
+ static VALUE
111
+ vm_call_iseq_setup_normal_0start_2params_6locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
112
+ {
113
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 2, 6);
114
+ }
115
+
116
+ static VALUE
117
+ vm_call_iseq_setup_normal_0start_3params_1locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
118
+ {
119
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 3, 1);
120
+ }
121
+
122
+ static VALUE
123
+ vm_call_iseq_setup_normal_0start_3params_2locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
124
+ {
125
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 3, 2);
126
+ }
127
+
128
+ static VALUE
129
+ vm_call_iseq_setup_normal_0start_3params_3locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
130
+ {
131
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 3, 3);
132
+ }
133
+
134
+ static VALUE
135
+ vm_call_iseq_setup_normal_0start_3params_4locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
136
+ {
137
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 3, 4);
138
+ }
139
+
140
+ static VALUE
141
+ vm_call_iseq_setup_normal_0start_3params_5locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
142
+ {
143
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 3, 5);
144
+ }
145
+
146
+ static VALUE
147
+ vm_call_iseq_setup_normal_0start_3params_6locals(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
148
+ {
149
+ return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, 3, 6);
150
+ }
151
+
152
+ /* vm_call_iseq_handlers[param][local] */
153
+ static const vm_call_handler vm_call_iseq_handlers[][6] = {
154
+ {vm_call_iseq_setup_normal_0start_0params_1locals,
155
+ vm_call_iseq_setup_normal_0start_0params_2locals,
156
+ vm_call_iseq_setup_normal_0start_0params_3locals,
157
+ vm_call_iseq_setup_normal_0start_0params_4locals,
158
+ vm_call_iseq_setup_normal_0start_0params_5locals,
159
+ vm_call_iseq_setup_normal_0start_0params_6locals},
160
+ {vm_call_iseq_setup_normal_0start_1params_1locals,
161
+ vm_call_iseq_setup_normal_0start_1params_2locals,
162
+ vm_call_iseq_setup_normal_0start_1params_3locals,
163
+ vm_call_iseq_setup_normal_0start_1params_4locals,
164
+ vm_call_iseq_setup_normal_0start_1params_5locals,
165
+ vm_call_iseq_setup_normal_0start_1params_6locals},
166
+ {vm_call_iseq_setup_normal_0start_2params_1locals,
167
+ vm_call_iseq_setup_normal_0start_2params_2locals,
168
+ vm_call_iseq_setup_normal_0start_2params_3locals,
169
+ vm_call_iseq_setup_normal_0start_2params_4locals,
170
+ vm_call_iseq_setup_normal_0start_2params_5locals,
171
+ vm_call_iseq_setup_normal_0start_2params_6locals},
172
+ {vm_call_iseq_setup_normal_0start_3params_1locals,
173
+ vm_call_iseq_setup_normal_0start_3params_2locals,
174
+ vm_call_iseq_setup_normal_0start_3params_3locals,
175
+ vm_call_iseq_setup_normal_0start_3params_4locals,
176
+ vm_call_iseq_setup_normal_0start_3params_5locals,
177
+ vm_call_iseq_setup_normal_0start_3params_6locals}
178
+ };
179
+
180
+ static inline vm_call_handler
181
+ vm_call_iseq_setup_func(const struct rb_call_info *ci, const int param_size, const int local_size)
182
+ {
183
+ if (UNLIKELY(ci->flag & VM_CALL_TAILCALL)) {
184
+ return vm_call_iseq_setup_tailcall_0start;
185
+ }
186
+ else if (0) { /* to disable optimize */
187
+ return vm_call_iseq_setup_normal_0start;
188
+ }
189
+ else {
190
+ if (param_size <= 3 &&
191
+ local_size <= 6) {
192
+ VM_ASSERT(local_size != 0);
193
+ return vm_call_iseq_handlers[param_size][local_size-1];
194
+ }
195
+ return vm_call_iseq_setup_normal_0start;
196
+ }
197
+ }
198
+
199
+ #else
200
+
201
+
202
+ static inline vm_call_handler
203
+ vm_call_iseq_setup_func(const struct rb_call_info *ci, struct rb_call_cache *cc)
204
+ {
205
+ if (UNLIKELY(ci->flag & VM_CALL_TAILCALL)) {
206
+ return vm_call_iseq_setup_tailcall_0start;
207
+ }
208
+ else {
209
+ return vm_call_iseq_setup_normal_0start;
210
+ }
211
+ }
212
+ #endif
@@ -0,0 +1,1240 @@
1
+ /**********************************************************************
2
+
3
+ vm_core.h -
4
+
5
+ $Author: naruse $
6
+ created at: 04/01/01 19:41:38 JST
7
+
8
+ Copyright (C) 2004-2007 Koichi Sasada
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_VM_CORE_H
13
+ #define RUBY_VM_CORE_H
14
+
15
+ /*
16
+ * Enable check mode.
17
+ * 1: enable local assertions.
18
+ */
19
+ #ifndef VM_CHECK_MODE
20
+ #define VM_CHECK_MODE 0
21
+ #endif
22
+
23
+ /**
24
+ * VM Debug Level
25
+ *
26
+ * debug level:
27
+ * 0: no debug output
28
+ * 1: show instruction name
29
+ * 2: show stack frame when control stack frame is changed
30
+ * 3: show stack status
31
+ * 4: show register
32
+ * 5:
33
+ * 10: gc check
34
+ */
35
+
36
+ #ifndef VMDEBUG
37
+ #define VMDEBUG 0
38
+ #endif
39
+
40
+ #if 0
41
+ #undef VMDEBUG
42
+ #define VMDEBUG 3
43
+ #endif
44
+
45
+ #if VM_CHECK_MODE > 0
46
+ #define VM_ASSERT(expr) ( \
47
+ LIKELY(expr) ? (void)0 : \
48
+ rb_bug("%s:%d assertion violation - %s", __FILE__, __LINE__, #expr))
49
+ #else
50
+ #define VM_ASSERT(expr) ((void)0)
51
+ #endif
52
+
53
+ #define RUBY_VM_THREAD_MODEL 2
54
+
55
+ #include "ruby/ruby.h"
56
+ #include "ruby/st.h"
57
+
58
+ #include "node.h"
59
+ #include "vm_debug.h"
60
+ #include "vm_opts.h"
61
+ #include "id.h"
62
+ #include "method.h"
63
+ #include "ruby_atomic.h"
64
+ #include "ccan/list/list.h"
65
+
66
+ #include "ruby/thread_native.h"
67
+ #if defined(_WIN32)
68
+ #include "thread_win32.h"
69
+ #elif defined(HAVE_PTHREAD_H)
70
+ #include "thread_pthread.h"
71
+ #endif
72
+
73
+ #ifndef ENABLE_VM_OBJSPACE
74
+ #ifdef _WIN32
75
+ /*
76
+ * TODO: object space independent st_table.
77
+ * socklist and conlist will be freed exit_handler(), after object
78
+ * space destruction.
79
+ */
80
+ #define ENABLE_VM_OBJSPACE 0
81
+ #else
82
+ #define ENABLE_VM_OBJSPACE 1
83
+ #endif
84
+ #endif
85
+
86
+ #include <setjmp.h>
87
+ #include <signal.h>
88
+
89
+ #ifndef NSIG
90
+ # define NSIG (_SIGMAX + 1) /* For QNX */
91
+ #endif
92
+
93
+ #define RUBY_NSIG NSIG
94
+
95
+ #ifdef HAVE_STDARG_PROTOTYPES
96
+ #include <stdarg.h>
97
+ #define va_init_list(a,b) va_start((a),(b))
98
+ #else
99
+ #include <varargs.h>
100
+ #define va_init_list(a,b) va_start((a))
101
+ #endif
102
+
103
+ #if defined(SIGSEGV) && defined(HAVE_SIGALTSTACK) && defined(SA_SIGINFO) && !defined(__NetBSD__)
104
+ #define USE_SIGALTSTACK
105
+ #endif
106
+
107
+ /*****************/
108
+ /* configuration */
109
+ /*****************/
110
+
111
+ /* gcc ver. check */
112
+ #if defined(__GNUC__) && __GNUC__ >= 2
113
+
114
+ #if OPT_TOKEN_THREADED_CODE
115
+ #if OPT_DIRECT_THREADED_CODE
116
+ #undef OPT_DIRECT_THREADED_CODE
117
+ #endif
118
+ #endif
119
+
120
+ #else /* defined(__GNUC__) && __GNUC__ >= 2 */
121
+
122
+ /* disable threaded code options */
123
+ #if OPT_DIRECT_THREADED_CODE
124
+ #undef OPT_DIRECT_THREADED_CODE
125
+ #endif
126
+ #if OPT_TOKEN_THREADED_CODE
127
+ #undef OPT_TOKEN_THREADED_CODE
128
+ #endif
129
+ #endif
130
+
131
+ #ifdef __native_client__
132
+ #undef OPT_DIRECT_THREADED_CODE
133
+ #endif
134
+
135
+ /* call threaded code */
136
+ #if OPT_CALL_THREADED_CODE
137
+ #if OPT_DIRECT_THREADED_CODE
138
+ #undef OPT_DIRECT_THREADED_CODE
139
+ #endif /* OPT_DIRECT_THREADED_CODE */
140
+ #if OPT_STACK_CACHING
141
+ #undef OPT_STACK_CACHING
142
+ #endif /* OPT_STACK_CACHING */
143
+ #endif /* OPT_CALL_THREADED_CODE */
144
+
145
+ typedef unsigned long rb_num_t;
146
+
147
+ enum ruby_tag_type {
148
+ RUBY_TAG_RETURN = 0x1,
149
+ RUBY_TAG_BREAK = 0x2,
150
+ RUBY_TAG_NEXT = 0x3,
151
+ RUBY_TAG_RETRY = 0x4,
152
+ RUBY_TAG_REDO = 0x5,
153
+ RUBY_TAG_RAISE = 0x6,
154
+ RUBY_TAG_THROW = 0x7,
155
+ RUBY_TAG_FATAL = 0x8,
156
+ RUBY_TAG_MASK = 0xf
157
+ };
158
+ #define TAG_RETURN RUBY_TAG_RETURN
159
+ #define TAG_BREAK RUBY_TAG_BREAK
160
+ #define TAG_NEXT RUBY_TAG_NEXT
161
+ #define TAG_RETRY RUBY_TAG_RETRY
162
+ #define TAG_REDO RUBY_TAG_REDO
163
+ #define TAG_RAISE RUBY_TAG_RAISE
164
+ #define TAG_THROW RUBY_TAG_THROW
165
+ #define TAG_FATAL RUBY_TAG_FATAL
166
+ #define TAG_MASK RUBY_TAG_MASK
167
+
168
+ enum ruby_vm_throw_flags {
169
+ VM_THROW_NO_ESCAPE_FLAG = 0x8000,
170
+ VM_THROW_LEVEL_SHIFT = 16,
171
+ VM_THROW_STATE_MASK = 0xff
172
+ };
173
+
174
+ /* forward declarations */
175
+ struct rb_thread_struct;
176
+ struct rb_control_frame_struct;
177
+
178
+ /* iseq data type */
179
+ typedef struct rb_compile_option_struct rb_compile_option_t;
180
+
181
+ struct iseq_inline_cache_entry {
182
+ rb_serial_t ic_serial;
183
+ const rb_cref_t *ic_cref;
184
+ union {
185
+ size_t index;
186
+ VALUE value;
187
+ } ic_value;
188
+ };
189
+
190
+ union iseq_inline_storage_entry {
191
+ struct {
192
+ struct rb_thread_struct *running_thread;
193
+ VALUE value;
194
+ } once;
195
+ struct iseq_inline_cache_entry cache;
196
+ };
197
+
198
+ enum method_missing_reason {
199
+ MISSING_NOENTRY = 0x00,
200
+ MISSING_PRIVATE = 0x01,
201
+ MISSING_PROTECTED = 0x02,
202
+ MISSING_VCALL = 0x04,
203
+ MISSING_SUPER = 0x08,
204
+ MISSING_MISSING = 0x10,
205
+ MISSING_NONE = 0x20
206
+ };
207
+
208
+ struct rb_call_info {
209
+ /* fixed at compile time */
210
+ ID mid;
211
+ unsigned int flag;
212
+ int orig_argc;
213
+ };
214
+
215
+ struct rb_call_info_kw_arg {
216
+ int keyword_len;
217
+ VALUE keywords[1];
218
+ };
219
+
220
+ struct rb_call_info_with_kwarg {
221
+ struct rb_call_info ci;
222
+ struct rb_call_info_kw_arg *kw_arg;
223
+ };
224
+
225
+ struct rb_calling_info {
226
+ struct rb_block_struct *blockptr;
227
+ VALUE recv;
228
+ int argc;
229
+ };
230
+
231
+ struct rb_call_cache;
232
+ typedef VALUE (*vm_call_handler)(struct rb_thread_struct *th, struct rb_control_frame_struct *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);
233
+
234
+ struct rb_call_cache {
235
+ /* inline cache: keys */
236
+ rb_serial_t method_state;
237
+ rb_serial_t class_serial;
238
+
239
+ /* inline cache: values */
240
+ const rb_callable_method_entry_t *me;
241
+
242
+ vm_call_handler call;
243
+
244
+ union {
245
+ unsigned int index; /* used by ivar */
246
+ enum method_missing_reason method_missing_reason; /* used by method_missing */
247
+ int inc_sp; /* used by cfunc */
248
+ } aux;
249
+ };
250
+
251
+ #if 1
252
+ #define GetCoreDataFromValue(obj, type, ptr) do { \
253
+ (ptr) = (type*)DATA_PTR(obj); \
254
+ } while (0)
255
+ #else
256
+ #define GetCoreDataFromValue(obj, type, ptr) Data_Get_Struct((obj), type, (ptr))
257
+ #endif
258
+
259
+ typedef struct rb_iseq_location_struct {
260
+ VALUE path;
261
+ VALUE absolute_path;
262
+ VALUE base_label;
263
+ VALUE label;
264
+ VALUE first_lineno; /* TODO: may be unsigned short */
265
+ } rb_iseq_location_t;
266
+
267
+ struct rb_iseq_constant_body {
268
+ enum iseq_type {
269
+ ISEQ_TYPE_TOP,
270
+ ISEQ_TYPE_METHOD,
271
+ ISEQ_TYPE_BLOCK,
272
+ ISEQ_TYPE_CLASS,
273
+ ISEQ_TYPE_RESCUE,
274
+ ISEQ_TYPE_ENSURE,
275
+ ISEQ_TYPE_EVAL,
276
+ ISEQ_TYPE_MAIN,
277
+ ISEQ_TYPE_DEFINED_GUARD
278
+ } type; /* instruction sequence type */
279
+
280
+ unsigned int stack_max; /* for stack overflow check */
281
+ /* sizeof(vars) + 1 */
282
+ unsigned int local_size;
283
+
284
+ unsigned int iseq_size;
285
+ const VALUE *iseq_encoded; /* encoded iseq (insn addr and operands) */
286
+
287
+ /**
288
+ * parameter information
289
+ *
290
+ * def m(a1, a2, ..., aM, # mandatory
291
+ * b1=(...), b2=(...), ..., bN=(...), # optional
292
+ * *c, # rest
293
+ * d1, d2, ..., dO, # post
294
+ * e1:(...), e2:(...), ..., eK:(...), # keyword
295
+ * **f, # keyword_rest
296
+ * &g) # block
297
+ * =>
298
+ *
299
+ * lead_num = M
300
+ * opt_num = N
301
+ * rest_start = M+N
302
+ * post_start = M+N+(*1)
303
+ * post_num = O
304
+ * keyword_num = K
305
+ * block_start = M+N+(*1)+O+K
306
+ * keyword_bits = M+N+(*1)+O+K+(&1)
307
+ * size = M+N+O+(*1)+K+(&1)+(**1) // parameter size.
308
+ */
309
+
310
+ struct {
311
+ struct {
312
+ unsigned int has_lead : 1;
313
+ unsigned int has_opt : 1;
314
+ unsigned int has_rest : 1;
315
+ unsigned int has_post : 1;
316
+ unsigned int has_kw : 1;
317
+ unsigned int has_kwrest : 1;
318
+ unsigned int has_block : 1;
319
+
320
+ unsigned int ambiguous_param0 : 1; /* {|a|} */
321
+ } flags;
322
+
323
+ unsigned int size;
324
+
325
+ int lead_num;
326
+ int opt_num;
327
+ int rest_start;
328
+ int post_start;
329
+ int post_num;
330
+ int block_start;
331
+
332
+ const VALUE *opt_table; /* (opt_num + 1) entries. */
333
+ /* opt_num and opt_table:
334
+ *
335
+ * def foo o1=e1, o2=e2, ..., oN=eN
336
+ * #=>
337
+ * # prologue code
338
+ * A1: e1
339
+ * A2: e2
340
+ * ...
341
+ * AN: eN
342
+ * AL: body
343
+ * opt_num = N
344
+ * opt_table = [A1, A2, ..., AN, AL]
345
+ */
346
+
347
+ const struct rb_iseq_param_keyword {
348
+ int num;
349
+ int required_num;
350
+ int bits_start;
351
+ int rest_start;
352
+ const ID *table;
353
+ const VALUE *default_values;
354
+ } *keyword;
355
+ } param;
356
+
357
+ rb_iseq_location_t location;
358
+
359
+ /* insn info, must be freed */
360
+ const struct iseq_line_info_entry *line_info_table;
361
+
362
+ const ID *local_table; /* must free */
363
+
364
+ /* catch table */
365
+ const struct iseq_catch_table *catch_table;
366
+
367
+ /* for child iseq */
368
+ const struct rb_iseq_struct *parent_iseq;
369
+ struct rb_iseq_struct *local_iseq; /* local_iseq->flip_cnt can be modified */
370
+
371
+ union iseq_inline_storage_entry *is_entries;
372
+ struct rb_call_info *ci_entries; /* struct rb_call_info ci_entries[ci_size];
373
+ * struct rb_call_info_with_kwarg cikw_entries[ci_kw_size];
374
+ * So that:
375
+ * struct rb_call_info_with_kwarg *cikw_entries = &body->ci_entries[ci_size];
376
+ */
377
+ struct rb_call_cache *cc_entries; /* size is ci_size = ci_kw_size */
378
+
379
+ VALUE mark_ary; /* Array: includes operands which should be GC marked */
380
+
381
+ unsigned int local_table_size;
382
+ unsigned int is_size;
383
+ unsigned int ci_size;
384
+ unsigned int ci_kw_size;
385
+ unsigned int line_info_size;
386
+ };
387
+
388
+ /* T_IMEMO/iseq */
389
+ /* typedef rb_iseq_t is in method.h */
390
+ struct rb_iseq_struct {
391
+ VALUE flags;
392
+ VALUE reserved1;
393
+ struct rb_iseq_constant_body *body;
394
+
395
+ union { /* 4, 5 words */
396
+ struct iseq_compile_data *compile_data; /* used at compile time */
397
+
398
+ struct {
399
+ VALUE obj;
400
+ int index;
401
+ } loader;
402
+ } aux;
403
+ };
404
+
405
+ #ifndef USE_LAZY_LOAD
406
+ #define USE_LAZY_LOAD 0
407
+ #endif
408
+
409
+ #if USE_LAZY_LOAD
410
+ const rb_iseq_t *rb_iseq_complete(const rb_iseq_t *iseq);
411
+ #endif
412
+
413
+ static inline const rb_iseq_t *
414
+ rb_iseq_check(const rb_iseq_t *iseq)
415
+ {
416
+ #if USE_LAZY_LOAD
417
+ if (iseq->body == NULL) {
418
+ rb_iseq_complete((rb_iseq_t *)iseq);
419
+ }
420
+ #endif
421
+ return iseq;
422
+ }
423
+
424
+ enum ruby_special_exceptions {
425
+ ruby_error_reenter,
426
+ ruby_error_nomemory,
427
+ ruby_error_sysstack,
428
+ ruby_error_closed_stream,
429
+ ruby_special_error_count
430
+ };
431
+
432
+ enum ruby_basic_operators {
433
+ BOP_PLUS,
434
+ BOP_MINUS,
435
+ BOP_MULT,
436
+ BOP_DIV,
437
+ BOP_MOD,
438
+ BOP_EQ,
439
+ BOP_EQQ,
440
+ BOP_LT,
441
+ BOP_LE,
442
+ BOP_LTLT,
443
+ BOP_AREF,
444
+ BOP_ASET,
445
+ BOP_LENGTH,
446
+ BOP_SIZE,
447
+ BOP_EMPTY_P,
448
+ BOP_SUCC,
449
+ BOP_GT,
450
+ BOP_GE,
451
+ BOP_NOT,
452
+ BOP_NEQ,
453
+ BOP_MATCH,
454
+ BOP_FREEZE,
455
+
456
+ BOP_LAST_
457
+ };
458
+
459
+ #define GetVMPtr(obj, ptr) \
460
+ GetCoreDataFromValue((obj), rb_vm_t, (ptr))
461
+
462
+ struct rb_vm_struct;
463
+ typedef void rb_vm_at_exit_func(struct rb_vm_struct*);
464
+
465
+ typedef struct rb_at_exit_list {
466
+ rb_vm_at_exit_func *func;
467
+ struct rb_at_exit_list *next;
468
+ } rb_at_exit_list;
469
+
470
+ struct rb_objspace;
471
+ struct rb_objspace *rb_objspace_alloc(void);
472
+ void rb_objspace_free(struct rb_objspace *);
473
+
474
+ typedef struct rb_hook_list_struct {
475
+ struct rb_event_hook_struct *hooks;
476
+ rb_event_flag_t events;
477
+ int need_clean;
478
+ } rb_hook_list_t;
479
+
480
+ typedef struct rb_vm_struct {
481
+ VALUE self;
482
+
483
+ rb_global_vm_lock_t gvl;
484
+ rb_nativethread_lock_t thread_destruct_lock;
485
+
486
+ struct rb_thread_struct *main_thread;
487
+ struct rb_thread_struct *running_thread;
488
+
489
+ struct list_head living_threads;
490
+ size_t living_thread_num;
491
+ VALUE thgroup_default;
492
+
493
+ int running;
494
+ int thread_abort_on_exception;
495
+ int trace_running;
496
+ volatile int sleeper;
497
+
498
+ /* object management */
499
+ VALUE mark_object_ary;
500
+ const VALUE special_exceptions[ruby_special_error_count];
501
+
502
+ /* load */
503
+ VALUE top_self;
504
+ VALUE load_path;
505
+ VALUE load_path_snapshot;
506
+ VALUE load_path_check_cache;
507
+ VALUE expanded_load_path;
508
+ VALUE loaded_features;
509
+ VALUE loaded_features_snapshot;
510
+ struct st_table *loaded_features_index;
511
+ struct st_table *loading_table;
512
+
513
+ /* signal */
514
+ struct {
515
+ VALUE cmd;
516
+ int safe;
517
+ } trap_list[RUBY_NSIG];
518
+
519
+ /* hook */
520
+ rb_hook_list_t event_hooks;
521
+
522
+ /* relation table of ensure - rollback for callcc */
523
+ struct st_table *ensure_rollback_table;
524
+
525
+ /* postponed_job */
526
+ struct rb_postponed_job_struct *postponed_job_buffer;
527
+ int postponed_job_index;
528
+
529
+ int src_encoding_index;
530
+
531
+ VALUE verbose, debug, orig_progname, progname;
532
+ VALUE coverages;
533
+
534
+ VALUE defined_module_hash;
535
+
536
+ struct rb_objspace *objspace;
537
+
538
+ rb_at_exit_list *at_exit;
539
+
540
+ VALUE *defined_strings;
541
+ st_table *frozen_strings;
542
+
543
+ /* params */
544
+ struct { /* size in byte */
545
+ size_t thread_vm_stack_size;
546
+ size_t thread_machine_stack_size;
547
+ size_t fiber_vm_stack_size;
548
+ size_t fiber_machine_stack_size;
549
+ } default_params;
550
+
551
+ short redefined_flag[BOP_LAST_];
552
+ } rb_vm_t;
553
+
554
+ /* default values */
555
+
556
+ #define RUBY_VM_SIZE_ALIGN 4096
557
+
558
+ #define RUBY_VM_THREAD_VM_STACK_SIZE ( 128 * 1024 * sizeof(VALUE)) /* 512 KB or 1024 KB */
559
+ #define RUBY_VM_THREAD_VM_STACK_SIZE_MIN ( 2 * 1024 * sizeof(VALUE)) /* 8 KB or 16 KB */
560
+ #define RUBY_VM_THREAD_MACHINE_STACK_SIZE ( 128 * 1024 * sizeof(VALUE)) /* 512 KB or 1024 KB */
561
+ #define RUBY_VM_THREAD_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
562
+
563
+ #define RUBY_VM_FIBER_VM_STACK_SIZE ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
564
+ #define RUBY_VM_FIBER_VM_STACK_SIZE_MIN ( 2 * 1024 * sizeof(VALUE)) /* 8 KB or 16 KB */
565
+ #define RUBY_VM_FIBER_MACHINE_STACK_SIZE ( 64 * 1024 * sizeof(VALUE)) /* 256 KB or 512 KB */
566
+ #define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
567
+
568
+ /* optimize insn */
569
+ #define FIXNUM_REDEFINED_OP_FLAG (1 << 0)
570
+ #define FLOAT_REDEFINED_OP_FLAG (1 << 1)
571
+ #define STRING_REDEFINED_OP_FLAG (1 << 2)
572
+ #define ARRAY_REDEFINED_OP_FLAG (1 << 3)
573
+ #define HASH_REDEFINED_OP_FLAG (1 << 4)
574
+ #define BIGNUM_REDEFINED_OP_FLAG (1 << 5)
575
+ #define SYMBOL_REDEFINED_OP_FLAG (1 << 6)
576
+ #define TIME_REDEFINED_OP_FLAG (1 << 7)
577
+ #define REGEXP_REDEFINED_OP_FLAG (1 << 8)
578
+ #define NIL_REDEFINED_OP_FLAG (1 << 9)
579
+ #define TRUE_REDEFINED_OP_FLAG (1 << 10)
580
+ #define FALSE_REDEFINED_OP_FLAG (1 << 11)
581
+
582
+ #define BASIC_OP_UNREDEFINED_P(op, klass) (LIKELY((GET_VM()->redefined_flag[(op)]&(klass)) == 0))
583
+
584
+ #ifndef VM_DEBUG_BP_CHECK
585
+ #define VM_DEBUG_BP_CHECK 0
586
+ #endif
587
+
588
+ #ifndef VM_DEBUG_VERIFY_METHOD_CACHE
589
+ #define VM_DEBUG_VERIFY_METHOD_CACHE (VM_DEBUG_MODE != 0)
590
+ #endif
591
+
592
+ typedef struct rb_control_frame_struct {
593
+ const VALUE *pc; /* cfp[0] */
594
+ VALUE *sp; /* cfp[1] */
595
+ const rb_iseq_t *iseq; /* cfp[2] */
596
+ VALUE flag; /* cfp[3] */
597
+ VALUE self; /* cfp[4] / block[0] */
598
+ VALUE *ep; /* cfp[5] / block[1] */
599
+ const rb_iseq_t *block_iseq;/* cfp[6] / block[2] */
600
+ VALUE proc; /* cfp[7] / block[3] */
601
+
602
+ #if VM_DEBUG_BP_CHECK
603
+ VALUE *bp_check; /* cfp[8] */
604
+ #endif
605
+ } rb_control_frame_t;
606
+
607
+ typedef struct rb_block_struct {
608
+ VALUE self; /* share with method frame if it's only block */
609
+ VALUE *ep; /* share with method frame if it's only block */
610
+ const rb_iseq_t *iseq;
611
+ VALUE proc;
612
+ } rb_block_t;
613
+
614
+ extern const rb_data_type_t ruby_threadptr_data_type;
615
+
616
+ #define GetThreadPtr(obj, ptr) \
617
+ TypedData_Get_Struct((obj), rb_thread_t, &ruby_threadptr_data_type, (ptr))
618
+
619
+ enum rb_thread_status {
620
+ THREAD_RUNNABLE,
621
+ THREAD_STOPPED,
622
+ THREAD_STOPPED_FOREVER,
623
+ THREAD_KILLED
624
+ };
625
+
626
+ typedef RUBY_JMP_BUF rb_jmpbuf_t;
627
+
628
+ /*
629
+ the members which are written in TH_PUSH_TAG() should be placed at
630
+ the beginning and the end, so that entire region is accessible.
631
+ */
632
+ struct rb_vm_tag {
633
+ VALUE tag;
634
+ VALUE retval;
635
+ rb_jmpbuf_t buf;
636
+ struct rb_vm_tag *prev;
637
+ };
638
+
639
+ struct rb_vm_protect_tag {
640
+ struct rb_vm_protect_tag *prev;
641
+ };
642
+
643
+ struct rb_unblock_callback {
644
+ rb_unblock_function_t *func;
645
+ void *arg;
646
+ };
647
+
648
+ struct rb_mutex_struct;
649
+
650
+ typedef struct rb_thread_list_struct{
651
+ struct rb_thread_list_struct *next;
652
+ struct rb_thread_struct *th;
653
+ } rb_thread_list_t;
654
+
655
+ typedef struct rb_ensure_entry {
656
+ VALUE marker;
657
+ VALUE (*e_proc)(ANYARGS);
658
+ VALUE data2;
659
+ } rb_ensure_entry_t;
660
+
661
+ typedef struct rb_ensure_list {
662
+ struct rb_ensure_list *next;
663
+ struct rb_ensure_entry entry;
664
+ } rb_ensure_list_t;
665
+
666
+ typedef char rb_thread_id_string_t[sizeof(rb_nativethread_id_t) * 2 + 3];
667
+
668
+ typedef struct rb_fiber_struct rb_fiber_t;
669
+
670
+ typedef struct rb_thread_struct {
671
+ struct list_node vmlt_node;
672
+ VALUE self;
673
+ rb_vm_t *vm;
674
+
675
+ /* execution information */
676
+ VALUE *stack; /* must free, must mark */
677
+ size_t stack_size; /* size in word (byte size / sizeof(VALUE)) */
678
+ rb_control_frame_t *cfp;
679
+ int safe_level;
680
+ int raised_flag;
681
+ VALUE last_status; /* $? */
682
+
683
+ /* passing state */
684
+ int state;
685
+
686
+ int waiting_fd;
687
+
688
+ /* for rb_iterate */
689
+ const rb_block_t *passed_block;
690
+
691
+ /* for bmethod */
692
+ const rb_callable_method_entry_t *passed_bmethod_me;
693
+
694
+ /* for cfunc */
695
+ struct rb_calling_info *calling;
696
+
697
+ /* for load(true) */
698
+ VALUE top_self;
699
+ VALUE top_wrapper;
700
+
701
+ /* eval env */
702
+ rb_block_t *base_block;
703
+
704
+ VALUE *root_lep;
705
+ VALUE root_svar;
706
+
707
+ /* thread control */
708
+ rb_nativethread_id_t thread_id;
709
+ #ifdef NON_SCALAR_THREAD_ID
710
+ rb_thread_id_string_t thread_id_string;
711
+ #endif
712
+ enum rb_thread_status status;
713
+ int to_kill;
714
+ int priority;
715
+
716
+ native_thread_data_t native_thread_data;
717
+ void *blocking_region_buffer;
718
+
719
+ VALUE thgroup;
720
+ VALUE value;
721
+
722
+ /* temporary place of errinfo */
723
+ VALUE errinfo;
724
+
725
+ /* temporary place of retval on OPT_CALL_THREADED_CODE */
726
+ #if OPT_CALL_THREADED_CODE
727
+ VALUE retval;
728
+ #endif
729
+
730
+ /* async errinfo queue */
731
+ VALUE pending_interrupt_queue;
732
+ VALUE pending_interrupt_mask_stack;
733
+ int pending_interrupt_queue_checked;
734
+
735
+ rb_atomic_t interrupt_flag;
736
+ unsigned long interrupt_mask;
737
+ rb_nativethread_lock_t interrupt_lock;
738
+ rb_nativethread_cond_t interrupt_cond;
739
+ struct rb_unblock_callback unblock;
740
+ VALUE locking_mutex;
741
+ struct rb_mutex_struct *keeping_mutexes;
742
+
743
+ struct rb_vm_tag *tag;
744
+ struct rb_vm_protect_tag *protect_tag;
745
+
746
+ /*! Thread-local state of evaluation context.
747
+ *
748
+ * If negative, this thread is evaluating the main program.
749
+ * If positive, this thread is evaluating a program under Kernel::eval
750
+ * family.
751
+ */
752
+ int parse_in_eval;
753
+
754
+ /*! Thread-local state of compiling context.
755
+ *
756
+ * If non-zero, the parser does not automatically print error messages to
757
+ * stderr. */
758
+ int mild_compile_error;
759
+
760
+ /* storage */
761
+ st_table *local_storage;
762
+ VALUE local_storage_recursive_hash;
763
+ VALUE local_storage_recursive_hash_for_trace;
764
+
765
+ rb_thread_list_t *join_list;
766
+
767
+ VALUE first_proc;
768
+ VALUE first_args;
769
+ VALUE (*first_func)(ANYARGS);
770
+
771
+ /* for GC */
772
+ struct {
773
+ VALUE *stack_start;
774
+ VALUE *stack_end;
775
+ size_t stack_maxsize;
776
+ #ifdef __ia64
777
+ VALUE *register_stack_start;
778
+ VALUE *register_stack_end;
779
+ size_t register_stack_maxsize;
780
+ #endif
781
+ jmp_buf regs;
782
+ } machine;
783
+
784
+ /* statistics data for profiler */
785
+ VALUE stat_insn_usage;
786
+
787
+ /* tracer */
788
+ rb_hook_list_t event_hooks;
789
+ struct rb_trace_arg_struct *trace_arg; /* trace information */
790
+
791
+ /* fiber */
792
+ rb_fiber_t *fiber;
793
+ rb_fiber_t *root_fiber;
794
+ rb_jmpbuf_t root_jmpbuf;
795
+
796
+ /* ensure & callcc */
797
+ rb_ensure_list_t *ensure_list;
798
+
799
+ /* misc */
800
+ enum method_missing_reason method_missing_reason;
801
+ int abort_on_exception;
802
+ #ifdef USE_SIGALTSTACK
803
+ void *altstack;
804
+ #endif
805
+ unsigned long running_time_us;
806
+ VALUE name;
807
+ } rb_thread_t;
808
+
809
+ typedef enum {
810
+ VM_DEFINECLASS_TYPE_CLASS = 0x00,
811
+ VM_DEFINECLASS_TYPE_SINGLETON_CLASS = 0x01,
812
+ VM_DEFINECLASS_TYPE_MODULE = 0x02,
813
+ /* 0x03..0x06 is reserved */
814
+ VM_DEFINECLASS_TYPE_MASK = 0x07
815
+ } rb_vm_defineclass_type_t;
816
+
817
+ #define VM_DEFINECLASS_TYPE(x) ((rb_vm_defineclass_type_t)(x) & VM_DEFINECLASS_TYPE_MASK)
818
+ #define VM_DEFINECLASS_FLAG_SCOPED 0x08
819
+ #define VM_DEFINECLASS_FLAG_HAS_SUPERCLASS 0x10
820
+ #define VM_DEFINECLASS_SCOPED_P(x) ((x) & VM_DEFINECLASS_FLAG_SCOPED)
821
+ #define VM_DEFINECLASS_HAS_SUPERCLASS_P(x) \
822
+ ((x) & VM_DEFINECLASS_FLAG_HAS_SUPERCLASS)
823
+
824
+ /* iseq.c */
825
+ RUBY_SYMBOL_EXPORT_BEGIN
826
+
827
+ /* node -> iseq */
828
+ rb_iseq_t *rb_iseq_new(NODE*, VALUE, VALUE, VALUE, const rb_iseq_t *parent, enum iseq_type);
829
+ rb_iseq_t *rb_iseq_new_top(NODE *node, VALUE name, VALUE path, VALUE absolute_path, const rb_iseq_t *parent);
830
+ rb_iseq_t *rb_iseq_new_main(NODE *node, VALUE path, VALUE absolute_path);
831
+ rb_iseq_t *rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, enum iseq_type, VALUE);
832
+ rb_iseq_t *rb_iseq_new_with_opt(NODE*, VALUE, VALUE, VALUE, VALUE, const rb_iseq_t *parent, enum iseq_type, const rb_compile_option_t*);
833
+
834
+ /* src -> iseq */
835
+ rb_iseq_t *rb_iseq_compile(VALUE src, VALUE file, VALUE line);
836
+ rb_iseq_t *rb_iseq_compile_on_base(VALUE src, VALUE file, VALUE line, rb_block_t *base_block);
837
+ rb_iseq_t *rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE absolute_path, VALUE line, rb_block_t *base_block, VALUE opt);
838
+
839
+ VALUE rb_iseq_disasm(const rb_iseq_t *iseq);
840
+ int rb_iseq_disasm_insn(VALUE str, const VALUE *iseqval, size_t pos, const rb_iseq_t *iseq, VALUE child);
841
+ const char *ruby_node_name(int node);
842
+
843
+ VALUE rb_iseq_coverage(const rb_iseq_t *iseq);
844
+
845
+ RUBY_EXTERN VALUE rb_cISeq;
846
+ RUBY_EXTERN VALUE rb_cRubyVM;
847
+ RUBY_EXTERN VALUE rb_cEnv;
848
+ RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
849
+ RUBY_SYMBOL_EXPORT_END
850
+
851
+ #define GetProcPtr(obj, ptr) \
852
+ GetCoreDataFromValue((obj), rb_proc_t, (ptr))
853
+
854
+ typedef struct {
855
+ rb_block_t block;
856
+ int8_t safe_level; /* 0..1 */
857
+ int8_t is_from_method; /* bool */
858
+ int8_t is_lambda; /* bool */
859
+ } rb_proc_t;
860
+
861
+ #define GetEnvPtr(obj, ptr) \
862
+ GetCoreDataFromValue((obj), rb_env_t, (ptr))
863
+
864
+ typedef struct {
865
+ int env_size;
866
+ rb_block_t block;
867
+ VALUE env[1]; /* flexible array */
868
+ } rb_env_t;
869
+
870
+ extern const rb_data_type_t ruby_binding_data_type;
871
+
872
+ #define GetBindingPtr(obj, ptr) \
873
+ GetCoreDataFromValue((obj), rb_binding_t, (ptr))
874
+
875
+ typedef struct {
876
+ VALUE env;
877
+ VALUE path;
878
+ unsigned short first_lineno;
879
+ } rb_binding_t;
880
+
881
+ /* used by compile time and send insn */
882
+
883
+ enum vm_check_match_type {
884
+ VM_CHECKMATCH_TYPE_WHEN = 1,
885
+ VM_CHECKMATCH_TYPE_CASE = 2,
886
+ VM_CHECKMATCH_TYPE_RESCUE = 3
887
+ };
888
+
889
+ #define VM_CHECKMATCH_TYPE_MASK 0x03
890
+ #define VM_CHECKMATCH_ARRAY 0x04
891
+
892
+ #define VM_CALL_ARGS_SPLAT (0x01 << 0) /* m(*args) */
893
+ #define VM_CALL_ARGS_BLOCKARG (0x01 << 1) /* m(&block) */
894
+ #define VM_CALL_FCALL (0x01 << 2) /* m(...) */
895
+ #define VM_CALL_VCALL (0x01 << 3) /* m */
896
+ #define VM_CALL_ARGS_SIMPLE (0x01 << 4) /* (ci->flag & (SPLAT|BLOCKARG)) && blockiseq == NULL && ci->kw_arg == NULL */
897
+ #define VM_CALL_BLOCKISEQ (0x01 << 5) /* has blockiseq */
898
+ #define VM_CALL_KWARG (0x01 << 6) /* has kwarg */
899
+ #define VM_CALL_TAILCALL (0x01 << 7) /* located at tail position */
900
+ #define VM_CALL_SUPER (0x01 << 8) /* super */
901
+ #define VM_CALL_OPT_SEND (0x01 << 9) /* internal flag */
902
+
903
+ enum vm_special_object_type {
904
+ VM_SPECIAL_OBJECT_VMCORE = 1,
905
+ VM_SPECIAL_OBJECT_CBASE,
906
+ VM_SPECIAL_OBJECT_CONST_BASE
907
+ };
908
+
909
+ enum vm_svar_index {
910
+ VM_SVAR_LASTLINE = 0, /* $_ */
911
+ VM_SVAR_BACKREF = 1, /* $~ */
912
+
913
+ VM_SVAR_EXTRA_START = 2,
914
+ VM_SVAR_FLIPFLOP_START = 2 /* flipflop */
915
+ };
916
+
917
+ #define VM_FRAME_MAGIC_METHOD 0x11
918
+ #define VM_FRAME_MAGIC_BLOCK 0x21
919
+ #define VM_FRAME_MAGIC_CLASS 0x31
920
+ #define VM_FRAME_MAGIC_TOP 0x41
921
+ #define VM_FRAME_MAGIC_CFUNC 0x61
922
+ #define VM_FRAME_MAGIC_PROC 0x71
923
+ #define VM_FRAME_MAGIC_IFUNC 0x81
924
+ #define VM_FRAME_MAGIC_EVAL 0x91
925
+ #define VM_FRAME_MAGIC_LAMBDA 0xa1
926
+ #define VM_FRAME_MAGIC_RESCUE 0xb1
927
+ #define VM_FRAME_MAGIC_DUMMY 0xc1
928
+ #define VM_FRAME_MAGIC_MASK_BITS 8
929
+ #define VM_FRAME_MAGIC_MASK (~(~(VALUE)0<<VM_FRAME_MAGIC_MASK_BITS))
930
+
931
+ #define VM_FRAME_TYPE(cfp) ((cfp)->flag & VM_FRAME_MAGIC_MASK)
932
+
933
+ /* other frame flag */
934
+ #define VM_FRAME_FLAG_PASSED 0x0100
935
+ #define VM_FRAME_FLAG_FINISH 0x0200
936
+ #define VM_FRAME_FLAG_BMETHOD 0x0400
937
+ #define VM_FRAME_TYPE_FINISH_P(cfp) (((cfp)->flag & VM_FRAME_FLAG_FINISH) != 0)
938
+ #define VM_FRAME_TYPE_BMETHOD_P(cfp) (((cfp)->flag & VM_FRAME_FLAG_BMETHOD) != 0)
939
+
940
+ #define RUBYVM_CFUNC_FRAME_P(cfp) \
941
+ (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)
942
+
943
+ /* inline cache */
944
+ typedef struct iseq_inline_cache_entry *IC;
945
+ typedef struct rb_call_info *CALL_INFO;
946
+ typedef struct rb_call_cache *CALL_CACHE;
947
+
948
+ void rb_vm_change_state(void);
949
+
950
+ typedef VALUE CDHASH;
951
+
952
+ #ifndef FUNC_FASTCALL
953
+ #define FUNC_FASTCALL(x) x
954
+ #endif
955
+
956
+ typedef rb_control_frame_t *
957
+ (FUNC_FASTCALL(*rb_insn_func_t))(rb_thread_t *, rb_control_frame_t *);
958
+
959
+ #define GC_GUARDED_PTR(p) ((VALUE)((VALUE)(p) | 0x01))
960
+ #define GC_GUARDED_PTR_REF(p) ((void *)(((VALUE)(p)) & ~0x03))
961
+ #define GC_GUARDED_PTR_P(p) (((VALUE)(p)) & 0x01)
962
+
963
+ /*
964
+ * block frame:
965
+ * ep[ 0]: prev frame
966
+ * ep[-1]: CREF (for *_eval)
967
+ *
968
+ * method frame:
969
+ * ep[ 0]: block pointer (ptr | VM_ENVVAL_BLOCK_PTR_FLAG)
970
+ */
971
+
972
+ #define VM_ENVVAL_BLOCK_PTR_FLAG 0x02
973
+ #define VM_ENVVAL_BLOCK_PTR(v) (GC_GUARDED_PTR(v) | VM_ENVVAL_BLOCK_PTR_FLAG)
974
+ #define VM_ENVVAL_BLOCK_PTR_P(v) ((v) & VM_ENVVAL_BLOCK_PTR_FLAG)
975
+ #define VM_ENVVAL_PREV_EP_PTR(v) ((VALUE)GC_GUARDED_PTR(v))
976
+ #define VM_ENVVAL_PREV_EP_PTR_P(v) (!(VM_ENVVAL_BLOCK_PTR_P(v)))
977
+
978
+ #define VM_EP_PREV_EP(ep) ((VALUE *)GC_GUARDED_PTR_REF((ep)[0]))
979
+ #define VM_EP_BLOCK_PTR(ep) ((rb_block_t *)GC_GUARDED_PTR_REF((ep)[0]))
980
+ #define VM_EP_LEP_P(ep) VM_ENVVAL_BLOCK_PTR_P((ep)[0])
981
+
982
+ VALUE *rb_vm_ep_local_ep(VALUE *ep);
983
+ rb_block_t *rb_vm_control_frame_block_ptr(const rb_control_frame_t *cfp);
984
+
985
+ #define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1)
986
+ #define RUBY_VM_NEXT_CONTROL_FRAME(cfp) ((cfp)-1)
987
+ #define RUBY_VM_END_CONTROL_FRAME(th) \
988
+ ((rb_control_frame_t *)((th)->stack + (th)->stack_size))
989
+ #define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \
990
+ ((void *)(ecfp) > (void *)(cfp))
991
+ #define RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp) \
992
+ (!RUBY_VM_VALID_CONTROL_FRAME_P((cfp), RUBY_VM_END_CONTROL_FRAME(th)))
993
+
994
+ #define RUBY_VM_IFUNC_P(ptr) (RB_TYPE_P((VALUE)(ptr), T_IMEMO) && imemo_type((VALUE)ptr) == imemo_ifunc)
995
+ #define RUBY_VM_NORMAL_ISEQ_P(ptr) (RB_TYPE_P((VALUE)(ptr), T_IMEMO) && imemo_type((VALUE)ptr) == imemo_iseq && rb_iseq_check((rb_iseq_t *)ptr))
996
+
997
+ #define RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp) ((rb_block_t *)(&(cfp)->self))
998
+ #define RUBY_VM_GET_CFP_FROM_BLOCK_PTR(b) \
999
+ ((rb_control_frame_t *)((VALUE *)(b) - 4))
1000
+ /* magic number `4' is depend on rb_control_frame_t layout. */
1001
+
1002
+ /* VM related object allocate functions */
1003
+ VALUE rb_thread_alloc(VALUE klass);
1004
+ VALUE rb_proc_alloc(VALUE klass);
1005
+ VALUE rb_binding_alloc(VALUE klass);
1006
+
1007
+ /* for debug */
1008
+ extern void rb_vmdebug_stack_dump_raw(rb_thread_t *, rb_control_frame_t *);
1009
+ extern void rb_vmdebug_debug_print_pre(rb_thread_t *th, rb_control_frame_t *cfp, VALUE *_pc);
1010
+ extern void rb_vmdebug_debug_print_post(rb_thread_t *th, rb_control_frame_t *cfp);
1011
+
1012
+ #define SDR() rb_vmdebug_stack_dump_raw(GET_THREAD(), GET_THREAD()->cfp)
1013
+ #define SDR2(cfp) rb_vmdebug_stack_dump_raw(GET_THREAD(), (cfp))
1014
+ void rb_vm_bugreport(const void *);
1015
+ NORETURN(void rb_bug_context(const void *, const char *fmt, ...));
1016
+
1017
+ /* functions about thread/vm execution */
1018
+ RUBY_SYMBOL_EXPORT_BEGIN
1019
+ VALUE rb_iseq_eval(const rb_iseq_t *iseq);
1020
+ VALUE rb_iseq_eval_main(const rb_iseq_t *iseq);
1021
+ RUBY_SYMBOL_EXPORT_END
1022
+ int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp);
1023
+
1024
+ VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc,
1025
+ int argc, const VALUE *argv, const rb_block_t *blockptr);
1026
+ VALUE rb_vm_make_proc_lambda(rb_thread_t *th, const rb_block_t *block, VALUE klass, int8_t is_lambda);
1027
+ VALUE rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass);
1028
+ VALUE rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp);
1029
+ VALUE rb_vm_env_local_variables(const rb_env_t *env);
1030
+ VALUE rb_vm_env_prev_envval(const rb_env_t *env);
1031
+ VALUE rb_vm_proc_envval(const rb_proc_t *proc);
1032
+ VALUE *rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars);
1033
+ void rb_vm_inc_const_missing_count(void);
1034
+ void rb_vm_gvl_destroy(rb_vm_t *vm);
1035
+ VALUE rb_vm_call(rb_thread_t *th, VALUE recv, VALUE id, int argc,
1036
+ const VALUE *argv, const rb_callable_method_entry_t *me);
1037
+
1038
+ void rb_thread_start_timer_thread(void);
1039
+ void rb_thread_stop_timer_thread(void);
1040
+ void rb_thread_reset_timer_thread(void);
1041
+ void rb_thread_wakeup_timer_thread(void);
1042
+
1043
+ static inline void
1044
+ rb_vm_living_threads_init(rb_vm_t *vm)
1045
+ {
1046
+ list_head_init(&vm->living_threads);
1047
+ vm->living_thread_num = 0;
1048
+ }
1049
+
1050
+ static inline void
1051
+ rb_vm_living_threads_insert(rb_vm_t *vm, rb_thread_t *th)
1052
+ {
1053
+ list_add_tail(&vm->living_threads, &th->vmlt_node);
1054
+ vm->living_thread_num++;
1055
+ }
1056
+
1057
+ static inline void
1058
+ rb_vm_living_threads_remove(rb_vm_t *vm, rb_thread_t *th)
1059
+ {
1060
+ list_del(&th->vmlt_node);
1061
+ vm->living_thread_num--;
1062
+ }
1063
+
1064
+ typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
1065
+ rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp);
1066
+ rb_control_frame_t *rb_vm_get_binding_creatable_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp);
1067
+ int rb_vm_get_sourceline(const rb_control_frame_t *);
1068
+ VALUE rb_name_err_mesg_new(VALUE mesg, VALUE recv, VALUE method);
1069
+ void rb_vm_stack_to_heap(rb_thread_t *th);
1070
+ void ruby_thread_init_stack(rb_thread_t *th);
1071
+ int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, VALUE *klassp);
1072
+ void rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
1073
+
1074
+ void rb_vm_register_special_exception(enum ruby_special_exceptions sp, VALUE exception_class, const char *mesg);
1075
+
1076
+ void rb_gc_mark_machine_stack(rb_thread_t *th);
1077
+
1078
+ int rb_autoloading_value(VALUE mod, ID id, VALUE* value);
1079
+
1080
+ void rb_vm_rewrite_cref(rb_cref_t *node, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr);
1081
+
1082
+ const rb_callable_method_entry_t *rb_vm_frame_method_entry(const rb_control_frame_t *cfp);
1083
+
1084
+ #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
1085
+
1086
+ #define RUBY_CONST_ASSERT(expr) (1/!!(expr)) /* expr must be a compile-time constant */
1087
+ #define VM_STACK_OVERFLOWED_P(cfp, sp, margin) \
1088
+ (!RUBY_CONST_ASSERT(sizeof(*(sp)) == sizeof(VALUE)) || \
1089
+ !RUBY_CONST_ASSERT(sizeof(*(cfp)) == sizeof(rb_control_frame_t)) || \
1090
+ ((rb_control_frame_t *)((sp) + (margin)) + 1) >= (cfp))
1091
+ #define WHEN_VM_STACK_OVERFLOWED(cfp, sp, margin) \
1092
+ if (LIKELY(!VM_STACK_OVERFLOWED_P(cfp, sp, margin))) {(void)0;} else /* overflowed */
1093
+ #define CHECK_VM_STACK_OVERFLOW0(cfp, sp, margin) \
1094
+ WHEN_VM_STACK_OVERFLOWED(cfp, sp, margin) vm_stackoverflow()
1095
+ #define CHECK_VM_STACK_OVERFLOW(cfp, margin) \
1096
+ WHEN_VM_STACK_OVERFLOWED(cfp, (cfp)->sp, margin) vm_stackoverflow()
1097
+
1098
+ /* for thread */
1099
+
1100
+ #if RUBY_VM_THREAD_MODEL == 2
1101
+ extern rb_thread_t *ruby_current_thread;
1102
+ extern rb_vm_t *ruby_current_vm;
1103
+ extern rb_event_flag_t ruby_vm_event_flags;
1104
+
1105
+ #define GET_VM() ruby_current_vm
1106
+
1107
+ #ifndef OPT_CALL_CFUNC_WITHOUT_FRAME
1108
+ #define OPT_CALL_CFUNC_WITHOUT_FRAME 0
1109
+ #endif
1110
+
1111
+ #define GET_THREAD() vm_thread_with_frame(ruby_current_thread)
1112
+ #if OPT_CALL_CFUNC_WITHOUT_FRAME
1113
+ static inline rb_thread_t *
1114
+ vm_thread_with_frame(rb_thread_t *th)
1115
+ {
1116
+ if (UNLIKELY(th->passed_ci != 0)) {
1117
+ void rb_vm_call_cfunc_push_frame(rb_thread_t *th);
1118
+ rb_vm_call_cfunc_push_frame(th);
1119
+ }
1120
+ return th;
1121
+ }
1122
+ #else
1123
+ #define vm_thread_with_frame(th) (th)
1124
+ #endif
1125
+
1126
+ #define rb_thread_set_current_raw(th) (void)(ruby_current_thread = (th))
1127
+ #define rb_thread_set_current(th) do { \
1128
+ if ((th)->vm->running_thread != (th)) { \
1129
+ (th)->running_time_us = 0; \
1130
+ } \
1131
+ rb_thread_set_current_raw(th); \
1132
+ (th)->vm->running_thread = (th); \
1133
+ } while (0)
1134
+
1135
+ #else
1136
+ #error "unsupported thread model"
1137
+ #endif
1138
+
1139
+ enum {
1140
+ TIMER_INTERRUPT_MASK = 0x01,
1141
+ PENDING_INTERRUPT_MASK = 0x02,
1142
+ POSTPONED_JOB_INTERRUPT_MASK = 0x04,
1143
+ TRAP_INTERRUPT_MASK = 0x08
1144
+ };
1145
+
1146
+ #define RUBY_VM_SET_TIMER_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, TIMER_INTERRUPT_MASK)
1147
+ #define RUBY_VM_SET_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, PENDING_INTERRUPT_MASK)
1148
+ #define RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, POSTPONED_JOB_INTERRUPT_MASK)
1149
+ #define RUBY_VM_SET_TRAP_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, TRAP_INTERRUPT_MASK)
1150
+ #define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & ~(th)->interrupt_mask & (PENDING_INTERRUPT_MASK|TRAP_INTERRUPT_MASK))
1151
+ #define RUBY_VM_INTERRUPTED_ANY(th) ((th)->interrupt_flag & ~(th)->interrupt_mask)
1152
+
1153
+ int rb_signal_buff_size(void);
1154
+ void rb_signal_exec(rb_thread_t *th, int sig);
1155
+ void rb_threadptr_check_signal(rb_thread_t *mth);
1156
+ void rb_threadptr_signal_raise(rb_thread_t *th, int sig);
1157
+ void rb_threadptr_signal_exit(rb_thread_t *th);
1158
+ void rb_threadptr_execute_interrupts(rb_thread_t *, int);
1159
+ void rb_threadptr_interrupt(rb_thread_t *th);
1160
+ void rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th);
1161
+ void rb_threadptr_pending_interrupt_clear(rb_thread_t *th);
1162
+ void rb_threadptr_pending_interrupt_enque(rb_thread_t *th, VALUE v);
1163
+ int rb_threadptr_pending_interrupt_active_p(rb_thread_t *th);
1164
+
1165
+ #define RUBY_VM_CHECK_INTS(th) ruby_vm_check_ints(th)
1166
+ static inline void
1167
+ ruby_vm_check_ints(rb_thread_t *th)
1168
+ {
1169
+ if (UNLIKELY(RUBY_VM_INTERRUPTED_ANY(th))) {
1170
+ rb_threadptr_execute_interrupts(th, 0);
1171
+ }
1172
+ }
1173
+
1174
+ /* tracer */
1175
+ struct rb_trace_arg_struct {
1176
+ rb_event_flag_t event;
1177
+ rb_thread_t *th;
1178
+ rb_control_frame_t *cfp;
1179
+ VALUE self;
1180
+ ID id;
1181
+ VALUE klass;
1182
+ VALUE data;
1183
+
1184
+ int klass_solved;
1185
+
1186
+ /* calc from cfp */
1187
+ int lineno;
1188
+ VALUE path;
1189
+ };
1190
+
1191
+ void rb_threadptr_exec_event_hooks(struct rb_trace_arg_struct *trace_arg);
1192
+ void rb_threadptr_exec_event_hooks_and_pop_frame(struct rb_trace_arg_struct *trace_arg);
1193
+
1194
+ #define EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, pop_p_) do { \
1195
+ const rb_event_flag_t flag_arg_ = (flag_); \
1196
+ if (UNLIKELY(ruby_vm_event_flags & (flag_arg_))) { \
1197
+ /* defer evaluating the other arguments */ \
1198
+ ruby_exec_event_hook_orig(th_, flag_arg_, self_, id_, klass_, data_, pop_p_); \
1199
+ } \
1200
+ } while (0)
1201
+
1202
+ static inline void
1203
+ ruby_exec_event_hook_orig(rb_thread_t *const th, const rb_event_flag_t flag,
1204
+ VALUE self, ID id, VALUE klass, VALUE data, int pop_p)
1205
+ {
1206
+ if ((th->event_hooks.events | th->vm->event_hooks.events) & flag) {
1207
+ struct rb_trace_arg_struct trace_arg;
1208
+ trace_arg.event = flag;
1209
+ trace_arg.th = th;
1210
+ trace_arg.cfp = th->cfp;
1211
+ trace_arg.self = self;
1212
+ trace_arg.id = id;
1213
+ trace_arg.klass = klass;
1214
+ trace_arg.data = data;
1215
+ trace_arg.path = Qundef;
1216
+ trace_arg.klass_solved = 0;
1217
+ if (pop_p) rb_threadptr_exec_event_hooks_and_pop_frame(&trace_arg);
1218
+ else rb_threadptr_exec_event_hooks(&trace_arg);
1219
+ }
1220
+ }
1221
+
1222
+ #define EXEC_EVENT_HOOK(th_, flag_, self_, id_, klass_, data_) \
1223
+ EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, 0)
1224
+
1225
+ #define EXEC_EVENT_HOOK_AND_POP_FRAME(th_, flag_, self_, id_, klass_, data_) \
1226
+ EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, 1)
1227
+
1228
+ RUBY_SYMBOL_EXPORT_BEGIN
1229
+
1230
+ int rb_thread_check_trap_pending(void);
1231
+
1232
+ extern VALUE rb_get_coverages(void);
1233
+ extern void rb_set_coverages(VALUE);
1234
+ extern void rb_reset_coverages(void);
1235
+
1236
+ void rb_postponed_job_flush(rb_vm_t *vm);
1237
+
1238
+ RUBY_SYMBOL_EXPORT_END
1239
+
1240
+ #endif /* RUBY_VM_CORE_H */