debase-ruby_core_source 3.3.1 → 3.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (289) hide show
  1. checksums.yaml +4 -4
  2. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/addr2line.h +22 -0
  3. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/builtin.h +117 -0
  4. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/ccan/build_assert/build_assert.h +40 -0
  5. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/ccan/check_type/check_type.h +63 -0
  6. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/ccan/container_of/container_of.h +142 -0
  7. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/ccan/list/list.h +791 -0
  8. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/ccan/str/str.h +17 -0
  9. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/constant.h +53 -0
  10. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/darray.h +246 -0
  11. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/debug_counter.h +423 -0
  12. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/dln.h +32 -0
  13. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/encindex.h +70 -0
  14. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/eval_intern.h +343 -0
  15. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/hrtime.h +227 -0
  16. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/id.h +343 -0
  17. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/id_table.h +39 -0
  18. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/insns.inc +251 -0
  19. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/insns_info.inc +9215 -0
  20. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/array.h +151 -0
  21. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/basic_operators.h +63 -0
  22. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/bignum.h +244 -0
  23. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/bits.h +568 -0
  24. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/class.h +277 -0
  25. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/cmdlineopt.h +65 -0
  26. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/compar.h +29 -0
  27. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/compile.h +34 -0
  28. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/compilers.h +107 -0
  29. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/complex.h +29 -0
  30. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/cont.h +35 -0
  31. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/dir.h +16 -0
  32. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/enc.h +19 -0
  33. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/encoding.h +35 -0
  34. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/enum.h +18 -0
  35. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/enumerator.h +21 -0
  36. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/error.h +216 -0
  37. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/eval.h +33 -0
  38. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/file.h +38 -0
  39. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/fixnum.h +184 -0
  40. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/gc.h +364 -0
  41. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/hash.h +191 -0
  42. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/imemo.h +240 -0
  43. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/inits.h +50 -0
  44. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/io.h +137 -0
  45. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/load.h +18 -0
  46. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/loadpath.h +16 -0
  47. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/math.h +23 -0
  48. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/missing.h +18 -0
  49. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/numeric.h +273 -0
  50. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/object.h +62 -0
  51. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/parse.h +108 -0
  52. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/proc.h +30 -0
  53. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/process.h +124 -0
  54. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/ractor.h +6 -0
  55. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/random.h +17 -0
  56. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/range.h +40 -0
  57. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/rational.h +71 -0
  58. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/re.h +28 -0
  59. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/ruby_parser.h +69 -0
  60. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/sanitizers.h +186 -0
  61. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/serial.h +23 -0
  62. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/signal.h +25 -0
  63. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/static_assert.h +16 -0
  64. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/string.h +160 -0
  65. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/struct.h +127 -0
  66. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/symbol.h +45 -0
  67. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/thread.h +78 -0
  68. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/time.h +34 -0
  69. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/transcode.h +23 -0
  70. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/util.h +27 -0
  71. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/variable.h +72 -0
  72. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/vm.h +136 -0
  73. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal/warnings.h +16 -0
  74. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/internal.h +112 -0
  75. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/iseq.h +338 -0
  76. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/known_errors.inc +791 -0
  77. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/method.h +254 -0
  78. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/node.h +128 -0
  79. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/node_name.inc +212 -0
  80. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/optinsn.inc +128 -0
  81. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/optunifs.inc +43 -0
  82. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/parse.h +243 -0
  83. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/parser_bits.h +564 -0
  84. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/parser_node.h +32 -0
  85. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/parser_st.h +162 -0
  86. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/parser_value.h +106 -0
  87. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/ast.h +4612 -0
  88. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/defines.h +94 -0
  89. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/diagnostic.h +297 -0
  90. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/encoding.h +248 -0
  91. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/extension.h +18 -0
  92. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/node.h +57 -0
  93. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/options.h +204 -0
  94. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/pack.h +152 -0
  95. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/parser.h +716 -0
  96. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/prettyprint.h +26 -0
  97. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/prism.h +272 -0
  98. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/regexp.h +33 -0
  99. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/util/pm_buffer.h +146 -0
  100. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/util/pm_char.h +205 -0
  101. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/util/pm_constant_pool.h +191 -0
  102. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/util/pm_list.h +97 -0
  103. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/util/pm_memchr.h +29 -0
  104. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/util/pm_newline_list.h +104 -0
  105. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/util/pm_state_stack.h +42 -0
  106. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/util/pm_string.h +150 -0
  107. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/util/pm_string_list.h +44 -0
  108. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/util/pm_strncasecmp.h +32 -0
  109. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/util/pm_strpbrk.h +43 -0
  110. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism/version.h +29 -0
  111. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/prism_compile.h +29 -0
  112. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/probes_helper.h +42 -0
  113. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/ractor_core.h +393 -0
  114. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/regenc.h +254 -0
  115. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/regint.h +1006 -0
  116. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/regparse.h +371 -0
  117. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/revision.h +5 -0
  118. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/rjit.h +101 -0
  119. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/rjit_c.h +164 -0
  120. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/ruby_assert.h +14 -0
  121. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/ruby_atomic.h +23 -0
  122. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/rubyparser.h +1405 -0
  123. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/shape.h +233 -0
  124. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/siphash.h +48 -0
  125. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/symbol.h +118 -0
  126. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/thread_none.h +21 -0
  127. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/thread_pthread.h +166 -0
  128. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/thread_win32.h +58 -0
  129. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/timev.h +58 -0
  130. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/transcode_data.h +138 -0
  131. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/variable.h +39 -0
  132. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/version.h +69 -0
  133. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/vm.inc +5436 -0
  134. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/vm_call_iseq_optimized.inc +244 -0
  135. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/vm_callinfo.h +614 -0
  136. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/vm_core.h +2202 -0
  137. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/vm_debug.h +122 -0
  138. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/vm_exec.h +199 -0
  139. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/vm_insnhelper.h +261 -0
  140. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/vm_opts.h +67 -0
  141. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/vm_sync.h +137 -0
  142. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/vmtc.inc +245 -0
  143. data/lib/debase/ruby_core_source/ruby-3.3.5-p100/yjit.h +72 -0
  144. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/addr2line.h +22 -0
  145. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/builtin.h +119 -0
  146. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/ccan/build_assert/build_assert.h +40 -0
  147. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/ccan/check_type/check_type.h +63 -0
  148. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/ccan/container_of/container_of.h +142 -0
  149. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/ccan/list/list.h +791 -0
  150. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/ccan/str/str.h +17 -0
  151. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/constant.h +53 -0
  152. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/darray.h +191 -0
  153. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/debug_counter.h +423 -0
  154. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/dln.h +34 -0
  155. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/encindex.h +70 -0
  156. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/eval_intern.h +324 -0
  157. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/hrtime.h +237 -0
  158. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/id.h +343 -0
  159. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/id_table.h +39 -0
  160. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/insns.inc +259 -0
  161. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/insns_info.inc +9530 -0
  162. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/array.h +151 -0
  163. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/basic_operators.h +63 -0
  164. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/bignum.h +244 -0
  165. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/bits.h +568 -0
  166. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/class.h +283 -0
  167. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/cmdlineopt.h +65 -0
  168. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/compar.h +29 -0
  169. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/compile.h +34 -0
  170. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/compilers.h +107 -0
  171. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/complex.h +29 -0
  172. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/cont.h +35 -0
  173. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/dir.h +16 -0
  174. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/enc.h +19 -0
  175. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/encoding.h +36 -0
  176. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/enum.h +18 -0
  177. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/enumerator.h +21 -0
  178. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/error.h +216 -0
  179. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/eval.h +33 -0
  180. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/file.h +38 -0
  181. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/fixnum.h +184 -0
  182. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/gc.h +334 -0
  183. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/hash.h +191 -0
  184. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/imemo.h +260 -0
  185. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/inits.h +47 -0
  186. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/io.h +140 -0
  187. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/load.h +18 -0
  188. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/loadpath.h +16 -0
  189. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/math.h +23 -0
  190. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/missing.h +19 -0
  191. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/numeric.h +274 -0
  192. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/object.h +63 -0
  193. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/parse.h +117 -0
  194. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/proc.h +30 -0
  195. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/process.h +124 -0
  196. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/ractor.h +6 -0
  197. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/random.h +17 -0
  198. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/range.h +40 -0
  199. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/rational.h +71 -0
  200. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/re.h +28 -0
  201. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/ruby_parser.h +102 -0
  202. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/sanitizers.h +297 -0
  203. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/serial.h +23 -0
  204. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/signal.h +24 -0
  205. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/st.h +11 -0
  206. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/static_assert.h +16 -0
  207. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/string.h +182 -0
  208. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/struct.h +127 -0
  209. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/symbol.h +45 -0
  210. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/thread.h +79 -0
  211. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/time.h +34 -0
  212. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/transcode.h +23 -0
  213. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/util.h +27 -0
  214. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/variable.h +72 -0
  215. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/vm.h +137 -0
  216. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal/warnings.h +16 -0
  217. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/internal.h +108 -0
  218. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/iseq.h +340 -0
  219. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/known_errors.inc +1419 -0
  220. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/method.h +255 -0
  221. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/node.h +111 -0
  222. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/node_name.inc +224 -0
  223. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/optinsn.inc +128 -0
  224. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/optunifs.inc +43 -0
  225. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/parse.h +243 -0
  226. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/parser_bits.h +564 -0
  227. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/parser_node.h +32 -0
  228. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/parser_st.h +162 -0
  229. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/parser_value.h +106 -0
  230. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/ast.h +6245 -0
  231. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/defines.h +206 -0
  232. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/diagnostic.h +433 -0
  233. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/encoding.h +283 -0
  234. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/extension.h +19 -0
  235. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/node.h +150 -0
  236. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/options.h +305 -0
  237. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/pack.h +163 -0
  238. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/parser.h +891 -0
  239. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/prettyprint.h +34 -0
  240. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/prism.h +347 -0
  241. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/regexp.h +33 -0
  242. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/static_literals.h +120 -0
  243. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/util/pm_buffer.h +218 -0
  244. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/util/pm_char.h +205 -0
  245. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/util/pm_constant_pool.h +226 -0
  246. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/util/pm_integer.h +119 -0
  247. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/util/pm_list.h +97 -0
  248. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/util/pm_memchr.h +29 -0
  249. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/util/pm_newline_list.h +102 -0
  250. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/util/pm_string.h +174 -0
  251. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/util/pm_string_list.h +44 -0
  252. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/util/pm_strncasecmp.h +32 -0
  253. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/util/pm_strpbrk.h +46 -0
  254. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism/version.h +29 -0
  255. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/prism_compile.h +88 -0
  256. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/probes_helper.h +42 -0
  257. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/ractor_core.h +393 -0
  258. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/regenc.h +254 -0
  259. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/regint.h +1010 -0
  260. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/regparse.h +371 -0
  261. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/revision.h +5 -0
  262. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/rjit.h +101 -0
  263. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/rjit_c.h +165 -0
  264. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/ruby_assert.h +14 -0
  265. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/ruby_atomic.h +23 -0
  266. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/rubyparser.h +1430 -0
  267. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/shape.h +233 -0
  268. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/siphash.h +48 -0
  269. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/symbol.h +118 -0
  270. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/thread_none.h +21 -0
  271. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/thread_pthread.h +166 -0
  272. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/thread_win32.h +58 -0
  273. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/timev.h +58 -0
  274. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/transcode_data.h +138 -0
  275. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/variable.h +39 -0
  276. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/version.h +69 -0
  277. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/vm.inc +5643 -0
  278. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/vm_call_iseq_optimized.inc +244 -0
  279. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/vm_callinfo.h +605 -0
  280. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/vm_core.h +2236 -0
  281. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/vm_debug.h +124 -0
  282. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/vm_exec.h +199 -0
  283. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/vm_insnhelper.h +272 -0
  284. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/vm_opts.h +67 -0
  285. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/vm_sync.h +137 -0
  286. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/vmtc.inc +253 -0
  287. data/lib/debase/ruby_core_source/ruby-3.4.0-preview1/yjit.h +79 -0
  288. data/lib/debase/ruby_core_source/version.rb +1 -1
  289. metadata +289 -3
