debase-ruby_core_source 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/debase/ruby_core_source.rb +1 -0
  4. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/addr2line.h +21 -0
  5. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/ccan/build_assert/build_assert.h +40 -0
  6. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/ccan/check_type/check_type.h +63 -0
  7. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/ccan/container_of/container_of.h +142 -0
  8. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/ccan/list/list.h +773 -0
  9. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/ccan/str/str.h +16 -0
  10. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/constant.h +50 -0
  11. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/dln.h +51 -0
  12. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/encindex.h +67 -0
  13. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/eval_intern.h +304 -0
  14. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/gc.h +114 -0
  15. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/id.h +211 -0
  16. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/id_table.h +30 -0
  17. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/insns.inc +110 -0
  18. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/insns_info.inc +776 -0
  19. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/internal.h +1400 -0
  20. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/iseq.h +249 -0
  21. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/known_errors.inc +746 -0
  22. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/method.h +213 -0
  23. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/node.h +519 -0
  24. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/node_name.inc +208 -0
  25. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/opt_sc.inc +758 -0
  26. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/optinsn.inc +83 -0
  27. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/optunifs.inc +127 -0
  28. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/parse.h +204 -0
  29. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/probes_helper.h +43 -0
  30. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/regenc.h +234 -0
  31. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/regint.h +987 -0
  32. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/regparse.h +367 -0
  33. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/revision.h +1 -0
  34. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/ruby_atomic.h +233 -0
  35. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/siphash.h +48 -0
  36. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/symbol.h +108 -0
  37. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/thread_pthread.h +54 -0
  38. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/thread_win32.h +36 -0
  39. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/timev.h +42 -0
  40. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/transcode_data.h +139 -0
  41. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/version.h +55 -0
  42. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/vm.inc +3412 -0
  43. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/vm_call_iseq_optimized.inc +212 -0
  44. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/vm_core.h +1238 -0
  45. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/vm_debug.h +37 -0
  46. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/vm_exec.h +182 -0
  47. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/vm_insnhelper.h +227 -0
  48. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/vm_opts.h +57 -0
  49. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/vmtc.inc +108 -0
  50. data/lib/debase/ruby_core_source/version.rb +1 -1
  51. 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,1238 @@
