debase-ruby_core_source 3.3.6 → 3.4.0

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