debase-ruby_core_source 0.10.13 → 0.10.16

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