1
+ /**********************************************************************
2
+
3
+ vm_core.h -
4
+
5
+ $Author: nobu $
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
+ #define USE_LAZY_LOAD 0
406
+
407
+ #ifndef USE_LAZY_LOAD
408
+ #define USE_LAZY_LOAD
409
+ #endif
410
+
411
+ #if USE_LAZY_LOAD
412
+ const rb_iseq_t *rb_iseq_complete(const rb_iseq_t *iseq);
413
+ #endif
414
+
415
+ static inline const rb_iseq_t *
416
+ rb_iseq_check(const rb_iseq_t *iseq)
417
+ {
418
+ #if USE_LAZY_LOAD
419
+ if (iseq->body == NULL) {
420
+ rb_iseq_complete((rb_iseq_t *)iseq);
421
+ }
422
+ #endif
423
+ return iseq;
424
+ }
425
+
426
+ enum ruby_special_exceptions {
427
+ ruby_error_reenter,
428
+ ruby_error_nomemory,
429
+ ruby_error_sysstack,
430
+ ruby_error_closed_stream,
431
+ ruby_special_error_count
432
+ };
433
+
434
+ enum ruby_basic_operators {
435
+ BOP_PLUS,
436
+ BOP_MINUS,
437
+ BOP_MULT,
438
+ BOP_DIV,
439
+ BOP_MOD,
440
+ BOP_EQ,
441
+ BOP_EQQ,
442
+ BOP_LT,
443
+ BOP_LE,
444
+ BOP_LTLT,
445
+ BOP_AREF,
446
+ BOP_ASET,
447
+ BOP_LENGTH,
448
+ BOP_SIZE,
449
+ BOP_EMPTY_P,
450
+ BOP_SUCC,
451
+ BOP_GT,
452
+ BOP_GE,
453
+ BOP_NOT,
454
+ BOP_NEQ,
455
+ BOP_MATCH,
456
+ BOP_FREEZE,
457
+
458
+ BOP_LAST_
459
+ };
460
+
461
+ #define GetVMPtr(obj, ptr) \
462
+ GetCoreDataFromValue((obj), rb_vm_t, (ptr))
463
+
464
+ struct rb_objspace;
465
+ struct rb_objspace *rb_objspace_alloc(void);
466
+ void rb_objspace_free(struct rb_objspace *);
467
+
468
+ typedef struct rb_hook_list_struct {
469
+ struct rb_event_hook_struct *hooks;
470
+ rb_event_flag_t events;
471
+ int need_clean;
472
+ } rb_hook_list_t;
473
+
474
+ typedef struct rb_vm_struct {
475
+ VALUE self;
476
+
477
+ rb_global_vm_lock_t gvl;
478
+ rb_nativethread_lock_t thread_destruct_lock;
479
+
480
+ struct rb_thread_struct *main_thread;
481
+ struct rb_thread_struct *running_thread;
482
+
483
+ struct list_head living_threads;
484
+ size_t living_thread_num;
485
+ VALUE thgroup_default;
486
+
487
+ int running;
488
+ int thread_abort_on_exception;
489
+ int trace_running;
490
+ volatile int sleeper;
491
+
492
+ /* object management */
493
+ VALUE mark_object_ary;
494
+ const VALUE special_exceptions[ruby_special_error_count];
495
+
496
+ /* load */
497
+ VALUE top_self;
498
+ VALUE load_path;
499
+ VALUE load_path_snapshot;
500
+ VALUE load_path_check_cache;
501
+ VALUE expanded_load_path;
502
+ VALUE loaded_features;
503
+ VALUE loaded_features_snapshot;
504
+ struct st_table *loaded_features_index;
505
+ struct st_table *loading_table;
506
+
507
+ /* signal */
508
+ struct {
509
+ VALUE cmd;
510
+ int safe;
511
+ } trap_list[RUBY_NSIG];
512
+
513
+ /* hook */
514
+ rb_hook_list_t event_hooks;
515
+
516
+ /* relation table of ensure - rollback for callcc */
517
+ struct st_table *ensure_rollback_table;
518
+
519
+ /* postponed_job */
520
+ struct rb_postponed_job_struct *postponed_job_buffer;
521
+ int postponed_job_index;
522
+
523
+ int src_encoding_index;
524
+
525
+ VALUE verbose, debug, orig_progname, progname;
526
+ VALUE coverages;
527
+
528
+ VALUE defined_module_hash;
529
+
530
+ struct rb_objspace *objspace;
531
+
532
+ /*
533
+ * @shyouhei notes that this is not for storing normal Ruby
534
+ * objects so do *NOT* mark this when you GC.
535
+ */
536
+ struct RArray at_exit;
537
+
538
+ VALUE *defined_strings;
539
+ st_table *frozen_strings;
540
+
541
+ /* params */
542
+ struct { /* size in byte */
543
+ size_t thread_vm_stack_size;
544
+ size_t thread_machine_stack_size;
545
+ size_t fiber_vm_stack_size;
546
+ size_t fiber_machine_stack_size;
547
+ } default_params;
548
+
549
+ short redefined_flag[BOP_LAST_];
550
+ } rb_vm_t;
551
+
552
+ /* default values */
553
+
554
+ #define RUBY_VM_SIZE_ALIGN 4096
555
+
556
+ #define RUBY_VM_THREAD_VM_STACK_SIZE ( 128 * 1024 * sizeof(VALUE)) /* 512 KB or 1024 KB */
557
+ #define RUBY_VM_THREAD_VM_STACK_SIZE_MIN ( 2 * 1024 * sizeof(VALUE)) /* 8 KB or 16 KB */
558
+ #define RUBY_VM_THREAD_MACHINE_STACK_SIZE ( 128 * 1024 * sizeof(VALUE)) /* 512 KB or 1024 KB */
559
+ #define RUBY_VM_THREAD_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
560
+
561
+ #define RUBY_VM_FIBER_VM_STACK_SIZE ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
562
+ #define RUBY_VM_FIBER_VM_STACK_SIZE_MIN ( 2 * 1024 * sizeof(VALUE)) /* 8 KB or 16 KB */
563
+ #define RUBY_VM_FIBER_MACHINE_STACK_SIZE ( 64 * 1024 * sizeof(VALUE)) /* 256 KB or 512 KB */
564
+ #define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
565
+
566
+ /* optimize insn */
567
+ #define FIXNUM_REDEFINED_OP_FLAG (1 << 0)
568
+ #define FLOAT_REDEFINED_OP_FLAG (1 << 1)
569
+ #define STRING_REDEFINED_OP_FLAG (1 << 2)
570
+ #define ARRAY_REDEFINED_OP_FLAG (1 << 3)
571
+ #define HASH_REDEFINED_OP_FLAG (1 << 4)
572
+ #define BIGNUM_REDEFINED_OP_FLAG (1 << 5)
573
+ #define SYMBOL_REDEFINED_OP_FLAG (1 << 6)
574
+ #define TIME_REDEFINED_OP_FLAG (1 << 7)
575
+ #define REGEXP_REDEFINED_OP_FLAG (1 << 8)
576
+ #define NIL_REDEFINED_OP_FLAG (1 << 9)
577
+ #define TRUE_REDEFINED_OP_FLAG (1 << 10)
578
+ #define FALSE_REDEFINED_OP_FLAG (1 << 11)
579
+
580
+ #define BASIC_OP_UNREDEFINED_P(op, klass) (LIKELY((GET_VM()->redefined_flag[(op)]&(klass)) == 0))
581
+
582
+ #ifndef VM_DEBUG_BP_CHECK
583
+ #define VM_DEBUG_BP_CHECK 0
584
+ #endif
585
+
586
+ #ifndef VM_DEBUG_VERIFY_METHOD_CACHE
587
+ #define VM_DEBUG_VERIFY_METHOD_CACHE (VM_DEBUG_MODE != 0)
588
+ #endif
589
+
590
+ typedef struct rb_control_frame_struct {
591
+ const VALUE *pc; /* cfp[0] */
592
+ VALUE *sp; /* cfp[1] */
593
+ const rb_iseq_t *iseq; /* cfp[2] */
594
+ VALUE flag; /* cfp[3] */
595
+ VALUE self; /* cfp[4] / block[0] */
596
+ VALUE *ep; /* cfp[5] / block[1] */
597
+ const rb_iseq_t *block_iseq;/* cfp[6] / block[2] */
598
+ VALUE proc; /* cfp[7] / block[3] */
599
+
600
+ #if VM_DEBUG_BP_CHECK
601
+ VALUE *bp_check; /* cfp[8] */
602
+ #endif
603
+ } rb_control_frame_t;
604
+
605
+ typedef struct rb_block_struct {
606
+ VALUE self; /* share with method frame if it's only block */
607
+ VALUE *ep; /* share with method frame if it's only block */
608
+ const rb_iseq_t *iseq;
609
+ VALUE proc;
610
+ } rb_block_t;
611
+
612
+ extern const rb_data_type_t ruby_threadptr_data_type;
613
+
614
+ #define GetThreadPtr(obj, ptr) \
615
+ TypedData_Get_Struct((obj), rb_thread_t, &ruby_threadptr_data_type, (ptr))
616
+
617
+ enum rb_thread_status {
618
+ THREAD_RUNNABLE,
619
+ THREAD_STOPPED,
620
+ THREAD_STOPPED_FOREVER,
621
+ THREAD_KILLED
622
+ };
623
+
624
+ typedef RUBY_JMP_BUF rb_jmpbuf_t;
625
+
626
+ /*
627
+ the members which are written in TH_PUSH_TAG() should be placed at
628
+ the beginning and the end, so that entire region is accessible.
629
+ */
630
+ struct rb_vm_tag {
631
+ VALUE tag;
632
+ VALUE retval;
633
+ rb_jmpbuf_t buf;
634
+ struct rb_vm_tag *prev;
635
+ };
636
+
637
+ struct rb_vm_protect_tag {
638
+ struct rb_vm_protect_tag *prev;
639
+ };
640
+
641
+ struct rb_unblock_callback {
642
+ rb_unblock_function_t *func;
643
+ void *arg;
644
+ };
645
+
646
+ struct rb_mutex_struct;
647
+
648
+ typedef struct rb_thread_list_struct{
649
+ struct rb_thread_list_struct *next;
650
+ struct rb_thread_struct *th;
651
+ } rb_thread_list_t;
652
+
653
+ typedef struct rb_ensure_entry {
654
+ VALUE marker;
655
+ VALUE (*e_proc)(ANYARGS);
656
+ VALUE data2;
657
+ } rb_ensure_entry_t;
658
+
659
+ typedef struct rb_ensure_list {
660
+ struct rb_ensure_list *next;
661
+ struct rb_ensure_entry entry;
662
+ } rb_ensure_list_t;
663
+
664
+ typedef char rb_thread_id_string_t[sizeof(rb_nativethread_id_t) * 2 + 3];
665
+
666
+ typedef struct rb_fiber_struct rb_fiber_t;
667
+
668
+ typedef struct rb_thread_struct {
669
+ struct list_node vmlt_node;
670
+ VALUE self;
671
+ rb_vm_t *vm;
672
+
673
+ /* execution information */
674
+ VALUE *stack; /* must free, must mark */
675
+ size_t stack_size; /* size in word (byte size / sizeof(VALUE)) */
676
+ rb_control_frame_t *cfp;
677
+ int safe_level;
678
+ int raised_flag;
679
+ VALUE last_status; /* $? */
680
+
681
+ /* passing state */
682
+ int state;
683
+
684
+ int waiting_fd;
685
+
686
+ /* for rb_iterate */
687
+ const rb_block_t *passed_block;
688
+
689
+ /* for bmethod */
690
+ const rb_callable_method_entry_t *passed_bmethod_me;
691
+
692
+ /* for cfunc */
693
+ struct rb_calling_info *calling;
694
+
695
+ /* for load(true) */
696
+ VALUE top_self;
697
+ VALUE top_wrapper;
698
+
699
+ /* eval env */
700
+ rb_block_t *base_block;
701
+
702
+ VALUE *root_lep;
703
+ VALUE root_svar;
704
+
705
+ /* thread control */
706
+ rb_nativethread_id_t thread_id;
707
+ #ifdef NON_SCALAR_THREAD_ID
708
+ rb_thread_id_string_t thread_id_string;
709
+ #endif
710
+ enum rb_thread_status status;
711
+ int to_kill;
712
+ int priority;
713
+
714
+ native_thread_data_t native_thread_data;
715
+ void *blocking_region_buffer;
716
+
717
+ VALUE thgroup;
718
+ VALUE value;
719
+
720
+ /* temporary place of errinfo */
721
+ VALUE errinfo;
722
+
723
+ /* temporary place of retval on OPT_CALL_THREADED_CODE */
724
+ #if OPT_CALL_THREADED_CODE
725
+ VALUE retval;
726
+ #endif
727
+
728
+ /* async errinfo queue */
729
+ VALUE pending_interrupt_queue;
730
+ VALUE pending_interrupt_mask_stack;
731
+ int pending_interrupt_queue_checked;
732
+
733
+ rb_atomic_t interrupt_flag;
734
+ unsigned long interrupt_mask;
735
+ rb_nativethread_lock_t interrupt_lock;
736
+ rb_nativethread_cond_t interrupt_cond;
737
+ struct rb_unblock_callback unblock;
738
+ VALUE locking_mutex;
739
+ struct rb_mutex_struct *keeping_mutexes;
740
+
741
+ struct rb_vm_tag *tag;
742
+ struct rb_vm_protect_tag *protect_tag;
743
+
744
+ /*! Thread-local state of evaluation context.
745
+ *
746
+ * If negative, this thread is evaluating the main program.
747
+ * If positive, this thread is evaluating a program under Kernel::eval
748
+ * family.
749
+ */
750
+ int parse_in_eval;
751
+
752
+ /*! Thread-local state of compiling context.
753
+ *
754
+ * If non-zero, the parser does not automatically print error messages to
755
+ * stderr. */
756
+ int mild_compile_error;
757
+
758
+ /* storage */
759
+ st_table *local_storage;
760
+ VALUE local_storage_recursive_hash;
761
+ VALUE local_storage_recursive_hash_for_trace;
762
+
763
+ rb_thread_list_t *join_list;
764
+
765
+ VALUE first_proc;
766
+ VALUE first_args;
767
+ VALUE (*first_func)(ANYARGS);
768
+
769
+ /* for GC */
770
+ struct {
771
+ VALUE *stack_start;
772
+ VALUE *stack_end;
773
+ size_t stack_maxsize;
774
+ #ifdef __ia64
775
+ VALUE *register_stack_start;
776
+ VALUE *register_stack_end;
777
+ size_t register_stack_maxsize;
778
+ #endif
779
+ jmp_buf regs;
780
+ } machine;
781
+
782
+ /* statistics data for profiler */
783
+ VALUE stat_insn_usage;
784
+
785
+ /* tracer */
786
+ rb_hook_list_t event_hooks;
787
+ struct rb_trace_arg_struct *trace_arg; /* trace information */
788
+
789
+ /* fiber */
790
+ rb_fiber_t *fiber;
791
+ rb_fiber_t *root_fiber;
792
+ rb_jmpbuf_t root_jmpbuf;
793
+
794
+ /* ensure & callcc */
795
+ rb_ensure_list_t *ensure_list;
796
+
797
+ /* misc */
798
+ enum method_missing_reason method_missing_reason;
799
+ int abort_on_exception;
800
+ #ifdef USE_SIGALTSTACK
801
+ void *altstack;
802
+ #endif
803
+ unsigned long running_time_us;
804
+ VALUE name;
805
+ } rb_thread_t;
806
+
807
+ typedef enum {
808
+ VM_DEFINECLASS_TYPE_CLASS = 0x00,
809
+ VM_DEFINECLASS_TYPE_SINGLETON_CLASS = 0x01,
810
+ VM_DEFINECLASS_TYPE_MODULE = 0x02,
811
+ /* 0x03..0x06 is reserved */
812
+ VM_DEFINECLASS_TYPE_MASK = 0x07
813
+ } rb_vm_defineclass_type_t;
814
+
815
+ #define VM_DEFINECLASS_TYPE(x) ((rb_vm_defineclass_type_t)(x) & VM_DEFINECLASS_TYPE_MASK)
816
+ #define VM_DEFINECLASS_FLAG_SCOPED 0x08
817
+ #define VM_DEFINECLASS_FLAG_HAS_SUPERCLASS 0x10
818
+ #define VM_DEFINECLASS_SCOPED_P(x) ((x) & VM_DEFINECLASS_FLAG_SCOPED)
819
+ #define VM_DEFINECLASS_HAS_SUPERCLASS_P(x) \
820
+ ((x) & VM_DEFINECLASS_FLAG_HAS_SUPERCLASS)
821
+
822
+ /* iseq.c */
823
+ RUBY_SYMBOL_EXPORT_BEGIN
824
+
825
+ /* node -> iseq */
826
+ rb_iseq_t *rb_iseq_new(NODE*, VALUE, VALUE, VALUE, const rb_iseq_t *parent, enum iseq_type);
827
+ rb_iseq_t *rb_iseq_new_top(NODE *node, VALUE name, VALUE path, VALUE absolute_path, const rb_iseq_t *parent);
828
+ rb_iseq_t *rb_iseq_new_main(NODE *node, VALUE path, VALUE absolute_path);
829
+ rb_iseq_t *rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, enum iseq_type, VALUE);
830
+ 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*);
831
+
832
+ /* src -> iseq */
833
+ rb_iseq_t *rb_iseq_compile(VALUE src, VALUE file, VALUE line);
834
+ rb_iseq_t *rb_iseq_compile_on_base(VALUE src, VALUE file, VALUE line, rb_block_t *base_block);
835
+ rb_iseq_t *rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE absolute_path, VALUE line, rb_block_t *base_block, VALUE opt);
836
+
837
+ VALUE rb_iseq_disasm(const rb_iseq_t *iseq);
838
+ int rb_iseq_disasm_insn(VALUE str, const VALUE *iseqval, size_t pos, const rb_iseq_t *iseq, VALUE child);
839
+ const char *ruby_node_name(int node);
840
+
841
+ VALUE rb_iseq_coverage(const rb_iseq_t *iseq);
842
+
843
+ RUBY_EXTERN VALUE rb_cISeq;
844
+ RUBY_EXTERN VALUE rb_cRubyVM;
845
+ RUBY_EXTERN VALUE rb_cEnv;
846
+ RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
847
+ RUBY_SYMBOL_EXPORT_END
848
+
849
+ #define GetProcPtr(obj, ptr) \
850
+ GetCoreDataFromValue((obj), rb_proc_t, (ptr))
851
+
852
+ typedef struct {
853
+ rb_block_t block;
854
+ int8_t safe_level; /* 0..1 */
855
+ int8_t is_from_method; /* bool */
856
+ int8_t is_lambda; /* bool */
857
+ } rb_proc_t;
858
+
859
+ #define GetEnvPtr(obj, ptr) \
860
+ GetCoreDataFromValue((obj), rb_env_t, (ptr))
861
+
862
+ typedef struct {
863
+ int env_size;
864
+ rb_block_t block;
865
+ VALUE env[1]; /* flexible array */
866
+ } rb_env_t;
867
+
868
+ extern const rb_data_type_t ruby_binding_data_type;
869
+
870
+ #define GetBindingPtr(obj, ptr) \
871
+ GetCoreDataFromValue((obj), rb_binding_t, (ptr))
872
+
873
+ typedef struct {
874
+ VALUE env;
875
+ VALUE path;
876
+ unsigned short first_lineno;
877
+ } rb_binding_t;
878
+
879
+ /* used by compile time and send insn */
880
+
881
+ enum vm_check_match_type {
882
+ VM_CHECKMATCH_TYPE_WHEN = 1,
883
+ VM_CHECKMATCH_TYPE_CASE = 2,
884
+ VM_CHECKMATCH_TYPE_RESCUE = 3
885
+ };
886
+
887
+ #define VM_CHECKMATCH_TYPE_MASK 0x03
888
+ #define VM_CHECKMATCH_ARRAY 0x04
889
+
890
+ #define VM_CALL_ARGS_SPLAT (0x01 << 0) /* m(*args) */
891
+ #define VM_CALL_ARGS_BLOCKARG (0x01 << 1) /* m(&block) */
892
+ #define VM_CALL_FCALL (0x01 << 2) /* m(...) */
893
+ #define VM_CALL_VCALL (0x01 << 3) /* m */
894
+ #define VM_CALL_ARGS_SIMPLE (0x01 << 4) /* (ci->flag & (SPLAT|BLOCKARG)) && blockiseq == NULL && ci->kw_arg == NULL */
895
+ #define VM_CALL_BLOCKISEQ (0x01 << 5) /* has blockiseq */
896
+ #define VM_CALL_KWARG (0x01 << 6) /* has kwarg */
897
+ #define VM_CALL_TAILCALL (0x01 << 7) /* located at tail position */
898
+ #define VM_CALL_SUPER (0x01 << 8) /* super */
899
+ #define VM_CALL_OPT_SEND (0x01 << 9) /* internal flag */
900
+
901
+ enum vm_special_object_type {
902
+ VM_SPECIAL_OBJECT_VMCORE = 1,
903
+ VM_SPECIAL_OBJECT_CBASE,
904
+ VM_SPECIAL_OBJECT_CONST_BASE
905
+ };
906
+
907
+ enum vm_svar_index {
908
+ VM_SVAR_LASTLINE = 0, /* $_ */
909
+ VM_SVAR_BACKREF = 1, /* $~ */
910
+
911
+ VM_SVAR_EXTRA_START = 2,
912
+ VM_SVAR_FLIPFLOP_START = 2 /* flipflop */
913
+ };
914
+
915
+ #define VM_FRAME_MAGIC_METHOD 0x11
916
+ #define VM_FRAME_MAGIC_BLOCK 0x21
917
+ #define VM_FRAME_MAGIC_CLASS 0x31
918
+ #define VM_FRAME_MAGIC_TOP 0x41
919
+ #define VM_FRAME_MAGIC_CFUNC 0x61
920
+ #define VM_FRAME_MAGIC_PROC 0x71
921
+ #define VM_FRAME_MAGIC_IFUNC 0x81
922
+ #define VM_FRAME_MAGIC_EVAL 0x91
923
+ #define VM_FRAME_MAGIC_LAMBDA 0xa1
924
+ #define VM_FRAME_MAGIC_RESCUE 0xb1
925
+ #define VM_FRAME_MAGIC_DUMMY 0xc1
926
+ #define VM_FRAME_MAGIC_MASK_BITS 8
927
+ #define VM_FRAME_MAGIC_MASK (~(~(VALUE)0<<VM_FRAME_MAGIC_MASK_BITS))
928
+
929
+ #define VM_FRAME_TYPE(cfp) ((cfp)->flag & VM_FRAME_MAGIC_MASK)
930
+
931
+ /* other frame flag */
932
+ #define VM_FRAME_FLAG_PASSED 0x0100
933
+ #define VM_FRAME_FLAG_FINISH 0x0200
934
+ #define VM_FRAME_FLAG_BMETHOD 0x0400
935
+ #define VM_FRAME_TYPE_FINISH_P(cfp) (((cfp)->flag & VM_FRAME_FLAG_FINISH) != 0)
936
+ #define VM_FRAME_TYPE_BMETHOD_P(cfp) (((cfp)->flag & VM_FRAME_FLAG_BMETHOD) != 0)
937
+
938
+ #define RUBYVM_CFUNC_FRAME_P(cfp) \
939
+ (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)
940
+
941
+ /* inline cache */
942
+ typedef struct iseq_inline_cache_entry *IC;
943
+ typedef struct rb_call_info *CALL_INFO;
944
+ typedef struct rb_call_cache *CALL_CACHE;
945
+
946
+ void rb_vm_change_state(void);
947
+
948
+ typedef VALUE CDHASH;
949
+
950
+ #ifndef FUNC_FASTCALL
951
+ #define FUNC_FASTCALL(x) x
952
+ #endif
953
+
954
+ typedef rb_control_frame_t *
955
+ (FUNC_FASTCALL(*rb_insn_func_t))(rb_thread_t *, rb_control_frame_t *);
956
+
957
+ #define GC_GUARDED_PTR(p) ((VALUE)((VALUE)(p) | 0x01))
958
+ #define GC_GUARDED_PTR_REF(p) ((void *)(((VALUE)(p)) & ~0x03))
959
+ #define GC_GUARDED_PTR_P(p) (((VALUE)(p)) & 0x01)
960
+
961
+ /*
962
+ * block frame:
963
+ * ep[ 0]: prev frame
964
+ * ep[-1]: CREF (for *_eval)
965
+ *
966
+ * method frame:
967
+ * ep[ 0]: block pointer (ptr | VM_ENVVAL_BLOCK_PTR_FLAG)
968
+ */
969
+
970
+ #define VM_ENVVAL_BLOCK_PTR_FLAG 0x02
971
+ #define VM_ENVVAL_BLOCK_PTR(v) (GC_GUARDED_PTR(v) | VM_ENVVAL_BLOCK_PTR_FLAG)
972
+ #define VM_ENVVAL_BLOCK_PTR_P(v) ((v) & VM_ENVVAL_BLOCK_PTR_FLAG)
973
+ #define VM_ENVVAL_PREV_EP_PTR(v) ((VALUE)GC_GUARDED_PTR(v))
974
+ #define VM_ENVVAL_PREV_EP_PTR_P(v) (!(VM_ENVVAL_BLOCK_PTR_P(v)))
975
+
976
+ #define VM_EP_PREV_EP(ep) ((VALUE *)GC_GUARDED_PTR_REF((ep)[0]))
977
+ #define VM_EP_BLOCK_PTR(ep) ((rb_block_t *)GC_GUARDED_PTR_REF((ep)[0]))
978
+ #define VM_EP_LEP_P(ep) VM_ENVVAL_BLOCK_PTR_P((ep)[0])
979
+
980
+ VALUE *rb_vm_ep_local_ep(VALUE *ep);
981
+ rb_block_t *rb_vm_control_frame_block_ptr(const rb_control_frame_t *cfp);
982
+
983
+ #define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1)
984
+ #define RUBY_VM_NEXT_CONTROL_FRAME(cfp) ((cfp)-1)
985
+ #define RUBY_VM_END_CONTROL_FRAME(th) \
986
+ ((rb_control_frame_t *)((th)->stack + (th)->stack_size))
987
+ #define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \
988
+ ((void *)(ecfp) > (void *)(cfp))
989
+ #define RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp) \
990
+ (!RUBY_VM_VALID_CONTROL_FRAME_P((cfp), RUBY_VM_END_CONTROL_FRAME(th)))
991
+
992
+ #define RUBY_VM_IFUNC_P(ptr) (RB_TYPE_P((VALUE)(ptr), T_IMEMO) && imemo_type((VALUE)ptr) == imemo_ifunc)
993
+ #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))
994
+
995
+ #define RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp) ((rb_block_t *)(&(cfp)->self))
996
+ #define RUBY_VM_GET_CFP_FROM_BLOCK_PTR(b) \
997
+ ((rb_control_frame_t *)((VALUE *)(b) - 4))
998
+ /* magic number `4' is depend on rb_control_frame_t layout. */
999
+
1000
+ /* VM related object allocate functions */
1001
+ VALUE rb_thread_alloc(VALUE klass);
1002
+ VALUE rb_proc_alloc(VALUE klass);
1003
+ VALUE rb_binding_alloc(VALUE klass);
1004
+
1005
+ /* for debug */
1006
+ extern void rb_vmdebug_stack_dump_raw(rb_thread_t *, rb_control_frame_t *);
1007
+ extern void rb_vmdebug_debug_print_pre(rb_thread_t *th, rb_control_frame_t *cfp, VALUE *_pc);
1008
+ extern void rb_vmdebug_debug_print_post(rb_thread_t *th, rb_control_frame_t *cfp);
1009
+
1010
+ #define SDR() rb_vmdebug_stack_dump_raw(GET_THREAD(), GET_THREAD()->cfp)
1011
+ #define SDR2(cfp) rb_vmdebug_stack_dump_raw(GET_THREAD(), (cfp))
1012
+ void rb_vm_bugreport(const void *);
1013
+ NORETURN(void rb_bug_context(const void *, const char *fmt, ...));
1014
+
1015
+ /* functions about thread/vm execution */
1016
+ RUBY_SYMBOL_EXPORT_BEGIN
1017
+ VALUE rb_iseq_eval(const rb_iseq_t *iseq);
1018
+ VALUE rb_iseq_eval_main(const rb_iseq_t *iseq);
1019
+ RUBY_SYMBOL_EXPORT_END
1020
+ int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp);
1021
+
1022
+ VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc,
1023
+ int argc, const VALUE *argv, const rb_block_t *blockptr);
1024
+ VALUE rb_vm_make_proc_lambda(rb_thread_t *th, const rb_block_t *block, VALUE klass, int8_t is_lambda);
1025
+ VALUE rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass);
1026
+ VALUE rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp);
1027
+ VALUE rb_vm_env_local_variables(const rb_env_t *env);
1028
+ VALUE rb_vm_env_prev_envval(const rb_env_t *env);
1029
+ VALUE rb_vm_proc_envval(const rb_proc_t *proc);
1030
+ VALUE *rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars);
1031
+ void rb_vm_inc_const_missing_count(void);
1032
+ void rb_vm_gvl_destroy(rb_vm_t *vm);
1033
+ VALUE rb_vm_call(rb_thread_t *th, VALUE recv, VALUE id, int argc,
1034
+ const VALUE *argv, const rb_callable_method_entry_t *me);
1035
+
1036
+ void rb_thread_start_timer_thread(void);
1037
+ void rb_thread_stop_timer_thread(void);
1038
+ void rb_thread_reset_timer_thread(void);
1039
+ void rb_thread_wakeup_timer_thread(void);
1040
+
1041
+ static inline void
1042
+ rb_vm_living_threads_init(rb_vm_t *vm)
1043
+ {
1044
+ list_head_init(&vm->living_threads);
1045
+ vm->living_thread_num = 0;
1046
+ }
1047
+
1048
+ static inline void
1049
+ rb_vm_living_threads_insert(rb_vm_t *vm, rb_thread_t *th)
1050
+ {
1051
+ list_add_tail(&vm->living_threads, &th->vmlt_node);
1052
+ vm->living_thread_num++;
1053
+ }
1054
+
1055
+ static inline void
1056
+ rb_vm_living_threads_remove(rb_vm_t *vm, rb_thread_t *th)
1057
+ {
1058
+ list_del(&th->vmlt_node);
1059
+ vm->living_thread_num--;
1060
+ }
1061
+
1062
+ typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
1063
+ rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp);
1064
+ rb_control_frame_t *rb_vm_get_binding_creatable_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp);
1065
+ int rb_vm_get_sourceline(const rb_control_frame_t *);
1066
+ VALUE rb_name_err_mesg_new(VALUE mesg, VALUE recv, VALUE method);
1067
+ void rb_vm_stack_to_heap(rb_thread_t *th);
1068
+ void ruby_thread_init_stack(rb_thread_t *th);
1069
+ int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, VALUE *klassp);
1070
+ void rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
1071
+
1072
+ void rb_vm_register_special_exception(enum ruby_special_exceptions sp, VALUE exception_class, const char *mesg);
1073
+
1074
+ void rb_gc_mark_machine_stack(rb_thread_t *th);
1075
+
1076
+ int rb_autoloading_value(VALUE mod, ID id, VALUE* value);
1077
+
1078
+ void rb_vm_rewrite_cref(rb_cref_t *node, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr);
1079
+
1080
+ const rb_callable_method_entry_t *rb_vm_frame_method_entry(const rb_control_frame_t *cfp);
1081
+
1082
+ #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
1083
+
1084
+ #define RUBY_CONST_ASSERT(expr) (1/!!(expr)) /* expr must be a compile-time constant */
1085
+ #define VM_STACK_OVERFLOWED_P(cfp, sp, margin) \
1086
+ (!RUBY_CONST_ASSERT(sizeof(*(sp)) == sizeof(VALUE)) || \
1087
+ !RUBY_CONST_ASSERT(sizeof(*(cfp)) == sizeof(rb_control_frame_t)) || \
1088
+ ((rb_control_frame_t *)((sp) + (margin)) + 1) >= (cfp))
1089
+ #define WHEN_VM_STACK_OVERFLOWED(cfp, sp, margin) \
1090
+ if (LIKELY(!VM_STACK_OVERFLOWED_P(cfp, sp, margin))) {(void)0;} else /* overflowed */
1091
+ #define CHECK_VM_STACK_OVERFLOW0(cfp, sp, margin) \
1092
+ WHEN_VM_STACK_OVERFLOWED(cfp, sp, margin) vm_stackoverflow()
1093
+ #define CHECK_VM_STACK_OVERFLOW(cfp, margin) \
1094
+ WHEN_VM_STACK_OVERFLOWED(cfp, (cfp)->sp, margin) vm_stackoverflow()
1095
+
1096
+ /* for thread */
1097
+
1098
+ #if RUBY_VM_THREAD_MODEL == 2
1099
+ extern rb_thread_t *ruby_current_thread;
1100
+ extern rb_vm_t *ruby_current_vm;
1101
+ extern rb_event_flag_t ruby_vm_event_flags;
1102
+
1103
+ #define GET_VM() ruby_current_vm
1104
+
1105
+ #ifndef OPT_CALL_CFUNC_WITHOUT_FRAME
1106
+ #define OPT_CALL_CFUNC_WITHOUT_FRAME 0
1107
+ #endif
1108
+
1109
+ #define GET_THREAD() vm_thread_with_frame(ruby_current_thread)
1110
+ #if OPT_CALL_CFUNC_WITHOUT_FRAME
1111
+ static inline rb_thread_t *
1112
+ vm_thread_with_frame(rb_thread_t *th)
1113
+ {
1114
+ if (UNLIKELY(th->passed_ci != 0)) {
1115
+ void rb_vm_call_cfunc_push_frame(rb_thread_t *th);
1116
+ rb_vm_call_cfunc_push_frame(th);
1117
+ }
1118
+ return th;
1119
+ }
1120
+ #else
1121
+ #define vm_thread_with_frame(th) (th)
1122
+ #endif
1123
+
1124
+ #define rb_thread_set_current_raw(th) (void)(ruby_current_thread = (th))
1125
+ #define rb_thread_set_current(th) do { \
1126
+ if ((th)->vm->running_thread != (th)) { \
1127
+ (th)->running_time_us = 0; \
1128
+ } \
1129
+ rb_thread_set_current_raw(th); \
1130
+ (th)->vm->running_thread = (th); \
1131
+ } while (0)
1132
+
1133
+ #else
1134
+ #error "unsupported thread model"
1135
+ #endif
1136
+
1137
+ enum {
1138
+ TIMER_INTERRUPT_MASK = 0x01,
1139
+ PENDING_INTERRUPT_MASK = 0x02,
1140
+ POSTPONED_JOB_INTERRUPT_MASK = 0x04,
1141
+ TRAP_INTERRUPT_MASK = 0x08
1142
+ };
1143
+
1144
+ #define RUBY_VM_SET_TIMER_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, TIMER_INTERRUPT_MASK)
1145
+ #define RUBY_VM_SET_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, PENDING_INTERRUPT_MASK)
1146
+ #define RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, POSTPONED_JOB_INTERRUPT_MASK)
1147
+ #define RUBY_VM_SET_TRAP_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, TRAP_INTERRUPT_MASK)
1148
+ #define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & ~(th)->interrupt_mask & (PENDING_INTERRUPT_MASK|TRAP_INTERRUPT_MASK))
1149
+ #define RUBY_VM_INTERRUPTED_ANY(th) ((th)->interrupt_flag & ~(th)->interrupt_mask)
1150
+
1151
+ int rb_signal_buff_size(void);
1152
+ void rb_signal_exec(rb_thread_t *th, int sig);
1153
+ void rb_threadptr_check_signal(rb_thread_t *mth);
1154
+ void rb_threadptr_signal_raise(rb_thread_t *th, int sig);
1155
+ void rb_threadptr_signal_exit(rb_thread_t *th);
1156
+ void rb_threadptr_execute_interrupts(rb_thread_t *, int);
1157
+ void rb_threadptr_interrupt(rb_thread_t *th);
1158
+ void rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th);
1159
+ void rb_threadptr_pending_interrupt_clear(rb_thread_t *th);
1160
+ void rb_threadptr_pending_interrupt_enque(rb_thread_t *th, VALUE v);
1161
+ int rb_threadptr_pending_interrupt_active_p(rb_thread_t *th);
1162
+
1163
+ #define RUBY_VM_CHECK_INTS(th) ruby_vm_check_ints(th)
1164
+ static inline void
1165
+ ruby_vm_check_ints(rb_thread_t *th)
1166
+ {
1167
+ if (UNLIKELY(RUBY_VM_INTERRUPTED_ANY(th))) {
1168
+ rb_threadptr_execute_interrupts(th, 0);
1169
+ }
1170
+ }
1171
+
1172
+ /* tracer */
1173
+ struct rb_trace_arg_struct {
1174
+ rb_event_flag_t event;
1175
+ rb_thread_t *th;
1176
+ rb_control_frame_t *cfp;
1177
+ VALUE self;
1178
+ ID id;
1179
+ VALUE klass;
1180
+ VALUE data;
1181
+
1182
+ int klass_solved;
1183
+
1184
+ /* calc from cfp */
1185
+ int lineno;
1186
+ VALUE path;
1187
+ };
1188
+
1189
+ void rb_threadptr_exec_event_hooks(struct rb_trace_arg_struct *trace_arg);
1190
+ void rb_threadptr_exec_event_hooks_and_pop_frame(struct rb_trace_arg_struct *trace_arg);
1191
+
1192
+ #define EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, pop_p_) do { \
1193
+ const rb_event_flag_t flag_arg_ = (flag_); \
1194
+ if (UNLIKELY(ruby_vm_event_flags & (flag_arg_))) { \
1195
+ /* defer evaluating the other arguments */ \
1196
+ ruby_exec_event_hook_orig(th_, flag_arg_, self_, id_, klass_, data_, pop_p_); \
1197
+ } \
1198
+ } while (0)
1199
+
1200
+ static inline void
1201
+ ruby_exec_event_hook_orig(rb_thread_t *const th, const rb_event_flag_t flag,
1202
+ VALUE self, ID id, VALUE klass, VALUE data, int pop_p)
1203
+ {
1204
+ if ((th->event_hooks.events | th->vm->event_hooks.events) & flag) {
1205
+ struct rb_trace_arg_struct trace_arg;
1206
+ trace_arg.event = flag;
1207
+ trace_arg.th = th;
1208
+ trace_arg.cfp = th->cfp;
1209
+ trace_arg.self = self;
1210
+ trace_arg.id = id;
1211
+ trace_arg.klass = klass;
1212
+ trace_arg.data = data;
1213
+ trace_arg.path = Qundef;
1214
+ trace_arg.klass_solved = 0;
1215
+ if (pop_p) rb_threadptr_exec_event_hooks_and_pop_frame(&trace_arg);
1216
+ else rb_threadptr_exec_event_hooks(&trace_arg);
1217
+ }
1218
+ }
1219
+
1220
+ #define EXEC_EVENT_HOOK(th_, flag_, self_, id_, klass_, data_) \
1221
+ EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, 0)
1222
+
1223
+ #define EXEC_EVENT_HOOK_AND_POP_FRAME(th_, flag_, self_, id_, klass_, data_) \
1224
+ EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, 1)
1225
+
1226
+ RUBY_SYMBOL_EXPORT_BEGIN
1227
+
1228
+ int rb_thread_check_trap_pending(void);
1229
+
1230
+ extern VALUE rb_get_coverages(void);
1231
+ extern void rb_set_coverages(VALUE);
1232
+ extern void rb_reset_coverages(void);
1233
+
1234
+ void rb_postponed_job_flush(rb_vm_t *vm);
1235
+
1236
+ RUBY_SYMBOL_EXPORT_END
1237
+
1238
+ #endif /* RUBY_VM_CORE_H */