debase-ruby_core_source 0.10.9 → 0.10.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +1 -1
  4. data/debase-ruby_core_source.gemspec +3 -2
  5. data/lib/debase/ruby_core_source.rb +0 -2
  6. data/lib/debase/ruby_core_source/version.rb +1 -1
  7. metadata +22 -113
  8. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/addr2line.h +0 -21
  9. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ccan/build_assert/build_assert.h +0 -40
  10. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ccan/check_type/check_type.h +0 -63
  11. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ccan/container_of/container_of.h +0 -142
  12. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ccan/list/list.h +0 -788
  13. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ccan/str/str.h +0 -16
  14. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/constant.h +0 -54
  15. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/debug_counter.h +0 -378
  16. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/dln.h +0 -51
  17. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/encindex.h +0 -69
  18. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/eval_intern.h +0 -314
  19. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/gc.h +0 -129
  20. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/hrtime.h +0 -168
  21. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/id.h +0 -292
  22. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/id_table.h +0 -34
  23. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/insns.inc +0 -249
  24. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/insns_info.inc +0 -9614
  25. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/internal.h +0 -2682
  26. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/iseq.h +0 -312
  27. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/known_errors.inc +0 -791
  28. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/method.h +0 -232
  29. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/mjit.h +0 -179
  30. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/mjit_compile.inc +0 -7883
  31. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/node.h +0 -483
  32. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/node_name.inc +0 -210
  33. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/opt_sc.inc +0 -109
  34. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/optinsn.inc +0 -128
  35. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/optunifs.inc +0 -43
  36. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/parse.h +0 -210
  37. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/probes_helper.h +0 -42
  38. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/regenc.h +0 -254
  39. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/regint.h +0 -938
  40. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/regparse.h +0 -370
  41. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/revision.h +0 -2
  42. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ruby_assert.h +0 -15
  43. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ruby_atomic.h +0 -244
  44. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/siphash.h +0 -48
  45. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/symbol.h +0 -119
  46. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/thread_pthread.h +0 -75
  47. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/thread_win32.h +0 -36
  48. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/timev.h +0 -56
  49. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/transcode_data.h +0 -139
  50. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/transient_heap.h +0 -62
  51. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/version.h +0 -77
  52. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm.inc +0 -5269
  53. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm_call_iseq_optimized.inc +0 -237
  54. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm_core.h +0 -1955
  55. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm_debug.h +0 -34
  56. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm_exec.h +0 -193
  57. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm_insnhelper.h +0 -255
  58. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm_opts.h +0 -70
  59. data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vmtc.inc +0 -243
  60. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/addr2line.h +0 -21
  61. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/builtin.h +0 -68
  62. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/ccan/build_assert/build_assert.h +0 -40
  63. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/ccan/check_type/check_type.h +0 -63
  64. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/ccan/container_of/container_of.h +0 -142
  65. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/ccan/list/list.h +0 -788
  66. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/ccan/str/str.h +0 -16
  67. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/constant.h +0 -50
  68. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/debug_counter.h +0 -378
  69. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/dln.h +0 -51
  70. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/encindex.h +0 -69
  71. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/eval_intern.h +0 -311
  72. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/gc.h +0 -129
  73. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/hrtime.h +0 -168
  74. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/id.h +0 -290
  75. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/id_table.h +0 -34
  76. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/insns.inc +0 -253
  77. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/insns_info.inc +0 -9196
  78. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/internal.h +0 -2657
  79. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/iseq.h +0 -311
  80. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/known_errors.inc +0 -791
  81. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/method.h +0 -228
  82. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/mjit.h +0 -175
  83. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/mjit_compile.inc +0 -7782
  84. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/node.h +0 -476
  85. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/node_name.inc +0 -208
  86. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/opt_sc.inc +0 -109
  87. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/optinsn.inc +0 -128
  88. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/optunifs.inc +0 -43
  89. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/parse.h +0 -210
  90. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/probes_helper.h +0 -42
  91. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/regenc.h +0 -254
  92. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/regint.h +0 -938
  93. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/regparse.h +0 -370
  94. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/revision.h +0 -2
  95. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/ruby_assert.h +0 -15
  96. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/ruby_atomic.h +0 -244
  97. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/siphash.h +0 -48
  98. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/symbol.h +0 -119
  99. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/thread_pthread.h +0 -75
  100. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/thread_win32.h +0 -36
  101. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/timev.h +0 -56
  102. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/transcode_data.h +0 -139
  103. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/transient_heap.h +0 -62
  104. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/version.h +0 -77
  105. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/vm.inc +0 -5319
  106. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/vm_call_iseq_optimized.inc +0 -237
  107. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/vm_core.h +0 -1957
  108. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/vm_debug.h +0 -34
  109. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/vm_exec.h +0 -193
  110. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/vm_insnhelper.h +0 -255
  111. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/vm_opts.h +0 -72
  112. data/lib/debase/ruby_core_source/ruby-2.7.0-preview3/vmtc.inc +0 -247