@@ -0,0 +1,2202 @@
1
+ #ifndef RUBY_VM_CORE_H
2
+ #define RUBY_VM_CORE_H
3
+ /**********************************************************************
4
+
5
+ vm_core.h -
6
+
7
+ $Author$
8
+ created at: 04/01/01 19:41:38 JST
9
+
10
+ Copyright (C) 2004-2007 Koichi Sasada
11
+
12
+ **********************************************************************/
13
+
14
+ /*
15
+ * Enable check mode.
16
+ * 1: enable local assertions.
17
+ */
18
+ #ifndef VM_CHECK_MODE
19
+
20
+ // respect RUBY_DUBUG: if given n is 0, then use RUBY_DEBUG
21
+ #define N_OR_RUBY_DEBUG(n) (((n) > 0) ? (n) : RUBY_DEBUG)
22
+
23
+ #define VM_CHECK_MODE N_OR_RUBY_DEBUG(0)
24
+ #endif
25
+
26
+ /**
27
+ * VM Debug Level
28
+ *
29
+ * debug level:
30
+ * 0: no debug output
31
+ * 1: show instruction name
32
+ * 2: show stack frame when control stack frame is changed
33
+ * 3: show stack status
34
+ * 4: show register
35
+ * 5:
36
+ * 10: gc check
37
+ */
38
+
39
+ #ifndef VMDEBUG
40
+ #define VMDEBUG 0
41
+ #endif
42
+
43
+ #if 0
44
+ #undef VMDEBUG
45
+ #define VMDEBUG 3
46
+ #endif
47
+
48
+ #include "ruby/internal/config.h"
49
+
50
+ #include <stddef.h>
51
+ #include <signal.h>
52
+ #include <stdarg.h>
53
+
54
+ #include "ruby_assert.h"
55
+
56
+ #define RVALUE_SIZE (sizeof(struct RBasic) + sizeof(VALUE[RBIMPL_RVALUE_EMBED_LEN_MAX]))
57
+
58
+ #if VM_CHECK_MODE > 0
59
+ #define VM_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(VM_CHECK_MODE > 0, expr, #expr)
60
+ #define VM_UNREACHABLE(func) rb_bug(#func ": unreachable")
61
+ #define RUBY_ASSERT_CRITICAL_SECTION
62
+ #define RUBY_DEBUG_THREAD_SCHEDULE() rb_thread_schedule()
63
+ #else
64
+ #define VM_ASSERT(expr) ((void)0)
65
+ #define VM_UNREACHABLE(func) UNREACHABLE
66
+ #define RUBY_DEBUG_THREAD_SCHEDULE()
67
+ #endif
68
+
69
+ #define RUBY_ASSERT_MUTEX_OWNED(mutex) VM_ASSERT(rb_mutex_owned_p(mutex))
70
+
71
+ #if defined(RUBY_ASSERT_CRITICAL_SECTION)
72
+ // TODO add documentation
73
+ extern int ruby_assert_critical_section_entered;
74
+ #define RUBY_ASSERT_CRITICAL_SECTION_ENTER() do{ruby_assert_critical_section_entered += 1;}while(false)
75
+ #define RUBY_ASSERT_CRITICAL_SECTION_LEAVE() do{VM_ASSERT(ruby_assert_critical_section_entered > 0);ruby_assert_critical_section_entered -= 1;}while(false)
76
+ #else
77
+ #define RUBY_ASSERT_CRITICAL_SECTION_ENTER()
78
+ #define RUBY_ASSERT_CRITICAL_SECTION_LEAVE()
79
+ #endif
80
+
81
+ #if defined(__wasm__) && !defined(__EMSCRIPTEN__)
82
+ # include "wasm/setjmp.h"
83
+ #else
84
+ # include <setjmp.h>
85
+ #endif
86
+
87
+ #if defined(__linux__) || defined(__FreeBSD__)
88
+ # define RB_THREAD_T_HAS_NATIVE_ID
89
+ #endif
90
+
91
+ #include "ruby/internal/stdbool.h"
92
+ #include "ccan/list/list.h"
93
+ #include "id.h"
94
+ #include "internal.h"
95
+ #include "internal/array.h"
96
+ #include "internal/basic_operators.h"
97
+ #include "internal/serial.h"
98
+ #include "internal/vm.h"
99
+ #include "method.h"
100
+ #include "node.h"
101
+ #include "ruby/ruby.h"
102
+ #include "ruby/st.h"
103
+ #include "ruby_atomic.h"
104
+ #include "vm_opts.h"
105
+
106
+ #include "ruby/thread_native.h"
107
+
108
+ /*
109
+ * implementation selector of get_insn_info algorithm
110
+ * 0: linear search
111
+ * 1: binary search
112
+ * 2: succinct bitvector
113
+ */
114
+ #ifndef VM_INSN_INFO_TABLE_IMPL
115
+ # define VM_INSN_INFO_TABLE_IMPL 2
116
+ #endif
117
+
118
+ #if defined(NSIG_MAX) /* POSIX issue 8 */
119
+ # undef NSIG
120
+ # define NSIG NSIG_MAX
121
+ #elif defined(_SIG_MAXSIG) /* FreeBSD */
122
+ # undef NSIG
123
+ # define NSIG _SIG_MAXSIG
124
+ #elif defined(_SIGMAX) /* QNX */
125
+ # define NSIG (_SIGMAX + 1)
126
+ #elif defined(NSIG) /* 99% of everything else */
127
+ # /* take it */
128
+ #else /* Last resort */
129
+ # define NSIG (sizeof(sigset_t) * CHAR_BIT + 1)
130
+ #endif
131
+
132
+ #define RUBY_NSIG NSIG
133
+
134
+ #if defined(SIGCLD)
135
+ # define RUBY_SIGCHLD (SIGCLD)
136
+ #elif defined(SIGCHLD)
137
+ # define RUBY_SIGCHLD (SIGCHLD)
138
+ #endif
139
+
140
+ #if defined(SIGSEGV) && defined(HAVE_SIGALTSTACK) && defined(SA_SIGINFO) && !defined(__NetBSD__)
141
+ # define USE_SIGALTSTACK
142
+ void *rb_allocate_sigaltstack(void);
143
+ void *rb_register_sigaltstack(void *);
144
+ # define RB_ALTSTACK_INIT(var, altstack) var = rb_register_sigaltstack(altstack)
145
+ # define RB_ALTSTACK_FREE(var) free(var)
146
+ # define RB_ALTSTACK(var) var
147
+ #else /* noop */
148
+ # define RB_ALTSTACK_INIT(var, altstack)
149
+ # define RB_ALTSTACK_FREE(var)
150
+ # define RB_ALTSTACK(var) (0)
151
+ #endif
152
+
153
+ #include THREAD_IMPL_H
154
+ #define RUBY_VM_THREAD_MODEL 2
155
+
156
+ /*****************/
157
+ /* configuration */
158
+ /*****************/
159
+
160
+ /* gcc ver. check */
161
+ #if defined(__GNUC__) && __GNUC__ >= 2
162
+
163
+ #if OPT_TOKEN_THREADED_CODE
164
+ #if OPT_DIRECT_THREADED_CODE
165
+ #undef OPT_DIRECT_THREADED_CODE
166
+ #endif
167
+ #endif
168
+
169
+ #else /* defined(__GNUC__) && __GNUC__ >= 2 */
170
+
171
+ /* disable threaded code options */
172
+ #if OPT_DIRECT_THREADED_CODE
173
+ #undef OPT_DIRECT_THREADED_CODE
174
+ #endif
175
+ #if OPT_TOKEN_THREADED_CODE
176
+ #undef OPT_TOKEN_THREADED_CODE
177
+ #endif
178
+ #endif
179
+
180
+ /* call threaded code */
181
+ #if OPT_CALL_THREADED_CODE
182
+ #if OPT_DIRECT_THREADED_CODE
183
+ #undef OPT_DIRECT_THREADED_CODE
184
+ #endif /* OPT_DIRECT_THREADED_CODE */
185
+ #endif /* OPT_CALL_THREADED_CODE */
186
+
187
+ void rb_vm_encoded_insn_data_table_init(void);
188
+ typedef unsigned long rb_num_t;
189
+ typedef signed long rb_snum_t;
190
+
191
+ enum ruby_tag_type {
192
+ RUBY_TAG_NONE = 0x0,
193
+ RUBY_TAG_RETURN = 0x1,
194
+ RUBY_TAG_BREAK = 0x2,
195
+ RUBY_TAG_NEXT = 0x3,
196
+ RUBY_TAG_RETRY = 0x4,
197
+ RUBY_TAG_REDO = 0x5,
198
+ RUBY_TAG_RAISE = 0x6,
199
+ RUBY_TAG_THROW = 0x7,
200
+ RUBY_TAG_FATAL = 0x8,
201
+ RUBY_TAG_MASK = 0xf
202
+ };
203
+
204
+ #define TAG_NONE RUBY_TAG_NONE
205
+ #define TAG_RETURN RUBY_TAG_RETURN
206
+ #define TAG_BREAK RUBY_TAG_BREAK
207
+ #define TAG_NEXT RUBY_TAG_NEXT
208
+ #define TAG_RETRY RUBY_TAG_RETRY
209
+ #define TAG_REDO RUBY_TAG_REDO
210
+ #define TAG_RAISE RUBY_TAG_RAISE
211
+ #define TAG_THROW RUBY_TAG_THROW
212
+ #define TAG_FATAL RUBY_TAG_FATAL
213
+ #define TAG_MASK RUBY_TAG_MASK
214
+
215
+ enum ruby_vm_throw_flags {
216
+ VM_THROW_NO_ESCAPE_FLAG = 0x8000,
217
+ VM_THROW_STATE_MASK = 0xff
218
+ };
219
+
220
+ /* forward declarations */
221
+ struct rb_thread_struct;
222
+ struct rb_control_frame_struct;
223
+
224
+ /* iseq data type */
225
+ typedef struct rb_compile_option_struct rb_compile_option_t;
226
+
227
+ union ic_serial_entry {
228
+ rb_serial_t raw;
229
+ VALUE data[2];
230
+ };
231
+
232
+ // imemo_constcache
233
+ struct iseq_inline_constant_cache_entry {
234
+ VALUE flags;
235
+
236
+ VALUE value; // v0
237
+ VALUE _unused1; // v1
238
+ VALUE _unused2; // v2
239
+ const rb_cref_t *ic_cref; // v3
240
+ };
241
+ STATIC_ASSERT(sizeof_iseq_inline_constant_cache_entry,
242
+ (offsetof(struct iseq_inline_constant_cache_entry, ic_cref) +
243
+ sizeof(const rb_cref_t *)) <= RVALUE_SIZE);
244
+
245
+ struct iseq_inline_constant_cache {
246
+ struct iseq_inline_constant_cache_entry *entry;
247
+
248
+ /**
249
+ * A null-terminated list of ids, used to represent a constant's path
250
+ * idNULL is used to represent the :: prefix, and 0 is used to donate the end
251
+ * of the list.
252
+ *
253
+ * For example
254
+ * FOO {rb_intern("FOO"), 0}
255
+ * FOO::BAR {rb_intern("FOO"), rb_intern("BAR"), 0}
256
+ * ::FOO {idNULL, rb_intern("FOO"), 0}
257
+ * ::FOO::BAR {idNULL, rb_intern("FOO"), rb_intern("BAR"), 0}
258
+ */
259
+ const ID *segments;
260
+ };
261
+
262
+ struct iseq_inline_iv_cache_entry {
263
+ uintptr_t value; // attr_index in lower bits, dest_shape_id in upper bits
264
+ ID iv_set_name;
265
+ };
266
+
267
+ struct iseq_inline_cvar_cache_entry {
268
+ struct rb_cvar_class_tbl_entry *entry;
269
+ };
270
+
271
+ union iseq_inline_storage_entry {
272
+ struct {
273
+ struct rb_thread_struct *running_thread;
274
+ VALUE value;
275
+ } once;
276
+ struct iseq_inline_constant_cache ic_cache;
277
+ struct iseq_inline_iv_cache_entry iv_cache;
278
+ };
279
+
280
+ struct rb_calling_info {
281
+ const struct rb_call_data *cd;
282
+ const struct rb_callcache *cc;
283
+ VALUE block_handler;
284
+ VALUE recv;
285
+ int argc;
286
+ bool kw_splat;
287
+ VALUE heap_argv;
288
+ };
289
+
290
+ #ifndef VM_ARGC_STACK_MAX
291
+ #define VM_ARGC_STACK_MAX 128
292
+ #endif
293
+
294
+ # define CALLING_ARGC(calling) ((calling)->heap_argv ? RARRAY_LENINT((calling)->heap_argv) : (calling)->argc)
295
+
296
+ struct rb_execution_context_struct;
297
+
298
+ #if 1
299
+ #define CoreDataFromValue(obj, type) (type*)DATA_PTR(obj)
300
+ #else
301
+ #define CoreDataFromValue(obj, type) (type*)rb_data_object_get(obj)
302
+ #endif
303
+ #define GetCoreDataFromValue(obj, type, ptr) ((ptr) = CoreDataFromValue((obj), type))
304
+
305
+ typedef struct rb_iseq_location_struct {
306
+ VALUE pathobj; /* String (path) or Array [path, realpath]. Frozen. */
307
+ VALUE base_label; /* String */
308
+ VALUE label; /* String */
309
+ int first_lineno;
310
+ int node_id;
311
+ rb_code_location_t code_location;
312
+ } rb_iseq_location_t;
313
+
314
+ #define PATHOBJ_PATH 0
315
+ #define PATHOBJ_REALPATH 1
316
+
317
+ static inline VALUE
318
+ pathobj_path(VALUE pathobj)
319
+ {
320
+ if (RB_TYPE_P(pathobj, T_STRING)) {
321
+ return pathobj;
322
+ }
323
+ else {
324
+ VM_ASSERT(RB_TYPE_P(pathobj, T_ARRAY));
325
+ return RARRAY_AREF(pathobj, PATHOBJ_PATH);
326
+ }
327
+ }
328
+
329
+ static inline VALUE
330
+ pathobj_realpath(VALUE pathobj)
331
+ {
332
+ if (RB_TYPE_P(pathobj, T_STRING)) {
333
+ return pathobj;
334
+ }
335
+ else {
336
+ VM_ASSERT(RB_TYPE_P(pathobj, T_ARRAY));
337
+ return RARRAY_AREF(pathobj, PATHOBJ_REALPATH);
338
+ }
339
+ }
340
+
341
+ /* Forward declarations */
342
+ struct rb_rjit_unit;
343
+
344
+ typedef uintptr_t iseq_bits_t;
345
+
346
+ #define ISEQ_IS_SIZE(body) (body->ic_size + body->ivc_size + body->ise_size + body->icvarc_size)
347
+
348
+ /* [ TS_IVC | TS_ICVARC | TS_ISE | TS_IC ] */
349
+ #define ISEQ_IS_IC_ENTRY(body, idx) (body->is_entries[(idx) + body->ise_size + body->icvarc_size + body->ivc_size].ic_cache);
350
+
351
+ /* instruction sequence type */
352
+ enum rb_iseq_type {
353
+ ISEQ_TYPE_TOP,
354
+ ISEQ_TYPE_METHOD,
355
+ ISEQ_TYPE_BLOCK,
356
+ ISEQ_TYPE_CLASS,
357
+ ISEQ_TYPE_RESCUE,
358
+ ISEQ_TYPE_ENSURE,
359
+ ISEQ_TYPE_EVAL,
360
+ ISEQ_TYPE_MAIN,
361
+ ISEQ_TYPE_PLAIN
362
+ };
363
+
364
+ // Attributes specified by Primitive.attr!
365
+ enum rb_builtin_attr {
366
+ // The iseq does not call methods.
367
+ BUILTIN_ATTR_LEAF = 0x01,
368
+ // The iseq does not allocate objects.
369
+ BUILTIN_ATTR_NO_GC = 0x02,
370
+ // This iseq only contains single `opt_invokebuiltin_delegate_leave` instruction with 0 arguments.
371
+ BUILTIN_ATTR_SINGLE_NOARG_INLINE = 0x04,
372
+ };
373
+
374
+ typedef VALUE (*rb_jit_func_t)(struct rb_execution_context_struct *, struct rb_control_frame_struct *);
375
+
376
+ struct rb_iseq_constant_body {
377
+ enum rb_iseq_type type;
378
+
379
+ unsigned int iseq_size;
380
+ VALUE *iseq_encoded; /* encoded iseq (insn addr and operands) */
381
+
382
+ /**
383
+ * parameter information
384
+ *
385
+ * def m(a1, a2, ..., aM, # mandatory
386
+ * b1=(...), b2=(...), ..., bN=(...), # optional
387
+ * *c, # rest
388
+ * d1, d2, ..., dO, # post
389
+ * e1:(...), e2:(...), ..., eK:(...), # keyword
390
+ * **f, # keyword_rest
391
+ * &g) # block
392
+ * =>
393
+ *
394
+ * lead_num = M
395
+ * opt_num = N
396
+ * rest_start = M+N
397
+ * post_start = M+N+(*1)
398
+ * post_num = O
399
+ * keyword_num = K
400
+ * block_start = M+N+(*1)+O+K
401
+ * keyword_bits = M+N+(*1)+O+K+(&1)
402
+ * size = M+N+O+(*1)+K+(&1)+(**1) // parameter size.
403
+ */
404
+
405
+ struct {
406
+ struct {
407
+ unsigned int has_lead : 1;
408
+ unsigned int has_opt : 1;
409
+ unsigned int has_rest : 1;
410
+ unsigned int has_post : 1;
411
+ unsigned int has_kw : 1;
412
+ unsigned int has_kwrest : 1;
413
+ unsigned int has_block : 1;
414
+
415
+ unsigned int ambiguous_param0 : 1; /* {|a|} */
416
+ unsigned int accepts_no_kwarg : 1;
417
+ unsigned int ruby2_keywords: 1;
418
+ } flags;
419
+
420
+ unsigned int size;
421
+
422
+ int lead_num;
423
+ int opt_num;
424
+ int rest_start;
425
+ int post_start;
426
+ int post_num;
427
+ int block_start;
428
+
429
+ const VALUE *opt_table; /* (opt_num + 1) entries. */
430
+ /* opt_num and opt_table:
431
+ *
432
+ * def foo o1=e1, o2=e2, ..., oN=eN
433
+ * #=>
434
+ * # prologue code
435
+ * A1: e1
436
+ * A2: e2
437
+ * ...
438
+ * AN: eN
439
+ * AL: body
440
+ * opt_num = N
441
+ * opt_table = [A1, A2, ..., AN, AL]
442
+ */
443
+
444
+ const struct rb_iseq_param_keyword {
445
+ int num;
446
+ int required_num;
447
+ int bits_start;
448
+ int rest_start;
449
+ const ID *table;
450
+ VALUE *default_values;
451
+ } *keyword;
452
+ } param;
453
+
454
+ rb_iseq_location_t location;
455
+
456
+ /* insn info, must be freed */
457
+ struct iseq_insn_info {
458
+ const struct iseq_insn_info_entry *body;
459
+ unsigned int *positions;
460
+ unsigned int size;
461
+ #if VM_INSN_INFO_TABLE_IMPL == 2
462
+ struct succ_index_table *succ_index_table;
463
+ #endif
464
+ } insns_info;
465
+
466
+ const ID *local_table; /* must free */
467
+
468
+ /* catch table */
469
+ struct iseq_catch_table *catch_table;
470
+
471
+ /* for child iseq */
472
+ const struct rb_iseq_struct *parent_iseq;
473
+ struct rb_iseq_struct *local_iseq; /* local_iseq->flip_cnt can be modified */
474
+
475
+ union iseq_inline_storage_entry *is_entries; /* [ TS_IVC | TS_ICVARC | TS_ISE | TS_IC ] */
476
+ struct rb_call_data *call_data; //struct rb_call_data calls[ci_size];
477
+
478
+ struct {
479
+ rb_snum_t flip_count;
480
+ VALUE script_lines;
481
+ VALUE coverage;
482
+ VALUE pc2branchindex;
483
+ VALUE *original_iseq;
484
+ } variable;
485
+
486
+ unsigned int local_table_size;
487
+ unsigned int ic_size; // Number of IC caches
488
+ unsigned int ise_size; // Number of ISE caches
489
+ unsigned int ivc_size; // Number of IVC caches
490
+ unsigned int icvarc_size; // Number of ICVARC caches
491
+ unsigned int ci_size;
492
+ unsigned int stack_max; /* for stack overflow check */
493
+
494
+ unsigned int builtin_attrs; // Union of rb_builtin_attr
495
+
496
+ union {
497
+ iseq_bits_t * list; /* Find references for GC */
498
+ iseq_bits_t single;
499
+ } mark_bits;
500
+
501
+ struct rb_id_table *outer_variables;
502
+
503
+ const rb_iseq_t *mandatory_only_iseq;
504
+
505
+ #if USE_RJIT || USE_YJIT
506
+ // Function pointer for JIT code on jit_exec()
507
+ rb_jit_func_t jit_entry;
508
+ // Number of calls on jit_exec()
509
+ long unsigned jit_entry_calls;
510
+ #endif
511
+
512
+ #if USE_YJIT
513
+ // Function pointer for JIT code on jit_exec_exception()
514
+ rb_jit_func_t jit_exception;
515
+ // Number of calls on jit_exec_exception()
516
+ long unsigned jit_exception_calls;
517
+ #endif
518
+
519
+ #if USE_RJIT
520
+ // RJIT stores some data on each iseq.
521
+ VALUE rjit_blocks;
522
+ #endif
523
+
524
+ #if USE_YJIT
525
+ // YJIT stores some data on each iseq.
526
+ void *yjit_payload;
527
+ // Used to estimate how frequently this ISEQ gets called
528
+ uint64_t yjit_calls_at_interv;
529
+ #endif
530
+ };
531
+
532
+ /* T_IMEMO/iseq */
533
+ /* typedef rb_iseq_t is in method.h */
534
+ struct rb_iseq_struct {
535
+ VALUE flags; /* 1 */
536
+ VALUE wrapper; /* 2 */
537
+
538
+ struct rb_iseq_constant_body *body; /* 3 */
539
+
540
+ union { /* 4, 5 words */
541
+ struct iseq_compile_data *compile_data; /* used at compile time */
542
+
543
+ struct {
544
+ VALUE obj;
545
+ int index;
546
+ } loader;
547
+
548
+ struct {
549
+ struct rb_hook_list_struct *local_hooks;
550
+ rb_event_flag_t global_trace_events;
551
+ } exec;
552
+ } aux;
553
+ };
554
+
555
+ #define ISEQ_BODY(iseq) ((iseq)->body)
556
+
557
+ #if !defined(USE_LAZY_LOAD) || !(USE_LAZY_LOAD+0)
558
+ #define USE_LAZY_LOAD 0
559
+ #endif
560
+
561
+ #if !USE_LAZY_LOAD
562
+ static inline const rb_iseq_t *rb_iseq_complete(const rb_iseq_t *iseq) {return 0;}
563
+ #endif
564
+ const rb_iseq_t *rb_iseq_complete(const rb_iseq_t *iseq);
565
+
566
+ static inline const rb_iseq_t *
567
+ rb_iseq_check(const rb_iseq_t *iseq)
568
+ {
569
+ if (USE_LAZY_LOAD && ISEQ_BODY(iseq) == NULL) {
570
+ rb_iseq_complete((rb_iseq_t *)iseq);
571
+ }
572
+ return iseq;
573
+ }
574
+
575
+ static inline const rb_iseq_t *
576
+ def_iseq_ptr(rb_method_definition_t *def)
577
+ {
578
+ //TODO: re-visit. to check the bug, enable this assertion.
579
+ #if VM_CHECK_MODE > 0
580
+ if (def->type != VM_METHOD_TYPE_ISEQ) rb_bug("def_iseq_ptr: not iseq (%d)", def->type);
581
+ #endif
582
+ return rb_iseq_check(def->body.iseq.iseqptr);
583
+ }
584
+
585
+ enum ruby_special_exceptions {
586
+ ruby_error_reenter,
587
+ ruby_error_nomemory,
588
+ ruby_error_sysstack,
589
+ ruby_error_stackfatal,
590
+ ruby_error_stream_closed,
591
+ ruby_special_error_count
592
+ };
593
+
594
+ #define GetVMPtr(obj, ptr) \
595
+ GetCoreDataFromValue((obj), rb_vm_t, (ptr))
596
+
597
+ struct rb_vm_struct;
598
+ typedef void rb_vm_at_exit_func(struct rb_vm_struct*);
599
+
600
+ typedef struct rb_at_exit_list {
601
+ rb_vm_at_exit_func *func;
602
+ struct rb_at_exit_list *next;
603
+ } rb_at_exit_list;
604
+
605
+ struct rb_objspace;
606
+ struct rb_objspace *rb_objspace_alloc(void);
607
+ void rb_objspace_free(struct rb_objspace *);
608
+ void rb_objspace_call_finalizer(struct rb_objspace *);
609
+
610
+ typedef struct rb_hook_list_struct {
611
+ struct rb_event_hook_struct *hooks;
612
+ rb_event_flag_t events;
613
+ unsigned int running;
614
+ bool need_clean;
615
+ bool is_local;
616
+ } rb_hook_list_t;
617
+
618
+
619
+ // see builtin.h for definition
620
+ typedef const struct rb_builtin_function *RB_BUILTIN;
621
+
622
+ typedef struct rb_vm_struct {
623
+ VALUE self;
624
+
625
+ struct {
626
+ struct ccan_list_head set;
627
+ unsigned int cnt;
628
+ unsigned int blocking_cnt;
629
+
630
+ struct rb_ractor_struct *main_ractor;
631
+ struct rb_thread_struct *main_thread; // == vm->ractor.main_ractor->threads.main
632
+
633
+ struct {
634
+ // monitor
635
+ rb_nativethread_lock_t lock;
636
+ struct rb_ractor_struct *lock_owner;
637
+ unsigned int lock_rec;
638
+
639
+ // join at exit
640
+ rb_nativethread_cond_t terminate_cond;
641
+ bool terminate_waiting;
642
+
643
+ #ifndef RUBY_THREAD_PTHREAD_H
644
+ bool barrier_waiting;
645
+ unsigned int barrier_cnt;
646
+ rb_nativethread_cond_t barrier_cond;
647
+ #endif
648
+ } sync;
649
+
650
+ // ractor scheduling
651
+ struct {
652
+ rb_nativethread_lock_t lock;
653
+ struct rb_ractor_struct *lock_owner;
654
+ bool locked;
655
+
656
+ rb_nativethread_cond_t cond; // GRQ
657
+ unsigned int snt_cnt; // count of shared NTs
658
+ unsigned int dnt_cnt; // count of dedicated NTs
659
+
660
+ unsigned int running_cnt;
661
+
662
+ unsigned int max_cpu;
663
+ struct ccan_list_head grq; // // Global Ready Queue
664
+ unsigned int grq_cnt;
665
+
666
+ // running threads
667
+ struct ccan_list_head running_threads;
668
+
669
+ // threads which switch context by timeslice
670
+ struct ccan_list_head timeslice_threads;
671
+
672
+ struct ccan_list_head zombie_threads;
673
+
674
+ // true if timeslice timer is not enable
675
+ bool timeslice_wait_inf;
676
+
677
+ // barrier
678
+ rb_nativethread_cond_t barrier_complete_cond;
679
+ rb_nativethread_cond_t barrier_release_cond;
680
+ bool barrier_waiting;
681
+ unsigned int barrier_waiting_cnt;
682
+ unsigned int barrier_serial;
683
+ } sched;
684
+ } ractor;
685
+
686
+ #ifdef USE_SIGALTSTACK
687
+ void *main_altstack;
688
+ #endif
689
+
690
+ rb_serial_t fork_gen;
691
+ struct ccan_list_head waiting_fds; /* <=> struct waiting_fd */
692
+
693
+ /* set in single-threaded processes only: */
694
+ volatile int ubf_async_safe;
695
+
696
+ unsigned int running: 1;
697
+ unsigned int thread_abort_on_exception: 1;
698
+ unsigned int thread_report_on_exception: 1;
699
+ unsigned int thread_ignore_deadlock: 1;
700
+
701
+ /* object management */
702
+ VALUE mark_object_ary;
703
+ const VALUE special_exceptions[ruby_special_error_count];
704
+
705
+ /* load */
706
+ VALUE top_self;
707
+ VALUE load_path;
708
+ VALUE load_path_snapshot;
709
+ VALUE load_path_check_cache;
710
+ VALUE expanded_load_path;
711
+ VALUE loaded_features;
712
+ VALUE loaded_features_snapshot;
713
+ VALUE loaded_features_realpaths;
714
+ VALUE loaded_features_realpath_map;
715
+ struct st_table *loaded_features_index;
716
+ struct st_table *loading_table;
717
+ // For running the init function of statically linked
718
+ // extensions when they are loaded
719
+ struct st_table *static_ext_inits;
720
+
721
+ /* signal */
722
+ struct {
723
+ VALUE cmd[RUBY_NSIG];
724
+ } trap_list;
725
+
726
+ /* relation table of ensure - rollback for callcc */
727
+ struct st_table *ensure_rollback_table;
728
+
729
+ /* postponed_job (async-signal-safe, and thread-safe) */
730
+ struct rb_postponed_job_queue *postponed_job_queue;
731
+
732
+ int src_encoding_index;
733
+
734
+ /* workqueue (thread-safe, NOT async-signal-safe) */
735
+ struct ccan_list_head workqueue; /* <=> rb_workqueue_job.jnode */
736
+ rb_nativethread_lock_t workqueue_lock;
737
+
738
+ VALUE orig_progname, progname;
739
+ VALUE coverages, me2counter;
740
+ int coverage_mode;
741
+
742
+ st_table * defined_module_hash;
743
+
744
+ struct rb_objspace *objspace;
745
+
746
+ rb_at_exit_list *at_exit;
747
+
748
+ st_table *frozen_strings;
749
+
750
+ const struct rb_builtin_function *builtin_function_table;
751
+ int builtin_inline_index;
752
+
753
+ st_table *ci_table;
754
+ struct rb_id_table *negative_cme_table;
755
+ st_table *overloaded_cme_table; // cme -> overloaded_cme
756
+
757
+ // This id table contains a mapping from ID to ICs. It does this with ID
758
+ // keys and nested st_tables as values. The nested tables have ICs as keys
759
+ // and Qtrue as values. It is used when inline constant caches need to be
760
+ // invalidated or ISEQs are being freed.
761
+ struct rb_id_table *constant_cache;
762
+
763
+ #ifndef VM_GLOBAL_CC_CACHE_TABLE_SIZE
764
+ #define VM_GLOBAL_CC_CACHE_TABLE_SIZE 1023
765
+ #endif
766
+ const struct rb_callcache *global_cc_cache_table[VM_GLOBAL_CC_CACHE_TABLE_SIZE]; // vm_eval.c
767
+
768
+ #if defined(USE_VM_CLOCK) && USE_VM_CLOCK
769
+ uint32_t clock;
770
+ #endif
771
+
772
+ /* params */
773
+ struct { /* size in byte */
774
+ size_t thread_vm_stack_size;
775
+ size_t thread_machine_stack_size;
776
+ size_t fiber_vm_stack_size;
777
+ size_t fiber_machine_stack_size;
778
+ } default_params;
779
+
780
+ } rb_vm_t;
781
+
782
+ /* default values */
783
+
784
+ #define RUBY_VM_SIZE_ALIGN 4096
785
+
786
+ #define RUBY_VM_THREAD_VM_STACK_SIZE ( 128 * 1024 * sizeof(VALUE)) /* 512 KB or 1024 KB */
787
+ #define RUBY_VM_THREAD_VM_STACK_SIZE_MIN ( 2 * 1024 * sizeof(VALUE)) /* 8 KB or 16 KB */
788
+ #define RUBY_VM_THREAD_MACHINE_STACK_SIZE ( 128 * 1024 * sizeof(VALUE)) /* 512 KB or 1024 KB */
789
+ #define RUBY_VM_THREAD_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
790
+
791
+ #define RUBY_VM_FIBER_VM_STACK_SIZE ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
792
+ #define RUBY_VM_FIBER_VM_STACK_SIZE_MIN ( 2 * 1024 * sizeof(VALUE)) /* 8 KB or 16 KB */
793
+ #define RUBY_VM_FIBER_MACHINE_STACK_SIZE ( 64 * 1024 * sizeof(VALUE)) /* 256 KB or 512 KB */
794
+ #if defined(__powerpc64__) || defined(__ppc64__) // macOS has __ppc64__
795
+ #define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 32 * 1024 * sizeof(VALUE)) /* 128 KB or 256 KB */
796
+ #else
797
+ #define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
798
+ #endif
799
+
800
+ #if __has_feature(memory_sanitizer) || __has_feature(address_sanitizer)
801
+ /* It seems sanitizers consume A LOT of machine stacks */
802
+ #undef RUBY_VM_THREAD_MACHINE_STACK_SIZE
803
+ #define RUBY_VM_THREAD_MACHINE_STACK_SIZE (1024 * 1024 * sizeof(VALUE))
804
+ #undef RUBY_VM_THREAD_MACHINE_STACK_SIZE_MIN
805
+ #define RUBY_VM_THREAD_MACHINE_STACK_SIZE_MIN ( 512 * 1024 * sizeof(VALUE))
806
+ #undef RUBY_VM_FIBER_MACHINE_STACK_SIZE
807
+ #define RUBY_VM_FIBER_MACHINE_STACK_SIZE ( 256 * 1024 * sizeof(VALUE))
808
+ #undef RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN
809
+ #define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 128 * 1024 * sizeof(VALUE))
810
+ #endif
811
+
812
+ #ifndef VM_DEBUG_BP_CHECK
813
+ #define VM_DEBUG_BP_CHECK 0
814
+ #endif
815
+
816
+ #ifndef VM_DEBUG_VERIFY_METHOD_CACHE
817
+ #define VM_DEBUG_VERIFY_METHOD_CACHE (VMDEBUG != 0)
818
+ #endif
819
+
820
+ struct rb_captured_block {
821
+ VALUE self;
822
+ const VALUE *ep;
823
+ union {
824
+ const rb_iseq_t *iseq;
825
+ const struct vm_ifunc *ifunc;
826
+ VALUE val;
827
+ } code;
828
+ };
829
+
830
+ enum rb_block_handler_type {
831
+ block_handler_type_iseq,
832
+ block_handler_type_ifunc,
833
+ block_handler_type_symbol,
834
+ block_handler_type_proc
835
+ };
836
+
837
+ enum rb_block_type {
838
+ block_type_iseq,
839
+ block_type_ifunc,
840
+ block_type_symbol,
841
+ block_type_proc
842
+ };
843
+
844
+ struct rb_block {
845
+ union {
846
+ struct rb_captured_block captured;
847
+ VALUE symbol;
848
+ VALUE proc;
849
+ } as;
850
+ enum rb_block_type type;
851
+ };
852
+
853
+ typedef struct rb_control_frame_struct {
854
+ const VALUE *pc; // cfp[0]
855
+ VALUE *sp; // cfp[1]
856
+ const rb_iseq_t *iseq; // cfp[2]
857
+ VALUE self; // cfp[3] / block[0]
858
+ const VALUE *ep; // cfp[4] / block[1]
859
+ const void *block_code; // cfp[5] / block[2] -- iseq, ifunc, or forwarded block handler
860
+ void *jit_return; // cfp[6] -- return address for JIT code
861
+ #if VM_DEBUG_BP_CHECK
862
+ VALUE *bp_check; // cfp[7]
863
+ #endif
864
+ } rb_control_frame_t;
865
+
866
+ extern const rb_data_type_t ruby_threadptr_data_type;
867
+
868
+ static inline struct rb_thread_struct *
869
+ rb_thread_ptr(VALUE thval)
870
+ {
871
+ return (struct rb_thread_struct *)rb_check_typeddata(thval, &ruby_threadptr_data_type);
872
+ }
873
+
874
+ enum rb_thread_status {
875
+ THREAD_RUNNABLE,
876
+ THREAD_STOPPED,
877
+ THREAD_STOPPED_FOREVER,
878
+ THREAD_KILLED
879
+ };
880
+
881
+ #ifdef RUBY_JMP_BUF
882
+ typedef RUBY_JMP_BUF rb_jmpbuf_t;
883
+ #else
884
+ typedef void *rb_jmpbuf_t[5];
885
+ #endif
886
+
887
+ /*
888
+ `rb_vm_tag_jmpbuf_t` type represents a buffer used to
889
+ long jump to a C frame associated with `rb_vm_tag`.
890
+
891
+ Use-site of `rb_vm_tag_jmpbuf_t` is responsible for calling the
892
+ following functions:
893
+ - `rb_vm_tag_jmpbuf_init` once `rb_vm_tag_jmpbuf_t` is allocated.
894
+ - `rb_vm_tag_jmpbuf_deinit` once `rb_vm_tag_jmpbuf_t` is no longer necessary.
895
+
896
+ `RB_VM_TAG_JMPBUF_GET` transforms a `rb_vm_tag_jmpbuf_t` into a
897
+ `rb_jmpbuf_t` to be passed to `rb_setjmp/rb_longjmp`.
898
+ */
899
+ #if defined(__wasm__) && !defined(__EMSCRIPTEN__)
900
+ /*
901
+ WebAssembly target with Asyncify-based SJLJ needs
902
+ to capture the execution context by unwind/rewind-ing
903
+ call frames into a jump buffer. The buffer space tends
904
+ to be considerably large unlike other architectures'
905
+ register-based buffers.
906
+ Therefore, we allocates the buffer on the heap on such
907
+ environments.
908
+ */
909
+ typedef rb_jmpbuf_t *rb_vm_tag_jmpbuf_t;
910
+
911
+ #define RB_VM_TAG_JMPBUF_GET(buf) (*buf)
912
+
913
+ static inline void
914
+ rb_vm_tag_jmpbuf_init(rb_vm_tag_jmpbuf_t *jmpbuf)
915
+ {
916
+ *jmpbuf = ruby_xmalloc(sizeof(rb_jmpbuf_t));
917
+ }
918
+
919
+ static inline void
920
+ rb_vm_tag_jmpbuf_deinit(const rb_vm_tag_jmpbuf_t *jmpbuf)
921
+ {
922
+ ruby_xfree(*jmpbuf);
923
+ }
924
+ #else
925
+ typedef rb_jmpbuf_t rb_vm_tag_jmpbuf_t;
926
+
927
+ #define RB_VM_TAG_JMPBUF_GET(buf) (buf)
928
+
929
+ static inline void
930
+ rb_vm_tag_jmpbuf_init(rb_vm_tag_jmpbuf_t *jmpbuf)
931
+ {
932
+ // no-op
933
+ }
934
+
935
+ static inline void
936
+ rb_vm_tag_jmpbuf_deinit(const rb_vm_tag_jmpbuf_t *jmpbuf)
937
+ {
938
+ // no-op
939
+ }
940
+ #endif
941
+
942
+ /*
943
+ the members which are written in EC_PUSH_TAG() should be placed at
944
+ the beginning and the end, so that entire region is accessible.
945
+ */
946
+ struct rb_vm_tag {
947
+ VALUE tag;
948
+ VALUE retval;
949
+ rb_vm_tag_jmpbuf_t buf;
950
+ struct rb_vm_tag *prev;
951
+ enum ruby_tag_type state;
952
+ unsigned int lock_rec;
953
+ };
954
+
955
+ STATIC_ASSERT(rb_vm_tag_buf_offset, offsetof(struct rb_vm_tag, buf) > 0);
956
+ STATIC_ASSERT(rb_vm_tag_buf_end,
957
+ offsetof(struct rb_vm_tag, buf) + sizeof(rb_vm_tag_jmpbuf_t) <
958
+ sizeof(struct rb_vm_tag));
959
+
960
+ struct rb_unblock_callback {
961
+ rb_unblock_function_t *func;
962
+ void *arg;
963
+ };
964
+
965
+ struct rb_mutex_struct;
966
+
967
+ typedef struct rb_ensure_entry {
968
+ VALUE marker;
969
+ VALUE (*e_proc)(VALUE);
970
+ VALUE data2;
971
+ } rb_ensure_entry_t;
972
+
973
+ typedef struct rb_ensure_list {
974
+ struct rb_ensure_list *next;
975
+ struct rb_ensure_entry entry;
976
+ } rb_ensure_list_t;
977
+
978
+ typedef struct rb_fiber_struct rb_fiber_t;
979
+
980
+ struct rb_waiting_list {
981
+ struct rb_waiting_list *next;
982
+ struct rb_thread_struct *thread;
983
+ struct rb_fiber_struct *fiber;
984
+ };
985
+
986
+ struct rb_execution_context_struct {
987
+ /* execution information */
988
+ VALUE *vm_stack; /* must free, must mark */
989
+ size_t vm_stack_size; /* size in word (byte size / sizeof(VALUE)) */
990
+ rb_control_frame_t *cfp;
991
+
992
+ struct rb_vm_tag *tag;
993
+
994
+ /* interrupt flags */
995
+ rb_atomic_t interrupt_flag;
996
+ rb_atomic_t interrupt_mask; /* size should match flag */
997
+ #if defined(USE_VM_CLOCK) && USE_VM_CLOCK
998
+ uint32_t checked_clock;
999
+ #endif
1000
+
1001
+ rb_fiber_t *fiber_ptr;
1002
+ struct rb_thread_struct *thread_ptr;
1003
+
1004
+ /* storage (ec (fiber) local) */
1005
+ struct rb_id_table *local_storage;
1006
+ VALUE local_storage_recursive_hash;
1007
+ VALUE local_storage_recursive_hash_for_trace;
1008
+
1009
+ /* Inheritable fiber storage. */
1010
+ VALUE storage;
1011
+
1012
+ /* eval env */
1013
+ const VALUE *root_lep;
1014
+ VALUE root_svar;
1015
+
1016
+ /* ensure & callcc */
1017
+ rb_ensure_list_t *ensure_list;
1018
+
1019
+ /* trace information */
1020
+ struct rb_trace_arg_struct *trace_arg;
1021
+
1022
+ /* temporary places */
1023
+ VALUE errinfo;
1024
+ VALUE passed_block_handler; /* for rb_iterate */
1025
+
1026
+ uint8_t raised_flag; /* only 3 bits needed */
1027
+
1028
+ /* n.b. only 7 bits needed, really: */
1029
+ BITFIELD(enum method_missing_reason, method_missing_reason, 8);
1030
+
1031
+ VALUE private_const_reference;
1032
+
1033
+ /* for GC */
1034
+ struct {
1035
+ VALUE *stack_start;
1036
+ VALUE *stack_end;
1037
+ size_t stack_maxsize;
1038
+ RUBY_ALIGNAS(SIZEOF_VALUE) jmp_buf regs;
1039
+ } machine;
1040
+ };
1041
+
1042
+ #ifndef rb_execution_context_t
1043
+ typedef struct rb_execution_context_struct rb_execution_context_t;
1044
+ #define rb_execution_context_t rb_execution_context_t
1045
+ #endif
1046
+
1047
+ // for builtin.h
1048
+ #define VM_CORE_H_EC_DEFINED 1
1049
+
1050
+ // Set the vm_stack pointer in the execution context.
1051
+ void rb_ec_set_vm_stack(rb_execution_context_t *ec, VALUE *stack, size_t size);
1052
+
1053
+ // Initialize the vm_stack pointer in the execution context and push the initial stack frame.
1054
+ // @param ec the execution context to update.
1055
+ // @param stack a pointer to the stack to use.
1056
+ // @param size the size of the stack, as in `VALUE stack[size]`.
1057
+ void rb_ec_initialize_vm_stack(rb_execution_context_t *ec, VALUE *stack, size_t size);
1058
+
1059
+ // Clear (set to `NULL`) the vm_stack pointer.
1060
+ // @param ec the execution context to update.
1061
+ void rb_ec_clear_vm_stack(rb_execution_context_t *ec);
1062
+
1063
+ struct rb_ext_config {
1064
+ bool ractor_safe;
1065
+ };
1066
+
1067
+ typedef struct rb_ractor_struct rb_ractor_t;
1068
+
1069
+ struct rb_native_thread;
1070
+
1071
+ typedef struct rb_thread_struct {
1072
+ struct ccan_list_node lt_node; // managed by a ractor
1073
+ VALUE self;
1074
+ rb_ractor_t *ractor;
1075
+ rb_vm_t *vm;
1076
+ struct rb_native_thread *nt;
1077
+ rb_execution_context_t *ec;
1078
+
1079
+ struct rb_thread_sched_item sched;
1080
+ rb_atomic_t serial; // only for RUBY_DEBUG_LOG()
1081
+
1082
+ VALUE last_status; /* $? */
1083
+
1084
+ /* for cfunc */
1085
+ struct rb_calling_info *calling;
1086
+
1087
+ /* for load(true) */
1088
+ VALUE top_self;
1089
+ VALUE top_wrapper;
1090
+
1091
+ /* thread control */
1092
+
1093
+ BITFIELD(enum rb_thread_status, status, 2);
1094
+ /* bit flags */
1095
+ unsigned int has_dedicated_nt : 1;
1096
+ unsigned int to_kill : 1;
1097
+ unsigned int abort_on_exception: 1;
1098
+ unsigned int report_on_exception: 1;
1099
+ unsigned int pending_interrupt_queue_checked: 1;
1100
+ int8_t priority; /* -3 .. 3 (RUBY_THREAD_PRIORITY_{MIN,MAX}) */
1101
+ uint32_t running_time_us; /* 12500..800000 */
1102
+
1103
+ void *blocking_region_buffer;
1104
+
1105
+ VALUE thgroup;
1106
+ VALUE value;
1107
+
1108
+ /* temporary place of retval on OPT_CALL_THREADED_CODE */
1109
+ #if OPT_CALL_THREADED_CODE
1110
+ VALUE retval;
1111
+ #endif
1112
+
1113
+ /* async errinfo queue */
1114
+ VALUE pending_interrupt_queue;
1115
+ VALUE pending_interrupt_mask_stack;
1116
+
1117
+ /* interrupt management */
1118
+ rb_nativethread_lock_t interrupt_lock;
1119
+ struct rb_unblock_callback unblock;
1120
+ VALUE locking_mutex;
1121
+ struct rb_mutex_struct *keeping_mutexes;
1122
+
1123
+ struct rb_waiting_list *join_list;
1124
+
1125
+ union {
1126
+ struct {
1127
+ VALUE proc;
1128
+ VALUE args;
1129
+ int kw_splat;
1130
+ } proc;
1131
+ struct {
1132
+ VALUE (*func)(void *);
1133
+ void *arg;
1134
+ } func;
1135
+ } invoke_arg;
1136
+
1137
+ enum thread_invoke_type {
1138
+ thread_invoke_type_none = 0,
1139
+ thread_invoke_type_proc,
1140
+ thread_invoke_type_ractor_proc,
1141
+ thread_invoke_type_func
1142
+ } invoke_type;
1143
+
1144
+ /* statistics data for profiler */
1145
+ VALUE stat_insn_usage;
1146
+
1147
+ /* fiber */
1148
+ rb_fiber_t *root_fiber;
1149
+
1150
+ VALUE scheduler;
1151
+ unsigned int blocking;
1152
+
1153
+ /* misc */
1154
+ VALUE name;
1155
+ void **specific_storage;
1156
+
1157
+ struct rb_ext_config ext_config;
1158
+ } rb_thread_t;
1159
+
1160
+ static inline unsigned int
1161
+ rb_th_serial(const rb_thread_t *th)
1162
+ {
1163
+ return th ? (unsigned int)th->serial : 0;
1164
+ }
1165
+
1166
+ typedef enum {
1167
+ VM_DEFINECLASS_TYPE_CLASS = 0x00,
1168
+ VM_DEFINECLASS_TYPE_SINGLETON_CLASS = 0x01,
1169
+ VM_DEFINECLASS_TYPE_MODULE = 0x02,
1170
+ /* 0x03..0x06 is reserved */
1171
+ VM_DEFINECLASS_TYPE_MASK = 0x07
1172
+ } rb_vm_defineclass_type_t;
1173
+
1174
+ #define VM_DEFINECLASS_TYPE(x) ((rb_vm_defineclass_type_t)(x) & VM_DEFINECLASS_TYPE_MASK)
1175
+ #define VM_DEFINECLASS_FLAG_SCOPED 0x08
1176
+ #define VM_DEFINECLASS_FLAG_HAS_SUPERCLASS 0x10
1177
+ #define VM_DEFINECLASS_SCOPED_P(x) ((x) & VM_DEFINECLASS_FLAG_SCOPED)
1178
+ #define VM_DEFINECLASS_HAS_SUPERCLASS_P(x) \
1179
+ ((x) & VM_DEFINECLASS_FLAG_HAS_SUPERCLASS)
1180
+
1181
+ /* iseq.c */
1182
+ RUBY_SYMBOL_EXPORT_BEGIN
1183
+
1184
+ /* node -> iseq */
1185
+ rb_iseq_t *rb_iseq_new (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, enum rb_iseq_type);
1186
+ rb_iseq_t *rb_iseq_new_top (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent);
1187
+ rb_iseq_t *rb_iseq_new_main (const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt);
1188
+ rb_iseq_t *rb_iseq_new_eval (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth);
1189
+ rb_iseq_t *rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth,
1190
+ enum rb_iseq_type, const rb_compile_option_t*);
1191
+
1192
+ struct iseq_link_anchor;
1193
+ struct rb_iseq_new_with_callback_callback_func {
1194
+ VALUE flags;
1195
+ VALUE reserved;
1196
+ void (*func)(rb_iseq_t *, struct iseq_link_anchor *, const void *);
1197
+ const void *data;
1198
+ };
1199
+ static inline struct rb_iseq_new_with_callback_callback_func *
1200
+ rb_iseq_new_with_callback_new_callback(
1201
+ void (*func)(rb_iseq_t *, struct iseq_link_anchor *, const void *), const void *ptr)
1202
+ {
1203
+ VALUE memo = rb_imemo_new(imemo_ifunc, (VALUE)func, (VALUE)ptr, Qundef, Qfalse);
1204
+ return (struct rb_iseq_new_with_callback_callback_func *)memo;
1205
+ }
1206
+ rb_iseq_t *rb_iseq_new_with_callback(const struct rb_iseq_new_with_callback_callback_func * ifunc,
1207
+ VALUE name, VALUE path, VALUE realpath, int first_lineno,
1208
+ const rb_iseq_t *parent, enum rb_iseq_type, const rb_compile_option_t*);
1209
+
1210
+ VALUE rb_iseq_disasm(const rb_iseq_t *iseq);
1211
+ int rb_iseq_disasm_insn(VALUE str, const VALUE *iseqval, size_t pos, const rb_iseq_t *iseq, VALUE child);
1212
+
1213
+ VALUE rb_iseq_coverage(const rb_iseq_t *iseq);
1214
+
1215
+ RUBY_EXTERN VALUE rb_cISeq;
1216
+ RUBY_EXTERN VALUE rb_cRubyVM;
1217
+ RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
1218
+ RUBY_EXTERN VALUE rb_block_param_proxy;
1219
+ RUBY_SYMBOL_EXPORT_END
1220
+
1221
+ #define GetProcPtr(obj, ptr) \
1222
+ GetCoreDataFromValue((obj), rb_proc_t, (ptr))
1223
+
1224
+ typedef struct {
1225
+ const struct rb_block block;
1226
+ unsigned int is_from_method: 1; /* bool */
1227
+ unsigned int is_lambda: 1; /* bool */
1228
+ unsigned int is_isolated: 1; /* bool */
1229
+ } rb_proc_t;
1230
+
1231
+ RUBY_SYMBOL_EXPORT_BEGIN
1232
+ VALUE rb_proc_isolate(VALUE self);
1233
+ VALUE rb_proc_isolate_bang(VALUE self);
1234
+ VALUE rb_proc_ractor_make_shareable(VALUE self);
1235
+ RUBY_SYMBOL_EXPORT_END
1236
+
1237
+ typedef struct {
1238
+ VALUE flags; /* imemo header */
1239
+ rb_iseq_t *iseq;
1240
+ const VALUE *ep;
1241
+ const VALUE *env;
1242
+ unsigned int env_size;
1243
+ } rb_env_t;
1244
+
1245
+ extern const rb_data_type_t ruby_binding_data_type;
1246
+
1247
+ #define GetBindingPtr(obj, ptr) \
1248
+ GetCoreDataFromValue((obj), rb_binding_t, (ptr))
1249
+
1250
+ typedef struct {
1251
+ const struct rb_block block;
1252
+ const VALUE pathobj;
1253
+ int first_lineno;
1254
+ } rb_binding_t;
1255
+
1256
+ /* used by compile time and send insn */
1257
+
1258
+ enum vm_check_match_type {
1259
+ VM_CHECKMATCH_TYPE_WHEN = 1,
1260
+ VM_CHECKMATCH_TYPE_CASE = 2,
1261
+ VM_CHECKMATCH_TYPE_RESCUE = 3
1262
+ };
1263
+
1264
+ #define VM_CHECKMATCH_TYPE_MASK 0x03
1265
+ #define VM_CHECKMATCH_ARRAY 0x04
1266
+
1267
+ enum vm_special_object_type {
1268
+ VM_SPECIAL_OBJECT_VMCORE = 1,
1269
+ VM_SPECIAL_OBJECT_CBASE,
1270
+ VM_SPECIAL_OBJECT_CONST_BASE
1271
+ };
1272
+
1273
+ enum vm_svar_index {
1274
+ VM_SVAR_LASTLINE = 0, /* $_ */
1275
+ VM_SVAR_BACKREF = 1, /* $~ */
1276
+
1277
+ VM_SVAR_EXTRA_START = 2,
1278
+ VM_SVAR_FLIPFLOP_START = 2 /* flipflop */
1279
+ };
1280
+
1281
+ /* inline cache */
1282
+ typedef struct iseq_inline_constant_cache *IC;
1283
+ typedef struct iseq_inline_iv_cache_entry *IVC;
1284
+ typedef struct iseq_inline_cvar_cache_entry *ICVARC;
1285
+ typedef union iseq_inline_storage_entry *ISE;
1286
+ typedef const struct rb_callinfo *CALL_INFO;
1287
+ typedef const struct rb_callcache *CALL_CACHE;
1288
+ typedef struct rb_call_data *CALL_DATA;
1289
+
1290
+ typedef VALUE CDHASH;
1291
+
1292
+ #ifndef FUNC_FASTCALL
1293
+ #define FUNC_FASTCALL(x) x
1294
+ #endif
1295
+
1296
+ typedef rb_control_frame_t *
1297
+ (FUNC_FASTCALL(*rb_insn_func_t))(rb_execution_context_t *, rb_control_frame_t *);
1298
+
1299
+ #define VM_TAGGED_PTR_SET(p, tag) ((VALUE)(p) | (tag))
1300
+ #define VM_TAGGED_PTR_REF(v, mask) ((void *)((v) & ~mask))
1301
+
1302
+ #define GC_GUARDED_PTR(p) VM_TAGGED_PTR_SET((p), 0x01)
1303
+ #define GC_GUARDED_PTR_REF(p) VM_TAGGED_PTR_REF((p), 0x03)
1304
+ #define GC_GUARDED_PTR_P(p) (((VALUE)(p)) & 0x01)
1305
+
1306
+ enum vm_frame_env_flags {
1307
+ /* Frame/Environment flag bits:
1308
+ * MMMM MMMM MMMM MMMM ____ FFFF FFFE EEEX (LSB)
1309
+ *
1310
+ * X : tag for GC marking (It seems as Fixnum)
1311
+ * EEE : 4 bits Env flags
1312
+ * FF..: 7 bits Frame flags
1313
+ * MM..: 15 bits frame magic (to check frame corruption)
1314
+ */
1315
+
1316
+ /* frame types */
1317
+ VM_FRAME_MAGIC_METHOD = 0x11110001,
1318
+ VM_FRAME_MAGIC_BLOCK = 0x22220001,
1319
+ VM_FRAME_MAGIC_CLASS = 0x33330001,
1320
+ VM_FRAME_MAGIC_TOP = 0x44440001,
1321
+ VM_FRAME_MAGIC_CFUNC = 0x55550001,
1322
+ VM_FRAME_MAGIC_IFUNC = 0x66660001,
1323
+ VM_FRAME_MAGIC_EVAL = 0x77770001,
1324
+ VM_FRAME_MAGIC_RESCUE = 0x78880001,
1325
+ VM_FRAME_MAGIC_DUMMY = 0x79990001,
1326
+
1327
+ VM_FRAME_MAGIC_MASK = 0x7fff0001,
1328
+
1329
+ /* frame flag */
1330
+ VM_FRAME_FLAG_FINISH = 0x0020,
1331
+ VM_FRAME_FLAG_BMETHOD = 0x0040,
1332
+ VM_FRAME_FLAG_CFRAME = 0x0080,
1333
+ VM_FRAME_FLAG_LAMBDA = 0x0100,
1334
+ VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM = 0x0200,
1335
+ VM_FRAME_FLAG_CFRAME_KW = 0x0400,
1336
+ VM_FRAME_FLAG_PASSED = 0x0800,
1337
+
1338
+ /* env flag */
1339
+ VM_ENV_FLAG_LOCAL = 0x0002,
1340
+ VM_ENV_FLAG_ESCAPED = 0x0004,
1341
+ VM_ENV_FLAG_WB_REQUIRED = 0x0008,
1342
+ VM_ENV_FLAG_ISOLATED = 0x0010,
1343
+ };
1344
+
1345
+ #define VM_ENV_DATA_SIZE ( 3)
1346
+
1347
+ #define VM_ENV_DATA_INDEX_ME_CREF (-2) /* ep[-2] */
1348
+ #define VM_ENV_DATA_INDEX_SPECVAL (-1) /* ep[-1] */
1349
+ #define VM_ENV_DATA_INDEX_FLAGS ( 0) /* ep[ 0] */
1350
+ #define VM_ENV_DATA_INDEX_ENV ( 1) /* ep[ 1] */
1351
+
1352
+ #define VM_ENV_INDEX_LAST_LVAR (-VM_ENV_DATA_SIZE)
1353
+
1354
+ static inline void VM_FORCE_WRITE_SPECIAL_CONST(const VALUE *ptr, VALUE special_const_value);
1355
+
1356
+ static inline void
1357
+ VM_ENV_FLAGS_SET(const VALUE *ep, VALUE flag)
1358
+ {
1359
+ VALUE flags = ep[VM_ENV_DATA_INDEX_FLAGS];
1360
+ VM_ASSERT(FIXNUM_P(flags));
1361
+ VM_FORCE_WRITE_SPECIAL_CONST(&ep[VM_ENV_DATA_INDEX_FLAGS], flags | flag);
1362
+ }
1363
+
1364
+ static inline void
1365
+ VM_ENV_FLAGS_UNSET(const VALUE *ep, VALUE flag)
1366
+ {
1367
+ VALUE flags = ep[VM_ENV_DATA_INDEX_FLAGS];
1368
+ VM_ASSERT(FIXNUM_P(flags));
1369
+ VM_FORCE_WRITE_SPECIAL_CONST(&ep[VM_ENV_DATA_INDEX_FLAGS], flags & ~flag);
1370
+ }
1371
+
1372
+ static inline unsigned long
1373
+ VM_ENV_FLAGS(const VALUE *ep, long flag)
1374
+ {
1375
+ VALUE flags = ep[VM_ENV_DATA_INDEX_FLAGS];
1376
+ VM_ASSERT(FIXNUM_P(flags));
1377
+ return flags & flag;
1378
+ }
1379
+
1380
+ static inline unsigned long
1381
+ VM_FRAME_TYPE(const rb_control_frame_t *cfp)
1382
+ {
1383
+ return VM_ENV_FLAGS(cfp->ep, VM_FRAME_MAGIC_MASK);
1384
+ }
1385
+
1386
+ static inline int
1387
+ VM_FRAME_LAMBDA_P(const rb_control_frame_t *cfp)
1388
+ {
1389
+ return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_LAMBDA) != 0;
1390
+ }
1391
+
1392
+ static inline int
1393
+ VM_FRAME_CFRAME_KW_P(const rb_control_frame_t *cfp)
1394
+ {
1395
+ return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_CFRAME_KW) != 0;
1396
+ }
1397
+
1398
+ static inline int
1399
+ VM_FRAME_FINISHED_P(const rb_control_frame_t *cfp)
1400
+ {
1401
+ return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_FINISH) != 0;
1402
+ }
1403
+
1404
+ static inline int
1405
+ VM_FRAME_BMETHOD_P(const rb_control_frame_t *cfp)
1406
+ {
1407
+ return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_BMETHOD) != 0;
1408
+ }
1409
+
1410
+ static inline int
1411
+ rb_obj_is_iseq(VALUE iseq)
1412
+ {
1413
+ return imemo_type_p(iseq, imemo_iseq);
1414
+ }
1415
+
1416
+ #if VM_CHECK_MODE > 0
1417
+ #define RUBY_VM_NORMAL_ISEQ_P(iseq) rb_obj_is_iseq((VALUE)iseq)
1418
+ #endif
1419
+
1420
+ static inline int
1421
+ VM_FRAME_CFRAME_P(const rb_control_frame_t *cfp)
1422
+ {
1423
+ int cframe_p = VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_CFRAME) != 0;
1424
+ VM_ASSERT(RUBY_VM_NORMAL_ISEQ_P(cfp->iseq) != cframe_p ||
1425
+ (VM_FRAME_TYPE(cfp) & VM_FRAME_MAGIC_MASK) == VM_FRAME_MAGIC_DUMMY);
1426
+ return cframe_p;
1427
+ }
1428
+
1429
+ static inline int
1430
+ VM_FRAME_RUBYFRAME_P(const rb_control_frame_t *cfp)
1431
+ {
1432
+ return !VM_FRAME_CFRAME_P(cfp);
1433
+ }
1434
+
1435
+ #define RUBYVM_CFUNC_FRAME_P(cfp) \
1436
+ (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)
1437
+
1438
+ #define VM_GUARDED_PREV_EP(ep) GC_GUARDED_PTR(ep)
1439
+ #define VM_BLOCK_HANDLER_NONE 0
1440
+
1441
+ static inline int
1442
+ VM_ENV_LOCAL_P(const VALUE *ep)
1443
+ {
1444
+ return VM_ENV_FLAGS(ep, VM_ENV_FLAG_LOCAL) ? 1 : 0;
1445
+ }
1446
+
1447
+ static inline const VALUE *
1448
+ VM_ENV_PREV_EP(const VALUE *ep)
1449
+ {
1450
+ VM_ASSERT(VM_ENV_LOCAL_P(ep) == 0);
1451
+ return GC_GUARDED_PTR_REF(ep[VM_ENV_DATA_INDEX_SPECVAL]);
1452
+ }
1453
+
1454
+ static inline VALUE
1455
+ VM_ENV_BLOCK_HANDLER(const VALUE *ep)
1456
+ {
1457
+ VM_ASSERT(VM_ENV_LOCAL_P(ep));
1458
+ return ep[VM_ENV_DATA_INDEX_SPECVAL];
1459
+ }
1460
+
1461
+ #if VM_CHECK_MODE > 0
1462
+ int rb_vm_ep_in_heap_p(const VALUE *ep);
1463
+ #endif
1464
+
1465
+ static inline int
1466
+ VM_ENV_ESCAPED_P(const VALUE *ep)
1467
+ {
1468
+ VM_ASSERT(rb_vm_ep_in_heap_p(ep) == !!VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED));
1469
+ return VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED) ? 1 : 0;
1470
+ }
1471
+
1472
+ #if VM_CHECK_MODE > 0
1473
+ static inline int
1474
+ vm_assert_env(VALUE obj)
1475
+ {
1476
+ VM_ASSERT(imemo_type_p(obj, imemo_env));
1477
+ return 1;
1478
+ }
1479
+ #endif
1480
+
1481
+ RBIMPL_ATTR_NONNULL((1))
1482
+ static inline VALUE
1483
+ VM_ENV_ENVVAL(const VALUE *ep)
1484
+ {
1485
+ VALUE envval = ep[VM_ENV_DATA_INDEX_ENV];
1486
+ VM_ASSERT(VM_ENV_ESCAPED_P(ep));
1487
+ VM_ASSERT(vm_assert_env(envval));
1488
+ return envval;
1489
+ }
1490
+
1491
+ RBIMPL_ATTR_NONNULL((1))
1492
+ static inline const rb_env_t *
1493
+ VM_ENV_ENVVAL_PTR(const VALUE *ep)
1494
+ {
1495
+ return (const rb_env_t *)VM_ENV_ENVVAL(ep);
1496
+ }
1497
+
1498
+ static inline const rb_env_t *
1499
+ vm_env_new(VALUE *env_ep, VALUE *env_body, unsigned int env_size, const rb_iseq_t *iseq)
1500
+ {
1501
+ rb_env_t *env = (rb_env_t *)rb_imemo_new(imemo_env, (VALUE)env_ep, (VALUE)env_body, 0, (VALUE)iseq);
1502
+ env->env_size = env_size;
1503
+ env_ep[VM_ENV_DATA_INDEX_ENV] = (VALUE)env;
1504
+ return env;
1505
+ }
1506
+
1507
+ static inline void
1508
+ VM_FORCE_WRITE(const VALUE *ptr, VALUE v)
1509
+ {
1510
+ *((VALUE *)ptr) = v;
1511
+ }
1512
+
1513
+ static inline void
1514
+ VM_FORCE_WRITE_SPECIAL_CONST(const VALUE *ptr, VALUE special_const_value)
1515
+ {
1516
+ VM_ASSERT(RB_SPECIAL_CONST_P(special_const_value));
1517
+ VM_FORCE_WRITE(ptr, special_const_value);
1518
+ }
1519
+
1520
+ static inline void
1521
+ VM_STACK_ENV_WRITE(const VALUE *ep, int index, VALUE v)
1522
+ {
1523
+ VM_ASSERT(VM_ENV_FLAGS(ep, VM_ENV_FLAG_WB_REQUIRED) == 0);
1524
+ VM_FORCE_WRITE(&ep[index], v);
1525
+ }
1526
+
1527
+ const VALUE *rb_vm_ep_local_ep(const VALUE *ep);
1528
+ const VALUE *rb_vm_proc_local_ep(VALUE proc);
1529
+ void rb_vm_block_ep_update(VALUE obj, const struct rb_block *dst, const VALUE *ep);
1530
+ void rb_vm_block_copy(VALUE obj, const struct rb_block *dst, const struct rb_block *src);
1531
+
1532
+ VALUE rb_vm_frame_block_handler(const rb_control_frame_t *cfp);
1533
+
1534
+ #define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1)
1535
+ #define RUBY_VM_NEXT_CONTROL_FRAME(cfp) ((cfp)-1)
1536
+
1537
+ #define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \
1538
+ ((void *)(ecfp) > (void *)(cfp))
1539
+
1540
+ static inline const rb_control_frame_t *
1541
+ RUBY_VM_END_CONTROL_FRAME(const rb_execution_context_t *ec)
1542
+ {
1543
+ return (rb_control_frame_t *)(ec->vm_stack + ec->vm_stack_size);
1544
+ }
1545
+
1546
+ static inline int
1547
+ RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(const rb_execution_context_t *ec, const rb_control_frame_t *cfp)
1548
+ {
1549
+ return !RUBY_VM_VALID_CONTROL_FRAME_P(cfp, RUBY_VM_END_CONTROL_FRAME(ec));
1550
+ }
1551
+
1552
+ static inline int
1553
+ VM_BH_ISEQ_BLOCK_P(VALUE block_handler)
1554
+ {
1555
+ if ((block_handler & 0x03) == 0x01) {
1556
+ #if VM_CHECK_MODE > 0
1557
+ struct rb_captured_block *captured = VM_TAGGED_PTR_REF(block_handler, 0x03);
1558
+ VM_ASSERT(imemo_type_p(captured->code.val, imemo_iseq));
1559
+ #endif
1560
+ return 1;
1561
+ }
1562
+ else {
1563
+ return 0;
1564
+ }
1565
+ }
1566
+
1567
+ static inline VALUE
1568
+ VM_BH_FROM_ISEQ_BLOCK(const struct rb_captured_block *captured)
1569
+ {
1570
+ VALUE block_handler = VM_TAGGED_PTR_SET(captured, 0x01);
1571
+ VM_ASSERT(VM_BH_ISEQ_BLOCK_P(block_handler));
1572
+ return block_handler;
1573
+ }
1574
+
1575
+ static inline const struct rb_captured_block *
1576
+ VM_BH_TO_ISEQ_BLOCK(VALUE block_handler)
1577
+ {
1578
+ struct rb_captured_block *captured = VM_TAGGED_PTR_REF(block_handler, 0x03);
1579
+ VM_ASSERT(VM_BH_ISEQ_BLOCK_P(block_handler));
1580
+ return captured;
1581
+ }
1582
+
1583
+ static inline int
1584
+ VM_BH_IFUNC_P(VALUE block_handler)
1585
+ {
1586
+ if ((block_handler & 0x03) == 0x03) {
1587
+ #if VM_CHECK_MODE > 0
1588
+ struct rb_captured_block *captured = (void *)(block_handler & ~0x03);
1589
+ VM_ASSERT(imemo_type_p(captured->code.val, imemo_ifunc));
1590
+ #endif
1591
+ return 1;
1592
+ }
1593
+ else {
1594
+ return 0;
1595
+ }
1596
+ }
1597
+
1598
+ static inline VALUE
1599
+ VM_BH_FROM_IFUNC_BLOCK(const struct rb_captured_block *captured)
1600
+ {
1601
+ VALUE block_handler = VM_TAGGED_PTR_SET(captured, 0x03);
1602
+ VM_ASSERT(VM_BH_IFUNC_P(block_handler));
1603
+ return block_handler;
1604
+ }
1605
+
1606
+ static inline const struct rb_captured_block *
1607
+ VM_BH_TO_IFUNC_BLOCK(VALUE block_handler)
1608
+ {
1609
+ struct rb_captured_block *captured = VM_TAGGED_PTR_REF(block_handler, 0x03);
1610
+ VM_ASSERT(VM_BH_IFUNC_P(block_handler));
1611
+ return captured;
1612
+ }
1613
+
1614
+ static inline const struct rb_captured_block *
1615
+ VM_BH_TO_CAPT_BLOCK(VALUE block_handler)
1616
+ {
1617
+ struct rb_captured_block *captured = VM_TAGGED_PTR_REF(block_handler, 0x03);
1618
+ VM_ASSERT(VM_BH_IFUNC_P(block_handler) || VM_BH_ISEQ_BLOCK_P(block_handler));
1619
+ return captured;
1620
+ }
1621
+
1622
+ static inline enum rb_block_handler_type
1623
+ vm_block_handler_type(VALUE block_handler)
1624
+ {
1625
+ if (VM_BH_ISEQ_BLOCK_P(block_handler)) {
1626
+ return block_handler_type_iseq;
1627
+ }
1628
+ else if (VM_BH_IFUNC_P(block_handler)) {
1629
+ return block_handler_type_ifunc;
1630
+ }
1631
+ else if (SYMBOL_P(block_handler)) {
1632
+ return block_handler_type_symbol;
1633
+ }
1634
+ else {
1635
+ VM_ASSERT(rb_obj_is_proc(block_handler));
1636
+ return block_handler_type_proc;
1637
+ }
1638
+ }
1639
+
1640
+ static inline void
1641
+ vm_block_handler_verify(MAYBE_UNUSED(VALUE block_handler))
1642
+ {
1643
+ VM_ASSERT(block_handler == VM_BLOCK_HANDLER_NONE ||
1644
+ (vm_block_handler_type(block_handler), 1));
1645
+ }
1646
+
1647
+ static inline enum rb_block_type
1648
+ vm_block_type(const struct rb_block *block)
1649
+ {
1650
+ #if VM_CHECK_MODE > 0
1651
+ switch (block->type) {
1652
+ case block_type_iseq:
1653
+ VM_ASSERT(imemo_type_p(block->as.captured.code.val, imemo_iseq));
1654
+ break;
1655
+ case block_type_ifunc:
1656
+ VM_ASSERT(imemo_type_p(block->as.captured.code.val, imemo_ifunc));
1657
+ break;
1658
+ case block_type_symbol:
1659
+ VM_ASSERT(SYMBOL_P(block->as.symbol));
1660
+ break;
1661
+ case block_type_proc:
1662
+ VM_ASSERT(rb_obj_is_proc(block->as.proc));
1663
+ break;
1664
+ }
1665
+ #endif
1666
+ return block->type;
1667
+ }
1668
+
1669
+ static inline void
1670
+ vm_block_type_set(const struct rb_block *block, enum rb_block_type type)
1671
+ {
1672
+ struct rb_block *mb = (struct rb_block *)block;
1673
+ mb->type = type;
1674
+ }
1675
+
1676
+ static inline const struct rb_block *
1677
+ vm_proc_block(VALUE procval)
1678
+ {
1679
+ VM_ASSERT(rb_obj_is_proc(procval));
1680
+ return &((rb_proc_t *)RTYPEDDATA_DATA(procval))->block;
1681
+ }
1682
+
1683
+ static inline const rb_iseq_t *vm_block_iseq(const struct rb_block *block);
1684
+ static inline const VALUE *vm_block_ep(const struct rb_block *block);
1685
+
1686
+ static inline const rb_iseq_t *
1687
+ vm_proc_iseq(VALUE procval)
1688
+ {
1689
+ return vm_block_iseq(vm_proc_block(procval));
1690
+ }
1691
+
1692
+ static inline const VALUE *
1693
+ vm_proc_ep(VALUE procval)
1694
+ {
1695
+ return vm_block_ep(vm_proc_block(procval));
1696
+ }
1697
+
1698
+ static inline const rb_iseq_t *
1699
+ vm_block_iseq(const struct rb_block *block)
1700
+ {
1701
+ switch (vm_block_type(block)) {
1702
+ case block_type_iseq: return rb_iseq_check(block->as.captured.code.iseq);
1703
+ case block_type_proc: return vm_proc_iseq(block->as.proc);
1704
+ case block_type_ifunc:
1705
+ case block_type_symbol: return NULL;
1706
+ }
1707
+ VM_UNREACHABLE(vm_block_iseq);
1708
+ return NULL;
1709
+ }
1710
+
1711
+ static inline const VALUE *
1712
+ vm_block_ep(const struct rb_block *block)
1713
+ {
1714
+ switch (vm_block_type(block)) {
1715
+ case block_type_iseq:
1716
+ case block_type_ifunc: return block->as.captured.ep;
1717
+ case block_type_proc: return vm_proc_ep(block->as.proc);
1718
+ case block_type_symbol: return NULL;
1719
+ }
1720
+ VM_UNREACHABLE(vm_block_ep);
1721
+ return NULL;
1722
+ }
1723
+
1724
+ static inline VALUE
1725
+ vm_block_self(const struct rb_block *block)
1726
+ {
1727
+ switch (vm_block_type(block)) {
1728
+ case block_type_iseq:
1729
+ case block_type_ifunc:
1730
+ return block->as.captured.self;
1731
+ case block_type_proc:
1732
+ return vm_block_self(vm_proc_block(block->as.proc));
1733
+ case block_type_symbol:
1734
+ return Qundef;
1735
+ }
1736
+ VM_UNREACHABLE(vm_block_self);
1737
+ return Qundef;
1738
+ }
1739
+
1740
+ static inline VALUE
1741
+ VM_BH_TO_SYMBOL(VALUE block_handler)
1742
+ {
1743
+ VM_ASSERT(SYMBOL_P(block_handler));
1744
+ return block_handler;
1745
+ }
1746
+
1747
+ static inline VALUE
1748
+ VM_BH_FROM_SYMBOL(VALUE symbol)
1749
+ {
1750
+ VM_ASSERT(SYMBOL_P(symbol));
1751
+ return symbol;
1752
+ }
1753
+
1754
+ static inline VALUE
1755
+ VM_BH_TO_PROC(VALUE block_handler)
1756
+ {
1757
+ VM_ASSERT(rb_obj_is_proc(block_handler));
1758
+ return block_handler;
1759
+ }
1760
+
1761
+ static inline VALUE
1762
+ VM_BH_FROM_PROC(VALUE procval)
1763
+ {
1764
+ VM_ASSERT(rb_obj_is_proc(procval));
1765
+ return procval;
1766
+ }
1767
+
1768
+ /* VM related object allocate functions */
1769
+ VALUE rb_thread_alloc(VALUE klass);
1770
+ VALUE rb_binding_alloc(VALUE klass);
1771
+ VALUE rb_proc_alloc(VALUE klass);
1772
+ VALUE rb_proc_dup(VALUE self);
1773
+
1774
+ /* for debug */
1775
+ extern bool rb_vmdebug_stack_dump_raw(const rb_execution_context_t *ec, const rb_control_frame_t *cfp, FILE *);
1776
+ extern bool rb_vmdebug_debug_print_pre(const rb_execution_context_t *ec, const rb_control_frame_t *cfp, const VALUE *_pc, FILE *);
1777
+ extern bool rb_vmdebug_debug_print_post(const rb_execution_context_t *ec, const rb_control_frame_t *cfp, FILE *);
1778
+
1779
+ #define SDR() rb_vmdebug_stack_dump_raw(GET_EC(), GET_EC()->cfp, stderr)
1780
+ #define SDR2(cfp) rb_vmdebug_stack_dump_raw(GET_EC(), (cfp), stderr)
1781
+ bool rb_vm_bugreport(const void *, FILE *);
1782
+ typedef void (*ruby_sighandler_t)(int);
1783
+ RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 4, 5)
1784
+ NORETURN(void rb_bug_for_fatal_signal(ruby_sighandler_t default_sighandler, int sig, const void *, const char *fmt, ...));
1785
+
1786
+ /* functions about thread/vm execution */
1787
+ RUBY_SYMBOL_EXPORT_BEGIN
1788
+ VALUE rb_iseq_eval(const rb_iseq_t *iseq);
1789
+ VALUE rb_iseq_eval_main(const rb_iseq_t *iseq);
1790
+ VALUE rb_iseq_path(const rb_iseq_t *iseq);
1791
+ VALUE rb_iseq_realpath(const rb_iseq_t *iseq);
1792
+ RUBY_SYMBOL_EXPORT_END
1793
+
1794
+ VALUE rb_iseq_pathobj_new(VALUE path, VALUE realpath);
1795
+ void rb_iseq_pathobj_set(const rb_iseq_t *iseq, VALUE path, VALUE realpath);
1796
+
1797
+ int rb_ec_frame_method_id_and_class(const rb_execution_context_t *ec, ID *idp, ID *called_idp, VALUE *klassp);
1798
+ void rb_ec_setup_exception(const rb_execution_context_t *ec, VALUE mesg, VALUE cause);
1799
+
1800
+ 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);
1801
+
1802
+ VALUE rb_vm_make_proc_lambda(const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass, int8_t is_lambda);
1803
+ static inline VALUE
1804
+ rb_vm_make_proc(const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass)
1805
+ {
1806
+ return rb_vm_make_proc_lambda(ec, captured, klass, 0);
1807
+ }
1808
+
1809
+ static inline VALUE
1810
+ rb_vm_make_lambda(const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass)
1811
+ {
1812
+ return rb_vm_make_proc_lambda(ec, captured, klass, 1);
1813
+ }
1814
+
1815
+ VALUE rb_vm_make_binding(const rb_execution_context_t *ec, const rb_control_frame_t *src_cfp);
1816
+ VALUE rb_vm_env_local_variables(const rb_env_t *env);
1817
+ const rb_env_t *rb_vm_env_prev_env(const rb_env_t *env);
1818
+ const VALUE *rb_binding_add_dynavars(VALUE bindval, rb_binding_t *bind, int dyncount, const ID *dynvars);
1819
+ void rb_vm_inc_const_missing_count(void);
1820
+ VALUE rb_vm_call_kw(rb_execution_context_t *ec, VALUE recv, VALUE id, int argc,
1821
+ const VALUE *argv, const rb_callable_method_entry_t *me, int kw_splat);
1822
+ void rb_vm_pop_frame_no_int(rb_execution_context_t *ec);
1823
+ void rb_vm_pop_frame(rb_execution_context_t *ec);
1824
+
1825
+ void rb_thread_start_timer_thread(void);
1826
+ void rb_thread_stop_timer_thread(void);
1827
+ void rb_thread_reset_timer_thread(void);
1828
+ void rb_thread_wakeup_timer_thread(int);
1829
+
1830
+ static inline void
1831
+ rb_vm_living_threads_init(rb_vm_t *vm)
1832
+ {
1833
+ ccan_list_head_init(&vm->waiting_fds);
1834
+ ccan_list_head_init(&vm->workqueue);
1835
+ ccan_list_head_init(&vm->ractor.set);
1836
+ ccan_list_head_init(&vm->ractor.sched.zombie_threads);
1837
+ }
1838
+
1839
+ typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
1840
+ rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
1841
+ rb_control_frame_t *rb_vm_get_binding_creatable_next_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
1842
+ VALUE *rb_vm_svar_lep(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
1843
+ int rb_vm_get_sourceline(const rb_control_frame_t *);
1844
+ void rb_vm_stack_to_heap(rb_execution_context_t *ec);
1845
+ void ruby_thread_init_stack(rb_thread_t *th);
1846
+ rb_thread_t * ruby_thread_from_native(void);
1847
+ int ruby_thread_set_native(rb_thread_t *th);
1848
+ int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, ID *called_idp, VALUE *klassp);
1849
+ void rb_vm_rewind_cfp(rb_execution_context_t *ec, rb_control_frame_t *cfp);
1850
+ void rb_vm_env_write(const VALUE *ep, int index, VALUE v);
1851
+ VALUE rb_vm_bh_to_procval(const rb_execution_context_t *ec, VALUE block_handler);
1852
+
1853
+ void rb_vm_register_special_exception_str(enum ruby_special_exceptions sp, VALUE exception_class, VALUE mesg);
1854
+
1855
+ #define rb_vm_register_special_exception(sp, e, m) \
1856
+ rb_vm_register_special_exception_str(sp, e, rb_usascii_str_new_static((m), (long)rb_strlen_lit(m)))
1857
+
1858
+ void rb_gc_mark_machine_stack(const rb_execution_context_t *ec);
1859
+
1860
+ void rb_vm_rewrite_cref(rb_cref_t *node, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr);
1861
+
1862
+ const rb_callable_method_entry_t *rb_vm_frame_method_entry(const rb_control_frame_t *cfp);
1863
+
1864
+ #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
1865
+
1866
+ #define CHECK_VM_STACK_OVERFLOW0(cfp, sp, margin) do { \
1867
+ STATIC_ASSERT(sizeof_sp, sizeof(*(sp)) == sizeof(VALUE)); \
1868
+ STATIC_ASSERT(sizeof_cfp, sizeof(*(cfp)) == sizeof(rb_control_frame_t)); \
1869
+ const struct rb_control_frame_struct *bound = (void *)&(sp)[(margin)]; \
1870
+ if (UNLIKELY((cfp) <= &bound[1])) { \
1871
+ vm_stackoverflow(); \
1872
+ } \
1873
+ } while (0)
1874
+
1875
+ #define CHECK_VM_STACK_OVERFLOW(cfp, margin) \
1876
+ CHECK_VM_STACK_OVERFLOW0((cfp), (cfp)->sp, (margin))
1877
+
1878
+ VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, enum ruby_tag_type *stateptr);
1879
+
1880
+ rb_execution_context_t *rb_vm_main_ractor_ec(rb_vm_t *vm); // ractor.c
1881
+
1882
+ /* for thread */
1883
+
1884
+ #if RUBY_VM_THREAD_MODEL == 2
1885
+
1886
+ RUBY_EXTERN struct rb_ractor_struct *ruby_single_main_ractor; // ractor.c
1887
+ RUBY_EXTERN rb_vm_t *ruby_current_vm_ptr;
1888
+ RUBY_EXTERN rb_event_flag_t ruby_vm_event_flags;
1889
+ RUBY_EXTERN rb_event_flag_t ruby_vm_event_enabled_global_flags;
1890
+ RUBY_EXTERN unsigned int ruby_vm_event_local_num;
1891
+
1892
+ #define GET_VM() rb_current_vm()
1893
+ #define GET_RACTOR() rb_current_ractor()
1894
+ #define GET_THREAD() rb_current_thread()
1895
+ #define GET_EC() rb_current_execution_context(true)
1896
+
1897
+ static inline rb_thread_t *
1898
+ rb_ec_thread_ptr(const rb_execution_context_t *ec)
1899
+ {
1900
+ return ec->thread_ptr;
1901
+ }
1902
+
1903
+ static inline rb_ractor_t *
1904
+ rb_ec_ractor_ptr(const rb_execution_context_t *ec)
1905
+ {
1906
+ const rb_thread_t *th = rb_ec_thread_ptr(ec);
1907
+ if (th) {
1908
+ VM_ASSERT(th->ractor != NULL);
1909
+ return th->ractor;
1910
+ }
1911
+ else {
1912
+ return NULL;
1913
+ }
1914
+ }
1915
+
1916
+ static inline rb_vm_t *
1917
+ rb_ec_vm_ptr(const rb_execution_context_t *ec)
1918
+ {
1919
+ const rb_thread_t *th = rb_ec_thread_ptr(ec);
1920
+ if (th) {
1921
+ return th->vm;
1922
+ }
1923
+ else {
1924
+ return NULL;
1925
+ }
1926
+ }
1927
+
1928
+ static inline rb_execution_context_t *
1929
+ rb_current_execution_context(bool expect_ec)
1930
+ {
1931
+ #ifdef RB_THREAD_LOCAL_SPECIFIER
1932
+ #ifdef __APPLE__
1933
+ rb_execution_context_t *ec = rb_current_ec();
1934
+ #else
1935
+ rb_execution_context_t *ec = ruby_current_ec;
1936
+ #endif
1937
+
1938
+ /* On the shared objects, `__tls_get_addr()` is used to access the TLS
1939
+ * and the address of the `ruby_current_ec` can be stored on a function
1940
+ * frame. However, this address can be mis-used after native thread
1941
+ * migration of a coroutine.
1942
+ * 1) Get `ptr =&ruby_current_ec` op NT1 and store it on the frame.
1943
+ * 2) Context switch and resume it on the NT2.
1944
+ * 3) `ptr` is used on NT2 but it accesses to the TLS on NT1.
1945
+ * This assertion checks such misusage.
1946
+ *
1947
+ * To avoid accidents, `GET_EC()` should be called once on the frame.
1948
+ * Note that inlining can produce the problem.
1949
+ */
1950
+ VM_ASSERT(ec == rb_current_ec_noinline());
1951
+ #else
1952
+ rb_execution_context_t *ec = native_tls_get(ruby_current_ec_key);
1953
+ #endif
1954
+ VM_ASSERT(!expect_ec || ec != NULL);
1955
+ return ec;
1956
+ }
1957
+
1958
+ static inline rb_thread_t *
1959
+ rb_current_thread(void)
1960
+ {
1961
+ const rb_execution_context_t *ec = GET_EC();
1962
+ return rb_ec_thread_ptr(ec);
1963
+ }
1964
+
1965
+ static inline rb_ractor_t *
1966
+ rb_current_ractor_raw(bool expect)
1967
+ {
1968
+ if (ruby_single_main_ractor) {
1969
+ return ruby_single_main_ractor;
1970
+ }
1971
+ else {
1972
+ const rb_execution_context_t *ec = rb_current_execution_context(expect);
1973
+ return (expect || ec) ? rb_ec_ractor_ptr(ec) : NULL;
1974
+ }
1975
+ }
1976
+
1977
+ static inline rb_ractor_t *
1978
+ rb_current_ractor(void)
1979
+ {
1980
+ return rb_current_ractor_raw(true);
1981
+ }
1982
+
1983
+ static inline rb_vm_t *
1984
+ rb_current_vm(void)
1985
+ {
1986
+ #if 0 // TODO: reconsider the assertions
1987
+ VM_ASSERT(ruby_current_vm_ptr == NULL ||
1988
+ ruby_current_execution_context_ptr == NULL ||
1989
+ rb_ec_thread_ptr(GET_EC()) == NULL ||
1990
+ rb_ec_thread_ptr(GET_EC())->status == THREAD_KILLED ||
1991
+ rb_ec_vm_ptr(GET_EC()) == ruby_current_vm_ptr);
1992
+ #endif
1993
+
1994
+ return ruby_current_vm_ptr;
1995
+ }
1996
+
1997
+ void rb_ec_vm_lock_rec_release(const rb_execution_context_t *ec,
1998
+ unsigned int recorded_lock_rec,
1999
+ unsigned int current_lock_rec);
2000
+
2001
+ static inline unsigned int
2002
+ rb_ec_vm_lock_rec(const rb_execution_context_t *ec)
2003
+ {
2004
+ rb_vm_t *vm = rb_ec_vm_ptr(ec);
2005
+
2006
+ if (vm->ractor.sync.lock_owner != rb_ec_ractor_ptr(ec)) {
2007
+ return 0;
2008
+ }
2009
+ else {
2010
+ return vm->ractor.sync.lock_rec;
2011
+ }
2012
+ }
2013
+
2014
+ #else
2015
+ #error "unsupported thread model"
2016
+ #endif
2017
+
2018
+ enum {
2019
+ TIMER_INTERRUPT_MASK = 0x01,
2020
+ PENDING_INTERRUPT_MASK = 0x02,
2021
+ POSTPONED_JOB_INTERRUPT_MASK = 0x04,
2022
+ TRAP_INTERRUPT_MASK = 0x08,
2023
+ TERMINATE_INTERRUPT_MASK = 0x10,
2024
+ VM_BARRIER_INTERRUPT_MASK = 0x20,
2025
+ };
2026
+
2027
+ #define RUBY_VM_SET_TIMER_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, TIMER_INTERRUPT_MASK)
2028
+ #define RUBY_VM_SET_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, PENDING_INTERRUPT_MASK)
2029
+ #define RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, POSTPONED_JOB_INTERRUPT_MASK)
2030
+ #define RUBY_VM_SET_TRAP_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, TRAP_INTERRUPT_MASK)
2031
+ #define RUBY_VM_SET_TERMINATE_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, TERMINATE_INTERRUPT_MASK)
2032
+ #define RUBY_VM_SET_VM_BARRIER_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, VM_BARRIER_INTERRUPT_MASK)
2033
+ #define RUBY_VM_INTERRUPTED(ec) ((ec)->interrupt_flag & ~(ec)->interrupt_mask & \
2034
+ (PENDING_INTERRUPT_MASK|TRAP_INTERRUPT_MASK))
2035
+
2036
+ static inline bool
2037
+ RUBY_VM_INTERRUPTED_ANY(rb_execution_context_t *ec)
2038
+ {
2039
+ #if defined(USE_VM_CLOCK) && USE_VM_CLOCK
2040
+ uint32_t current_clock = rb_ec_vm_ptr(ec)->clock;
2041
+
2042
+ if (current_clock != ec->checked_clock) {
2043
+ ec->checked_clock = current_clock;
2044
+ RUBY_VM_SET_TIMER_INTERRUPT(ec);
2045
+ }
2046
+ #endif
2047
+ return ec->interrupt_flag & ~(ec)->interrupt_mask;
2048
+ }
2049
+
2050
+ VALUE rb_exc_set_backtrace(VALUE exc, VALUE bt);
2051
+ int rb_signal_buff_size(void);
2052
+ int rb_signal_exec(rb_thread_t *th, int sig);
2053
+ void rb_threadptr_check_signal(rb_thread_t *mth);
2054
+ void rb_threadptr_signal_raise(rb_thread_t *th, int sig);
2055
+ void rb_threadptr_signal_exit(rb_thread_t *th);
2056
+ int rb_threadptr_execute_interrupts(rb_thread_t *, int);
2057
+ void rb_threadptr_interrupt(rb_thread_t *th);
2058
+ void rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th);
2059
+ void rb_threadptr_pending_interrupt_clear(rb_thread_t *th);
2060
+ void rb_threadptr_pending_interrupt_enque(rb_thread_t *th, VALUE v);
2061
+ VALUE rb_ec_get_errinfo(const rb_execution_context_t *ec);
2062
+ void rb_ec_error_print(rb_execution_context_t * volatile ec, volatile VALUE errinfo);
2063
+ void rb_execution_context_update(rb_execution_context_t *ec);
2064
+ void rb_execution_context_mark(const rb_execution_context_t *ec);
2065
+ void rb_fiber_close(rb_fiber_t *fib);
2066
+ void Init_native_thread(rb_thread_t *th);
2067
+ int rb_vm_check_ints_blocking(rb_execution_context_t *ec);
2068
+
2069
+ // vm_sync.h
2070
+ void rb_vm_cond_wait(rb_vm_t *vm, rb_nativethread_cond_t *cond);
2071
+ void rb_vm_cond_timedwait(rb_vm_t *vm, rb_nativethread_cond_t *cond, unsigned long msec);
2072
+
2073
+ #define RUBY_VM_CHECK_INTS(ec) rb_vm_check_ints(ec)
2074
+ static inline void
2075
+ rb_vm_check_ints(rb_execution_context_t *ec)
2076
+ {
2077
+ #ifdef RUBY_ASSERT_CRITICAL_SECTION
2078
+ VM_ASSERT(ruby_assert_critical_section_entered == 0);
2079
+ #endif
2080
+
2081
+ VM_ASSERT(ec == GET_EC());
2082
+
2083
+ if (UNLIKELY(RUBY_VM_INTERRUPTED_ANY(ec))) {
2084
+ rb_threadptr_execute_interrupts(rb_ec_thread_ptr(ec), 0);
2085
+ }
2086
+ }
2087
+
2088
+ /* tracer */
2089
+
2090
+ struct rb_trace_arg_struct {
2091
+ rb_event_flag_t event;
2092
+ rb_execution_context_t *ec;
2093
+ const rb_control_frame_t *cfp;
2094
+ VALUE self;
2095
+ ID id;
2096
+ ID called_id;
2097
+ VALUE klass;
2098
+ VALUE data;
2099
+
2100
+ int klass_solved;
2101
+
2102
+ /* calc from cfp */
2103
+ int lineno;
2104
+ VALUE path;
2105
+ };
2106
+
2107
+ void rb_hook_list_mark(rb_hook_list_t *hooks);
2108
+ void rb_hook_list_mark_and_update(rb_hook_list_t *hooks);
2109
+ void rb_hook_list_free(rb_hook_list_t *hooks);
2110
+ void rb_hook_list_connect_tracepoint(VALUE target, rb_hook_list_t *list, VALUE tpval, unsigned int target_line);
2111
+ void rb_hook_list_remove_tracepoint(rb_hook_list_t *list, VALUE tpval);
2112
+
2113
+ void rb_exec_event_hooks(struct rb_trace_arg_struct *trace_arg, rb_hook_list_t *hooks, int pop_p);
2114
+
2115
+ #define EXEC_EVENT_HOOK_ORIG(ec_, hooks_, flag_, self_, id_, called_id_, klass_, data_, pop_p_) do { \
2116
+ const rb_event_flag_t flag_arg_ = (flag_); \
2117
+ rb_hook_list_t *hooks_arg_ = (hooks_); \
2118
+ if (UNLIKELY((hooks_arg_)->events & (flag_arg_))) { \
2119
+ /* defer evaluating the other arguments */ \
2120
+ rb_exec_event_hook_orig(ec_, hooks_arg_, flag_arg_, self_, id_, called_id_, klass_, data_, pop_p_); \
2121
+ } \
2122
+ } while (0)
2123
+
2124
+ static inline void
2125
+ rb_exec_event_hook_orig(rb_execution_context_t *ec, rb_hook_list_t *hooks, rb_event_flag_t flag,
2126
+ VALUE self, ID id, ID called_id, VALUE klass, VALUE data, int pop_p)
2127
+ {
2128
+ struct rb_trace_arg_struct trace_arg;
2129
+
2130
+ VM_ASSERT((hooks->events & flag) != 0);
2131
+
2132
+ trace_arg.event = flag;
2133
+ trace_arg.ec = ec;
2134
+ trace_arg.cfp = ec->cfp;
2135
+ trace_arg.self = self;
2136
+ trace_arg.id = id;
2137
+ trace_arg.called_id = called_id;
2138
+ trace_arg.klass = klass;
2139
+ trace_arg.data = data;
2140
+ trace_arg.path = Qundef;
2141
+ trace_arg.klass_solved = 0;
2142
+
2143
+ rb_exec_event_hooks(&trace_arg, hooks, pop_p);
2144
+ }
2145
+
2146
+ struct rb_ractor_pub {
2147
+ VALUE self;
2148
+ uint32_t id;
2149
+ rb_hook_list_t hooks;
2150
+ };
2151
+
2152
+ static inline rb_hook_list_t *
2153
+ rb_ec_ractor_hooks(const rb_execution_context_t *ec)
2154
+ {
2155
+ struct rb_ractor_pub *cr_pub = (struct rb_ractor_pub *)rb_ec_ractor_ptr(ec);
2156
+ return &cr_pub->hooks;
2157
+ }
2158
+
2159
+ #define EXEC_EVENT_HOOK(ec_, flag_, self_, id_, called_id_, klass_, data_) \
2160
+ EXEC_EVENT_HOOK_ORIG(ec_, rb_ec_ractor_hooks(ec_), flag_, self_, id_, called_id_, klass_, data_, 0)
2161
+
2162
+ #define EXEC_EVENT_HOOK_AND_POP_FRAME(ec_, flag_, self_, id_, called_id_, klass_, data_) \
2163
+ EXEC_EVENT_HOOK_ORIG(ec_, rb_ec_ractor_hooks(ec_), flag_, self_, id_, called_id_, klass_, data_, 1)
2164
+
2165
+ static inline void
2166
+ rb_exec_event_hook_script_compiled(rb_execution_context_t *ec, const rb_iseq_t *iseq, VALUE eval_script)
2167
+ {
2168
+ EXEC_EVENT_HOOK(ec, RUBY_EVENT_SCRIPT_COMPILED, ec->cfp->self, 0, 0, 0,
2169
+ NIL_P(eval_script) ? (VALUE)iseq :
2170
+ rb_ary_new_from_args(2, eval_script, (VALUE)iseq));
2171
+ }
2172
+
2173
+ void rb_vm_trap_exit(rb_vm_t *vm);
2174
+ void rb_vm_postponed_job_atfork(void); /* vm_trace.c */
2175
+ void rb_vm_postponed_job_free(void); /* vm_trace.c */
2176
+ size_t rb_vm_memsize_postponed_job_queue(void); /* vm_trace.c */
2177
+ void rb_vm_postponed_job_queue_init(rb_vm_t *vm); /* vm_trace.c */
2178
+
2179
+ RUBY_SYMBOL_EXPORT_BEGIN
2180
+
2181
+ int rb_thread_check_trap_pending(void);
2182
+
2183
+ /* #define RUBY_EVENT_RESERVED_FOR_INTERNAL_USE 0x030000 */ /* from vm_core.h */
2184
+ #define RUBY_EVENT_COVERAGE_LINE 0x010000
2185
+ #define RUBY_EVENT_COVERAGE_BRANCH 0x020000
2186
+
2187
+ extern VALUE rb_get_coverages(void);
2188
+ extern void rb_set_coverages(VALUE, int, VALUE);
2189
+ extern void rb_clear_coverages(void);
2190
+ extern void rb_reset_coverages(void);
2191
+ extern void rb_resume_coverages(void);
2192
+ extern void rb_suspend_coverages(void);
2193
+
2194
+ void rb_postponed_job_flush(rb_vm_t *vm);
2195
+
2196
+ // ractor.c
2197
+ RUBY_EXTERN VALUE rb_eRactorUnsafeError;
2198
+ RUBY_EXTERN VALUE rb_eRactorIsolationError;
2199
+
2200
+ RUBY_SYMBOL_EXPORT_END
2201
+
2202
+ #endif /* RUBY_VM_CORE_H */