@@ -1,237 +0,0 @@
1
- /* -*- c -*- */
2
- #if 1 /* enable or disable this optimization */
3
-
4
- /* DO NOT EDIT THIS FILE DIRECTLY
5
- *
6
- * This file is generated by tool/mk_call_iseq_optimized.rb
7
- */
8
-
9
- static VALUE
10
- vm_call_iseq_setup_normal_0start_0params_0locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
11
- {
12
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
13
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 0, 0);
14
- }
15
-
16
- static VALUE
17
- vm_call_iseq_setup_normal_0start_0params_1locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
18
- {
19
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
20
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 0, 1);
21
- }
22
-
23
- static VALUE
24
- vm_call_iseq_setup_normal_0start_0params_2locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
25
- {
26
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
27
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 0, 2);
28
- }
29
-
30
- static VALUE
31
- vm_call_iseq_setup_normal_0start_0params_3locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
32
- {
33
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
34
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 0, 3);
35
- }
36
-
37
- static VALUE
38
- vm_call_iseq_setup_normal_0start_0params_4locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
39
- {
40
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
41
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 0, 4);
42
- }
43
-
44
- static VALUE
45
- vm_call_iseq_setup_normal_0start_0params_5locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
46
- {
47
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
48
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 0, 5);
49
- }
50
-
51
- static VALUE
52
- vm_call_iseq_setup_normal_0start_1params_0locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
53
- {
54
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
55
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 1, 0);
56
- }
57
-
58
- static VALUE
59
- vm_call_iseq_setup_normal_0start_1params_1locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
60
- {
61
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
62
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 1, 1);
63
- }
64
-
65
- static VALUE
66
- vm_call_iseq_setup_normal_0start_1params_2locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
67
- {
68
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
69
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 1, 2);
70
- }
71
-
72
- static VALUE
73
- vm_call_iseq_setup_normal_0start_1params_3locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
74
- {
75
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
76
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 1, 3);
77
- }
78
-
79
- static VALUE
80
- vm_call_iseq_setup_normal_0start_1params_4locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
81
- {
82
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
83
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 1, 4);
84
- }
85
-
86
- static VALUE
87
- vm_call_iseq_setup_normal_0start_1params_5locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
88
- {
89
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
90
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 1, 5);
91
- }
92
-
93
- static VALUE
94
- vm_call_iseq_setup_normal_0start_2params_0locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
95
- {
96
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
97
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 2, 0);
98
- }
99
-
100
- static VALUE
101
- vm_call_iseq_setup_normal_0start_2params_1locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
102
- {
103
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
104
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 2, 1);
105
- }
106
-
107
- static VALUE
108
- vm_call_iseq_setup_normal_0start_2params_2locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
109
- {
110
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
111
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 2, 2);
112
- }
113
-
114
- static VALUE
115
- vm_call_iseq_setup_normal_0start_2params_3locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
116
- {
117
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
118
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 2, 3);
119
- }
120
-
121
- static VALUE
122
- vm_call_iseq_setup_normal_0start_2params_4locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
123
- {
124
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
125
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 2, 4);
126
- }
127
-
128
- static VALUE
129
- vm_call_iseq_setup_normal_0start_2params_5locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
130
- {
131
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
132
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 2, 5);
133
- }
134
-
135
- static VALUE
136
- vm_call_iseq_setup_normal_0start_3params_0locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
137
- {
138
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
139
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 3, 0);
140
- }
141
-
142
- static VALUE
143
- vm_call_iseq_setup_normal_0start_3params_1locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
144
- {
145
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
146
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 3, 1);
147
- }
148
-
149
- static VALUE
150
- vm_call_iseq_setup_normal_0start_3params_2locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
151
- {
152
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
153
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 3, 2);
154
- }
155
-
156
- static VALUE
157
- vm_call_iseq_setup_normal_0start_3params_3locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
158
- {
159
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
160
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 3, 3);
161
- }
162
-
163
- static VALUE
164
- vm_call_iseq_setup_normal_0start_3params_4locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
165
- {
166
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
167
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 3, 4);
168
- }
169
-
170
- static VALUE
171
- vm_call_iseq_setup_normal_0start_3params_5locals(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
172
- {
173
- RB_DEBUG_COUNTER_INC(ccf_iseq_fix);
174
- return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, 3, 5);
175
- }
176
-
177
- /* vm_call_iseq_handlers[param][local] */
178
- static const vm_call_handler vm_call_iseq_handlers[][6] = {
179
- {vm_call_iseq_setup_normal_0start_0params_0locals,
180
- vm_call_iseq_setup_normal_0start_0params_1locals,
181
- vm_call_iseq_setup_normal_0start_0params_2locals,
182
- vm_call_iseq_setup_normal_0start_0params_3locals,
183
- vm_call_iseq_setup_normal_0start_0params_4locals,
184
- vm_call_iseq_setup_normal_0start_0params_5locals},
185
- {vm_call_iseq_setup_normal_0start_1params_0locals,
186
- vm_call_iseq_setup_normal_0start_1params_1locals,
187
- vm_call_iseq_setup_normal_0start_1params_2locals,
188
- vm_call_iseq_setup_normal_0start_1params_3locals,
189
- vm_call_iseq_setup_normal_0start_1params_4locals,
190
- vm_call_iseq_setup_normal_0start_1params_5locals},
191
- {vm_call_iseq_setup_normal_0start_2params_0locals,
192
- vm_call_iseq_setup_normal_0start_2params_1locals,
193
- vm_call_iseq_setup_normal_0start_2params_2locals,
194
- vm_call_iseq_setup_normal_0start_2params_3locals,
195
- vm_call_iseq_setup_normal_0start_2params_4locals,
196
- vm_call_iseq_setup_normal_0start_2params_5locals},
197
- {vm_call_iseq_setup_normal_0start_3params_0locals,
198
- vm_call_iseq_setup_normal_0start_3params_1locals,
199
- vm_call_iseq_setup_normal_0start_3params_2locals,
200
- vm_call_iseq_setup_normal_0start_3params_3locals,
201
- vm_call_iseq_setup_normal_0start_3params_4locals,
202
- vm_call_iseq_setup_normal_0start_3params_5locals}
203
- };
204
-
205
- static inline vm_call_handler
206
- vm_call_iseq_setup_func(const struct rb_call_info *ci, const int param_size, const int local_size)
207
- {
208
- if (UNLIKELY(ci->flag & VM_CALL_TAILCALL)) {
209
- return &vm_call_iseq_setup_tailcall_0start;
210
- }
211
- else if (0) { /* to disable optimize */
212
- return &vm_call_iseq_setup_normal_0start;
213
- }
214
- else {
215
- if (param_size <= 3 &&
216
- local_size <= 5) {
217
- VM_ASSERT(local_size >= 0);
218
- return vm_call_iseq_handlers[param_size][local_size];
219
- }
220
- return &vm_call_iseq_setup_normal_0start;
221
- }
222
- }
223
-
224
- #else
225
-
226
-
227
- static inline vm_call_handler
228
- vm_call_iseq_setup_func(const struct rb_call_info *ci, const int param_size, const int local_size)
229
- {
230
- if (UNLIKELY(ci->flag & VM_CALL_TAILCALL)) {
231
- return &vm_call_iseq_setup_tailcall_0start;
232
- }
233
- else {
234
- return &vm_call_iseq_setup_normal_0start;
235
- }
236
- }
237
- #endif
@@ -1,1957 +0,0 @@
1
- /**********************************************************************
2
-
3
- vm_core.h -
4
-
5
- $Author$
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
-
21
- // respect RUBY_DUBUG: if given n is 0, then use RUBY_DEBUG
22
- #define N_OR_RUBY_DEBUG(n) (((n) > 0) ? (n) : RUBY_DEBUG)
23
-
24
- #define VM_CHECK_MODE N_OR_RUBY_DEBUG(0)
25
- #endif
26
-
27
- /**
28
- * VM Debug Level
29
- *
30
- * debug level:
31
- * 0: no debug output
32
- * 1: show instruction name
33
- * 2: show stack frame when control stack frame is changed
34
- * 3: show stack status
35
- * 4: show register
36
- * 5:
37
- * 10: gc check
38
- */
39
-
40
- #ifndef VMDEBUG
41
- #define VMDEBUG 0
42
- #endif
43
-
44
- #if 0
45
- #undef VMDEBUG
46
- #define VMDEBUG 3
47
- #endif
48
-
49
- #include "ruby_assert.h"
50
-
51
- #if VM_CHECK_MODE > 0
52
- #define VM_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(VM_CHECK_MODE > 0, expr, #expr)
53
- #define VM_UNREACHABLE(func) rb_bug(#func ": unreachable")
54
-
55
- #else
56
- #define VM_ASSERT(expr) ((void)0)
57
- #define VM_UNREACHABLE(func) UNREACHABLE
58
- #endif
59
-
60
- #define RUBY_VM_THREAD_MODEL 2
61
-
62
- /*
63
- * implementation selector of get_insn_info algorithm
64
- * 0: linear search
65
- * 1: binary search
66
- * 2: succinct bitvector
67
- */
68
- #ifndef VM_INSN_INFO_TABLE_IMPL
69
- # define VM_INSN_INFO_TABLE_IMPL 2
70
- #endif
71
-
72
- #include "ruby/ruby.h"
73
- #include "ruby/st.h"
74
-
75
- #include "node.h"
76
- #include "vm_opts.h"
77
- #include "id.h"
78
- #include "method.h"
79
- #include "ruby_atomic.h"
80
- #include "ccan/list/list.h"
81
-
82
- #include "ruby/thread_native.h"
83
- #if defined(_WIN32)
84
- #include "thread_win32.h"
85
- #elif defined(HAVE_PTHREAD_H)
86
- #include "thread_pthread.h"
87
- #endif
88
-
89
- #include <setjmp.h>
90
- #include <signal.h>
91
-
92
- #if defined(NSIG_MAX) /* POSIX issue 8 */
93
- # undef NSIG
94
- # define NSIG NSIG_MAX
95
- #elif defined(_SIG_MAXSIG) /* FreeBSD */
96
- # undef NSIG
97
- # define NSIG _SIG_MAXSIG
98
- #elif defined(_SIGMAX) /* QNX */
99
- # define NSIG (_SIGMAX + 1)
100
- #elif defined(NSIG) /* 99% of everything else */
101
- # /* take it */
102
- #else /* Last resort */
103
- # define NSIG (sizeof(sigset_t) * CHAR_BIT + 1)
104
- #endif
105
-
106
- #define RUBY_NSIG NSIG
107
-
108
- #if defined(SIGCLD)
109
- # define RUBY_SIGCHLD (SIGCLD)
110
- #elif defined(SIGCHLD)
111
- # define RUBY_SIGCHLD (SIGCHLD)
112
- #else
113
- # define RUBY_SIGCHLD (0)
114
- #endif
115
-
116
- /* platforms with broken or non-existent SIGCHLD work by polling */
117
- #if defined(__APPLE__)
118
- # define SIGCHLD_LOSSY (1)
119
- #else
120
- # define SIGCHLD_LOSSY (0)
121
- #endif
122
-
123
- /* define to 0 to test old code path */
124
- #define WAITPID_USE_SIGCHLD (RUBY_SIGCHLD || SIGCHLD_LOSSY)
125
-
126
- #ifdef HAVE_STDARG_PROTOTYPES
127
- #include <stdarg.h>
128
- #define va_init_list(a,b) va_start((a),(b))
129
- #else
130
- #include <varargs.h>
131
- #define va_init_list(a,b) va_start((a))
132
- #endif
133
-
134
- #if defined(SIGSEGV) && defined(HAVE_SIGALTSTACK) && defined(SA_SIGINFO) && !defined(__NetBSD__)
135
- # define USE_SIGALTSTACK
136
- void *rb_register_sigaltstack(void);
137
- # define RB_ALTSTACK_INIT(var) var = rb_register_sigaltstack()
138
- # define RB_ALTSTACK_FREE(var) xfree(var)
139
- # define RB_ALTSTACK(var) var
140
- #else /* noop */
141
- # define RB_ALTSTACK_INIT(var)
142
- # define RB_ALTSTACK_FREE(var)
143
- # define RB_ALTSTACK(var) (0)
144
- #endif
145
-
146
- /*****************/
147
- /* configuration */
148
- /*****************/
149
-
150
- /* gcc ver. check */
151
- #if defined(__GNUC__) && __GNUC__ >= 2
152
-
153
- #if OPT_TOKEN_THREADED_CODE
154
- #if OPT_DIRECT_THREADED_CODE
155
- #undef OPT_DIRECT_THREADED_CODE
156
- #endif
157
- #endif
158
-
159
- #else /* defined(__GNUC__) && __GNUC__ >= 2 */
160
-
161
- /* disable threaded code options */
162
- #if OPT_DIRECT_THREADED_CODE
163
- #undef OPT_DIRECT_THREADED_CODE
164
- #endif
165
- #if OPT_TOKEN_THREADED_CODE
166
- #undef OPT_TOKEN_THREADED_CODE
167
- #endif
168
- #endif
169
-
170
- /* call threaded code */
171
- #if OPT_CALL_THREADED_CODE
172
- #if OPT_DIRECT_THREADED_CODE
173
- #undef OPT_DIRECT_THREADED_CODE
174
- #endif /* OPT_DIRECT_THREADED_CODE */
175
- #if OPT_STACK_CACHING
176
- #undef OPT_STACK_CACHING
177
- #endif /* OPT_STACK_CACHING */
178
- #endif /* OPT_CALL_THREADED_CODE */
179
-
180
- void rb_vm_encoded_insn_data_table_init(void);
181
- typedef unsigned long rb_num_t;
182
- typedef signed long rb_snum_t;
183
-
184
- enum ruby_tag_type {
185
- RUBY_TAG_NONE = 0x0,
186
- RUBY_TAG_RETURN = 0x1,
187
- RUBY_TAG_BREAK = 0x2,
188
- RUBY_TAG_NEXT = 0x3,
189
- RUBY_TAG_RETRY = 0x4,
190
- RUBY_TAG_REDO = 0x5,
191
- RUBY_TAG_RAISE = 0x6,
192
- RUBY_TAG_THROW = 0x7,
193
- RUBY_TAG_FATAL = 0x8,
194
- RUBY_TAG_MASK = 0xf
195
- };
196
-
197
- #define TAG_NONE RUBY_TAG_NONE
198
- #define TAG_RETURN RUBY_TAG_RETURN
199
- #define TAG_BREAK RUBY_TAG_BREAK
200
- #define TAG_NEXT RUBY_TAG_NEXT
201
- #define TAG_RETRY RUBY_TAG_RETRY
202
- #define TAG_REDO RUBY_TAG_REDO
203
- #define TAG_RAISE RUBY_TAG_RAISE
204
- #define TAG_THROW RUBY_TAG_THROW
205
- #define TAG_FATAL RUBY_TAG_FATAL
206
- #define TAG_MASK RUBY_TAG_MASK
207
-
208
- enum ruby_vm_throw_flags {
209
- VM_THROW_NO_ESCAPE_FLAG = 0x8000,
210
- VM_THROW_STATE_MASK = 0xff
211
- };
212
-
213
- /* forward declarations */
214
- struct rb_thread_struct;
215
- struct rb_control_frame_struct;
216
-
217
- /* iseq data type */
218
- typedef struct rb_compile_option_struct rb_compile_option_t;
219
-
220
- struct iseq_inline_cache_entry {
221
- rb_serial_t ic_serial;
222
- const rb_cref_t *ic_cref;
223
- union {
224
- size_t index;
225
- VALUE value;
226
- } ic_value;
227
- };
228
-
229
- union iseq_inline_storage_entry {
230
- struct {
231
- struct rb_thread_struct *running_thread;
232
- VALUE value;
233
- } once;
234
- struct iseq_inline_cache_entry cache;
235
- };
236
-
237
- struct rb_call_info_kw_arg {
238
- int keyword_len;
239
- VALUE keywords[1];
240
- };
241
-
242
- struct rb_call_info_with_kwarg {
243
- struct rb_call_info ci;
244
- struct rb_call_info_kw_arg *kw_arg;
245
- };
246
-
247
- struct rb_calling_info {
248
- VALUE block_handler;
249
- VALUE recv;
250
- int argc;
251
- int kw_splat;
252
- };
253
-
254
- struct rb_kwarg_call_data {
255
- struct rb_call_cache cc;
256
- struct rb_call_info_with_kwarg ci_kw;
257
- };
258
-
259
- struct rb_execution_context_struct;
260
- typedef VALUE (*vm_call_handler)(struct rb_execution_context_struct *ec, struct rb_control_frame_struct *cfp, struct rb_calling_info *calling, struct rb_call_data *cd);
261
-
262
- #if 1
263
- #define CoreDataFromValue(obj, type) (type*)DATA_PTR(obj)
264
- #else
265
- #define CoreDataFromValue(obj, type) (type*)rb_data_object_get(obj)
266
- #endif
267
- #define GetCoreDataFromValue(obj, type, ptr) ((ptr) = CoreDataFromValue((obj), type))
268
-
269
- typedef struct rb_iseq_location_struct {
270
- VALUE pathobj; /* String (path) or Array [path, realpath]. Frozen. */
271
- VALUE base_label; /* String */
272
- VALUE label; /* String */
273
- VALUE first_lineno; /* TODO: may be unsigned short */
274
- int node_id;
275
- rb_code_location_t code_location;
276
- } rb_iseq_location_t;
277
-
278
- #define PATHOBJ_PATH 0
279
- #define PATHOBJ_REALPATH 1
280
-
281
- static inline VALUE
282
- pathobj_path(VALUE pathobj)
283
- {
284
- if (RB_TYPE_P(pathobj, T_STRING)) {
285
- return pathobj;
286
- }
287
- else {
288
- VM_ASSERT(RB_TYPE_P(pathobj, T_ARRAY));
289
- return RARRAY_AREF(pathobj, PATHOBJ_PATH);
290
- }
291
- }
292
-
293
- static inline VALUE
294
- pathobj_realpath(VALUE pathobj)
295
- {
296
- if (RB_TYPE_P(pathobj, T_STRING)) {
297
- return pathobj;
298
- }
299
- else {
300
- VM_ASSERT(RB_TYPE_P(pathobj, T_ARRAY));
301
- return RARRAY_AREF(pathobj, PATHOBJ_REALPATH);
302
- }
303
- }
304
-
305
- /* Forward declarations */
306
- struct rb_mjit_unit;
307
-
308
- struct rb_iseq_constant_body {
309
- enum iseq_type {
310
- ISEQ_TYPE_TOP,
311
- ISEQ_TYPE_METHOD,
312
- ISEQ_TYPE_BLOCK,
313
- ISEQ_TYPE_CLASS,
314
- ISEQ_TYPE_RESCUE,
315
- ISEQ_TYPE_ENSURE,
316
- ISEQ_TYPE_EVAL,
317
- ISEQ_TYPE_MAIN,
318
- ISEQ_TYPE_PLAIN
319
- } type; /* instruction sequence type */
320
-
321
- unsigned int iseq_size;
322
- VALUE *iseq_encoded; /* encoded iseq (insn addr and operands) */
323
-
324
- /**
325
- * parameter information
326
- *
327
- * def m(a1, a2, ..., aM, # mandatory
328
- * b1=(...), b2=(...), ..., bN=(...), # optional
329
- * *c, # rest
330
- * d1, d2, ..., dO, # post
331
- * e1:(...), e2:(...), ..., eK:(...), # keyword
332
- * **f, # keyword_rest
333
- * &g) # block
334
- * =>
335
- *
336
- * lead_num = M
337
- * opt_num = N
338
- * rest_start = M+N
339
- * post_start = M+N+(*1)
340
- * post_num = O
341
- * keyword_num = K
342
- * block_start = M+N+(*1)+O+K
343
- * keyword_bits = M+N+(*1)+O+K+(&1)
344
- * size = M+N+O+(*1)+K+(&1)+(**1) // parameter size.
345
- */
346
-
347
- struct {
348
- struct {
349
- unsigned int has_lead : 1;
350
- unsigned int has_opt : 1;
351
- unsigned int has_rest : 1;
352
- unsigned int has_post : 1;
353
- unsigned int has_kw : 1;
354
- unsigned int has_kwrest : 1;
355
- unsigned int has_block : 1;
356
-
357
- unsigned int ambiguous_param0 : 1; /* {|a|} */
358
- unsigned int accepts_no_kwarg : 1;
359
- unsigned int ruby2_keywords: 1;
360
- } flags;
361
-
362
- unsigned int size;
363
-
364
- int lead_num;
365
- int opt_num;
366
- int rest_start;
367
- int post_start;
368
- int post_num;
369
- int block_start;
370
-
371
- const VALUE *opt_table; /* (opt_num + 1) entries. */
372
- /* opt_num and opt_table:
373
- *
374
- * def foo o1=e1, o2=e2, ..., oN=eN
375
- * #=>
376
- * # prologue code
377
- * A1: e1
378
- * A2: e2
379
- * ...
380
- * AN: eN
381
- * AL: body
382
- * opt_num = N
383
- * opt_table = [A1, A2, ..., AN, AL]
384
- */
385
-
386
- const struct rb_iseq_param_keyword {
387
- int num;
388
- int required_num;
389
- int bits_start;
390
- int rest_start;
391
- const ID *table;
392
- VALUE *default_values;
393
- } *keyword;
394
- } param;
395
-
396
- rb_iseq_location_t location;
397
-
398
- /* insn info, must be freed */
399
- struct iseq_insn_info {
400
- const struct iseq_insn_info_entry *body;
401
- unsigned int *positions;
402
- unsigned int size;
403
- #if VM_INSN_INFO_TABLE_IMPL == 2
404
- struct succ_index_table *succ_index_table;
405
- #endif
406
- } insns_info;
407
-
408
- const ID *local_table; /* must free */
409
-
410
- /* catch table */
411
- struct iseq_catch_table *catch_table;
412
-
413
- /* for child iseq */
414
- const struct rb_iseq_struct *parent_iseq;
415
- struct rb_iseq_struct *local_iseq; /* local_iseq->flip_cnt can be modified */
416
-
417
- union iseq_inline_storage_entry *is_entries;
418
- struct rb_call_data *call_data; /* A buffer for two arrays:
419
- * struct rb_call_data calls[ci_size];
420
- * struct rb_kwarg_call_data kw_calls[ci_kw_size];
421
- * Such that:
422
- * struct rb_kwarg_call_data *kw_calls = &body->call_data[ci_size];
423
- */
424
-
425
- struct {
426
- rb_snum_t flip_count;
427
- VALUE coverage;
428
- VALUE pc2branchindex;
429
- VALUE *original_iseq;
430
- } variable;
431
-
432
- unsigned int local_table_size;
433
- unsigned int is_size;
434
- unsigned int ci_size;
435
- unsigned int ci_kw_size;
436
- unsigned int stack_max; /* for stack overflow check */
437
-
438
- char catch_except_p; /* If a frame of this ISeq may catch exception, set TRUE */
439
-
440
- #if USE_MJIT
441
- /* The following fields are MJIT related info. */
442
- VALUE (*jit_func)(struct rb_execution_context_struct *,
443
- struct rb_control_frame_struct *); /* function pointer for loaded native code */
444
- long unsigned total_calls; /* number of total calls with `mjit_exec()` */
445
- struct rb_mjit_unit *jit_unit;
446
- #endif
447
- };
448
-
449
- /* T_IMEMO/iseq */
450
- /* typedef rb_iseq_t is in method.h */
451
- struct rb_iseq_struct {
452
- VALUE flags; /* 1 */
453
- VALUE wrapper; /* 2 */
454
-
455
- struct rb_iseq_constant_body *body; /* 3 */
456
-
457
- union { /* 4, 5 words */
458
- struct iseq_compile_data *compile_data; /* used at compile time */
459
-
460
- struct {
461
- VALUE obj;
462
- int index;
463
- } loader;
464
-
465
- struct {
466
- struct rb_hook_list_struct *local_hooks;
467
- rb_event_flag_t global_trace_events;
468
- } exec;
469
- } aux;
470
- };
471
-
472
- #ifndef USE_LAZY_LOAD
473
- #define USE_LAZY_LOAD 0
474
- #endif
475
-
476
- #if USE_LAZY_LOAD
477
- const rb_iseq_t *rb_iseq_complete(const rb_iseq_t *iseq);
478
- #endif
479
-
480
- static inline const rb_iseq_t *
481
- rb_iseq_check(const rb_iseq_t *iseq)
482
- {
483
- #if USE_LAZY_LOAD
484
- if (iseq->body == NULL) {
485
- rb_iseq_complete((rb_iseq_t *)iseq);
486
- }
487
- #endif
488
- return iseq;
489
- }
490
-
491
- static inline const rb_iseq_t *
492
- def_iseq_ptr(rb_method_definition_t *def)
493
- {
494
- //TODO: re-visit. to check the bug, enable this assertion.
495
- #if 1 || VM_CHECK_MODE > 0
496
- if (def->type != VM_METHOD_TYPE_ISEQ) rb_bug("def_iseq_ptr: not iseq (%d)", def->type);
497
- #endif
498
- return rb_iseq_check(def->body.iseq.iseqptr);
499
- }
500
-
501
- enum ruby_special_exceptions {
502
- ruby_error_reenter,
503
- ruby_error_nomemory,
504
- ruby_error_sysstack,
505
- ruby_error_stackfatal,
506
- ruby_error_stream_closed,
507
- ruby_special_error_count
508
- };
509
-
510
- enum ruby_basic_operators {
511
- BOP_PLUS,
512
- BOP_MINUS,
513
- BOP_MULT,
514
- BOP_DIV,
515
- BOP_MOD,
516
- BOP_EQ,
517
- BOP_EQQ,
518
- BOP_LT,
519
- BOP_LE,
520
- BOP_LTLT,
521
- BOP_AREF,
522
- BOP_ASET,
523
- BOP_LENGTH,
524
- BOP_SIZE,
525
- BOP_EMPTY_P,
526
- BOP_NIL_P,
527
- BOP_SUCC,
528
- BOP_GT,
529
- BOP_GE,
530
- BOP_NOT,
531
- BOP_NEQ,
532
- BOP_MATCH,
533
- BOP_FREEZE,
534
- BOP_UMINUS,
535
- BOP_MAX,
536
- BOP_MIN,
537
- BOP_CALL,
538
- BOP_AND,
539
- BOP_OR,
540
-
541
- BOP_LAST_
542
- };
543
-
544
- #define GetVMPtr(obj, ptr) \
545
- GetCoreDataFromValue((obj), rb_vm_t, (ptr))
546
-
547
- struct rb_vm_struct;
548
- typedef void rb_vm_at_exit_func(struct rb_vm_struct*);
549
-
550
- typedef struct rb_at_exit_list {
551
- rb_vm_at_exit_func *func;
552
- struct rb_at_exit_list *next;
553
- } rb_at_exit_list;
554
-
555
- struct rb_objspace;
556
- struct rb_objspace *rb_objspace_alloc(void);
557
- void rb_objspace_free(struct rb_objspace *);
558
- void rb_objspace_call_finalizer(struct rb_objspace *);
559
-
560
- typedef struct rb_hook_list_struct {
561
- struct rb_event_hook_struct *hooks;
562
- rb_event_flag_t events;
563
- unsigned int need_clean;
564
- unsigned int running;
565
- } rb_hook_list_t;
566
-
567
-
568
- // see builtin.h for definition
569
- typedef const struct rb_builtin_function *RB_BUILTIN;
570
-
571
- typedef struct rb_vm_struct {
572
- VALUE self;
573
-
574
- rb_global_vm_lock_t gvl;
575
-
576
- struct rb_thread_struct *main_thread;
577
-
578
- /* persists across uncontended GVL release/acquire for time slice */
579
- const struct rb_thread_struct *running_thread;
580
-
581
- #ifdef USE_SIGALTSTACK
582
- void *main_altstack;
583
- #endif
584
-
585
- rb_serial_t fork_gen;
586
- rb_nativethread_lock_t waitpid_lock;
587
- struct list_head waiting_pids; /* PID > 0: <=> struct waitpid_state */
588
- struct list_head waiting_grps; /* PID <= 0: <=> struct waitpid_state */
589
- struct list_head waiting_fds; /* <=> struct waiting_fd */
590
- struct list_head living_threads;
591
- VALUE thgroup_default;
592
- int living_thread_num;
593
-
594
- /* set in single-threaded processes only: */
595
- volatile int ubf_async_safe;
596
-
597
- unsigned int running: 1;
598
- unsigned int thread_abort_on_exception: 1;
599
- unsigned int thread_report_on_exception: 1;
600
-
601
- unsigned int safe_level_: 1;
602
- int sleeper;
603
-
604
- /* object management */
605
- VALUE mark_object_ary;
606
- const VALUE special_exceptions[ruby_special_error_count];
607
-
608
- /* load */
609
- VALUE top_self;
610
- VALUE load_path;
611
- VALUE load_path_snapshot;
612
- VALUE load_path_check_cache;
613
- VALUE expanded_load_path;
614
- VALUE loaded_features;
615
- VALUE loaded_features_snapshot;
616
- struct st_table *loaded_features_index;
617
- struct st_table *loading_table;
618
-
619
- /* signal */
620
- struct {
621
- VALUE cmd[RUBY_NSIG];
622
- } trap_list;
623
-
624
- /* hook */
625
- rb_hook_list_t global_hooks;
626
-
627
- /* relation table of ensure - rollback for callcc */
628
- struct st_table *ensure_rollback_table;
629
-
630
- /* postponed_job (async-signal-safe, NOT thread-safe) */
631
- struct rb_postponed_job_struct *postponed_job_buffer;
632
- int postponed_job_index;
633
-
634
- int src_encoding_index;
635
-
636
- /* workqueue (thread-safe, NOT async-signal-safe) */
637
- struct list_head workqueue; /* <=> rb_workqueue_job.jnode */
638
- rb_nativethread_lock_t workqueue_lock;
639
-
640
- VALUE verbose, debug, orig_progname, progname;
641
- VALUE coverages;
642
- int coverage_mode;
643
-
644
- st_table * defined_module_hash;
645
-
646
- struct rb_objspace *objspace;
647
-
648
- rb_at_exit_list *at_exit;
649
-
650
- VALUE *defined_strings;
651
- st_table *frozen_strings;
652
-
653
- const struct rb_builtin_function *builtin_function_table;
654
- int builtin_inline_index;
655
-
656
- /* params */
657
- struct { /* size in byte */
658
- size_t thread_vm_stack_size;
659
- size_t thread_machine_stack_size;
660
- size_t fiber_vm_stack_size;
661
- size_t fiber_machine_stack_size;
662
- } default_params;
663
-
664
- short redefined_flag[BOP_LAST_];
665
- } rb_vm_t;
666
-
667
- /* default values */
668
-
669
- #define RUBY_VM_SIZE_ALIGN 4096
670
-
671
- #define RUBY_VM_THREAD_VM_STACK_SIZE ( 128 * 1024 * sizeof(VALUE)) /* 512 KB or 1024 KB */
672
- #define RUBY_VM_THREAD_VM_STACK_SIZE_MIN ( 2 * 1024 * sizeof(VALUE)) /* 8 KB or 16 KB */
673
- #define RUBY_VM_THREAD_MACHINE_STACK_SIZE ( 128 * 1024 * sizeof(VALUE)) /* 512 KB or 1024 KB */
674
- #define RUBY_VM_THREAD_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
675
-
676
- #define RUBY_VM_FIBER_VM_STACK_SIZE ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
677
- #define RUBY_VM_FIBER_VM_STACK_SIZE_MIN ( 2 * 1024 * sizeof(VALUE)) /* 8 KB or 16 KB */
678
- #define RUBY_VM_FIBER_MACHINE_STACK_SIZE ( 64 * 1024 * sizeof(VALUE)) /* 256 KB or 512 KB */
679
- #if defined(__powerpc64__)
680
- #define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 32 * 1024 * sizeof(VALUE)) /* 128 KB or 256 KB */
681
- #else
682
- #define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
683
- #endif
684
-
685
- #if __has_feature(memory_sanitizer) || __has_feature(address_sanitizer)
686
- /* It seems sanitizers consume A LOT of machine stacks */
687
- #undef RUBY_VM_THREAD_MACHINE_STACK_SIZE
688
- #define RUBY_VM_THREAD_MACHINE_STACK_SIZE (1024 * 1024 * sizeof(VALUE))
689
- #undef RUBY_VM_THREAD_MACHINE_STACK_SIZE_MIN
690
- #define RUBY_VM_THREAD_MACHINE_STACK_SIZE_MIN ( 512 * 1024 * sizeof(VALUE))
691
- #undef RUBY_VM_FIBER_MACHINE_STACK_SIZE
692
- #define RUBY_VM_FIBER_MACHINE_STACK_SIZE ( 256 * 1024 * sizeof(VALUE))
693
- #undef RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN
694
- #define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 128 * 1024 * sizeof(VALUE))
695
- #endif
696
-
697
- /* optimize insn */
698
- #define INTEGER_REDEFINED_OP_FLAG (1 << 0)
699
- #define FLOAT_REDEFINED_OP_FLAG (1 << 1)
700
- #define STRING_REDEFINED_OP_FLAG (1 << 2)
701
- #define ARRAY_REDEFINED_OP_FLAG (1 << 3)
702
- #define HASH_REDEFINED_OP_FLAG (1 << 4)
703
- /* #define BIGNUM_REDEFINED_OP_FLAG (1 << 5) */
704
- #define SYMBOL_REDEFINED_OP_FLAG (1 << 6)
705
- #define TIME_REDEFINED_OP_FLAG (1 << 7)
706
- #define REGEXP_REDEFINED_OP_FLAG (1 << 8)
707
- #define NIL_REDEFINED_OP_FLAG (1 << 9)
708
- #define TRUE_REDEFINED_OP_FLAG (1 << 10)
709
- #define FALSE_REDEFINED_OP_FLAG (1 << 11)
710
- #define PROC_REDEFINED_OP_FLAG (1 << 12)
711
-
712
- #define BASIC_OP_UNREDEFINED_P(op, klass) (LIKELY((GET_VM()->redefined_flag[(op)]&(klass)) == 0))
713
-
714
- #ifndef VM_DEBUG_BP_CHECK
715
- #define VM_DEBUG_BP_CHECK 0
716
- #endif
717
-
718
- #ifndef VM_DEBUG_VERIFY_METHOD_CACHE
719
- #define VM_DEBUG_VERIFY_METHOD_CACHE (VMDEBUG != 0)
720
- #endif
721
-
722
- struct rb_captured_block {
723
- VALUE self;
724
- const VALUE *ep;
725
- union {
726
- const rb_iseq_t *iseq;
727
- const struct vm_ifunc *ifunc;
728
- VALUE val;
729
- } code;
730
- };
731
-
732
- enum rb_block_handler_type {
733
- block_handler_type_iseq,
734
- block_handler_type_ifunc,
735
- block_handler_type_symbol,
736
- block_handler_type_proc
737
- };
738
-
739
- enum rb_block_type {
740
- block_type_iseq,
741
- block_type_ifunc,
742
- block_type_symbol,
743
- block_type_proc
744
- };
745
-
746
- struct rb_block {
747
- union {
748
- struct rb_captured_block captured;
749
- VALUE symbol;
750
- VALUE proc;
751
- } as;
752
- enum rb_block_type type;
753
- };
754
-
755
- typedef struct rb_control_frame_struct {
756
- const VALUE *pc; /* cfp[0] */
757
- VALUE *sp; /* cfp[1] */
758
- const rb_iseq_t *iseq; /* cfp[2] */
759
- VALUE self; /* cfp[3] / block[0] */
760
- const VALUE *ep; /* cfp[4] / block[1] */
761
- const void *block_code; /* cfp[5] / block[2] */ /* iseq or ifunc */
762
- VALUE *__bp__; /* cfp[6] */ /* outside vm_push_frame, use vm_base_ptr instead. */
763
-
764
- #if VM_DEBUG_BP_CHECK
765
- VALUE *bp_check; /* cfp[7] */
766
- #endif
767
- } rb_control_frame_t;
768
-
769
- extern const rb_data_type_t ruby_threadptr_data_type;
770
-
771
- static inline struct rb_thread_struct *
772
- rb_thread_ptr(VALUE thval)
773
- {
774
- return (struct rb_thread_struct *)rb_check_typeddata(thval, &ruby_threadptr_data_type);
775
- }
776
-
777
- enum rb_thread_status {
778
- THREAD_RUNNABLE,
779
- THREAD_STOPPED,
780
- THREAD_STOPPED_FOREVER,
781
- THREAD_KILLED
782
- };
783
-
784
- #ifdef RUBY_JMP_BUF
785
- typedef RUBY_JMP_BUF rb_jmpbuf_t;
786
- #else
787
- typedef void *rb_jmpbuf_t[5];
788
- #endif
789
-
790
- /*
791
- the members which are written in EC_PUSH_TAG() should be placed at
792
- the beginning and the end, so that entire region is accessible.
793
- */
794
- struct rb_vm_tag {
795
- VALUE tag;
796
- VALUE retval;
797
- rb_jmpbuf_t buf;
798
- struct rb_vm_tag *prev;
799
- enum ruby_tag_type state;
800
- };
801
-
802
- STATIC_ASSERT(rb_vm_tag_buf_offset, offsetof(struct rb_vm_tag, buf) > 0);
803
- STATIC_ASSERT(rb_vm_tag_buf_end,
804
- offsetof(struct rb_vm_tag, buf) + sizeof(rb_jmpbuf_t) <
805
- sizeof(struct rb_vm_tag));
806
-
807
- struct rb_vm_protect_tag {
808
- struct rb_vm_protect_tag *prev;
809
- };
810
-
811
- struct rb_unblock_callback {
812
- rb_unblock_function_t *func;
813
- void *arg;
814
- };
815
-
816
- struct rb_mutex_struct;
817
-
818
- typedef struct rb_thread_list_struct{
819
- struct rb_thread_list_struct *next;
820
- struct rb_thread_struct *th;
821
- } rb_thread_list_t;
822
-
823
- typedef struct rb_ensure_entry {
824
- VALUE marker;
825
- VALUE (*e_proc)(VALUE);
826
- VALUE data2;
827
- } rb_ensure_entry_t;
828
-
829
- typedef struct rb_ensure_list {
830
- struct rb_ensure_list *next;
831
- struct rb_ensure_entry entry;
832
- } rb_ensure_list_t;
833
-
834
- typedef char rb_thread_id_string_t[sizeof(rb_nativethread_id_t) * 2 + 3];
835
-
836
- typedef struct rb_fiber_struct rb_fiber_t;
837
-
838
- typedef struct rb_execution_context_struct {
839
- /* execution information */
840
- VALUE *vm_stack; /* must free, must mark */
841
- size_t vm_stack_size; /* size in word (byte size / sizeof(VALUE)) */
842
- rb_control_frame_t *cfp;
843
-
844
- struct rb_vm_tag *tag;
845
- struct rb_vm_protect_tag *protect_tag;
846
-
847
- /* interrupt flags */
848
- rb_atomic_t interrupt_flag;
849
- rb_atomic_t interrupt_mask; /* size should match flag */
850
-
851
- rb_fiber_t *fiber_ptr;
852
- struct rb_thread_struct *thread_ptr;
853
-
854
- /* storage (ec (fiber) local) */
855
- st_table *local_storage;
856
- VALUE local_storage_recursive_hash;
857
- VALUE local_storage_recursive_hash_for_trace;
858
-
859
- /* eval env */
860
- const VALUE *root_lep;
861
- VALUE root_svar;
862
-
863
- /* ensure & callcc */
864
- rb_ensure_list_t *ensure_list;
865
-
866
- /* trace information */
867
- struct rb_trace_arg_struct *trace_arg;
868
-
869
- /* temporary places */
870
- VALUE errinfo;
871
- VALUE passed_block_handler; /* for rb_iterate */
872
-
873
- uint8_t raised_flag; /* only 3 bits needed */
874
-
875
- /* n.b. only 7 bits needed, really: */
876
- BITFIELD(enum method_missing_reason, method_missing_reason, 8);
877
-
878
- VALUE private_const_reference;
879
-
880
- /* for GC */
881
- struct {
882
- VALUE *stack_start;
883
- VALUE *stack_end;
884
- size_t stack_maxsize;
885
- RUBY_ALIGNAS(SIZEOF_VALUE) jmp_buf regs;
886
- } machine;
887
- } rb_execution_context_t;
888
-
889
- // for builtin.h
890
- #define VM_CORE_H_EC_DEFINED 1
891
-
892
- // Set the vm_stack pointer in the execution context.
893
- void rb_ec_set_vm_stack(rb_execution_context_t *ec, VALUE *stack, size_t size);
894
-
895
- // Initialize the vm_stack pointer in the execution context and push the initial stack frame.
896
- // @param ec the execution context to update.
897
- // @param stack a pointer to the stack to use.
898
- // @param size the size of the stack, as in `VALUE stack[size]`.
899
- void rb_ec_initialize_vm_stack(rb_execution_context_t *ec, VALUE *stack, size_t size);
900
-
901
- // Clear (set to `NULL`) the vm_stack pointer.
902
- // @param ec the execution context to update.
903
- void rb_ec_clear_vm_stack(rb_execution_context_t *ec);
904
-
905
- typedef struct rb_thread_struct {
906
- struct list_node vmlt_node;
907
- VALUE self;
908
- rb_vm_t *vm;
909
-
910
- rb_execution_context_t *ec;
911
-
912
- VALUE last_status; /* $? */
913
-
914
- /* for cfunc */
915
- struct rb_calling_info *calling;
916
-
917
- /* for load(true) */
918
- VALUE top_self;
919
- VALUE top_wrapper;
920
-
921
- /* thread control */
922
- rb_nativethread_id_t thread_id;
923
- #ifdef NON_SCALAR_THREAD_ID
924
- rb_thread_id_string_t thread_id_string;
925
- #endif
926
- BITFIELD(enum rb_thread_status, status, 2);
927
- /* bit flags */
928
- unsigned int to_kill : 1;
929
- unsigned int abort_on_exception: 1;
930
- unsigned int report_on_exception: 1;
931
- unsigned int pending_interrupt_queue_checked: 1;
932
- int8_t priority; /* -3 .. 3 (RUBY_THREAD_PRIORITY_{MIN,MAX}) */
933
- uint32_t running_time_us; /* 12500..800000 */
934
-
935
- native_thread_data_t native_thread_data;
936
- void *blocking_region_buffer;
937
-
938
- VALUE thgroup;
939
- VALUE value;
940
-
941
- /* temporary place of retval on OPT_CALL_THREADED_CODE */
942
- #if OPT_CALL_THREADED_CODE
943
- VALUE retval;
944
- #endif
945
-
946
- /* async errinfo queue */
947
- VALUE pending_interrupt_queue;
948
- VALUE pending_interrupt_mask_stack;
949
-
950
- /* interrupt management */
951
- rb_nativethread_lock_t interrupt_lock;
952
- struct rb_unblock_callback unblock;
953
- VALUE locking_mutex;
954
- struct rb_mutex_struct *keeping_mutexes;
955
-
956
- rb_thread_list_t *join_list;
957
-
958
- union {
959
- struct {
960
- VALUE proc;
961
- VALUE args;
962
- int kw_splat;
963
- } proc;
964
- struct {
965
- VALUE (*func)(void *);
966
- void *arg;
967
- } func;
968
- } invoke_arg;
969
-
970
- enum {
971
- thread_invoke_type_none = 0,
972
- thread_invoke_type_proc,
973
- thread_invoke_type_func
974
- } invoke_type;
975
-
976
- /* statistics data for profiler */
977
- VALUE stat_insn_usage;
978
-
979
- /* fiber */
980
- rb_fiber_t *root_fiber;
981
- rb_jmpbuf_t root_jmpbuf;
982
-
983
- /* misc */
984
- VALUE name;
985
-
986
- } rb_thread_t;
987
-
988
- typedef enum {
989
- VM_DEFINECLASS_TYPE_CLASS = 0x00,
990
- VM_DEFINECLASS_TYPE_SINGLETON_CLASS = 0x01,
991
- VM_DEFINECLASS_TYPE_MODULE = 0x02,
992
- /* 0x03..0x06 is reserved */
993
- VM_DEFINECLASS_TYPE_MASK = 0x07
994
- } rb_vm_defineclass_type_t;
995
-
996
- #define VM_DEFINECLASS_TYPE(x) ((rb_vm_defineclass_type_t)(x) & VM_DEFINECLASS_TYPE_MASK)
997
- #define VM_DEFINECLASS_FLAG_SCOPED 0x08
998
- #define VM_DEFINECLASS_FLAG_HAS_SUPERCLASS 0x10
999
- #define VM_DEFINECLASS_SCOPED_P(x) ((x) & VM_DEFINECLASS_FLAG_SCOPED)
1000
- #define VM_DEFINECLASS_HAS_SUPERCLASS_P(x) \
1001
- ((x) & VM_DEFINECLASS_FLAG_HAS_SUPERCLASS)
1002
-
1003
- /* iseq.c */
1004
- RUBY_SYMBOL_EXPORT_BEGIN
1005
-
1006
- /* node -> iseq */
1007
- rb_iseq_t *rb_iseq_new (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, enum iseq_type);
1008
- rb_iseq_t *rb_iseq_new_top (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent);
1009
- rb_iseq_t *rb_iseq_new_main (const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent);
1010
- rb_iseq_t *rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno,
1011
- const rb_iseq_t *parent, enum iseq_type, const rb_compile_option_t*);
1012
- struct iseq_link_anchor;
1013
- struct rb_iseq_new_with_callback_callback_func {
1014
- VALUE flags;
1015
- VALUE reserved;
1016
- void (*func)(rb_iseq_t *, struct iseq_link_anchor *, const void *);
1017
- const void *data;
1018
- };
1019
- static inline struct rb_iseq_new_with_callback_callback_func *
1020
- rb_iseq_new_with_callback_new_callback(
1021
- void (*func)(rb_iseq_t *, struct iseq_link_anchor *, const void *), const void *ptr)
1022
- {
1023
- VALUE memo = rb_imemo_new(imemo_ifunc, (VALUE)func, (VALUE)ptr, Qundef, Qfalse);
1024
- return (struct rb_iseq_new_with_callback_callback_func *)memo;
1025
- }
1026
- rb_iseq_t *rb_iseq_new_with_callback(const struct rb_iseq_new_with_callback_callback_func * ifunc,
1027
- VALUE name, VALUE path, VALUE realpath, VALUE first_lineno,
1028
- const rb_iseq_t *parent, enum iseq_type, const rb_compile_option_t*);
1029
-
1030
- VALUE rb_iseq_disasm(const rb_iseq_t *iseq);
1031
- int rb_iseq_disasm_insn(VALUE str, const VALUE *iseqval, size_t pos, const rb_iseq_t *iseq, VALUE child);
1032
-
1033
- VALUE rb_iseq_coverage(const rb_iseq_t *iseq);
1034
-
1035
- RUBY_EXTERN VALUE rb_cISeq;
1036
- RUBY_EXTERN VALUE rb_cRubyVM;
1037
- RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
1038
- RUBY_EXTERN VALUE rb_block_param_proxy;
1039
- RUBY_SYMBOL_EXPORT_END
1040
-
1041
- #define GetProcPtr(obj, ptr) \
1042
- GetCoreDataFromValue((obj), rb_proc_t, (ptr))
1043
-
1044
- typedef struct {
1045
- const struct rb_block block;
1046
- unsigned int is_from_method: 1; /* bool */
1047
- unsigned int is_lambda: 1; /* bool */
1048
- } rb_proc_t;
1049
-
1050
- typedef struct {
1051
- VALUE flags; /* imemo header */
1052
- rb_iseq_t *iseq;
1053
- const VALUE *ep;
1054
- const VALUE *env;
1055
- unsigned int env_size;
1056
- } rb_env_t;
1057
-
1058
- extern const rb_data_type_t ruby_binding_data_type;
1059
-
1060
- #define GetBindingPtr(obj, ptr) \
1061
- GetCoreDataFromValue((obj), rb_binding_t, (ptr))
1062
-
1063
- typedef struct {
1064
- const struct rb_block block;
1065
- const VALUE pathobj;
1066
- unsigned short first_lineno;
1067
- } rb_binding_t;
1068
-
1069
- /* used by compile time and send insn */
1070
-
1071
- enum vm_check_match_type {
1072
- VM_CHECKMATCH_TYPE_WHEN = 1,
1073
- VM_CHECKMATCH_TYPE_CASE = 2,
1074
- VM_CHECKMATCH_TYPE_RESCUE = 3
1075
- };
1076
-
1077
- #define VM_CHECKMATCH_TYPE_MASK 0x03
1078
- #define VM_CHECKMATCH_ARRAY 0x04
1079
-
1080
- enum vm_call_flag_bits {
1081
- VM_CALL_ARGS_SPLAT_bit, /* m(*args) */
1082
- VM_CALL_ARGS_BLOCKARG_bit, /* m(&block) */
1083
- VM_CALL_FCALL_bit, /* m(...) */
1084
- VM_CALL_VCALL_bit, /* m */
1085
- VM_CALL_ARGS_SIMPLE_bit, /* (ci->flag & (SPLAT|BLOCKARG)) && blockiseq == NULL && ci->kw_arg == NULL */
1086
- VM_CALL_BLOCKISEQ_bit, /* has blockiseq */
1087
- VM_CALL_KWARG_bit, /* has kwarg */
1088
- VM_CALL_KW_SPLAT_bit, /* m(**opts) */
1089
- VM_CALL_TAILCALL_bit, /* located at tail position */
1090
- VM_CALL_SUPER_bit, /* super */
1091
- VM_CALL_ZSUPER_bit, /* zsuper */
1092
- VM_CALL_OPT_SEND_bit, /* internal flag */
1093
- VM_CALL__END
1094
- };
1095
-
1096
- #define VM_CALL_ARGS_SPLAT (0x01 << VM_CALL_ARGS_SPLAT_bit)
1097
- #define VM_CALL_ARGS_BLOCKARG (0x01 << VM_CALL_ARGS_BLOCKARG_bit)
1098
- #define VM_CALL_FCALL (0x01 << VM_CALL_FCALL_bit)
1099
- #define VM_CALL_VCALL (0x01 << VM_CALL_VCALL_bit)
1100
- #define VM_CALL_ARGS_SIMPLE (0x01 << VM_CALL_ARGS_SIMPLE_bit)
1101
- #define VM_CALL_BLOCKISEQ (0x01 << VM_CALL_BLOCKISEQ_bit)
1102
- #define VM_CALL_KWARG (0x01 << VM_CALL_KWARG_bit)
1103
- #define VM_CALL_KW_SPLAT (0x01 << VM_CALL_KW_SPLAT_bit)
1104
- #define VM_CALL_TAILCALL (0x01 << VM_CALL_TAILCALL_bit)
1105
- #define VM_CALL_SUPER (0x01 << VM_CALL_SUPER_bit)
1106
- #define VM_CALL_ZSUPER (0x01 << VM_CALL_ZSUPER_bit)
1107
- #define VM_CALL_OPT_SEND (0x01 << VM_CALL_OPT_SEND_bit)
1108
-
1109
- enum vm_special_object_type {
1110
- VM_SPECIAL_OBJECT_VMCORE = 1,
1111
- VM_SPECIAL_OBJECT_CBASE,
1112
- VM_SPECIAL_OBJECT_CONST_BASE
1113
- };
1114
-
1115
- enum vm_svar_index {
1116
- VM_SVAR_LASTLINE = 0, /* $_ */
1117
- VM_SVAR_BACKREF = 1, /* $~ */
1118
-
1119
- VM_SVAR_EXTRA_START = 2,
1120
- VM_SVAR_FLIPFLOP_START = 2 /* flipflop */
1121
- };
1122
-
1123
- /* inline cache */
1124
- typedef struct iseq_inline_cache_entry *IC;
1125
- typedef union iseq_inline_storage_entry *ISE;
1126
- typedef struct rb_call_info *CALL_INFO;
1127
- typedef struct rb_call_cache *CALL_CACHE;
1128
- typedef struct rb_call_data *CALL_DATA;
1129
-
1130
- typedef VALUE CDHASH;
1131
-
1132
- #ifndef FUNC_FASTCALL
1133
- #define FUNC_FASTCALL(x) x
1134
- #endif
1135
-
1136
- typedef rb_control_frame_t *
1137
- (FUNC_FASTCALL(*rb_insn_func_t))(rb_execution_context_t *, rb_control_frame_t *);
1138
-
1139
- #define VM_TAGGED_PTR_SET(p, tag) ((VALUE)(p) | (tag))
1140
- #define VM_TAGGED_PTR_REF(v, mask) ((void *)((v) & ~mask))
1141
-
1142
- #define GC_GUARDED_PTR(p) VM_TAGGED_PTR_SET((p), 0x01)
1143
- #define GC_GUARDED_PTR_REF(p) VM_TAGGED_PTR_REF((p), 0x03)
1144
- #define GC_GUARDED_PTR_P(p) (((VALUE)(p)) & 0x01)
1145
-
1146
- enum {
1147
- /* Frame/Environment flag bits:
1148
- * MMMM MMMM MMMM MMMM ____ FFFF FFFF EEEX (LSB)
1149
- *
1150
- * X : tag for GC marking (It seems as Fixnum)
1151
- * EEE : 3 bits Env flags
1152
- * FF..: 8 bits Frame flags
1153
- * MM..: 15 bits frame magic (to check frame corruption)
1154
- */
1155
-
1156
- /* frame types */
1157
- VM_FRAME_MAGIC_METHOD = 0x11110001,
1158
- VM_FRAME_MAGIC_BLOCK = 0x22220001,
1159
- VM_FRAME_MAGIC_CLASS = 0x33330001,
1160
- VM_FRAME_MAGIC_TOP = 0x44440001,
1161
- VM_FRAME_MAGIC_CFUNC = 0x55550001,
1162
- VM_FRAME_MAGIC_IFUNC = 0x66660001,
1163
- VM_FRAME_MAGIC_EVAL = 0x77770001,
1164
- VM_FRAME_MAGIC_RESCUE = 0x78880001,
1165
- VM_FRAME_MAGIC_DUMMY = 0x79990001,
1166
-
1167
- VM_FRAME_MAGIC_MASK = 0x7fff0001,
1168
-
1169
- /* frame flag */
1170
- VM_FRAME_FLAG_PASSED = 0x0010,
1171
- VM_FRAME_FLAG_FINISH = 0x0020,
1172
- VM_FRAME_FLAG_BMETHOD = 0x0040,
1173
- VM_FRAME_FLAG_CFRAME = 0x0080,
1174
- VM_FRAME_FLAG_LAMBDA = 0x0100,
1175
- VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM = 0x0200,
1176
- VM_FRAME_FLAG_CFRAME_KW = 0x0400,
1177
- VM_FRAME_FLAG_CFRAME_EMPTY_KW = 0x0800, /* -- Remove In 3.0 -- */
1178
-
1179
- /* env flag */
1180
- VM_ENV_FLAG_LOCAL = 0x0002,
1181
- VM_ENV_FLAG_ESCAPED = 0x0004,
1182
- VM_ENV_FLAG_WB_REQUIRED = 0x0008
1183
- };
1184
-
1185
- #define VM_ENV_DATA_SIZE ( 3)
1186
-
1187
- #define VM_ENV_DATA_INDEX_ME_CREF (-2) /* ep[-2] */
1188
- #define VM_ENV_DATA_INDEX_SPECVAL (-1) /* ep[-1] */
1189
- #define VM_ENV_DATA_INDEX_FLAGS ( 0) /* ep[ 0] */
1190
- #define VM_ENV_DATA_INDEX_ENV ( 1) /* ep[ 1] */
1191
-
1192
- #define VM_ENV_INDEX_LAST_LVAR (-VM_ENV_DATA_SIZE)
1193
-
1194
- static inline void VM_FORCE_WRITE_SPECIAL_CONST(const VALUE *ptr, VALUE special_const_value);
1195
-
1196
- static inline void
1197
- VM_ENV_FLAGS_SET(const VALUE *ep, VALUE flag)
1198
- {
1199
- VALUE flags = ep[VM_ENV_DATA_INDEX_FLAGS];
1200
- VM_ASSERT(FIXNUM_P(flags));
1201
- VM_FORCE_WRITE_SPECIAL_CONST(&ep[VM_ENV_DATA_INDEX_FLAGS], flags | flag);
1202
- }
1203
-
1204
- static inline void
1205
- VM_ENV_FLAGS_UNSET(const VALUE *ep, VALUE flag)
1206
- {
1207
- VALUE flags = ep[VM_ENV_DATA_INDEX_FLAGS];
1208
- VM_ASSERT(FIXNUM_P(flags));
1209
- VM_FORCE_WRITE_SPECIAL_CONST(&ep[VM_ENV_DATA_INDEX_FLAGS], flags & ~flag);
1210
- }
1211
-
1212
- static inline unsigned long
1213
- VM_ENV_FLAGS(const VALUE *ep, long flag)
1214
- {
1215
- VALUE flags = ep[VM_ENV_DATA_INDEX_FLAGS];
1216
- VM_ASSERT(FIXNUM_P(flags));
1217
- return flags & flag;
1218
- }
1219
-
1220
- static inline unsigned long
1221
- VM_FRAME_TYPE(const rb_control_frame_t *cfp)
1222
- {
1223
- return VM_ENV_FLAGS(cfp->ep, VM_FRAME_MAGIC_MASK);
1224
- }
1225
-
1226
- static inline int
1227
- VM_FRAME_LAMBDA_P(const rb_control_frame_t *cfp)
1228
- {
1229
- return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_LAMBDA) != 0;
1230
- }
1231
-
1232
- static inline int
1233
- VM_FRAME_CFRAME_KW_P(const rb_control_frame_t *cfp)
1234
- {
1235
- return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_CFRAME_KW) != 0;
1236
- }
1237
-
1238
- /* -- Remove In 3.0 -- */
1239
- static inline int
1240
- VM_FRAME_CFRAME_EMPTY_KW_P(const rb_control_frame_t *cfp)
1241
- {
1242
- return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_CFRAME_EMPTY_KW) != 0;
1243
- }
1244
-
1245
- static inline int
1246
- VM_FRAME_FINISHED_P(const rb_control_frame_t *cfp)
1247
- {
1248
- return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_FINISH) != 0;
1249
- }
1250
-
1251
- static inline int
1252
- VM_FRAME_BMETHOD_P(const rb_control_frame_t *cfp)
1253
- {
1254
- return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_BMETHOD) != 0;
1255
- }
1256
-
1257
- static inline int
1258
- rb_obj_is_iseq(VALUE iseq)
1259
- {
1260
- return imemo_type_p(iseq, imemo_iseq);
1261
- }
1262
-
1263
- #if VM_CHECK_MODE > 0
1264
- #define RUBY_VM_NORMAL_ISEQ_P(iseq) rb_obj_is_iseq((VALUE)iseq)
1265
- #endif
1266
-
1267
- static inline int
1268
- VM_FRAME_CFRAME_P(const rb_control_frame_t *cfp)
1269
- {
1270
- int cframe_p = VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_CFRAME) != 0;
1271
- VM_ASSERT(RUBY_VM_NORMAL_ISEQ_P(cfp->iseq) != cframe_p);
1272
- return cframe_p;
1273
- }
1274
-
1275
- static inline int
1276
- VM_FRAME_RUBYFRAME_P(const rb_control_frame_t *cfp)
1277
- {
1278
- return !VM_FRAME_CFRAME_P(cfp);
1279
- }
1280
-
1281
- #define RUBYVM_CFUNC_FRAME_P(cfp) \
1282
- (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)
1283
-
1284
- #define VM_GUARDED_PREV_EP(ep) GC_GUARDED_PTR(ep)
1285
- #define VM_BLOCK_HANDLER_NONE 0
1286
-
1287
- static inline int
1288
- VM_ENV_LOCAL_P(const VALUE *ep)
1289
- {
1290
- return VM_ENV_FLAGS(ep, VM_ENV_FLAG_LOCAL) ? 1 : 0;
1291
- }
1292
-
1293
- static inline const VALUE *
1294
- VM_ENV_PREV_EP(const VALUE *ep)
1295
- {
1296
- VM_ASSERT(VM_ENV_LOCAL_P(ep) == 0);
1297
- return GC_GUARDED_PTR_REF(ep[VM_ENV_DATA_INDEX_SPECVAL]);
1298
- }
1299
-
1300
- static inline VALUE
1301
- VM_ENV_BLOCK_HANDLER(const VALUE *ep)
1302
- {
1303
- VM_ASSERT(VM_ENV_LOCAL_P(ep));
1304
- return ep[VM_ENV_DATA_INDEX_SPECVAL];
1305
- }
1306
-
1307
- #if VM_CHECK_MODE > 0
1308
- int rb_vm_ep_in_heap_p(const VALUE *ep);
1309
- #endif
1310
-
1311
- static inline int
1312
- VM_ENV_ESCAPED_P(const VALUE *ep)
1313
- {
1314
- VM_ASSERT(rb_vm_ep_in_heap_p(ep) == !!VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED));
1315
- return VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED) ? 1 : 0;
1316
- }
1317
-
1318
- #if VM_CHECK_MODE > 0
1319
- static inline int
1320
- vm_assert_env(VALUE obj)
1321
- {
1322
- VM_ASSERT(imemo_type_p(obj, imemo_env));
1323
- return 1;
1324
- }
1325
- #endif
1326
-
1327
- static inline VALUE
1328
- VM_ENV_ENVVAL(const VALUE *ep)
1329
- {
1330
- VALUE envval = ep[VM_ENV_DATA_INDEX_ENV];
1331
- VM_ASSERT(VM_ENV_ESCAPED_P(ep));
1332
- VM_ASSERT(vm_assert_env(envval));
1333
- return envval;
1334
- }
1335
-
1336
- static inline const rb_env_t *
1337
- VM_ENV_ENVVAL_PTR(const VALUE *ep)
1338
- {
1339
- return (const rb_env_t *)VM_ENV_ENVVAL(ep);
1340
- }
1341
-
1342
- static inline const rb_env_t *
1343
- vm_env_new(VALUE *env_ep, VALUE *env_body, unsigned int env_size, const rb_iseq_t *iseq)
1344
- {
1345
- rb_env_t *env = (rb_env_t *)rb_imemo_new(imemo_env, (VALUE)env_ep, (VALUE)env_body, 0, (VALUE)iseq);
1346
- env->env_size = env_size;
1347
- env_ep[VM_ENV_DATA_INDEX_ENV] = (VALUE)env;
1348
- return env;
1349
- }
1350
-
1351
- static inline void
1352
- VM_FORCE_WRITE(const VALUE *ptr, VALUE v)
1353
- {
1354
- *((VALUE *)ptr) = v;
1355
- }
1356
-
1357
- static inline void
1358
- VM_FORCE_WRITE_SPECIAL_CONST(const VALUE *ptr, VALUE special_const_value)
1359
- {
1360
- VM_ASSERT(RB_SPECIAL_CONST_P(special_const_value));
1361
- VM_FORCE_WRITE(ptr, special_const_value);
1362
- }
1363
-
1364
- static inline void
1365
- VM_STACK_ENV_WRITE(const VALUE *ep, int index, VALUE v)
1366
- {
1367
- VM_ASSERT(VM_ENV_FLAGS(ep, VM_ENV_FLAG_WB_REQUIRED) == 0);
1368
- VM_FORCE_WRITE(&ep[index], v);
1369
- }
1370
-
1371
- const VALUE *rb_vm_ep_local_ep(const VALUE *ep);
1372
- const VALUE *rb_vm_proc_local_ep(VALUE proc);
1373
- void rb_vm_block_ep_update(VALUE obj, const struct rb_block *dst, const VALUE *ep);
1374
- void rb_vm_block_copy(VALUE obj, const struct rb_block *dst, const struct rb_block *src);
1375
-
1376
- VALUE rb_vm_frame_block_handler(const rb_control_frame_t *cfp);
1377
-
1378
- #define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1)
1379
- #define RUBY_VM_NEXT_CONTROL_FRAME(cfp) ((cfp)-1)
1380
-
1381
- #define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \
1382
- ((void *)(ecfp) > (void *)(cfp))
1383
-
1384
- static inline const rb_control_frame_t *
1385
- RUBY_VM_END_CONTROL_FRAME(const rb_execution_context_t *ec)
1386
- {
1387
- return (rb_control_frame_t *)(ec->vm_stack + ec->vm_stack_size);
1388
- }
1389
-
1390
- static inline int
1391
- RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(const rb_execution_context_t *ec, const rb_control_frame_t *cfp)
1392
- {
1393
- return !RUBY_VM_VALID_CONTROL_FRAME_P(cfp, RUBY_VM_END_CONTROL_FRAME(ec));
1394
- }
1395
-
1396
- static inline int
1397
- VM_BH_ISEQ_BLOCK_P(VALUE block_handler)
1398
- {
1399
- if ((block_handler & 0x03) == 0x01) {
1400
- #if VM_CHECK_MODE > 0
1401
- struct rb_captured_block *captured = VM_TAGGED_PTR_REF(block_handler, 0x03);
1402
- VM_ASSERT(imemo_type_p(captured->code.val, imemo_iseq));
1403
- #endif
1404
- return 1;
1405
- }
1406
- else {
1407
- return 0;
1408
- }
1409
- }
1410
-
1411
- static inline VALUE
1412
- VM_BH_FROM_ISEQ_BLOCK(const struct rb_captured_block *captured)
1413
- {
1414
- VALUE block_handler = VM_TAGGED_PTR_SET(captured, 0x01);
1415
- VM_ASSERT(VM_BH_ISEQ_BLOCK_P(block_handler));
1416
- return block_handler;
1417
- }
1418
-
1419
- static inline const struct rb_captured_block *
1420
- VM_BH_TO_ISEQ_BLOCK(VALUE block_handler)
1421
- {
1422
- struct rb_captured_block *captured = VM_TAGGED_PTR_REF(block_handler, 0x03);
1423
- VM_ASSERT(VM_BH_ISEQ_BLOCK_P(block_handler));
1424
- return captured;
1425
- }
1426
-
1427
- static inline int
1428
- VM_BH_IFUNC_P(VALUE block_handler)
1429
- {
1430
- if ((block_handler & 0x03) == 0x03) {
1431
- #if VM_CHECK_MODE > 0
1432
- struct rb_captured_block *captured = (void *)(block_handler & ~0x03);
1433
- VM_ASSERT(imemo_type_p(captured->code.val, imemo_ifunc));
1434
- #endif
1435
- return 1;
1436
- }
1437
- else {
1438
- return 0;
1439
- }
1440
- }
1441
-
1442
- static inline VALUE
1443
- VM_BH_FROM_IFUNC_BLOCK(const struct rb_captured_block *captured)
1444
- {
1445
- VALUE block_handler = VM_TAGGED_PTR_SET(captured, 0x03);
1446
- VM_ASSERT(VM_BH_IFUNC_P(block_handler));
1447
- return block_handler;
1448
- }
1449
-
1450
- static inline const struct rb_captured_block *
1451
- VM_BH_TO_IFUNC_BLOCK(VALUE block_handler)
1452
- {
1453
- struct rb_captured_block *captured = VM_TAGGED_PTR_REF(block_handler, 0x03);
1454
- VM_ASSERT(VM_BH_IFUNC_P(block_handler));
1455
- return captured;
1456
- }
1457
-
1458
- static inline const struct rb_captured_block *
1459
- VM_BH_TO_CAPT_BLOCK(VALUE block_handler)
1460
- {
1461
- struct rb_captured_block *captured = VM_TAGGED_PTR_REF(block_handler, 0x03);
1462
- VM_ASSERT(VM_BH_IFUNC_P(block_handler) || VM_BH_ISEQ_BLOCK_P(block_handler));
1463
- return captured;
1464
- }
1465
-
1466
- static inline enum rb_block_handler_type
1467
- vm_block_handler_type(VALUE block_handler)
1468
- {
1469
- if (VM_BH_ISEQ_BLOCK_P(block_handler)) {
1470
- return block_handler_type_iseq;
1471
- }
1472
- else if (VM_BH_IFUNC_P(block_handler)) {
1473
- return block_handler_type_ifunc;
1474
- }
1475
- else if (SYMBOL_P(block_handler)) {
1476
- return block_handler_type_symbol;
1477
- }
1478
- else {
1479
- VM_ASSERT(rb_obj_is_proc(block_handler));
1480
- return block_handler_type_proc;
1481
- }
1482
- }
1483
-
1484
- static inline void
1485
- vm_block_handler_verify(MAYBE_UNUSED(VALUE block_handler))
1486
- {
1487
- VM_ASSERT(block_handler == VM_BLOCK_HANDLER_NONE ||
1488
- (vm_block_handler_type(block_handler), 1));
1489
- }
1490
-
1491
- static inline enum rb_block_type
1492
- vm_block_type(const struct rb_block *block)
1493
- {
1494
- #if VM_CHECK_MODE > 0
1495
- switch (block->type) {
1496
- case block_type_iseq:
1497
- VM_ASSERT(imemo_type_p(block->as.captured.code.val, imemo_iseq));
1498
- break;
1499
- case block_type_ifunc:
1500
- VM_ASSERT(imemo_type_p(block->as.captured.code.val, imemo_ifunc));
1501
- break;
1502
- case block_type_symbol:
1503
- VM_ASSERT(SYMBOL_P(block->as.symbol));
1504
- break;
1505
- case block_type_proc:
1506
- VM_ASSERT(rb_obj_is_proc(block->as.proc));
1507
- break;
1508
- }
1509
- #endif
1510
- return block->type;
1511
- }
1512
-
1513
- static inline void
1514
- vm_block_type_set(const struct rb_block *block, enum rb_block_type type)
1515
- {
1516
- struct rb_block *mb = (struct rb_block *)block;
1517
- mb->type = type;
1518
- }
1519
-
1520
- static inline const struct rb_block *
1521
- vm_proc_block(VALUE procval)
1522
- {
1523
- VM_ASSERT(rb_obj_is_proc(procval));
1524
- return &((rb_proc_t *)RTYPEDDATA_DATA(procval))->block;
1525
- }
1526
-
1527
- static inline const rb_iseq_t *vm_block_iseq(const struct rb_block *block);
1528
- static inline const VALUE *vm_block_ep(const struct rb_block *block);
1529
-
1530
- static inline const rb_iseq_t *
1531
- vm_proc_iseq(VALUE procval)
1532
- {
1533
- return vm_block_iseq(vm_proc_block(procval));
1534
- }
1535
-
1536
- static inline const VALUE *
1537
- vm_proc_ep(VALUE procval)
1538
- {
1539
- return vm_block_ep(vm_proc_block(procval));
1540
- }
1541
-
1542
- static inline const rb_iseq_t *
1543
- vm_block_iseq(const struct rb_block *block)
1544
- {
1545
- switch (vm_block_type(block)) {
1546
- case block_type_iseq: return rb_iseq_check(block->as.captured.code.iseq);
1547
- case block_type_proc: return vm_proc_iseq(block->as.proc);
1548
- case block_type_ifunc:
1549
- case block_type_symbol: return NULL;
1550
- }
1551
- VM_UNREACHABLE(vm_block_iseq);
1552
- return NULL;
1553
- }
1554
-
1555
- static inline const VALUE *
1556
- vm_block_ep(const struct rb_block *block)
1557
- {
1558
- switch (vm_block_type(block)) {
1559
- case block_type_iseq:
1560
- case block_type_ifunc: return block->as.captured.ep;
1561
- case block_type_proc: return vm_proc_ep(block->as.proc);
1562
- case block_type_symbol: return NULL;
1563
- }
1564
- VM_UNREACHABLE(vm_block_ep);
1565
- return NULL;
1566
- }
1567
-
1568
- static inline VALUE
1569
- vm_block_self(const struct rb_block *block)
1570
- {
1571
- switch (vm_block_type(block)) {
1572
- case block_type_iseq:
1573
- case block_type_ifunc:
1574
- return block->as.captured.self;
1575
- case block_type_proc:
1576
- return vm_block_self(vm_proc_block(block->as.proc));
1577
- case block_type_symbol:
1578
- return Qundef;
1579
- }
1580
- VM_UNREACHABLE(vm_block_self);
1581
- return Qundef;
1582
- }
1583
-
1584
- static inline VALUE
1585
- VM_BH_TO_SYMBOL(VALUE block_handler)
1586
- {
1587
- VM_ASSERT(SYMBOL_P(block_handler));
1588
- return block_handler;
1589
- }
1590
-
1591
- static inline VALUE
1592
- VM_BH_FROM_SYMBOL(VALUE symbol)
1593
- {
1594
- VM_ASSERT(SYMBOL_P(symbol));
1595
- return symbol;
1596
- }
1597
-
1598
- static inline VALUE
1599
- VM_BH_TO_PROC(VALUE block_handler)
1600
- {
1601
- VM_ASSERT(rb_obj_is_proc(block_handler));
1602
- return block_handler;
1603
- }
1604
-
1605
- static inline VALUE
1606
- VM_BH_FROM_PROC(VALUE procval)
1607
- {
1608
- VM_ASSERT(rb_obj_is_proc(procval));
1609
- return procval;
1610
- }
1611
-
1612
- /* VM related object allocate functions */
1613
- VALUE rb_thread_alloc(VALUE klass);
1614
- VALUE rb_binding_alloc(VALUE klass);
1615
- VALUE rb_proc_alloc(VALUE klass);
1616
- VALUE rb_proc_dup(VALUE self);
1617
-
1618
- /* for debug */
1619
- extern void rb_vmdebug_stack_dump_raw(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
1620
- extern void rb_vmdebug_debug_print_pre(const rb_execution_context_t *ec, const rb_control_frame_t *cfp, const VALUE *_pc);
1621
- extern void rb_vmdebug_debug_print_post(const rb_execution_context_t *ec, const rb_control_frame_t *cfp
1622
- #if OPT_STACK_CACHING
1623
- , VALUE reg_a, VALUE reg_b
1624
- #endif
1625
- );
1626
-
1627
- #define SDR() rb_vmdebug_stack_dump_raw(GET_EC(), GET_EC()->cfp)
1628
- #define SDR2(cfp) rb_vmdebug_stack_dump_raw(GET_EC(), (cfp))
1629
- void rb_vm_bugreport(const void *);
1630
- typedef RETSIGTYPE (*ruby_sighandler_t)(int);
1631
- NORETURN(void rb_bug_for_fatal_signal(ruby_sighandler_t default_sighandler, int sig, const void *, const char *fmt, ...));
1632
-
1633
- /* functions about thread/vm execution */
1634
- RUBY_SYMBOL_EXPORT_BEGIN
1635
- VALUE rb_iseq_eval(const rb_iseq_t *iseq);
1636
- VALUE rb_iseq_eval_main(const rb_iseq_t *iseq);
1637
- VALUE rb_iseq_path(const rb_iseq_t *iseq);
1638
- VALUE rb_iseq_realpath(const rb_iseq_t *iseq);
1639
- RUBY_SYMBOL_EXPORT_END
1640
-
1641
- VALUE rb_iseq_pathobj_new(VALUE path, VALUE realpath);
1642
- void rb_iseq_pathobj_set(const rb_iseq_t *iseq, VALUE path, VALUE realpath);
1643
-
1644
- int rb_ec_frame_method_id_and_class(const rb_execution_context_t *ec, ID *idp, ID *called_idp, VALUE *klassp);
1645
- void rb_ec_setup_exception(const rb_execution_context_t *ec, VALUE mesg, VALUE cause);
1646
-
1647
- VALUE rb_vm_invoke_proc(rb_execution_context_t *ec, rb_proc_t *proc, int argc, const VALUE *argv, int kw_splat, VALUE block_handler);
1648
-
1649
- VALUE rb_vm_make_proc_lambda(const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass, int8_t is_lambda);
1650
- static inline VALUE
1651
- rb_vm_make_proc(const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass)
1652
- {
1653
- return rb_vm_make_proc_lambda(ec, captured, klass, 0);
1654
- }
1655
-
1656
- static inline VALUE
1657
- rb_vm_make_lambda(const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass)
1658
- {
1659
- return rb_vm_make_proc_lambda(ec, captured, klass, 1);
1660
- }
1661
-
1662
- VALUE rb_vm_make_binding(const rb_execution_context_t *ec, const rb_control_frame_t *src_cfp);
1663
- VALUE rb_vm_env_local_variables(const rb_env_t *env);
1664
- const rb_env_t *rb_vm_env_prev_env(const rb_env_t *env);
1665
- const VALUE *rb_binding_add_dynavars(VALUE bindval, rb_binding_t *bind, int dyncount, const ID *dynvars);
1666
- void rb_vm_inc_const_missing_count(void);
1667
- void rb_vm_gvl_destroy(rb_vm_t *vm);
1668
- VALUE rb_vm_call(rb_execution_context_t *ec, VALUE recv, VALUE id, int argc,
1669
- const VALUE *argv, const rb_callable_method_entry_t *me);
1670
- VALUE rb_vm_call_kw(rb_execution_context_t *ec, VALUE recv, VALUE id, int argc,
1671
- const VALUE *argv, const rb_callable_method_entry_t *me, int kw_splat);
1672
- MJIT_STATIC void rb_vm_pop_frame(rb_execution_context_t *ec);
1673
-
1674
- void rb_thread_start_timer_thread(void);
1675
- void rb_thread_stop_timer_thread(void);
1676
- void rb_thread_reset_timer_thread(void);
1677
- void rb_thread_wakeup_timer_thread(int);
1678
-
1679
- static inline void
1680
- rb_vm_living_threads_init(rb_vm_t *vm)
1681
- {
1682
- list_head_init(&vm->waiting_fds);
1683
- list_head_init(&vm->waiting_pids);
1684
- list_head_init(&vm->workqueue);
1685
- list_head_init(&vm->waiting_grps);
1686
- list_head_init(&vm->living_threads);
1687
- vm->living_thread_num = 0;
1688
- }
1689
-
1690
- static inline void
1691
- rb_vm_living_threads_insert(rb_vm_t *vm, rb_thread_t *th)
1692
- {
1693
- list_add_tail(&vm->living_threads, &th->vmlt_node);
1694
- vm->living_thread_num++;
1695
- }
1696
-
1697
- static inline void
1698
- rb_vm_living_threads_remove(rb_vm_t *vm, rb_thread_t *th)
1699
- {
1700
- list_del(&th->vmlt_node);
1701
- vm->living_thread_num--;
1702
- }
1703
-
1704
- typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
1705
- rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
1706
- rb_control_frame_t *rb_vm_get_binding_creatable_next_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
1707
- int rb_vm_get_sourceline(const rb_control_frame_t *);
1708
- void rb_vm_stack_to_heap(rb_execution_context_t *ec);
1709
- void ruby_thread_init_stack(rb_thread_t *th);
1710
- int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, ID *called_idp, VALUE *klassp);
1711
- void rb_vm_rewind_cfp(rb_execution_context_t *ec, rb_control_frame_t *cfp);
1712
- MJIT_STATIC VALUE rb_vm_bh_to_procval(const rb_execution_context_t *ec, VALUE block_handler);
1713
-
1714
- void rb_vm_register_special_exception_str(enum ruby_special_exceptions sp, VALUE exception_class, VALUE mesg);
1715
-
1716
- #define rb_vm_register_special_exception(sp, e, m) \
1717
- rb_vm_register_special_exception_str(sp, e, rb_usascii_str_new_static((m), (long)rb_strlen_lit(m)))
1718
-
1719
- void rb_gc_mark_machine_stack(const rb_execution_context_t *ec);
1720
-
1721
- void rb_vm_rewrite_cref(rb_cref_t *node, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr);
1722
-
1723
- MJIT_STATIC const rb_callable_method_entry_t *rb_vm_frame_method_entry(const rb_control_frame_t *cfp);
1724
-
1725
- #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
1726
-
1727
- #define RUBY_CONST_ASSERT(expr) (1/!!(expr)) /* expr must be a compile-time constant */
1728
- #define VM_STACK_OVERFLOWED_P(cfp, sp, margin) \
1729
- (!RUBY_CONST_ASSERT(sizeof(*(sp)) == sizeof(VALUE)) || \
1730
- !RUBY_CONST_ASSERT(sizeof(*(cfp)) == sizeof(rb_control_frame_t)) || \
1731
- ((rb_control_frame_t *)((sp) + (margin)) + 1) >= (cfp))
1732
- #define WHEN_VM_STACK_OVERFLOWED(cfp, sp, margin) \
1733
- if (LIKELY(!VM_STACK_OVERFLOWED_P(cfp, sp, margin))) {(void)0;} else /* overflowed */
1734
- #define CHECK_VM_STACK_OVERFLOW0(cfp, sp, margin) \
1735
- WHEN_VM_STACK_OVERFLOWED(cfp, sp, margin) vm_stackoverflow()
1736
- #define CHECK_VM_STACK_OVERFLOW(cfp, margin) \
1737
- WHEN_VM_STACK_OVERFLOWED(cfp, (cfp)->sp, margin) vm_stackoverflow()
1738
-
1739
- VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, enum ruby_tag_type *stateptr);
1740
-
1741
- /* for thread */
1742
-
1743
- #if RUBY_VM_THREAD_MODEL == 2
1744
- RUBY_SYMBOL_EXPORT_BEGIN
1745
-
1746
- RUBY_EXTERN rb_vm_t *ruby_current_vm_ptr;
1747
- RUBY_EXTERN rb_execution_context_t *ruby_current_execution_context_ptr;
1748
- RUBY_EXTERN rb_event_flag_t ruby_vm_event_flags;
1749
- RUBY_EXTERN rb_event_flag_t ruby_vm_event_enabled_global_flags;
1750
- RUBY_EXTERN unsigned int ruby_vm_event_local_num;
1751
-
1752
- RUBY_SYMBOL_EXPORT_END
1753
-
1754
- #define GET_VM() rb_current_vm()
1755
- #define GET_THREAD() rb_current_thread()
1756
- #define GET_EC() rb_current_execution_context()
1757
-
1758
- static inline rb_thread_t *
1759
- rb_ec_thread_ptr(const rb_execution_context_t *ec)
1760
- {
1761
- return ec->thread_ptr;
1762
- }
1763
-
1764
- static inline rb_vm_t *
1765
- rb_ec_vm_ptr(const rb_execution_context_t *ec)
1766
- {
1767
- const rb_thread_t *th = rb_ec_thread_ptr(ec);
1768
- if (th) {
1769
- return th->vm;
1770
- }
1771
- else {
1772
- return NULL;
1773
- }
1774
- }
1775
-
1776
- static inline rb_execution_context_t *
1777
- rb_current_execution_context(void)
1778
- {
1779
- return ruby_current_execution_context_ptr;
1780
- }
1781
-
1782
- static inline rb_thread_t *
1783
- rb_current_thread(void)
1784
- {
1785
- const rb_execution_context_t *ec = GET_EC();
1786
- return rb_ec_thread_ptr(ec);
1787
- }
1788
-
1789
- static inline rb_vm_t *
1790
- rb_current_vm(void)
1791
- {
1792
- VM_ASSERT(ruby_current_vm_ptr == NULL ||
1793
- ruby_current_execution_context_ptr == NULL ||
1794
- rb_ec_thread_ptr(GET_EC()) == NULL ||
1795
- rb_ec_vm_ptr(GET_EC()) == ruby_current_vm_ptr);
1796
- return ruby_current_vm_ptr;
1797
- }
1798
-
1799
- static inline void
1800
- rb_thread_set_current_raw(const rb_thread_t *th)
1801
- {
1802
- ruby_current_execution_context_ptr = th->ec;
1803
- }
1804
-
1805
- static inline void
1806
- rb_thread_set_current(rb_thread_t *th)
1807
- {
1808
- if (th->vm->running_thread != th) {
1809
- th->running_time_us = 0;
1810
- }
1811
- rb_thread_set_current_raw(th);
1812
- th->vm->running_thread = th;
1813
- }
1814
-
1815
- #else
1816
- #error "unsupported thread model"
1817
- #endif
1818
-
1819
- enum {
1820
- TIMER_INTERRUPT_MASK = 0x01,
1821
- PENDING_INTERRUPT_MASK = 0x02,
1822
- POSTPONED_JOB_INTERRUPT_MASK = 0x04,
1823
- TRAP_INTERRUPT_MASK = 0x08
1824
- };
1825
-
1826
- #define RUBY_VM_SET_TIMER_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, TIMER_INTERRUPT_MASK)
1827
- #define RUBY_VM_SET_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, PENDING_INTERRUPT_MASK)
1828
- #define RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, POSTPONED_JOB_INTERRUPT_MASK)
1829
- #define RUBY_VM_SET_TRAP_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, TRAP_INTERRUPT_MASK)
1830
- #define RUBY_VM_INTERRUPTED(ec) ((ec)->interrupt_flag & ~(ec)->interrupt_mask & \
1831
- (PENDING_INTERRUPT_MASK|TRAP_INTERRUPT_MASK))
1832
- #define RUBY_VM_INTERRUPTED_ANY(ec) ((ec)->interrupt_flag & ~(ec)->interrupt_mask)
1833
-
1834
- VALUE rb_exc_set_backtrace(VALUE exc, VALUE bt);
1835
- int rb_signal_buff_size(void);
1836
- int rb_signal_exec(rb_thread_t *th, int sig);
1837
- void rb_threadptr_check_signal(rb_thread_t *mth);
1838
- void rb_threadptr_signal_raise(rb_thread_t *th, int sig);
1839
- void rb_threadptr_signal_exit(rb_thread_t *th);
1840
- int rb_threadptr_execute_interrupts(rb_thread_t *, int);
1841
- void rb_threadptr_interrupt(rb_thread_t *th);
1842
- void rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th);
1843
- void rb_threadptr_pending_interrupt_clear(rb_thread_t *th);
1844
- void rb_threadptr_pending_interrupt_enque(rb_thread_t *th, VALUE v);
1845
- void rb_ec_error_print(rb_execution_context_t * volatile ec, volatile VALUE errinfo);
1846
- void rb_execution_context_update(const rb_execution_context_t *ec);
1847
- void rb_execution_context_mark(const rb_execution_context_t *ec);
1848
- void rb_fiber_close(rb_fiber_t *fib);
1849
- void Init_native_thread(rb_thread_t *th);
1850
-
1851
- #define RUBY_VM_CHECK_INTS(ec) rb_vm_check_ints(ec)
1852
- static inline void
1853
- rb_vm_check_ints(rb_execution_context_t *ec)
1854
- {
1855
- VM_ASSERT(ec == GET_EC());
1856
- if (UNLIKELY(RUBY_VM_INTERRUPTED_ANY(ec))) {
1857
- rb_threadptr_execute_interrupts(rb_ec_thread_ptr(ec), 0);
1858
- }
1859
- }
1860
-
1861
- /* tracer */
1862
-
1863
- struct rb_trace_arg_struct {
1864
- rb_event_flag_t event;
1865
- rb_execution_context_t *ec;
1866
- const rb_control_frame_t *cfp;
1867
- VALUE self;
1868
- ID id;
1869
- ID called_id;
1870
- VALUE klass;
1871
- VALUE data;
1872
-
1873
- int klass_solved;
1874
-
1875
- /* calc from cfp */
1876
- int lineno;
1877
- VALUE path;
1878
- };
1879
-
1880
- void rb_hook_list_mark(rb_hook_list_t *hooks);
1881
- void rb_hook_list_free(rb_hook_list_t *hooks);
1882
- void rb_hook_list_connect_tracepoint(VALUE target, rb_hook_list_t *list, VALUE tpval, unsigned int target_line);
1883
- void rb_hook_list_remove_tracepoint(rb_hook_list_t *list, VALUE tpval);
1884
-
1885
- void rb_exec_event_hooks(struct rb_trace_arg_struct *trace_arg, rb_hook_list_t *hooks, int pop_p);
1886
-
1887
- #define EXEC_EVENT_HOOK_ORIG(ec_, hooks_, flag_, self_, id_, called_id_, klass_, data_, pop_p_) do { \
1888
- const rb_event_flag_t flag_arg_ = (flag_); \
1889
- rb_hook_list_t *hooks_arg_ = (hooks_); \
1890
- if (UNLIKELY((hooks_arg_)->events & (flag_arg_))) { \
1891
- /* defer evaluating the other arguments */ \
1892
- rb_exec_event_hook_orig(ec_, hooks_arg_, flag_arg_, self_, id_, called_id_, klass_, data_, pop_p_); \
1893
- } \
1894
- } while (0)
1895
-
1896
- static inline void
1897
- rb_exec_event_hook_orig(rb_execution_context_t *ec, rb_hook_list_t *hooks, rb_event_flag_t flag,
1898
- VALUE self, ID id, ID called_id, VALUE klass, VALUE data, int pop_p)
1899
- {
1900
- struct rb_trace_arg_struct trace_arg;
1901
-
1902
- VM_ASSERT((hooks->events & flag) != 0);
1903
-
1904
- trace_arg.event = flag;
1905
- trace_arg.ec = ec;
1906
- trace_arg.cfp = ec->cfp;
1907
- trace_arg.self = self;
1908
- trace_arg.id = id;
1909
- trace_arg.called_id = called_id;
1910
- trace_arg.klass = klass;
1911
- trace_arg.data = data;
1912
- trace_arg.path = Qundef;
1913
- trace_arg.klass_solved = 0;
1914
-
1915
- rb_exec_event_hooks(&trace_arg, hooks, pop_p);
1916
- }
1917
-
1918
- static inline rb_hook_list_t *
1919
- rb_vm_global_hooks(const rb_execution_context_t *ec)
1920
- {
1921
- return &rb_ec_vm_ptr(ec)->global_hooks;
1922
- }
1923
-
1924
- #define EXEC_EVENT_HOOK(ec_, flag_, self_, id_, called_id_, klass_, data_) \
1925
- EXEC_EVENT_HOOK_ORIG(ec_, rb_vm_global_hooks(ec_), flag_, self_, id_, called_id_, klass_, data_, 0)
1926
-
1927
- #define EXEC_EVENT_HOOK_AND_POP_FRAME(ec_, flag_, self_, id_, called_id_, klass_, data_) \
1928
- EXEC_EVENT_HOOK_ORIG(ec_, rb_vm_global_hooks(ec_), flag_, self_, id_, called_id_, klass_, data_, 1)
1929
-
1930
- static inline void
1931
- rb_exec_event_hook_script_compiled(rb_execution_context_t *ec, const rb_iseq_t *iseq, VALUE eval_script)
1932
- {
1933
- EXEC_EVENT_HOOK(ec, RUBY_EVENT_SCRIPT_COMPILED, ec->cfp->self, 0, 0, 0,
1934
- NIL_P(eval_script) ? (VALUE)iseq :
1935
- rb_ary_new_from_args(2, eval_script, (VALUE)iseq));
1936
- }
1937
-
1938
- void rb_vm_trap_exit(rb_vm_t *vm);
1939
-
1940
- RUBY_SYMBOL_EXPORT_BEGIN
1941
-
1942
- int rb_thread_check_trap_pending(void);
1943
-
1944
- /* #define RUBY_EVENT_RESERVED_FOR_INTERNAL_USE 0x030000 */ /* from vm_core.h */
1945
- #define RUBY_EVENT_COVERAGE_LINE 0x010000
1946
- #define RUBY_EVENT_COVERAGE_BRANCH 0x020000
1947
-
1948
- extern VALUE rb_get_coverages(void);
1949
- extern void rb_set_coverages(VALUE, int, VALUE);
1950
- extern void rb_clear_coverages(void);
1951
- extern void rb_reset_coverages(void);
1952
-
1953
- void rb_postponed_job_flush(rb_vm_t *vm);
1954
-
1955
- RUBY_SYMBOL_EXPORT_END
1956
-
1957
- #endif /* RUBY_VM_CORE_H */