script_core 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (529) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +35 -57
  3. data/.ruby-version +1 -1
  4. data/Gemfile +2 -2
  5. data/README.md +7 -1
  6. data/ext/enterprise_script_service/Rakefile +1 -1
  7. data/ext/enterprise_script_service/libseccomp/.travis.yml +24 -12
  8. data/ext/enterprise_script_service/libseccomp/CHANGELOG +32 -0
  9. data/ext/enterprise_script_service/libseccomp/CONTRIBUTING.md +37 -26
  10. data/ext/enterprise_script_service/libseccomp/CREDITS +11 -0
  11. data/ext/enterprise_script_service/libseccomp/README.md +21 -1
  12. data/ext/enterprise_script_service/libseccomp/configure.ac +13 -8
  13. data/ext/enterprise_script_service/libseccomp/doc/Makefile.am +6 -0
  14. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_api_get.3 +12 -2
  15. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_arch_add.3 +38 -6
  16. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_attr_set.3 +53 -2
  17. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_export_bpf.3 +20 -2
  18. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_init.3 +9 -2
  19. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_load.3 +32 -2
  20. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_merge.3 +16 -2
  21. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_alloc.3 +113 -0
  22. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_fd.3 +1 -0
  23. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_free.3 +1 -0
  24. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_id_valid.3 +1 -0
  25. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_receive.3 +1 -0
  26. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_respond.3 +1 -0
  27. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_rule_add.3 +64 -3
  28. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_syscall_priority.3 +18 -3
  29. data/ext/enterprise_script_service/libseccomp/include/seccomp-syscalls.h +19 -0
  30. data/ext/enterprise_script_service/libseccomp/include/seccomp.h.in +116 -0
  31. data/ext/enterprise_script_service/libseccomp/src/.gitignore +2 -0
  32. data/ext/enterprise_script_service/libseccomp/src/Makefile.am +31 -17
  33. data/ext/enterprise_script_service/libseccomp/src/api.c +254 -58
  34. data/ext/enterprise_script_service/libseccomp/src/arch-aarch64.h +1 -9
  35. data/ext/enterprise_script_service/libseccomp/src/arch-arm.c +47 -2
  36. data/ext/enterprise_script_service/libseccomp/src/arch-arm.h +1 -9
  37. data/ext/enterprise_script_service/libseccomp/src/arch-gperf-generate +40 -0
  38. data/ext/enterprise_script_service/libseccomp/src/arch-mips.c +41 -4
  39. data/ext/enterprise_script_service/libseccomp/src/arch-mips.h +2 -10
  40. data/ext/enterprise_script_service/libseccomp/src/arch-mips64.c +41 -4
  41. data/ext/enterprise_script_service/libseccomp/src/arch-mips64.h +3 -11
  42. data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32.c +41 -4
  43. data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32.h +2 -10
  44. data/ext/enterprise_script_service/libseccomp/src/arch-parisc.h +1 -10
  45. data/ext/enterprise_script_service/libseccomp/src/arch-parisc64.c +3 -3
  46. data/ext/enterprise_script_service/libseccomp/src/arch-parisc64.h +29 -0
  47. data/ext/enterprise_script_service/libseccomp/src/arch-ppc.h +1 -9
  48. data/ext/enterprise_script_service/libseccomp/src/arch-ppc64.c +606 -8
  49. data/ext/enterprise_script_service/libseccomp/src/arch-ppc64.h +2 -10
  50. data/ext/enterprise_script_service/libseccomp/src/arch-riscv64.c +31 -0
  51. data/ext/enterprise_script_service/libseccomp/src/arch-riscv64.h +22 -0
  52. data/ext/enterprise_script_service/libseccomp/src/arch-s390.c +171 -12
  53. data/ext/enterprise_script_service/libseccomp/src/arch-s390.h +1 -17
  54. data/ext/enterprise_script_service/libseccomp/src/arch-s390x.c +166 -10
  55. data/ext/enterprise_script_service/libseccomp/src/arch-s390x.h +1 -20
  56. data/ext/enterprise_script_service/libseccomp/src/arch-syscall-dump.c +8 -1
  57. data/ext/enterprise_script_service/libseccomp/src/arch-syscall-validate +359 -143
  58. data/ext/enterprise_script_service/libseccomp/src/arch-x32.c +36 -2
  59. data/ext/enterprise_script_service/libseccomp/src/arch-x32.h +2 -10
  60. data/ext/enterprise_script_service/libseccomp/src/arch-x86.c +172 -10
  61. data/ext/enterprise_script_service/libseccomp/src/arch-x86.h +1 -14
  62. data/ext/enterprise_script_service/libseccomp/src/arch-x86_64.h +1 -9
  63. data/ext/enterprise_script_service/libseccomp/src/arch.c +11 -3
  64. data/ext/enterprise_script_service/libseccomp/src/arch.h +7 -0
  65. data/ext/enterprise_script_service/libseccomp/src/db.c +268 -57
  66. data/ext/enterprise_script_service/libseccomp/src/db.h +16 -2
  67. data/ext/enterprise_script_service/libseccomp/src/gen_bpf.c +503 -148
  68. data/ext/enterprise_script_service/libseccomp/src/gen_bpf.h +2 -1
  69. data/ext/enterprise_script_service/libseccomp/src/gen_pfc.c +165 -37
  70. data/ext/enterprise_script_service/libseccomp/src/python/libseccomp.pxd +37 -1
  71. data/ext/enterprise_script_service/libseccomp/src/python/seccomp.pyx +295 -5
  72. data/ext/enterprise_script_service/libseccomp/src/syscalls.c +56 -0
  73. data/ext/enterprise_script_service/libseccomp/src/syscalls.csv +470 -0
  74. data/ext/enterprise_script_service/libseccomp/src/syscalls.h +62 -0
  75. data/ext/enterprise_script_service/libseccomp/src/syscalls.perf.template +82 -0
  76. data/ext/enterprise_script_service/libseccomp/src/system.c +196 -16
  77. data/ext/enterprise_script_service/libseccomp/src/system.h +68 -13
  78. data/ext/enterprise_script_service/libseccomp/tests/.gitignore +10 -2
  79. data/ext/enterprise_script_service/libseccomp/tests/06-sim-actions.tests +1 -1
  80. data/ext/enterprise_script_service/libseccomp/tests/11-basic-basic_errors.c +5 -5
  81. data/ext/enterprise_script_service/libseccomp/tests/13-basic-attrs.c +35 -1
  82. data/ext/enterprise_script_service/libseccomp/tests/13-basic-attrs.py +10 -1
  83. data/ext/enterprise_script_service/libseccomp/tests/15-basic-resolver.c +4 -3
  84. data/ext/enterprise_script_service/libseccomp/tests/16-sim-arch_basic.c +12 -0
  85. data/ext/enterprise_script_service/libseccomp/tests/16-sim-arch_basic.py +1 -0
  86. data/ext/enterprise_script_service/libseccomp/tests/{18-sim-basic_whitelist.c → 18-sim-basic_allowlist.c} +0 -0
  87. data/ext/enterprise_script_service/libseccomp/tests/{18-sim-basic_whitelist.py → 18-sim-basic_allowlist.py} +0 -0
  88. data/ext/enterprise_script_service/libseccomp/tests/18-sim-basic_allowlist.tests +32 -0
  89. data/ext/enterprise_script_service/libseccomp/tests/23-sim-arch_all_le_basic.c +3 -0
  90. data/ext/enterprise_script_service/libseccomp/tests/23-sim-arch_all_le_basic.py +1 -0
  91. data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.c +3 -0
  92. data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.py +1 -0
  93. data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.tests +33 -17
  94. data/ext/enterprise_script_service/libseccomp/tests/{34-sim-basic_blacklist.c → 34-sim-basic_denylist.c} +0 -0
  95. data/ext/enterprise_script_service/libseccomp/tests/{34-sim-basic_blacklist.py → 34-sim-basic_denylist.py} +0 -0
  96. data/ext/enterprise_script_service/libseccomp/tests/34-sim-basic_denylist.tests +32 -0
  97. data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.c +3 -0
  98. data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.py +1 -0
  99. data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.tests +25 -25
  100. data/ext/enterprise_script_service/libseccomp/tests/39-basic-api_level.c +24 -3
  101. data/ext/enterprise_script_service/libseccomp/tests/39-basic-api_level.py +16 -1
  102. data/ext/enterprise_script_service/libseccomp/tests/47-live-kill_process.c +3 -3
  103. data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.c +112 -0
  104. data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.py +60 -0
  105. data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.tests +11 -0
  106. data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.c +48 -0
  107. data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.py +38 -0
  108. data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.tests +11 -0
  109. data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.c +156 -0
  110. data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.py +95 -0
  111. data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.tests +65 -0
  112. data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.c +128 -0
  113. data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.py +95 -0
  114. data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.tests +11 -0
  115. data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.c +134 -0
  116. data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.sh +46 -0
  117. data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.tests +11 -0
  118. data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.c +90 -0
  119. data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.py +65 -0
  120. data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.tests +11 -0
  121. data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.c +64 -0
  122. data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.py +46 -0
  123. data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.tests +11 -0
  124. data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.c +116 -0
  125. data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.py +61 -0
  126. data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.tests +11 -0
  127. data/ext/enterprise_script_service/libseccomp/tests/Makefile.am +34 -10
  128. data/ext/enterprise_script_service/libseccomp/tests/regression +10 -3
  129. data/ext/enterprise_script_service/libseccomp/tests/util.c +3 -3
  130. data/ext/enterprise_script_service/libseccomp/tools/Makefile.am +0 -3
  131. data/ext/enterprise_script_service/libseccomp/tools/check-syntax +1 -1
  132. data/ext/enterprise_script_service/libseccomp/tools/scmp_arch_detect.c +3 -0
  133. data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_disasm.c +4 -2
  134. data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_sim.c +4 -0
  135. data/ext/enterprise_script_service/libseccomp/tools/util.c +14 -12
  136. data/ext/enterprise_script_service/libseccomp/tools/util.h +7 -0
  137. data/ext/enterprise_script_service/mruby/.github/workflows/build.yml +149 -0
  138. data/ext/enterprise_script_service/mruby/.github/workflows/codeql-analysis.yml +55 -0
  139. data/ext/enterprise_script_service/mruby/.github/workflows/lint.yml +23 -0
  140. data/ext/enterprise_script_service/mruby/.github/workflows/oss-fuzz.yml +27 -0
  141. data/ext/enterprise_script_service/mruby/.github/workflows/spell-checker.yml +17 -0
  142. data/ext/enterprise_script_service/mruby/.gitignore +3 -0
  143. data/ext/enterprise_script_service/mruby/.gitlab-ci.yml +3 -3
  144. data/ext/enterprise_script_service/mruby/.markdownlint.yml +16 -0
  145. data/ext/enterprise_script_service/mruby/.travis.yml +7 -10
  146. data/ext/enterprise_script_service/mruby/.yamllint +8 -0
  147. data/ext/enterprise_script_service/mruby/AUTHORS +4 -0
  148. data/ext/enterprise_script_service/mruby/CODEOWNERS +1 -0
  149. data/ext/enterprise_script_service/mruby/CONTRIBUTING.md +6 -13
  150. data/ext/enterprise_script_service/mruby/Doxyfile +4 -4
  151. data/ext/enterprise_script_service/mruby/LICENSE +1 -1
  152. data/ext/enterprise_script_service/mruby/Makefile +1 -1
  153. data/ext/enterprise_script_service/mruby/README.md +5 -11
  154. data/ext/enterprise_script_service/mruby/Rakefile +18 -108
  155. data/ext/enterprise_script_service/mruby/TODO.md +17 -0
  156. data/ext/enterprise_script_service/mruby/appveyor.yml +29 -26
  157. data/ext/enterprise_script_service/mruby/benchmark/bm_ao_render.rb +1 -1
  158. data/ext/enterprise_script_service/mruby/build_config.rb +9 -152
  159. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_ArduinoDue.rb → build_config/ArduinoDue.rb} +4 -21
  160. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_IntelEdison.rb → build_config/IntelEdison.rb} +4 -4
  161. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_IntelGalileo.rb → build_config/IntelGalileo.rb} +3 -20
  162. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_RX630.rb → build_config/RX630.rb} +4 -21
  163. data/ext/enterprise_script_service/mruby/build_config/android_arm64-v8a.rb +11 -0
  164. data/ext/enterprise_script_service/mruby/build_config/android_armeabi.rb +11 -0
  165. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_android_armeabi_v7a_neon_hard.rb → build_config/android_armeabi_v7a_neon_hard.rb} +0 -15
  166. data/ext/enterprise_script_service/mruby/build_config/bench.rb +11 -0
  167. data/ext/enterprise_script_service/mruby/build_config/boxing.rb +21 -0
  168. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_chipKITMax32.rb → build_config/chipKITMax32.rb} +4 -21
  169. data/ext/enterprise_script_service/mruby/{appveyor_config.rb → build_config/ci/gcc-clang.rb} +11 -8
  170. data/ext/enterprise_script_service/mruby/build_config/ci/msvc.rb +20 -0
  171. data/ext/enterprise_script_service/mruby/build_config/clang-asan.rb +11 -0
  172. data/ext/enterprise_script_service/mruby/build_config/cross-32bit.rb +14 -0
  173. data/ext/enterprise_script_service/mruby/build_config/default.rb +80 -0
  174. data/ext/enterprise_script_service/mruby/build_config/dreamcast_shelf.rb +94 -0
  175. data/ext/enterprise_script_service/mruby/build_config/gameboyadvance.rb +73 -0
  176. data/ext/enterprise_script_service/mruby/build_config/host-cxx.rb +12 -0
  177. data/ext/enterprise_script_service/mruby/build_config/host-debug.rb +20 -0
  178. data/ext/enterprise_script_service/mruby/build_config/host-gprof.rb +14 -0
  179. data/ext/enterprise_script_service/mruby/build_config/host-m32.rb +15 -0
  180. data/ext/enterprise_script_service/mruby/build_config/host-shared.rb +36 -0
  181. data/ext/enterprise_script_service/mruby/build_config/mrbc.rb +11 -0
  182. data/ext/enterprise_script_service/mruby/build_config/no-float.rb +17 -0
  183. data/ext/enterprise_script_service/mruby/doc/guides/compile.md +142 -49
  184. data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +5 -4
  185. data/ext/enterprise_script_service/mruby/doc/guides/gc-arena-howto.md +1 -1
  186. data/ext/enterprise_script_service/mruby/doc/guides/mrbconf.md +53 -30
  187. data/ext/enterprise_script_service/mruby/doc/guides/mrbgems.md +31 -14
  188. data/ext/enterprise_script_service/mruby/doc/guides/symbol.md +83 -0
  189. data/ext/enterprise_script_service/mruby/doc/limitations.md +35 -36
  190. data/ext/enterprise_script_service/mruby/doc/mruby3.md +163 -0
  191. data/ext/enterprise_script_service/mruby/doc/opcode.md +102 -103
  192. data/ext/enterprise_script_service/mruby/examples/mrbgems/c_and_ruby_extension_example/mrblib/example.rb +1 -1
  193. data/ext/enterprise_script_service/mruby/examples/mrbgems/c_and_ruby_extension_example/src/example.c +5 -1
  194. data/ext/enterprise_script_service/mruby/examples/mrbgems/c_extension_example/src/example.c +5 -1
  195. data/ext/enterprise_script_service/mruby/examples/mrbgems/ruby_extension_example/mrblib/example.rb +1 -1
  196. data/ext/enterprise_script_service/mruby/include/mrbconf.h +88 -66
  197. data/ext/enterprise_script_service/mruby/include/mruby.h +160 -104
  198. data/ext/enterprise_script_service/mruby/include/mruby/array.h +27 -6
  199. data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +80 -46
  200. data/ext/enterprise_script_service/mruby/include/mruby/boxing_no.h +8 -8
  201. data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +76 -55
  202. data/ext/enterprise_script_service/mruby/include/mruby/class.h +10 -8
  203. data/ext/enterprise_script_service/mruby/include/mruby/common.h +14 -1
  204. data/ext/enterprise_script_service/mruby/include/mruby/compile.h +20 -6
  205. data/ext/enterprise_script_service/mruby/include/mruby/debug.h +2 -2
  206. data/ext/enterprise_script_service/mruby/include/mruby/dump.h +18 -52
  207. data/ext/enterprise_script_service/mruby/include/mruby/endian.h +44 -0
  208. data/ext/enterprise_script_service/mruby/include/mruby/error.h +39 -5
  209. data/ext/enterprise_script_service/mruby/include/mruby/gc.h +1 -0
  210. data/ext/enterprise_script_service/mruby/include/mruby/hash.h +33 -13
  211. data/ext/enterprise_script_service/mruby/include/mruby/irep.h +74 -14
  212. data/ext/enterprise_script_service/mruby/include/mruby/istruct.h +4 -1
  213. data/ext/enterprise_script_service/mruby/include/mruby/khash.h +19 -9
  214. data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +37 -63
  215. data/ext/enterprise_script_service/mruby/include/mruby/opcode.h +1 -27
  216. data/ext/enterprise_script_service/mruby/include/mruby/ops.h +29 -24
  217. data/ext/enterprise_script_service/mruby/include/mruby/presym.h +40 -0
  218. data/ext/enterprise_script_service/mruby/include/mruby/presym/disable.h +70 -0
  219. data/ext/enterprise_script_service/mruby/include/mruby/presym/enable.h +37 -0
  220. data/ext/enterprise_script_service/mruby/include/mruby/presym/scanning.h +73 -0
  221. data/ext/enterprise_script_service/mruby/include/mruby/proc.h +93 -21
  222. data/ext/enterprise_script_service/mruby/include/mruby/string.h +12 -16
  223. data/ext/enterprise_script_service/mruby/include/mruby/throw.h +14 -3
  224. data/ext/enterprise_script_service/mruby/include/mruby/value.h +60 -59
  225. data/ext/enterprise_script_service/mruby/include/mruby/variable.h +1 -0
  226. data/ext/enterprise_script_service/mruby/include/mruby/version.h +25 -6
  227. data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +198 -72
  228. data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +71 -78
  229. data/ext/enterprise_script_service/mruby/lib/mruby/build/load_gems.rb +12 -10
  230. data/ext/enterprise_script_service/mruby/lib/{mruby-core-ext.rb → mruby/core_ext.rb} +10 -3
  231. data/ext/enterprise_script_service/mruby/lib/mruby/gem.rb +84 -32
  232. data/ext/enterprise_script_service/mruby/lib/mruby/lockfile.rb +1 -1
  233. data/ext/enterprise_script_service/mruby/lib/mruby/presym.rb +132 -0
  234. data/ext/enterprise_script_service/mruby/lib/mruby/source.rb +3 -1
  235. data/ext/enterprise_script_service/mruby/mrbgems/default-no-fpu.gembox +3 -0
  236. data/ext/enterprise_script_service/mruby/mrbgems/default-no-stdio.gembox +4 -0
  237. data/ext/enterprise_script_service/mruby/mrbgems/default.gembox +9 -81
  238. data/ext/enterprise_script_service/mruby/mrbgems/full-core.gembox +1 -4
  239. data/ext/enterprise_script_service/mruby/mrbgems/math.gembox +10 -0
  240. data/ext/enterprise_script_service/mruby/mrbgems/metaprog.gembox +15 -0
  241. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +1 -32
  242. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/src/array.c +10 -12
  243. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/test/array.rb +0 -13
  244. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mrbgem.rake +30 -18
  245. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mruby-config +18 -8
  246. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/bintest/mrdb.rb +3 -6
  247. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/bintest/print.rb +10 -10
  248. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c +14 -9
  249. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c +3 -2
  250. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +4 -4
  251. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h +2 -6
  252. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +6 -2
  253. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/bintest/mirb.rb +23 -5
  254. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/mrbgem.rake +11 -2
  255. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +46 -35
  256. data/ext/enterprise_script_service/mruby/mrbgems/{mruby-compiler → mruby-bin-mrbc}/bintest/mrbc.rb +0 -0
  257. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/mrbgem.rake +3 -4
  258. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +41 -28
  259. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/bintest/mruby.rb +25 -4
  260. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +1 -2
  261. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +26 -6
  262. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb +1 -1
  263. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c +6 -2
  264. data/ext/enterprise_script_service/mruby/mrbgems/mruby-catch/mrbgem.rake +5 -0
  265. data/ext/enterprise_script_service/mruby/mrbgems/mruby-catch/mrblib/catch.rb +27 -0
  266. data/ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/src/class.c +7 -1
  267. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +495 -436
  268. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/keywords +5 -0
  269. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/lex.def +49 -44
  270. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/parse.y +637 -220
  271. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/y.tab.c +13734 -0
  272. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/mrbgem.rake +20 -23
  273. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrblib/complex.rb +2 -2
  274. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/src/complex.c +9 -9
  275. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/test/complex.rb +4 -4
  276. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/mrblib/enumerator.rb +1 -0
  277. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/test/enumerator.rb +2 -2
  278. data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/mrbgem.rake +2 -2
  279. data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/src/exception.c +3 -3
  280. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +19 -238
  281. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/test/eval.rb +21 -0
  282. data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/src/fiber.c +19 -15
  283. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +31 -5
  284. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/test/hash.rb +7 -0
  285. data/ext/enterprise_script_service/mruby/mrbgems/mruby-inline-struct/test/inline.c +5 -6
  286. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/README.md +18 -16
  287. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/include/mruby/ext/io.h +39 -7
  288. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrbgem.rake +2 -8
  289. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file.rb +9 -4
  290. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file_constants.rb +0 -16
  291. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +9 -14
  292. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +107 -59
  293. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +22 -38
  294. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +417 -203
  295. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +20 -12
  296. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +33 -2
  297. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +58 -50
  298. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +13 -14
  299. data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/src/math.c +13 -12
  300. data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/test/math.rb +5 -4
  301. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/src/metaprog.c +56 -73
  302. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +13 -4
  303. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/README.md +4 -3
  304. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +80 -78
  305. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/test/method.rb +4 -4
  306. data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/src/numeric_ext.c +14 -13
  307. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/src/object.c +8 -16
  308. data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +18 -13
  309. data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/mrbgem.rake +10 -0
  310. data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/src/memsize.c +231 -0
  311. data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/test/memsize.rb +63 -0
  312. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/README.md +15 -18
  313. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/src/pack.c +120 -67
  314. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/mrblib/print.rb +1 -30
  315. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/src/print.c +65 -26
  316. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +34 -21
  317. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/test/proc.c +1 -1
  318. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/random.c +98 -43
  319. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/test/random.rb +2 -2
  320. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/mrblib/range.rb +39 -6
  321. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/src/range.c +21 -43
  322. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/test/range.rb +27 -3
  323. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb +12 -20
  324. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/src/rational.c +216 -38
  325. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/test/rational.rb +6 -6
  326. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/README.md +6 -4
  327. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/src/mrb_sleep.c +5 -5
  328. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/README.md +3 -2
  329. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrbgem.rake +1 -1
  330. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/src/socket.c +47 -45
  331. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/test/sockettest.c +3 -2
  332. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +161 -93
  333. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +9 -25
  334. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +23 -1
  335. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +17 -14
  336. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/mrblib/struct.rb +1 -1
  337. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/src/struct.c +23 -36
  338. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +7 -6
  339. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +1 -1
  340. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/README.md +0 -1
  341. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/driver.c +5 -5
  342. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/mrbgem.rake +17 -44
  343. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/vformat.c +4 -4
  344. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +37 -41
  345. data/ext/enterprise_script_service/mruby/mrbgems/stdlib-ext.gembox +18 -0
  346. data/ext/enterprise_script_service/mruby/mrbgems/stdlib-io.gembox +12 -0
  347. data/ext/enterprise_script_service/mruby/mrbgems/stdlib.gembox +54 -0
  348. data/ext/enterprise_script_service/mruby/mrblib/00class.rb +10 -0
  349. data/ext/enterprise_script_service/mruby/mrblib/10error.rb +4 -0
  350. data/ext/enterprise_script_service/mruby/mrblib/array.rb +17 -9
  351. data/ext/enterprise_script_service/mruby/mrblib/enum.rb +1 -1
  352. data/ext/enterprise_script_service/mruby/mrblib/hash.rb +3 -23
  353. data/ext/enterprise_script_service/mruby/mrblib/init_mrblib.c +0 -11
  354. data/ext/enterprise_script_service/mruby/mrblib/numeric.rb +36 -11
  355. data/ext/enterprise_script_service/mruby/mrblib/range.rb +25 -3
  356. data/ext/enterprise_script_service/mruby/oss-fuzz/mruby_proto_fuzzer.cpp +2 -2
  357. data/ext/enterprise_script_service/mruby/oss-fuzz/proto_to_ruby.h +1 -1
  358. data/ext/enterprise_script_service/mruby/src/array.c +67 -90
  359. data/ext/enterprise_script_service/mruby/src/backtrace.c +18 -19
  360. data/ext/enterprise_script_service/mruby/src/class.c +819 -211
  361. data/ext/enterprise_script_service/mruby/src/codedump.c +226 -197
  362. data/ext/enterprise_script_service/mruby/src/debug.c +14 -11
  363. data/ext/enterprise_script_service/mruby/src/dump.c +470 -207
  364. data/ext/enterprise_script_service/mruby/src/enum.c +1 -1
  365. data/ext/enterprise_script_service/mruby/src/error.c +94 -20
  366. data/ext/enterprise_script_service/mruby/src/etc.c +56 -39
  367. data/ext/enterprise_script_service/mruby/src/fmt_fp.c +103 -27
  368. data/ext/enterprise_script_service/mruby/src/gc.c +86 -349
  369. data/ext/enterprise_script_service/mruby/src/hash.c +1058 -723
  370. data/ext/enterprise_script_service/mruby/src/kernel.c +78 -226
  371. data/ext/enterprise_script_service/mruby/src/load.c +215 -159
  372. data/ext/enterprise_script_service/mruby/src/numeric.c +400 -382
  373. data/ext/enterprise_script_service/mruby/src/object.c +115 -90
  374. data/ext/enterprise_script_service/mruby/src/print.c +31 -6
  375. data/ext/enterprise_script_service/mruby/src/proc.c +56 -45
  376. data/ext/enterprise_script_service/mruby/src/range.c +49 -33
  377. data/ext/enterprise_script_service/mruby/src/state.c +58 -42
  378. data/ext/enterprise_script_service/mruby/src/string.c +151 -156
  379. data/ext/enterprise_script_service/mruby/src/symbol.c +132 -66
  380. data/ext/enterprise_script_service/mruby/src/value_array.h +1 -0
  381. data/ext/enterprise_script_service/mruby/src/variable.c +158 -158
  382. data/ext/enterprise_script_service/mruby/src/vm.c +655 -645
  383. data/ext/enterprise_script_service/mruby/tasks/benchmark.rake +6 -6
  384. data/ext/enterprise_script_service/mruby/tasks/bin.rake +23 -0
  385. data/ext/enterprise_script_service/mruby/tasks/core.rake +12 -0
  386. data/ext/enterprise_script_service/mruby/tasks/doc.rake +50 -38
  387. data/ext/enterprise_script_service/mruby/tasks/gitlab.rake +64 -61
  388. data/ext/enterprise_script_service/mruby/tasks/libmruby.rake +10 -1
  389. data/ext/enterprise_script_service/mruby/tasks/mrbgems.rake +13 -1
  390. data/ext/enterprise_script_service/mruby/tasks/mrblib.rake +40 -0
  391. data/ext/enterprise_script_service/mruby/tasks/presym.rake +44 -0
  392. data/ext/enterprise_script_service/mruby/tasks/test.rake +68 -0
  393. data/ext/enterprise_script_service/mruby/tasks/toolchains/android.rake +46 -1
  394. data/ext/enterprise_script_service/mruby/tasks/toolchains/gcc.rake +8 -7
  395. data/ext/enterprise_script_service/mruby/tasks/toolchains/openwrt.rake +13 -17
  396. data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +21 -25
  397. data/ext/enterprise_script_service/mruby/test/assert.rb +5 -4
  398. data/ext/enterprise_script_service/mruby/test/bintest.rb +5 -5
  399. data/ext/enterprise_script_service/mruby/test/t/argumenterror.rb +16 -0
  400. data/ext/enterprise_script_service/mruby/test/t/array.rb +7 -3
  401. data/ext/enterprise_script_service/mruby/test/t/bs_literal.rb +1 -1
  402. data/ext/enterprise_script_service/mruby/test/t/ensure.rb +8 -26
  403. data/ext/enterprise_script_service/mruby/test/t/exception.rb +2 -2
  404. data/ext/enterprise_script_service/mruby/test/t/float.rb +18 -8
  405. data/ext/enterprise_script_service/mruby/test/t/hash.rb +903 -281
  406. data/ext/enterprise_script_service/mruby/test/t/integer.rb +10 -38
  407. data/ext/enterprise_script_service/mruby/test/t/kernel.rb +16 -25
  408. data/ext/enterprise_script_service/mruby/test/t/literals.rb +50 -0
  409. data/ext/enterprise_script_service/mruby/test/t/module.rb +2 -2
  410. data/ext/enterprise_script_service/mruby/test/t/numeric.rb +1 -1
  411. data/ext/enterprise_script_service/mruby/test/t/range.rb +83 -1
  412. data/ext/enterprise_script_service/mruby/test/t/string.rb +4 -0
  413. data/ext/enterprise_script_service/mruby/test/t/superclass.rb +10 -10
  414. data/ext/enterprise_script_service/mruby/test/t/syntax.rb +24 -0
  415. data/ext/enterprise_script_service/mruby/test/t/vformat.rb +3 -3
  416. data/ext/enterprise_script_service/mruby_config.rb +2 -5
  417. data/ext/enterprise_script_service/mruby_engine.cpp +1 -1
  418. data/ext/enterprise_script_service/msgpack/.github/depends/boost.sh +56 -0
  419. data/ext/enterprise_script_service/msgpack/.github/workflows/coverage.yml +62 -0
  420. data/ext/enterprise_script_service/msgpack/.github/workflows/gha.yml +304 -0
  421. data/ext/enterprise_script_service/msgpack/CHANGELOG.md +11 -0
  422. data/ext/enterprise_script_service/msgpack/CMakeLists.txt +82 -39
  423. data/ext/enterprise_script_service/msgpack/Files.cmake +22 -12
  424. data/ext/enterprise_script_service/msgpack/QUICKSTART-C.md +26 -29
  425. data/ext/enterprise_script_service/msgpack/README.md +3 -2
  426. data/ext/enterprise_script_service/msgpack/appveyor.yml +6 -2
  427. data/ext/enterprise_script_service/msgpack/ci/build_cmake.sh +3 -1
  428. data/ext/enterprise_script_service/msgpack/cmake/CodeCoverage.cmake +55 -0
  429. data/ext/enterprise_script_service/msgpack/codecov.yml +36 -0
  430. data/ext/enterprise_script_service/msgpack/example/CMakeLists.txt +9 -5
  431. data/ext/enterprise_script_service/msgpack/example/boost/CMakeLists.txt +1 -1
  432. data/ext/enterprise_script_service/msgpack/example/c/CMakeLists.txt +17 -6
  433. data/ext/enterprise_script_service/msgpack/example/c/boundary.c +296 -0
  434. data/ext/enterprise_script_service/msgpack/example/c/jsonconv.c +419 -0
  435. data/ext/enterprise_script_service/msgpack/example/c/simple_c.c +1 -1
  436. data/ext/enterprise_script_service/msgpack/example/cpp03/CMakeLists.txt +3 -3
  437. data/ext/enterprise_script_service/msgpack/example/cpp11/CMakeLists.txt +2 -2
  438. data/ext/enterprise_script_service/msgpack/example/x3/CMakeLists.txt +2 -2
  439. data/ext/enterprise_script_service/msgpack/include/msgpack/pack.h +24 -1
  440. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/array_ref.hpp +5 -4
  441. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/boost/optional.hpp +4 -4
  442. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp17/vector_byte.hpp +8 -8
  443. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/map.hpp +4 -4
  444. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector.hpp +4 -4
  445. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_char.hpp +8 -8
  446. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_unsigned_char.hpp +8 -8
  447. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/wstring.hpp +4 -4
  448. data/ext/enterprise_script_service/msgpack/include/msgpack/v3/unpack.hpp +6 -6
  449. data/ext/enterprise_script_service/msgpack/include/msgpack/version_master.h +2 -2
  450. data/ext/enterprise_script_service/msgpack/include/msgpack/zbuffer.h +4 -4
  451. data/ext/enterprise_script_service/msgpack/make_file_list.sh +38 -11
  452. data/ext/enterprise_script_service/msgpack/src/vrefbuffer.c +6 -0
  453. data/ext/enterprise_script_service/msgpack/test/CMakeLists.txt +86 -64
  454. data/ext/enterprise_script_service/msgpack/test/array_ref.cpp +4 -0
  455. data/ext/enterprise_script_service/msgpack/test/boost_fusion.cpp +4 -0
  456. data/ext/enterprise_script_service/msgpack/test/boost_optional.cpp +4 -0
  457. data/ext/enterprise_script_service/msgpack/test/boost_string_ref.cpp +4 -1
  458. data/ext/enterprise_script_service/msgpack/test/boost_string_view.cpp +4 -0
  459. data/ext/enterprise_script_service/msgpack/test/boost_variant.cpp +4 -0
  460. data/ext/enterprise_script_service/msgpack/test/buffer.cpp +4 -47
  461. data/ext/enterprise_script_service/msgpack/test/buffer_c.cpp +148 -0
  462. data/ext/enterprise_script_service/msgpack/test/carray.cpp +4 -0
  463. data/ext/enterprise_script_service/msgpack/test/cases.cpp +8 -4
  464. data/ext/enterprise_script_service/msgpack/test/convert.cpp +8 -4
  465. data/ext/enterprise_script_service/msgpack/test/fixint.cpp +4 -0
  466. data/ext/enterprise_script_service/msgpack/test/fixint_c.cpp +4 -0
  467. data/ext/enterprise_script_service/msgpack/test/fuzz_unpack_pack_fuzzer_cpp11.cpp +4 -0
  468. data/ext/enterprise_script_service/msgpack/test/iterator_cpp11.cpp +4 -0
  469. data/ext/enterprise_script_service/msgpack/test/json.cpp +4 -0
  470. data/ext/enterprise_script_service/msgpack/test/limit.cpp +8 -4
  471. data/ext/enterprise_script_service/msgpack/test/msgpack_basic.cpp +4 -0
  472. data/ext/enterprise_script_service/msgpack/test/msgpack_c.cpp +159 -0
  473. data/ext/enterprise_script_service/msgpack/test/msgpack_container.cpp +4 -0
  474. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp11.cpp +32 -27
  475. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp17.cpp +4 -0
  476. data/ext/enterprise_script_service/msgpack/test/msgpack_stream.cpp +4 -0
  477. data/ext/enterprise_script_service/msgpack/test/msgpack_tuple.cpp +4 -1
  478. data/ext/enterprise_script_service/msgpack/test/msgpack_vref.cpp +4 -0
  479. data/ext/enterprise_script_service/msgpack/test/msgpack_x3_parse.cpp +4 -0
  480. data/ext/enterprise_script_service/msgpack/test/object.cpp +4 -1
  481. data/ext/enterprise_script_service/msgpack/test/object_with_zone.cpp +12 -8
  482. data/ext/enterprise_script_service/msgpack/test/pack_unpack.cpp +30 -26
  483. data/ext/enterprise_script_service/msgpack/test/pack_unpack_c.cpp +4 -0
  484. data/ext/enterprise_script_service/msgpack/test/raw.cpp +4 -0
  485. data/ext/enterprise_script_service/msgpack/test/reference.cpp +4 -0
  486. data/ext/enterprise_script_service/msgpack/test/reference_cpp11.cpp +4 -0
  487. data/ext/enterprise_script_service/msgpack/test/reference_wrapper_cpp11.cpp +4 -0
  488. data/ext/enterprise_script_service/msgpack/test/shared_ptr_cpp11.cpp +4 -0
  489. data/ext/enterprise_script_service/msgpack/test/size_equal_only.cpp +4 -0
  490. data/ext/enterprise_script_service/msgpack/test/streaming.cpp +8 -4
  491. data/ext/enterprise_script_service/msgpack/test/streaming_c.cpp +4 -0
  492. data/ext/enterprise_script_service/msgpack/test/unique_ptr_cpp11.cpp +4 -0
  493. data/ext/enterprise_script_service/msgpack/test/user_class.cpp +16 -12
  494. data/ext/enterprise_script_service/msgpack/test/version.cpp +4 -0
  495. data/ext/enterprise_script_service/msgpack/test/visitor.cpp +4 -0
  496. data/ext/enterprise_script_service/msgpack/test/zone.cpp +4 -0
  497. data/lib/script_core/engine.rb +24 -5
  498. data/lib/script_core/executable.rb +4 -3
  499. data/lib/script_core/version.rb +1 -1
  500. data/lib/tasks/script_core.rake +3 -1
  501. data/script_core.gemspec +1 -2
  502. data/spec/dummy/app/lib/script_engine.rb +64 -5
  503. data/spec/script_core_spec.rb +13 -0
  504. metadata +123 -61
  505. data/ext/enterprise_script_service/libseccomp/src/arch-aarch64-syscalls.c +0 -559
  506. data/ext/enterprise_script_service/libseccomp/src/arch-arm-syscalls.c +0 -570
  507. data/ext/enterprise_script_service/libseccomp/src/arch-mips-syscalls.c +0 -562
  508. data/ext/enterprise_script_service/libseccomp/src/arch-mips64-syscalls.c +0 -562
  509. data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32-syscalls.c +0 -562
  510. data/ext/enterprise_script_service/libseccomp/src/arch-parisc-syscalls.c +0 -542
  511. data/ext/enterprise_script_service/libseccomp/src/arch-ppc-syscalls.c +0 -559
  512. data/ext/enterprise_script_service/libseccomp/src/arch-ppc64-syscalls.c +0 -559
  513. data/ext/enterprise_script_service/libseccomp/src/arch-s390-syscalls.c +0 -626
  514. data/ext/enterprise_script_service/libseccomp/src/arch-s390x-syscalls.c +0 -626
  515. data/ext/enterprise_script_service/libseccomp/src/arch-x32-syscalls.c +0 -558
  516. data/ext/enterprise_script_service/libseccomp/src/arch-x86-syscalls.c +0 -692
  517. data/ext/enterprise_script_service/libseccomp/src/arch-x86_64-syscalls.c +0 -559
  518. data/ext/enterprise_script_service/libseccomp/tests/18-sim-basic_whitelist.tests +0 -32
  519. data/ext/enterprise_script_service/libseccomp/tests/34-sim-basic_blacklist.tests +0 -32
  520. data/ext/enterprise_script_service/mruby/TODO +0 -8
  521. data/ext/enterprise_script_service/mruby/benchmark/build_config_boxing.rb +0 -28
  522. data/ext/enterprise_script_service/mruby/examples/targets/build_config_android_arm64-v8a.rb +0 -26
  523. data/ext/enterprise_script_service/mruby/examples/targets/build_config_android_armeabi.rb +0 -26
  524. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/kernel.c +0 -30
  525. data/ext/enterprise_script_service/mruby/mrblib/mrblib.rake +0 -18
  526. data/ext/enterprise_script_service/mruby/src/crc.c +0 -39
  527. data/ext/enterprise_script_service/mruby/src/mruby_core.rake +0 -19
  528. data/ext/enterprise_script_service/mruby/travis_config.rb +0 -54
  529. data/ext/enterprise_script_service/msgpack/.travis.yml +0 -258
@@ -6,7 +6,9 @@
6
6
 
7
7
  #include <stddef.h>
8
8
  #include <stdarg.h>
9
+ #ifndef MRB_NO_FLOAT
9
10
  #include <math.h>
11
+ #endif
10
12
  #include <mruby.h>
11
13
  #include <mruby/array.h>
12
14
  #include <mruby/class.h>
@@ -21,8 +23,10 @@
21
23
  #include <mruby/opcode.h>
22
24
  #include "value_array.h"
23
25
  #include <mruby/throw.h>
26
+ #include <mruby/dump.h>
27
+ #include <mruby/presym.h>
24
28
 
25
- #ifdef MRB_DISABLE_STDIO
29
+ #ifdef MRB_NO_STDIO
26
30
  #if defined(__cplusplus)
27
31
  extern "C" {
28
32
  #endif
@@ -35,14 +39,6 @@ void abort(void);
35
39
  #define STACK_INIT_SIZE 128
36
40
  #define CALLINFO_INIT_SIZE 32
37
41
 
38
- #ifndef ENSURE_STACK_INIT_SIZE
39
- #define ENSURE_STACK_INIT_SIZE 16
40
- #endif
41
-
42
- #ifndef RESCUE_STACK_INIT_SIZE
43
- #define RESCUE_STACK_INIT_SIZE 16
44
- #endif
45
-
46
42
  /* Define amount of linear stack growth. */
47
43
  #ifndef MRB_STACK_GROWTH
48
44
  #define MRB_STACK_GROWTH 128
@@ -53,11 +49,6 @@ void abort(void);
53
49
  #define MRB_FUNCALL_DEPTH_MAX 512
54
50
  #endif
55
51
 
56
- /* Maximum depth of ecall() recursion. */
57
- #ifndef MRB_ECALL_DEPTH_MAX
58
- #define MRB_ECALL_DEPTH_MAX 512
59
- #endif
60
-
61
52
  /* Maximum stack depth. Should be set lower on memory constrained systems.
62
53
  The value below allows about 60000 recursive calls in the simplest case. */
63
54
  #ifndef MRB_STACK_MAX
@@ -100,26 +91,20 @@ void mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value
100
91
  static inline void
101
92
  stack_clear(mrb_value *from, size_t count)
102
93
  {
103
- #ifndef MRB_NAN_BOXING
104
- const mrb_value mrb_value_zero = { { 0 } };
105
-
106
- while (count-- > 0) {
107
- *from++ = mrb_value_zero;
108
- }
109
- #else
94
+ #ifdef MRB_NAN_BOXING
110
95
  while (count-- > 0) {
111
96
  SET_NIL_VALUE(*from);
112
97
  from++;
113
98
  }
99
+ #else
100
+ memset(from, 0, sizeof(mrb_value)*count);
114
101
  #endif
115
102
  }
116
103
 
117
104
  static inline void
118
105
  stack_copy(mrb_value *dst, const mrb_value *src, size_t size)
119
106
  {
120
- while (size-- > 0) {
121
- *dst++ = *src++;
122
- }
107
+ memcpy(dst, src, sizeof(mrb_value)*size);
123
108
  }
124
109
 
125
110
  static void
@@ -130,14 +115,13 @@ stack_init(mrb_state *mrb)
130
115
  /* mrb_assert(mrb->stack == NULL); */
131
116
  c->stbase = (mrb_value *)mrb_calloc(mrb, STACK_INIT_SIZE, sizeof(mrb_value));
132
117
  c->stend = c->stbase + STACK_INIT_SIZE;
133
- c->stack = c->stbase;
134
118
 
135
119
  /* mrb_assert(ci == NULL); */
136
120
  c->cibase = (mrb_callinfo *)mrb_calloc(mrb, CALLINFO_INIT_SIZE, sizeof(mrb_callinfo));
137
121
  c->ciend = c->cibase + CALLINFO_INIT_SIZE;
138
122
  c->ci = c->cibase;
139
- c->ci->target_class = mrb->object_class;
140
- c->ci->stackent = c->stack;
123
+ c->ci->u.target_class = mrb->object_class;
124
+ c->ci->stack = c->stbase;
141
125
  }
142
126
 
143
127
  static inline void
@@ -147,20 +131,20 @@ envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase, size_t oldsize
147
131
 
148
132
  if (newbase == oldbase) return;
149
133
  while (ci <= mrb->c->ci) {
150
- struct REnv *e = ci->env;
134
+ struct REnv *e = mrb_vm_ci_env(ci);
151
135
  mrb_value *st;
152
136
 
153
- if (e && MRB_ENV_STACK_SHARED_P(e) &&
137
+ if (e && MRB_ENV_ONSTACK_P(e) &&
154
138
  (st = e->stack) && oldbase <= st && st < oldbase+oldsize) {
155
139
  ptrdiff_t off = e->stack - oldbase;
156
140
 
157
141
  e->stack = newbase + off;
158
142
  }
159
143
 
160
- if (ci->proc && MRB_PROC_ENV_P(ci->proc) && ci->env != MRB_PROC_ENV(ci->proc)) {
144
+ if (ci->proc && MRB_PROC_ENV_P(ci->proc) && e != MRB_PROC_ENV(ci->proc)) {
161
145
  e = MRB_PROC_ENV(ci->proc);
162
146
 
163
- if (e && MRB_ENV_STACK_SHARED_P(e) &&
147
+ if (e && MRB_ENV_ONSTACK_P(e) &&
164
148
  (st = e->stack) && oldbase <= st && st < oldbase+oldsize) {
165
149
  ptrdiff_t off = e->stack - oldbase;
166
150
 
@@ -168,7 +152,7 @@ envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase, size_t oldsize
168
152
  }
169
153
  }
170
154
 
171
- ci->stackent = newbase + (ci->stackent - oldbase);
155
+ ci->stack = newbase + (ci->stack - oldbase);
172
156
  ci++;
173
157
  }
174
158
  }
@@ -182,7 +166,7 @@ stack_extend_alloc(mrb_state *mrb, mrb_int room)
182
166
  mrb_value *newstack;
183
167
  size_t oldsize = mrb->c->stend - mrb->c->stbase;
184
168
  size_t size = oldsize;
185
- size_t off = mrb->c->stack - mrb->c->stbase;
169
+ size_t off = mrb->c->ci->stack ? mrb->c->stend - mrb->c->ci->stack : 0;
186
170
 
187
171
  if (off > size) size = off;
188
172
  #ifdef MRB_STACK_EXTEND_DOUBLING
@@ -200,14 +184,13 @@ stack_extend_alloc(mrb_state *mrb, mrb_int room)
200
184
  size += room;
201
185
  #endif
202
186
 
203
- newstack = (mrb_value *)mrb_realloc(mrb, mrb->c->stbase, sizeof(mrb_value) * size);
187
+ newstack = (mrb_value *)mrb_realloc_simple(mrb, mrb->c->stbase, sizeof(mrb_value) * size);
204
188
  if (newstack == NULL) {
205
189
  mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));
206
190
  }
207
191
  stack_clear(&(newstack[oldsize]), size - oldsize);
208
192
  envadjust(mrb, oldbase, newstack, oldsize);
209
193
  mrb->c->stbase = newstack;
210
- mrb->c->stack = mrb->c->stbase + off;
211
194
  mrb->c->stend = mrb->c->stbase + size;
212
195
 
213
196
  /* Raise an exception if the new stack size will be too large,
@@ -220,15 +203,15 @@ stack_extend_alloc(mrb_state *mrb, mrb_int room)
220
203
  MRB_API void
221
204
  mrb_stack_extend(mrb_state *mrb, mrb_int room)
222
205
  {
223
- if (mrb->c->stack + room >= mrb->c->stend) {
206
+ if (!mrb->c->ci->stack || mrb->c->ci->stack + room >= mrb->c->stend) {
224
207
  stack_extend_alloc(mrb, room);
225
208
  }
226
209
  }
227
210
 
228
211
  static inline struct REnv*
229
- uvenv(mrb_state *mrb, int up)
212
+ uvenv(mrb_state *mrb, mrb_int up)
230
213
  {
231
- struct RProc *proc = mrb->c->ci->proc;
214
+ const struct RProc *proc = mrb->c->ci->proc;
232
215
  struct REnv *e;
233
216
 
234
217
  while (up--) {
@@ -243,7 +226,7 @@ uvenv(mrb_state *mrb, int up)
243
226
 
244
227
  while (cb <= ci) {
245
228
  if (ci->proc == proc) {
246
- return ci->env;
229
+ return mrb_vm_ci_env(ci);
247
230
  }
248
231
  ci--;
249
232
  }
@@ -251,8 +234,8 @@ uvenv(mrb_state *mrb, int up)
251
234
  return NULL;
252
235
  }
253
236
 
254
- static inline struct RProc*
255
- top_proc(mrb_state *mrb, struct RProc *proc)
237
+ static inline const struct RProc*
238
+ top_proc(mrb_state *mrb, const struct RProc *proc)
256
239
  {
257
240
  while (proc->upper) {
258
241
  if (MRB_PROC_SCOPE_P(proc) || MRB_PROC_STRICT_P(proc))
@@ -267,14 +250,12 @@ top_proc(mrb_state *mrb, struct RProc *proc)
267
250
  #define CI_ACC_RESUMED -3
268
251
 
269
252
  static inline mrb_callinfo*
270
- cipush(mrb_state *mrb)
253
+ cipush(mrb_state *mrb, mrb_int push_stacks, mrb_int acc,
254
+ struct RClass *target_class, const struct RProc *proc, mrb_sym mid, mrb_int argc)
271
255
  {
272
256
  struct mrb_context *c = mrb->c;
273
- static const mrb_callinfo ci_zero = { 0 };
274
257
  mrb_callinfo *ci = c->ci;
275
258
 
276
- int ridx = ci->ridx;
277
-
278
259
  if (ci + 1 == c->ciend) {
279
260
  ptrdiff_t size = ci - c->cibase;
280
261
 
@@ -283,9 +264,12 @@ cipush(mrb_state *mrb)
283
264
  c->ciend = c->cibase + size * 2;
284
265
  }
285
266
  ci = ++c->ci;
286
- *ci = ci_zero;
287
- ci->epos = mrb->c->eidx;
288
- ci->ridx = ridx;
267
+ ci->mid = mid;
268
+ mrb_vm_ci_proc_set(ci, proc);
269
+ ci->stack = ci[-1].stack + push_stacks;
270
+ ci->argc = (int16_t)argc;
271
+ ci->acc = (int16_t)acc;
272
+ ci->u.target_class = target_class;
289
273
 
290
274
  return ci;
291
275
  }
@@ -295,86 +279,35 @@ mrb_env_unshare(mrb_state *mrb, struct REnv *e)
295
279
  {
296
280
  if (e == NULL) return;
297
281
  else {
298
- size_t len = (size_t)MRB_ENV_STACK_LEN(e);
282
+ size_t len = (size_t)MRB_ENV_LEN(e);
299
283
  mrb_value *p;
300
284
 
301
- if (!MRB_ENV_STACK_SHARED_P(e)) return;
285
+ if (!MRB_ENV_ONSTACK_P(e)) return;
302
286
  if (e->cxt != mrb->c) return;
303
- if (e == mrb->c->cibase->env) return; /* for mirb */
287
+ if (e == mrb_vm_ci_env(mrb->c->cibase)) return; /* for mirb */
304
288
  p = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value)*len);
305
289
  if (len > 0) {
306
290
  stack_copy(p, e->stack, len);
307
291
  }
308
292
  e->stack = p;
309
- MRB_ENV_UNSHARE_STACK(e);
293
+ MRB_ENV_CLOSE(e);
310
294
  mrb_write_barrier(mrb, (struct RBasic *)e);
311
295
  }
312
296
  }
313
297
 
314
- static inline void
298
+ static inline mrb_callinfo*
315
299
  cipop(mrb_state *mrb)
316
300
  {
317
301
  struct mrb_context *c = mrb->c;
318
- struct REnv *env = c->ci->env;
302
+ struct REnv *env = mrb_vm_ci_env(c->ci);
319
303
 
320
304
  c->ci--;
321
305
  if (env) mrb_env_unshare(mrb, env);
306
+ return c->ci;
322
307
  }
323
308
 
324
309
  void mrb_exc_set(mrb_state *mrb, mrb_value exc);
325
-
326
- static void
327
- ecall(mrb_state *mrb)
328
- {
329
- struct RProc *p;
330
- struct mrb_context *c = mrb->c;
331
- mrb_callinfo *ci = c->ci;
332
- struct RObject *exc;
333
- struct REnv *env;
334
- ptrdiff_t cioff;
335
- int ai = mrb_gc_arena_save(mrb);
336
- uint16_t i = --c->eidx;
337
- int nregs;
338
-
339
- if (i<0) return;
340
- /* restrict total call depth of ecall() */
341
- if (++mrb->ecall_nest > MRB_ECALL_DEPTH_MAX) {
342
- mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));
343
- }
344
- p = c->ensure[i];
345
- if (!p) return;
346
- mrb_assert(!MRB_PROC_CFUNC_P(p));
347
- c->ensure[i] = NULL;
348
- nregs = p->upper->body.irep->nregs;
349
- if (ci->proc && !MRB_PROC_CFUNC_P(ci->proc) &&
350
- ci->proc->body.irep->nregs > nregs) {
351
- nregs = ci->proc->body.irep->nregs;
352
- }
353
- cioff = ci - c->cibase;
354
- ci = cipush(mrb);
355
- ci->stackent = mrb->c->stack;
356
- ci->mid = ci[-1].mid;
357
- ci->acc = CI_ACC_SKIP;
358
- ci->argc = 0;
359
- ci->proc = p;
360
- ci->target_class = MRB_PROC_TARGET_CLASS(p);
361
- env = MRB_PROC_ENV(p);
362
- mrb_assert(env);
363
- c->stack += nregs;
364
- exc = mrb->exc; mrb->exc = 0;
365
- if (exc) {
366
- mrb_gc_protect(mrb, mrb_obj_value(exc));
367
- }
368
- if (mrb->c->fib) {
369
- mrb_gc_protect(mrb, mrb_obj_value(mrb->c->fib));
370
- }
371
- mrb_run(mrb, p, env->stack[0]);
372
- mrb->c = c;
373
- c->ci = c->cibase + cioff;
374
- if (!mrb->exc) mrb->exc = exc;
375
- mrb_gc_arena_restore(mrb, ai);
376
- mrb->ecall_nest--;
377
- }
310
+ static mrb_value mrb_run(mrb_state *mrb, const struct RProc* proc, mrb_value self);
378
311
 
379
312
  #ifndef MRB_FUNCALL_ARGC_MAX
380
313
  #define MRB_FUNCALL_ARGC_MAX 16
@@ -400,11 +333,30 @@ mrb_funcall(mrb_state *mrb, mrb_value self, const char *name, mrb_int argc, ...)
400
333
  return mrb_funcall_argv(mrb, self, mid, argc, argv);
401
334
  }
402
335
 
403
- static int
336
+ MRB_API mrb_value
337
+ mrb_funcall_id(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc, ...)
338
+ {
339
+ mrb_value argv[MRB_FUNCALL_ARGC_MAX];
340
+ va_list ap;
341
+ mrb_int i;
342
+
343
+ if (argc > MRB_FUNCALL_ARGC_MAX) {
344
+ mrb_raise(mrb, E_ARGUMENT_ERROR, "Too long arguments. (limit=" MRB_STRINGIZE(MRB_FUNCALL_ARGC_MAX) ")");
345
+ }
346
+
347
+ va_start(ap, argc);
348
+ for (i = 0; i < argc; i++) {
349
+ argv[i] = va_arg(ap, mrb_value);
350
+ }
351
+ va_end(ap);
352
+ return mrb_funcall_argv(mrb, self, mid, argc, argv);
353
+ }
354
+
355
+ static mrb_int
404
356
  ci_nregs(mrb_callinfo *ci)
405
357
  {
406
- struct RProc *p;
407
- int n = 0;
358
+ const struct RProc *p;
359
+ mrb_int n = 0;
408
360
 
409
361
  if (!ci) return 3;
410
362
  p = ci->proc;
@@ -428,6 +380,7 @@ MRB_API mrb_value
428
380
  mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc, const mrb_value *argv, mrb_value blk)
429
381
  {
430
382
  mrb_value val;
383
+ int ai = mrb_gc_arena_save(mrb);
431
384
 
432
385
  if (!mrb->jmp) {
433
386
  struct mrb_jmpbuf c_jmp;
@@ -441,7 +394,6 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc
441
394
  }
442
395
  MRB_CATCH(&c_jmp) { /* error */
443
396
  while (nth_ci < (mrb->c->ci - mrb->c->cibase)) {
444
- mrb->c->stack = mrb->c->ci->stackent;
445
397
  cipop(mrb);
446
398
  }
447
399
  mrb->jmp = 0;
@@ -454,10 +406,10 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc
454
406
  mrb_method_t m;
455
407
  struct RClass *c;
456
408
  mrb_callinfo *ci;
457
- int n = ci_nregs(mrb->c->ci);
409
+ mrb_int n = ci_nregs(mrb->c->ci);
458
410
  ptrdiff_t voff = -1;
459
411
 
460
- if (!mrb->c->stack) {
412
+ if (!mrb->c->stbase) {
461
413
  stack_init(mrb);
462
414
  }
463
415
  if (argc < 0) {
@@ -466,7 +418,7 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc
466
418
  c = mrb_class(mrb, self);
467
419
  m = mrb_method_search_vm(mrb, &c, mid);
468
420
  if (MRB_METHOD_UNDEF_P(m)) {
469
- mrb_sym missing = mrb_intern_lit(mrb, "method_missing");
421
+ mrb_sym missing = MRB_SYM(method_missing);
470
422
  mrb_value args = mrb_ary_new_from_values(mrb, argc, argv);
471
423
  m = mrb_method_search_vm(mrb, &c, missing);
472
424
  if (MRB_METHOD_UNDEF_P(m)) {
@@ -474,18 +426,13 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc
474
426
  }
475
427
  mrb_ary_unshift(mrb, args, mrb_symbol_value(mid));
476
428
  mrb_stack_extend(mrb, n+2);
477
- mrb->c->stack[n+1] = args;
429
+ mrb->c->ci->stack[n+1] = args;
478
430
  argc = -1;
479
431
  }
480
432
  if (mrb->c->ci - mrb->c->cibase > MRB_FUNCALL_DEPTH_MAX) {
481
433
  mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));
482
434
  }
483
- ci = cipush(mrb);
484
- ci->mid = mid;
485
- ci->stackent = mrb->c->stack;
486
- ci->argc = (int)argc;
487
- ci->target_class = c;
488
- mrb->c->stack = mrb->c->stack + n;
435
+ ci = cipush(mrb, n, 0, c, NULL, mid, argc);
489
436
  if (argc < 0) argc = 1;
490
437
  if (mrb->c->stbase <= argv && argv < mrb->c->stend) {
491
438
  voff = argv - mrb->c->stbase;
@@ -493,7 +440,7 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc
493
440
  if (argc >= CALL_MAXARGS) {
494
441
  mrb_value args = mrb_ary_new_from_values(mrb, argc, argv);
495
442
 
496
- mrb->c->stack[1] = args;
443
+ mrb->c->ci->stack[1] = args;
497
444
  ci->argc = -1;
498
445
  argc = 1;
499
446
  }
@@ -501,7 +448,7 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc
501
448
  if (MRB_METHOD_PROC_P(m)) {
502
449
  struct RProc *p = MRB_METHOD_PROC(m);
503
450
 
504
- ci->proc = p;
451
+ mrb_vm_ci_proc_set(ci, p);
505
452
  if (!MRB_PROC_CFUNC_P(p)) {
506
453
  mrb_stack_extend(mrb, p->body.irep->nregs + argc);
507
454
  }
@@ -509,26 +456,23 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc
509
456
  if (voff >= 0) {
510
457
  argv = mrb->c->stbase + voff;
511
458
  }
512
- mrb->c->stack[0] = self;
459
+ mrb->c->ci->stack[0] = self;
513
460
  if (ci->argc > 0) {
514
- stack_copy(mrb->c->stack+1, argv, argc);
461
+ stack_copy(mrb->c->ci->stack+1, argv, argc);
515
462
  }
516
- mrb->c->stack[argc+1] = blk;
463
+ mrb->c->ci->stack[argc+1] = blk;
517
464
 
518
465
  if (MRB_METHOD_CFUNC_P(m)) {
519
- int ai = mrb_gc_arena_save(mrb);
520
-
521
466
  ci->acc = CI_ACC_DIRECT;
522
467
  val = MRB_METHOD_CFUNC(m)(mrb, self);
523
- mrb->c->stack = mrb->c->ci->stackent;
524
468
  cipop(mrb);
525
- mrb_gc_arena_restore(mrb, ai);
526
469
  }
527
470
  else {
528
471
  ci->acc = CI_ACC_SKIP;
529
472
  val = mrb_run(mrb, MRB_METHOD_PROC(m), self);
530
473
  }
531
474
  }
475
+ mrb_gc_arena_restore(mrb, ai);
532
476
  mrb_gc_protect(mrb, val);
533
477
  return val;
534
478
  }
@@ -543,10 +487,10 @@ mrb_value
543
487
  mrb_exec_irep(mrb_state *mrb, mrb_value self, struct RProc *p)
544
488
  {
545
489
  mrb_callinfo *ci = mrb->c->ci;
546
- int keep, nregs;
490
+ mrb_int keep, nregs;
547
491
 
548
- mrb->c->stack[0] = self;
549
- ci->proc = p;
492
+ mrb->c->ci->stack[0] = self;
493
+ mrb_vm_ci_proc_set(ci, p);
550
494
  if (MRB_PROC_CFUNC_P(p)) {
551
495
  return MRB_PROC_CFUNC(p)(mrb, self);
552
496
  }
@@ -558,14 +502,10 @@ mrb_exec_irep(mrb_state *mrb, mrb_value self, struct RProc *p)
558
502
  }
559
503
  else {
560
504
  mrb_stack_extend(mrb, nregs);
561
- stack_clear(mrb->c->stack+keep, nregs-keep);
505
+ stack_clear(mrb->c->ci->stack+keep, nregs-keep);
562
506
  }
563
507
 
564
- ci = cipush(mrb);
565
- ci->target_class = 0;
566
- ci->pc = p->body.irep->iseq;
567
- ci->stackent = mrb->c->stack;
568
- ci->acc = 0;
508
+ cipush(mrb, 0, 0, NULL, NULL, 0, 0);
569
509
 
570
510
  return self;
571
511
  }
@@ -593,7 +533,8 @@ mrb_value
593
533
  mrb_f_send(mrb_state *mrb, mrb_value self)
594
534
  {
595
535
  mrb_sym name;
596
- mrb_value block, *argv, *regs;
536
+ mrb_value block, *regs;
537
+ const mrb_value *argv;
597
538
  mrb_int argc, i, len;
598
539
  mrb_method_t m;
599
540
  struct RClass *c;
@@ -613,8 +554,8 @@ mrb_f_send(mrb_state *mrb, mrb_value self)
613
554
  }
614
555
 
615
556
  ci->mid = name;
616
- ci->target_class = c;
617
- regs = mrb->c->stack+1;
557
+ ci->u.target_class = c;
558
+ regs = mrb->c->ci->stack+1;
618
559
  /* remove first symbol from arguments */
619
560
  if (ci->argc >= 0) {
620
561
  for (i=0,len=ci->argc; i<len; i++) {
@@ -623,12 +564,12 @@ mrb_f_send(mrb_state *mrb, mrb_value self)
623
564
  ci->argc--;
624
565
  }
625
566
  else { /* variable length arguments */
626
- mrb_ary_shift(mrb, regs[0]);
567
+ regs[0] = mrb_ary_subseq(mrb, regs[0], 1, RARRAY_LEN(regs[0]) - 1);
627
568
  }
628
569
 
629
570
  if (MRB_METHOD_CFUNC_P(m)) {
630
571
  if (MRB_METHOD_PROC_P(m)) {
631
- ci->proc = MRB_METHOD_PROC(m);
572
+ mrb_vm_ci_proc_set(ci, MRB_METHOD_PROC(m));
632
573
  }
633
574
  return MRB_METHOD_CFUNC(m)(mrb, self);
634
575
  }
@@ -647,32 +588,27 @@ eval_under(mrb_state *mrb, mrb_value self, mrb_value blk, struct RClass *c)
647
588
  }
648
589
  ci = mrb->c->ci;
649
590
  if (ci->acc == CI_ACC_DIRECT) {
650
- ci->target_class = c;
651
- return mrb_yield_cont(mrb, blk, self, 1, &self);
591
+ return mrb_yield_with_class(mrb, blk, 1, &self, self, c);
652
592
  }
653
- ci->target_class = c;
593
+ ci->u.target_class = c;
654
594
  p = mrb_proc_ptr(blk);
655
- ci->proc = p;
595
+ mrb_vm_ci_proc_set(ci, p);
656
596
  ci->argc = 1;
657
597
  ci->mid = ci[-1].mid;
658
598
  if (MRB_PROC_CFUNC_P(p)) {
659
599
  mrb_stack_extend(mrb, 3);
660
- mrb->c->stack[0] = self;
661
- mrb->c->stack[1] = self;
662
- mrb->c->stack[2] = mrb_nil_value();
600
+ mrb->c->ci->stack[0] = self;
601
+ mrb->c->ci->stack[1] = self;
602
+ mrb->c->ci->stack[2] = mrb_nil_value();
663
603
  return MRB_PROC_CFUNC(p)(mrb, self);
664
604
  }
665
605
  nregs = p->body.irep->nregs;
666
606
  if (nregs < 3) nregs = 3;
667
607
  mrb_stack_extend(mrb, nregs);
668
- mrb->c->stack[0] = self;
669
- mrb->c->stack[1] = self;
670
- stack_clear(mrb->c->stack+2, nregs-2);
671
- ci = cipush(mrb);
672
- ci->target_class = 0;
673
- ci->pc = p->body.irep->iseq;
674
- ci->stackent = mrb->c->stack;
675
- ci->acc = 0;
608
+ mrb->c->ci->stack[0] = self;
609
+ mrb->c->ci->stack[1] = self;
610
+ stack_clear(mrb->c->ci->stack+2, nregs-2);
611
+ ci = cipush(mrb, 0, 0, NULL, NULL, 0, 0);
676
612
 
677
613
  return self;
678
614
  }
@@ -723,26 +659,11 @@ mrb_value
723
659
  mrb_obj_instance_eval(mrb_state *mrb, mrb_value self)
724
660
  {
725
661
  mrb_value a, b;
726
- mrb_value cv;
727
- struct RClass *c;
728
662
 
729
663
  if (mrb_get_args(mrb, "|S&", &a, &b) == 1) {
730
664
  mrb_raise(mrb, E_NOTIMP_ERROR, "instance_eval with string not implemented");
731
665
  }
732
- switch (mrb_type(self)) {
733
- case MRB_TT_SYMBOL:
734
- case MRB_TT_FIXNUM:
735
- #ifndef MRB_WITHOUT_FLOAT
736
- case MRB_TT_FLOAT:
737
- #endif
738
- c = 0;
739
- break;
740
- default:
741
- cv = mrb_singleton_class(mrb, self);
742
- c = mrb_class_ptr(cv);
743
- break;
744
- }
745
- return eval_under(mrb, self, b, c);
666
+ return eval_under(mrb, self, b, mrb_singleton_class_ptr(mrb, self));
746
667
  }
747
668
 
748
669
  MRB_API mrb_value
@@ -752,7 +673,7 @@ mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value
752
673
  mrb_sym mid = mrb->c->ci->mid;
753
674
  mrb_callinfo *ci;
754
675
  mrb_value val;
755
- int n;
676
+ mrb_int n;
756
677
 
757
678
  if (mrb_nil_p(b)) {
758
679
  mrb_raise(mrb, E_ARGUMENT_ERROR, "no block given");
@@ -763,26 +684,28 @@ mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value
763
684
  mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));
764
685
  }
765
686
  p = mrb_proc_ptr(b);
766
- ci = cipush(mrb);
767
- ci->mid = mid;
768
- ci->proc = p;
769
- ci->stackent = mrb->c->stack;
770
- ci->argc = (int)argc;
771
- ci->target_class = c;
772
- ci->acc = CI_ACC_SKIP;
773
- n = MRB_PROC_CFUNC_P(p) ? (int)(argc+2) : p->body.irep->nregs;
774
- mrb->c->stack = mrb->c->stack + n;
687
+ ci = cipush(mrb, n, CI_ACC_SKIP, c, p, mid, 0 /* dummy */);
688
+ if (argc >= CALL_MAXARGS) {
689
+ ci->argc = -1;
690
+ n = 3;
691
+ }
692
+ else {
693
+ ci->argc = (int)argc;
694
+ n = argc + 2;
695
+ }
775
696
  mrb_stack_extend(mrb, n);
776
-
777
- mrb->c->stack[0] = self;
778
- if (argc > 0) {
779
- stack_copy(mrb->c->stack+1, argv, argc);
697
+ mrb->c->ci->stack[0] = self;
698
+ if (ci->argc < 0) {
699
+ mrb->c->ci->stack[1] = mrb_ary_new_from_values(mrb, argc, argv);
700
+ argc = 1;
701
+ }
702
+ else if (argc > 0) {
703
+ stack_copy(mrb->c->ci->stack+1, argv, argc);
780
704
  }
781
- mrb->c->stack[argc+1] = mrb_nil_value();
705
+ mrb->c->ci->stack[argc+1] = mrb_nil_value();
782
706
 
783
707
  if (MRB_PROC_CFUNC_P(p)) {
784
708
  val = MRB_PROC_CFUNC(p)(mrb, self);
785
- mrb->c->stack = mrb->c->ci->stackent;
786
709
  cipop(mrb);
787
710
  }
788
711
  else {
@@ -824,24 +747,63 @@ mrb_yield_cont(mrb_state *mrb, mrb_value b, mrb_value self, mrb_int argc, const
824
747
  ci = mrb->c->ci;
825
748
 
826
749
  mrb_stack_extend(mrb, 3);
827
- mrb->c->stack[1] = mrb_ary_new_from_values(mrb, argc, argv);
828
- mrb->c->stack[2] = mrb_nil_value();
750
+ mrb->c->ci->stack[1] = mrb_ary_new_from_values(mrb, argc, argv);
751
+ mrb->c->ci->stack[2] = mrb_nil_value();
829
752
  ci->argc = -1;
830
753
  return mrb_exec_irep(mrb, self, p);
831
754
  }
832
755
 
833
756
  static struct RBreak*
834
- break_new(mrb_state *mrb, struct RProc *p, mrb_value val)
757
+ break_new(mrb_state *mrb, uint32_t tag, const struct RProc *p, mrb_value val)
835
758
  {
836
759
  struct RBreak *brk;
837
760
 
838
761
  brk = (struct RBreak*)mrb_obj_alloc(mrb, MRB_TT_BREAK, NULL);
839
762
  mrb_break_proc_set(brk, p);
840
763
  mrb_break_value_set(brk, val);
764
+ mrb_break_tag_set(brk, tag);
841
765
 
842
766
  return brk;
843
767
  }
844
768
 
769
+ #define MRB_CATCH_FILTER_RESCUE (UINT32_C(1) << MRB_CATCH_RESCUE)
770
+ #define MRB_CATCH_FILTER_ENSURE (UINT32_C(1) << MRB_CATCH_ENSURE)
771
+ #define MRB_CATCH_FILTER_ALL (MRB_CATCH_FILTER_RESCUE | MRB_CATCH_FILTER_ENSURE)
772
+
773
+ static const struct mrb_irep_catch_handler *
774
+ catch_handler_find(mrb_state *mrb, mrb_callinfo *ci, const mrb_code *pc, uint32_t filter)
775
+ {
776
+ const mrb_irep *irep;
777
+ ptrdiff_t xpc;
778
+ size_t cnt;
779
+ const struct mrb_irep_catch_handler *e;
780
+
781
+ /* The comparison operators use `>` and `<=` because pc already points to the next instruction */
782
+ #define catch_cover_p(pc, beg, end) ((pc) > (ptrdiff_t)(beg) && (pc) <= (ptrdiff_t)(end))
783
+
784
+ if (ci->proc == NULL || MRB_PROC_CFUNC_P(ci->proc)) return NULL;
785
+ irep = ci->proc->body.irep;
786
+ if (irep->clen < 1) return NULL;
787
+ xpc = pc - irep->iseq;
788
+ /* If it retry at the top level, pc will be 0, so check with -1 as the start position */
789
+ mrb_assert(catch_cover_p(xpc, -1, irep->ilen));
790
+ if (!catch_cover_p(xpc, -1, irep->ilen)) return NULL;
791
+
792
+ /* Currently uses a simple linear search to avoid processing complexity. */
793
+ cnt = irep->clen;
794
+ e = mrb_irep_catch_handler_table(irep) + cnt - 1;
795
+ for (; cnt > 0; cnt --, e --) {
796
+ if (((UINT32_C(1) << e->type) & filter) &&
797
+ catch_cover_p(xpc, mrb_irep_catch_handler_unpack(e->begin), mrb_irep_catch_handler_unpack(e->end))) {
798
+ return e;
799
+ }
800
+ }
801
+
802
+ #undef catch_cover_p
803
+
804
+ return NULL;
805
+ }
806
+
845
807
  typedef enum {
846
808
  LOCALJUMP_ERROR_RETURN = 0,
847
809
  LOCALJUMP_ERROR_BREAK = 1,
@@ -872,7 +834,7 @@ argnum_error(mrb_state *mrb, mrb_int num)
872
834
  mrb_int argc = mrb->c->ci->argc;
873
835
 
874
836
  if (argc < 0) {
875
- mrb_value args = mrb->c->stack[1];
837
+ mrb_value args = mrb->c->ci->stack[1];
876
838
  if (mrb_array_p(args)) {
877
839
  argc = RARRAY_LEN(args);
878
840
  }
@@ -888,9 +850,71 @@ argnum_error(mrb_state *mrb, mrb_int num)
888
850
  mrb_exc_set(mrb, exc);
889
851
  }
890
852
 
891
- #define ERR_PC_SET(mrb) mrb->c->ci->err = pc0;
892
- #define ERR_PC_CLR(mrb) mrb->c->ci->err = 0;
893
- #ifdef MRB_ENABLE_DEBUG_HOOK
853
+ static mrb_bool
854
+ break_tag_p(struct RBreak *brk, uint32_t tag)
855
+ {
856
+ return (brk != NULL && brk->tt == MRB_TT_BREAK) ? TRUE : FALSE;
857
+ }
858
+
859
+ static void
860
+ prepare_tagged_break(mrb_state *mrb, uint32_t tag, const struct RProc *proc, mrb_value val)
861
+ {
862
+ if (break_tag_p((struct RBreak*)mrb->exc, tag)) {
863
+ mrb_break_tag_set((struct RBreak*)mrb->exc, tag);
864
+ }
865
+ else {
866
+ mrb->exc = (struct RObject*)break_new(mrb, tag, proc, val);
867
+ }
868
+ }
869
+
870
+ #define THROW_TAGGED_BREAK(mrb, tag, proc, val) \
871
+ do { \
872
+ prepare_tagged_break(mrb, tag, proc, val); \
873
+ goto L_CATCH_TAGGED_BREAK; \
874
+ } while (0)
875
+
876
+ #define UNWIND_ENSURE(mrb, ci, pc, tag, proc, val) \
877
+ do { \
878
+ ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ENSURE); \
879
+ if (ch) { \
880
+ THROW_TAGGED_BREAK(mrb, tag, proc, val); \
881
+ } \
882
+ } while (0)
883
+
884
+ /*
885
+ * CHECKPOINT_RESTORE(tag) {
886
+ * This part is executed when jumping by the same "tag" of RBreak (it is not executed the first time).
887
+ * Write the code required (initialization of variables, etc.) for the subsequent processing.
888
+ * }
889
+ * CHECKPOINT_MAIN(tag) {
890
+ * This part is always executed.
891
+ * }
892
+ * CHECKPOINT_END(tag);
893
+ *
894
+ * ...
895
+ *
896
+ * // Jump to CHECKPOINT_RESTORE with the same "tag".
897
+ * goto CHECKPOINT_LABEL_MAKE(tag);
898
+ */
899
+
900
+ #define CHECKPOINT_LABEL_MAKE(tag) L_CHECKPOINT_ ## tag
901
+
902
+ #define CHECKPOINT_RESTORE(tag) \
903
+ do { \
904
+ if (FALSE) { \
905
+ CHECKPOINT_LABEL_MAKE(tag): \
906
+ do {
907
+
908
+ #define CHECKPOINT_MAIN(tag) \
909
+ } while (0); \
910
+ } \
911
+ do {
912
+
913
+ #define CHECKPOINT_END(tag) \
914
+ } while (0); \
915
+ } while (0)
916
+
917
+ #ifdef MRB_USE_DEBUG_HOOK
894
918
  #define CODE_FETCH_HOOK(mrb, irep, pc, regs) if ((mrb)->code_fetch_hook) (mrb)->code_fetch_hook((mrb), (irep), (pc), (regs));
895
919
  #else
896
920
  #define CODE_FETCH_HOOK(mrb, irep, pc, regs)
@@ -902,24 +926,24 @@ argnum_error(mrb_state *mrb, mrb_int num)
902
926
  #define BYTECODE_DECODER(x) (x)
903
927
  #endif
904
928
 
905
- #ifndef MRB_DISABLE_DIRECT_THREADING
929
+ #ifndef MRB_NO_DIRECT_THREADING
906
930
  #if defined __GNUC__ || defined __clang__ || defined __INTEL_COMPILER
907
931
  #define DIRECT_THREADED
908
932
  #endif
909
- #endif /* ifndef MRB_DISABLE_DIRECT_THREADING */
933
+ #endif /* ifndef MRB_NO_DIRECT_THREADING */
910
934
 
911
935
  #ifndef DIRECT_THREADED
912
936
 
913
937
  #define INIT_DISPATCH for (;;) { insn = BYTECODE_DECODER(*pc); CODE_FETCH_HOOK(mrb, irep, pc, regs); switch (insn) {
914
- #define CASE(insn,ops) case insn: pc0=pc++; FETCH_ ## ops ();; L_ ## insn ## _BODY:
915
- #define NEXT break
938
+ #define CASE(insn,ops) case insn: pc++; FETCH_ ## ops (); mrb->c->ci->pc = pc;
939
+ #define NEXT goto L_END_DISPATCH
916
940
  #define JUMP NEXT
917
- #define END_DISPATCH }}
941
+ #define END_DISPATCH L_END_DISPATCH:;}}
918
942
 
919
943
  #else
920
944
 
921
945
  #define INIT_DISPATCH JUMP; return mrb_nil_value();
922
- #define CASE(insn,ops) L_ ## insn: pc0=pc++; FETCH_ ## ops (); L_ ## insn ## _BODY:
946
+ #define CASE(insn,ops) L_ ## insn: pc++; FETCH_ ## ops (); mrb->c->ci->pc = pc;
923
947
  #define NEXT insn=BYTECODE_DECODER(*pc); CODE_FETCH_HOOK(mrb, irep, pc, regs); goto *optable[insn]
924
948
  #define JUMP NEXT
925
949
 
@@ -928,22 +952,22 @@ argnum_error(mrb_state *mrb, mrb_int num)
928
952
  #endif
929
953
 
930
954
  MRB_API mrb_value
931
- mrb_vm_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep)
955
+ mrb_vm_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int stack_keep)
932
956
  {
933
- mrb_irep *irep = proc->body.irep;
957
+ const mrb_irep *irep = proc->body.irep;
934
958
  mrb_value result;
935
959
  struct mrb_context *c = mrb->c;
936
960
  ptrdiff_t cioff = c->ci - c->cibase;
937
- unsigned int nregs = irep->nregs;
961
+ mrb_int nregs = irep->nregs;
938
962
 
939
- if (!c->stack) {
963
+ if (!c->stbase) {
940
964
  stack_init(mrb);
941
965
  }
942
966
  if (stack_keep > nregs)
943
967
  nregs = stack_keep;
944
968
  mrb_stack_extend(mrb, nregs);
945
- stack_clear(c->stack + stack_keep, nregs - stack_keep);
946
- c->stack[0] = self;
969
+ stack_clear(c->ci->stack + stack_keep, nregs - stack_keep);
970
+ c->ci->stack[0] = self;
947
971
  result = mrb_vm_exec(mrb, proc, irep->iseq);
948
972
  if (mrb->c != c) {
949
973
  if (mrb->c->fib) {
@@ -960,8 +984,8 @@ mrb_vm_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stac
960
984
  static mrb_bool
961
985
  check_target_class(mrb_state *mrb)
962
986
  {
963
- if (!mrb->c->ci->target_class) {
964
- mrb_value exc = mrb_exc_new_str_lit(mrb, E_TYPE_ERROR, "no target class or module");
987
+ if (!mrb_vm_ci_target_class(mrb->c->ci)) {
988
+ mrb_value exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR, "no target class or module");
965
989
  mrb_exc_set(mrb, exc);
966
990
  return FALSE;
967
991
  }
@@ -971,21 +995,21 @@ check_target_class(mrb_state *mrb)
971
995
  void mrb_hash_check_kdict(mrb_state *mrb, mrb_value self);
972
996
 
973
997
  MRB_API mrb_value
974
- mrb_vm_exec(mrb_state *mrb, struct RProc *proc, const mrb_code *pc)
998
+ mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc)
975
999
  {
976
1000
  /* mrb_assert(MRB_PROC_CFUNC_P(proc)) */
977
- const mrb_code *pc0 = pc;
978
- mrb_irep *irep = proc->body.irep;
979
- mrb_value *pool = irep->pool;
980
- mrb_sym *syms = irep->syms;
1001
+ const mrb_irep *irep = proc->body.irep;
1002
+ const mrb_pool_value *pool = irep->pool;
1003
+ const mrb_sym *syms = irep->syms;
981
1004
  mrb_code insn;
982
1005
  int ai = mrb_gc_arena_save(mrb);
983
1006
  struct mrb_jmpbuf *prev_jmp = mrb->jmp;
984
1007
  struct mrb_jmpbuf c_jmp;
985
1008
  uint32_t a;
986
1009
  uint16_t b;
987
- uint8_t c;
1010
+ uint16_t c;
988
1011
  mrb_sym mid;
1012
+ const struct mrb_irep_catch_handler *ch;
989
1013
 
990
1014
  #ifdef DIRECT_THREADED
991
1015
  static void *optable[] = {
@@ -1008,9 +1032,9 @@ RETRY_TRY_BLOCK:
1008
1032
  goto L_RAISE;
1009
1033
  }
1010
1034
  mrb->jmp = &c_jmp;
1011
- mrb->c->ci->proc = proc;
1035
+ mrb_vm_ci_proc_set(mrb->c->ci, proc);
1012
1036
 
1013
- #define regs (mrb->c->stack)
1037
+ #define regs (mrb->c->ci->stack)
1014
1038
  INIT_DISPATCH {
1015
1039
  CASE(OP_NOP, Z) {
1016
1040
  /* do nothing */
@@ -1022,28 +1046,48 @@ RETRY_TRY_BLOCK:
1022
1046
  NEXT;
1023
1047
  }
1024
1048
 
1049
+ CASE(OP_LOADL16, BS) {
1050
+ goto op_loadl;
1051
+ }
1025
1052
  CASE(OP_LOADL, BB) {
1026
- #ifdef MRB_WORD_BOXING
1027
- mrb_value val = pool[b];
1028
- #ifndef MRB_WITHOUT_FLOAT
1029
- if (mrb_float_p(val)) {
1030
- val = mrb_float_value(mrb, mrb_float(val));
1031
- }
1032
- #endif
1033
- regs[a] = val;
1053
+ op_loadl:
1054
+ switch (pool[b].tt) { /* number */
1055
+ case IREP_TT_INT32:
1056
+ regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i32);
1057
+ break;
1058
+ case IREP_TT_INT64:
1059
+ #if defined(MRB_INT64)
1060
+ regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);
1061
+ break;
1034
1062
  #else
1035
- regs[a] = pool[b];
1063
+ #if defined(MRB_64BIT)
1064
+ if (INT32_MIN <= pool[b].u.i64 && pool[b].u.i64 <= INT32_MAX) {
1065
+ regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);
1066
+ break;
1067
+ }
1068
+ #endif
1069
+ goto L_INT_OVERFLOW;
1036
1070
  #endif
1071
+ #ifndef MRB_NO_FLOAT
1072
+ case IREP_TT_FLOAT:
1073
+ regs[a] = mrb_float_value(mrb, pool[b].u.f);
1074
+ break;
1075
+ #endif
1076
+ default:
1077
+ /* should not happen (tt:string) */
1078
+ regs[a] = mrb_nil_value();
1079
+ break;
1080
+ }
1037
1081
  NEXT;
1038
1082
  }
1039
1083
 
1040
1084
  CASE(OP_LOADI, BB) {
1041
- SET_INT_VALUE(regs[a], b);
1085
+ SET_FIXNUM_VALUE(regs[a], b);
1042
1086
  NEXT;
1043
1087
  }
1044
1088
 
1045
1089
  CASE(OP_LOADINEG, BB) {
1046
- SET_INT_VALUE(regs[a], -b);
1090
+ SET_FIXNUM_VALUE(regs[a], -b);
1047
1091
  NEXT;
1048
1092
  }
1049
1093
 
@@ -1057,7 +1101,17 @@ RETRY_TRY_BLOCK:
1057
1101
  CASE(OP_LOADI_6,B) goto L_LOADI;
1058
1102
  CASE(OP_LOADI_7, B) {
1059
1103
  L_LOADI:
1060
- SET_INT_VALUE(regs[a], (mrb_int)insn - (mrb_int)OP_LOADI_0);
1104
+ SET_FIXNUM_VALUE(regs[a], (mrb_int)insn - (mrb_int)OP_LOADI_0);
1105
+ NEXT;
1106
+ }
1107
+
1108
+ CASE(OP_LOADI16, BS) {
1109
+ SET_FIXNUM_VALUE(regs[a], (mrb_int)(int16_t)b);
1110
+ NEXT;
1111
+ }
1112
+
1113
+ CASE(OP_LOADI32, BSS) {
1114
+ SET_INT_VALUE(mrb, regs[a], (int32_t)(((uint32_t)b<<16)+c));
1061
1115
  NEXT;
1062
1116
  }
1063
1117
 
@@ -1066,6 +1120,11 @@ RETRY_TRY_BLOCK:
1066
1120
  NEXT;
1067
1121
  }
1068
1122
 
1123
+ CASE(OP_LOADSYM16, BS) {
1124
+ SET_SYM_VALUE(regs[a], syms[b]);
1125
+ NEXT;
1126
+ }
1127
+
1069
1128
  CASE(OP_LOADNIL, B) {
1070
1129
  SET_NIL_VALUE(regs[a]);
1071
1130
  NEXT;
@@ -1098,13 +1157,13 @@ RETRY_TRY_BLOCK:
1098
1157
  }
1099
1158
 
1100
1159
  CASE(OP_GETSV, BB) {
1101
- mrb_value val = mrb_vm_special_get(mrb, b);
1160
+ mrb_value val = mrb_vm_special_get(mrb, syms[b]);
1102
1161
  regs[a] = val;
1103
1162
  NEXT;
1104
1163
  }
1105
1164
 
1106
1165
  CASE(OP_SETSV, BB) {
1107
- mrb_vm_special_set(mrb, b, regs[a]);
1166
+ mrb_vm_special_set(mrb, syms[b], regs[a]);
1108
1167
  NEXT;
1109
1168
  }
1110
1169
 
@@ -1120,9 +1179,7 @@ RETRY_TRY_BLOCK:
1120
1179
 
1121
1180
  CASE(OP_GETCV, BB) {
1122
1181
  mrb_value val;
1123
- ERR_PC_SET(mrb);
1124
1182
  val = mrb_vm_cv_get(mrb, syms[b]);
1125
- ERR_PC_CLR(mrb);
1126
1183
  regs[a] = val;
1127
1184
  NEXT;
1128
1185
  }
@@ -1136,9 +1193,7 @@ RETRY_TRY_BLOCK:
1136
1193
  mrb_value val;
1137
1194
  mrb_sym sym = syms[b];
1138
1195
 
1139
- ERR_PC_SET(mrb);
1140
1196
  val = mrb_vm_const_get(mrb, sym);
1141
- ERR_PC_CLR(mrb);
1142
1197
  regs[a] = val;
1143
1198
  NEXT;
1144
1199
  }
@@ -1151,9 +1206,7 @@ RETRY_TRY_BLOCK:
1151
1206
  CASE(OP_GETMCNST, BB) {
1152
1207
  mrb_value val;
1153
1208
 
1154
- ERR_PC_SET(mrb);
1155
1209
  val = mrb_const_get(mrb, regs[a], syms[b]);
1156
- ERR_PC_CLR(mrb);
1157
1210
  regs[a] = val;
1158
1211
  NEXT;
1159
1212
  }
@@ -1167,7 +1220,7 @@ RETRY_TRY_BLOCK:
1167
1220
  mrb_value *regs_a = regs + a;
1168
1221
  struct REnv *e = uvenv(mrb, c);
1169
1222
 
1170
- if (e && b < MRB_ENV_STACK_LEN(e)) {
1223
+ if (e && b < MRB_ENV_LEN(e)) {
1171
1224
  *regs_a = e->stack[b];
1172
1225
  }
1173
1226
  else {
@@ -1182,7 +1235,7 @@ RETRY_TRY_BLOCK:
1182
1235
  if (e) {
1183
1236
  mrb_value *regs_a = regs + a;
1184
1237
 
1185
- if (b < MRB_ENV_STACK_LEN(e)) {
1238
+ if (b < MRB_ENV_LEN(e)) {
1186
1239
  e->stack[b] = *regs_a;
1187
1240
  mrb_write_barrier(mrb, (struct RBasic*)e);
1188
1241
  }
@@ -1191,57 +1244,75 @@ RETRY_TRY_BLOCK:
1191
1244
  }
1192
1245
 
1193
1246
  CASE(OP_JMP, S) {
1194
- pc = irep->iseq+a;
1247
+ pc += (int16_t)a;
1195
1248
  JUMP;
1196
1249
  }
1197
1250
  CASE(OP_JMPIF, BS) {
1198
1251
  if (mrb_test(regs[a])) {
1199
- pc = irep->iseq+b;
1252
+ pc += (int16_t)b;
1200
1253
  JUMP;
1201
1254
  }
1202
1255
  NEXT;
1203
1256
  }
1204
1257
  CASE(OP_JMPNOT, BS) {
1205
1258
  if (!mrb_test(regs[a])) {
1206
- pc = irep->iseq+b;
1259
+ pc += (int16_t)b;
1207
1260
  JUMP;
1208
1261
  }
1209
1262
  NEXT;
1210
1263
  }
1211
1264
  CASE(OP_JMPNIL, BS) {
1212
1265
  if (mrb_nil_p(regs[a])) {
1213
- pc = irep->iseq+b;
1266
+ pc += (int16_t)b;
1214
1267
  JUMP;
1215
1268
  }
1216
1269
  NEXT;
1217
1270
  }
1218
1271
 
1219
- CASE(OP_ONERR, S) {
1220
- /* check rescue stack */
1221
- if (mrb->c->ci->ridx == UINT16_MAX-1) {
1222
- mrb_value exc = mrb_exc_new_str_lit(mrb, E_RUNTIME_ERROR, "too many nested rescues");
1223
- mrb_exc_set(mrb, exc);
1224
- goto L_RAISE;
1272
+ CASE(OP_JMPUW, S) {
1273
+ a = (uint32_t)((pc - irep->iseq) + (int16_t)a);
1274
+ CHECKPOINT_RESTORE(RBREAK_TAG_JUMP) {
1275
+ struct RBreak *brk = (struct RBreak*)mrb->exc;
1276
+ mrb_value target = mrb_break_value_get(brk);
1277
+ mrb_assert(mrb_integer_p(target));
1278
+ a = (uint32_t)mrb_integer(target);
1279
+ mrb_assert(a >= 0 && a < irep->ilen);
1225
1280
  }
1226
- /* expand rescue stack */
1227
- if (mrb->c->rsize <= mrb->c->ci->ridx) {
1228
- if (mrb->c->rsize == 0) mrb->c->rsize = RESCUE_STACK_INIT_SIZE;
1229
- else {
1230
- mrb->c->rsize *= 2;
1231
- if (mrb->c->rsize <= mrb->c->ci->ridx) {
1232
- mrb->c->rsize = UINT16_MAX;
1281
+ CHECKPOINT_MAIN(RBREAK_TAG_JUMP) {
1282
+ ch = catch_handler_find(mrb, mrb->c->ci, pc, MRB_CATCH_FILTER_ENSURE);
1283
+ if (ch) {
1284
+ /* avoiding a jump from a catch handler into the same handler */
1285
+ if (a < mrb_irep_catch_handler_unpack(ch->begin) || a >= mrb_irep_catch_handler_unpack(ch->end)) {
1286
+ THROW_TAGGED_BREAK(mrb, RBREAK_TAG_JUMP, proc, mrb_fixnum_value(a));
1233
1287
  }
1234
1288
  }
1235
- mrb->c->rescue = (uint16_t*)mrb_realloc(mrb, mrb->c->rescue, sizeof(uint16_t)*mrb->c->rsize);
1236
1289
  }
1237
- /* push rescue stack */
1238
- mrb->c->rescue[mrb->c->ci->ridx++] = a;
1239
- NEXT;
1290
+ CHECKPOINT_END(RBREAK_TAG_JUMP);
1291
+
1292
+ mrb->exc = NULL; /* clear break object */
1293
+ pc = irep->iseq + a;
1294
+ JUMP;
1240
1295
  }
1241
1296
 
1242
1297
  CASE(OP_EXCEPT, B) {
1243
- mrb_value exc = mrb_obj_value(mrb->exc);
1244
- mrb->exc = 0;
1298
+ mrb_value exc;
1299
+
1300
+ if (mrb->exc == NULL) {
1301
+ exc = mrb_nil_value();
1302
+ }
1303
+ else {
1304
+ switch (mrb->exc->tt) {
1305
+ case MRB_TT_BREAK:
1306
+ case MRB_TT_EXCEPTION:
1307
+ exc = mrb_obj_value(mrb->exc);
1308
+ break;
1309
+ default:
1310
+ mrb_assert(!"bad mrb_type");
1311
+ exc = mrb_nil_value();
1312
+ break;
1313
+ }
1314
+ mrb->exc = NULL;
1315
+ }
1245
1316
  regs[a] = exc;
1246
1317
  NEXT;
1247
1318
  }
@@ -1258,7 +1329,7 @@ RETRY_TRY_BLOCK:
1258
1329
  {
1259
1330
  mrb_value exc;
1260
1331
 
1261
- exc = mrb_exc_new_str_lit(mrb, E_TYPE_ERROR,
1332
+ exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,
1262
1333
  "class or module required for rescue clause");
1263
1334
  mrb_exc_set(mrb, exc);
1264
1335
  goto L_RAISE;
@@ -1269,82 +1340,19 @@ RETRY_TRY_BLOCK:
1269
1340
  NEXT;
1270
1341
  }
1271
1342
 
1272
- CASE(OP_POPERR, B) {
1273
- mrb->c->ci->ridx -= a;
1274
- NEXT;
1275
- }
1276
-
1277
- CASE(OP_RAISE, B) {
1278
- mrb_exc_set(mrb, regs[a]);
1279
- goto L_RAISE;
1280
- }
1281
-
1282
- CASE(OP_EPUSH, B) {
1283
- struct RProc *p;
1284
-
1285
- p = mrb_closure_new(mrb, irep->reps[a]);
1286
- /* check ensure stack */
1287
- if (mrb->c->eidx == UINT16_MAX-1) {
1288
- mrb_value exc = mrb_exc_new_str_lit(mrb, E_RUNTIME_ERROR, "too many nested ensures");
1289
- mrb_exc_set(mrb, exc);
1290
- goto L_RAISE;
1343
+ CASE(OP_RAISEIF, B) {
1344
+ mrb_value exc = regs[a];
1345
+ if (mrb_break_p(exc)) {
1346
+ mrb->exc = mrb_obj_ptr(exc);
1347
+ goto L_BREAK;
1291
1348
  }
1292
- /* expand ensure stack */
1293
- if (mrb->c->esize <= mrb->c->eidx+1) {
1294
- if (mrb->c->esize == 0) mrb->c->esize = ENSURE_STACK_INIT_SIZE;
1295
- else {
1296
- mrb->c->esize *= 2;
1297
- if (mrb->c->esize <= mrb->c->eidx) {
1298
- mrb->c->esize = UINT16_MAX;
1299
- }
1300
- }
1301
- mrb->c->ensure = (struct RProc**)mrb_realloc(mrb, mrb->c->ensure, sizeof(struct RProc*)*mrb->c->esize);
1349
+ mrb_exc_set(mrb, exc);
1350
+ if (mrb->exc) {
1351
+ goto L_RAISE;
1302
1352
  }
1303
- /* push ensure stack */
1304
- mrb->c->ensure[mrb->c->eidx++] = p;
1305
- mrb->c->ensure[mrb->c->eidx] = NULL;
1306
- mrb_gc_arena_restore(mrb, ai);
1307
1353
  NEXT;
1308
1354
  }
1309
1355
 
1310
- CASE(OP_EPOP, B) {
1311
- mrb_callinfo *ci = mrb->c->ci;
1312
- unsigned int n, epos = ci->epos;
1313
- mrb_value self = regs[0];
1314
- struct RClass *target_class = ci->target_class;
1315
-
1316
- if (mrb->c->eidx <= epos) {
1317
- NEXT;
1318
- }
1319
-
1320
- if (a > (int)mrb->c->eidx - epos)
1321
- a = mrb->c->eidx - epos;
1322
- for (n=0; n<a; n++) {
1323
- int nregs = irep->nregs;
1324
-
1325
- proc = mrb->c->ensure[epos+n];
1326
- mrb->c->ensure[epos+n] = NULL;
1327
- if (proc == NULL) continue;
1328
- irep = proc->body.irep;
1329
- ci = cipush(mrb);
1330
- ci->mid = ci[-1].mid;
1331
- ci->argc = 0;
1332
- ci->proc = proc;
1333
- ci->stackent = mrb->c->stack;
1334
- ci->target_class = target_class;
1335
- ci->pc = pc;
1336
- ci->acc = nregs;
1337
- mrb->c->stack += ci->acc;
1338
- mrb_stack_extend(mrb, irep->nregs);
1339
- regs[0] = self;
1340
- pc = irep->iseq;
1341
- }
1342
- pool = irep->pool;
1343
- syms = irep->syms;
1344
- mrb->c->eidx = epos;
1345
- JUMP;
1346
- }
1347
-
1348
1356
  CASE(OP_SENDV, BB) {
1349
1357
  c = CALL_MAXARGS;
1350
1358
  goto L_SEND;
@@ -1376,8 +1384,8 @@ RETRY_TRY_BLOCK:
1376
1384
  mid = syms[b];
1377
1385
  L_SENDB_SYM:
1378
1386
  {
1379
- int argc = (c == CALL_MAXARGS) ? -1 : c;
1380
- int bidx = (argc < 0) ? a+2 : a+c+1;
1387
+ mrb_int argc = (c == CALL_MAXARGS) ? -1 : c;
1388
+ mrb_int bidx = (argc < 0) ? a+2 : a+c+1;
1381
1389
  mrb_method_t m;
1382
1390
  struct RClass *cls;
1383
1391
  mrb_callinfo *ci = mrb->c->ci;
@@ -1388,19 +1396,18 @@ RETRY_TRY_BLOCK:
1388
1396
  recv = regs[a];
1389
1397
  blk = regs[bidx];
1390
1398
  if (!mrb_nil_p(blk) && !mrb_proc_p(blk)) {
1391
- blk = mrb_convert_type(mrb, blk, MRB_TT_PROC, "Proc", "to_proc");
1392
- /* The stack might have been reallocated during mrb_convert_type(),
1399
+ blk = mrb_type_convert(mrb, blk, MRB_TT_PROC, MRB_SYM(to_proc));
1400
+ /* The stack might have been reallocated during mrb_type_convert(),
1393
1401
  see #3622 */
1394
1402
  regs[bidx] = blk;
1395
1403
  }
1396
1404
  cls = mrb_class(mrb, recv);
1397
1405
  m = mrb_method_search_vm(mrb, &cls, mid);
1398
1406
  if (MRB_METHOD_UNDEF_P(m)) {
1399
- mrb_sym missing = mrb_intern_lit(mrb, "method_missing");
1407
+ mrb_sym missing = MRB_SYM(method_missing);
1400
1408
  m = mrb_method_search_vm(mrb, &cls, missing);
1401
1409
  if (MRB_METHOD_UNDEF_P(m) || (missing == mrb->c->ci->mid && mrb_obj_eq(mrb, regs[0], recv))) {
1402
1410
  mrb_value args = (argc < 0) ? regs[a+1] : mrb_ary_new_from_values(mrb, c, regs+a+1);
1403
- ERR_PC_SET(mrb);
1404
1411
  mrb_method_missing(mrb, mid, recv, args);
1405
1412
  }
1406
1413
  if (argc >= 0) {
@@ -1416,23 +1423,13 @@ RETRY_TRY_BLOCK:
1416
1423
  }
1417
1424
 
1418
1425
  /* push callinfo */
1419
- ci = cipush(mrb);
1420
- ci->mid = mid;
1421
- ci->stackent = mrb->c->stack;
1422
- ci->target_class = cls;
1423
- ci->argc = argc;
1424
-
1425
- ci->pc = pc;
1426
- ci->acc = a;
1427
-
1428
- /* prepare stack */
1429
- mrb->c->stack += a;
1426
+ ci = cipush(mrb, a, a, cls, NULL, mid, argc);
1430
1427
 
1431
1428
  if (MRB_METHOD_CFUNC_P(m)) {
1432
1429
  if (MRB_METHOD_PROC_P(m)) {
1433
1430
  struct RProc *p = MRB_METHOD_PROC(m);
1434
1431
 
1435
- ci->proc = p;
1432
+ mrb_vm_ci_proc_set(ci, p);
1436
1433
  recv = p->body.func(mrb, recv);
1437
1434
  }
1438
1435
  else if (MRB_METHOD_NOARG_P(m) &&
@@ -1449,11 +1446,11 @@ RETRY_TRY_BLOCK:
1449
1446
  ci = mrb->c->ci;
1450
1447
  if (mrb_proc_p(blk)) {
1451
1448
  struct RProc *p = mrb_proc_ptr(blk);
1452
- if (p && !MRB_PROC_STRICT_P(p) && MRB_PROC_ENV(p) == ci[-1].env) {
1449
+ if (p && !MRB_PROC_STRICT_P(p) && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {
1453
1450
  p->flags |= MRB_PROC_ORPHAN;
1454
1451
  }
1455
1452
  }
1456
- if (!ci->target_class) { /* return from context modifying method (resume/yield) */
1453
+ if (!ci->u.target_class) { /* return from context modifying method (resume/yield) */
1457
1454
  if (ci->acc == CI_ACC_RESUMED) {
1458
1455
  mrb->jmp = prev_jmp;
1459
1456
  return recv;
@@ -1466,16 +1463,15 @@ RETRY_TRY_BLOCK:
1466
1463
  syms = irep->syms;
1467
1464
  }
1468
1465
  }
1469
- mrb->c->stack[0] = recv;
1466
+ mrb->c->ci->stack[0] = recv;
1470
1467
  /* pop stackpos */
1471
- mrb->c->stack = ci->stackent;
1468
+ ci = cipop(mrb);
1472
1469
  pc = ci->pc;
1473
- cipop(mrb);
1474
1470
  JUMP;
1475
1471
  }
1476
1472
  else {
1477
1473
  /* setup environment for calling method */
1478
- proc = ci->proc = MRB_METHOD_PROC(m);
1474
+ mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));
1479
1475
  irep = proc->body.irep;
1480
1476
  pool = irep->pool;
1481
1477
  syms = irep->syms;
@@ -1487,22 +1483,15 @@ RETRY_TRY_BLOCK:
1487
1483
 
1488
1484
  CASE(OP_CALL, Z) {
1489
1485
  mrb_callinfo *ci;
1490
- mrb_value recv = mrb->c->stack[0];
1486
+ mrb_value recv = mrb->c->ci->stack[0];
1491
1487
  struct RProc *m = mrb_proc_ptr(recv);
1492
1488
 
1493
1489
  /* replace callinfo */
1494
1490
  ci = mrb->c->ci;
1495
- ci->target_class = MRB_PROC_TARGET_CLASS(m);
1496
- ci->proc = m;
1491
+ ci->u.target_class = MRB_PROC_TARGET_CLASS(m);
1492
+ mrb_vm_ci_proc_set(ci, m);
1497
1493
  if (MRB_PROC_ENV_P(m)) {
1498
- mrb_sym mid;
1499
- struct REnv *e = MRB_PROC_ENV(m);
1500
-
1501
- mid = e->mid;
1502
- if (mid) ci->mid = mid;
1503
- if (!e->stack) {
1504
- e->stack = mrb->c->stack;
1505
- }
1494
+ ci->mid = MRB_PROC_ENV(m)->mid;
1506
1495
  }
1507
1496
 
1508
1497
  /* prepare stack */
@@ -1512,11 +1501,9 @@ RETRY_TRY_BLOCK:
1512
1501
  mrb_gc_arena_shrink(mrb, ai);
1513
1502
  if (mrb->exc) goto L_RAISE;
1514
1503
  /* pop stackpos */
1515
- ci = mrb->c->ci;
1516
- mrb->c->stack = ci->stackent;
1517
- regs[ci->acc] = recv;
1504
+ ci = cipop(mrb);
1518
1505
  pc = ci->pc;
1519
- cipop(mrb);
1506
+ regs[ci[1].acc] = recv;
1520
1507
  irep = mrb->c->ci->proc->body.irep;
1521
1508
  pool = irep->pool;
1522
1509
  syms = irep->syms;
@@ -1527,10 +1514,10 @@ RETRY_TRY_BLOCK:
1527
1514
  proc = m;
1528
1515
  irep = m->body.irep;
1529
1516
  if (!irep) {
1530
- mrb->c->stack[0] = mrb_nil_value();
1517
+ mrb->c->ci->stack[0] = mrb_nil_value();
1531
1518
  a = 0;
1532
1519
  c = OP_R_NORMAL;
1533
- goto L_OP_RETURN_BODY;
1520
+ goto L_RETURN;
1534
1521
  }
1535
1522
  pool = irep->pool;
1536
1523
  syms = irep->syms;
@@ -1552,13 +1539,13 @@ RETRY_TRY_BLOCK:
1552
1539
  }
1553
1540
 
1554
1541
  CASE(OP_SUPER, BB) {
1555
- int argc = (b == CALL_MAXARGS) ? -1 : b;
1542
+ mrb_int argc = (b == CALL_MAXARGS) ? -1 : b;
1556
1543
  int bidx = (argc < 0) ? a+2 : a+b+1;
1557
1544
  mrb_method_t m;
1558
1545
  struct RClass *cls;
1559
1546
  mrb_callinfo *ci = mrb->c->ci;
1560
1547
  mrb_value recv, blk;
1561
- struct RProc *p = ci->proc;
1548
+ const struct RProc *p = ci->proc;
1562
1549
  mrb_sym mid = ci->mid;
1563
1550
  struct RClass* target_class = MRB_PROC_TARGET_CLASS(p);
1564
1551
 
@@ -1568,37 +1555,40 @@ RETRY_TRY_BLOCK:
1568
1555
  mrb_assert(bidx < irep->nregs);
1569
1556
 
1570
1557
  if (mid == 0 || !target_class) {
1571
- mrb_value exc = mrb_exc_new_str_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
1558
+ mrb_value exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
1572
1559
  mrb_exc_set(mrb, exc);
1573
1560
  goto L_RAISE;
1574
1561
  }
1575
- if (target_class->tt == MRB_TT_MODULE) {
1576
- target_class = ci->target_class;
1562
+ if (target_class->flags & MRB_FL_CLASS_IS_PREPENDED) {
1563
+ target_class = mrb_vm_ci_target_class(ci);
1564
+ }
1565
+ else if (target_class->tt == MRB_TT_MODULE) {
1566
+ target_class = mrb_vm_ci_target_class(ci);
1577
1567
  if (target_class->tt != MRB_TT_ICLASS) {
1578
- mrb_value exc = mrb_exc_new_str_lit(mrb, E_RUNTIME_ERROR, "superclass info lost [mruby limitations]");
1568
+ mrb_value exc = mrb_exc_new_lit(mrb, E_RUNTIME_ERROR, "superclass info lost [mruby limitations]");
1579
1569
  mrb_exc_set(mrb, exc);
1580
1570
  goto L_RAISE;
1581
1571
  }
1582
1572
  }
1583
1573
  recv = regs[0];
1584
1574
  if (!mrb_obj_is_kind_of(mrb, recv, target_class)) {
1585
- mrb_value exc = mrb_exc_new_str_lit(mrb, E_TYPE_ERROR,
1575
+ mrb_value exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,
1586
1576
  "self has wrong type to call super in this context");
1587
1577
  mrb_exc_set(mrb, exc);
1588
1578
  goto L_RAISE;
1589
1579
  }
1590
1580
  blk = regs[bidx];
1591
1581
  if (!mrb_nil_p(blk) && !mrb_proc_p(blk)) {
1592
- blk = mrb_convert_type(mrb, blk, MRB_TT_PROC, "Proc", "to_proc");
1582
+ blk = mrb_type_convert(mrb, blk, MRB_TT_PROC, MRB_SYM(to_proc));
1593
1583
  /* The stack or ci stack might have been reallocated during
1594
- mrb_convert_type(), see #3622 and #3784 */
1584
+ mrb_type_convert(), see #3622 and #3784 */
1595
1585
  regs[bidx] = blk;
1596
1586
  ci = mrb->c->ci;
1597
1587
  }
1598
1588
  cls = target_class->super;
1599
1589
  m = mrb_method_search_vm(mrb, &cls, mid);
1600
1590
  if (MRB_METHOD_UNDEF_P(m)) {
1601
- mrb_sym missing = mrb_intern_lit(mrb, "method_missing");
1591
+ mrb_sym missing = MRB_SYM(method_missing);
1602
1592
 
1603
1593
  if (mid != missing) {
1604
1594
  cls = mrb_class(mrb, recv);
@@ -1606,7 +1596,6 @@ RETRY_TRY_BLOCK:
1606
1596
  m = mrb_method_search_vm(mrb, &cls, missing);
1607
1597
  if (MRB_METHOD_UNDEF_P(m)) {
1608
1598
  mrb_value args = (argc < 0) ? regs[a+1] : mrb_ary_new_from_values(mrb, b, regs+a+1);
1609
- ERR_PC_SET(mrb);
1610
1599
  mrb_method_missing(mrb, mid, recv, args);
1611
1600
  }
1612
1601
  mid = missing;
@@ -1622,28 +1611,23 @@ RETRY_TRY_BLOCK:
1622
1611
  }
1623
1612
 
1624
1613
  /* push callinfo */
1625
- ci = cipush(mrb);
1626
- ci->mid = mid;
1627
- ci->stackent = mrb->c->stack;
1628
- ci->target_class = cls;
1629
- ci->pc = pc;
1630
- ci->argc = argc;
1614
+ ci = cipush(mrb, a, 0, cls, NULL, mid, argc);
1631
1615
 
1632
1616
  /* prepare stack */
1633
- mrb->c->stack += a;
1634
- mrb->c->stack[0] = recv;
1617
+ mrb->c->ci->stack[0] = recv;
1635
1618
 
1636
1619
  if (MRB_METHOD_CFUNC_P(m)) {
1637
1620
  mrb_value v;
1638
1621
 
1639
1622
  if (MRB_METHOD_PROC_P(m)) {
1640
- ci->proc = MRB_METHOD_PROC(m);
1623
+ mrb_vm_ci_proc_set(ci, MRB_METHOD_PROC(m));
1641
1624
  }
1642
1625
  v = MRB_METHOD_CFUNC(m)(mrb, recv);
1643
1626
  mrb_gc_arena_restore(mrb, ai);
1644
1627
  if (mrb->exc) goto L_RAISE;
1645
1628
  ci = mrb->c->ci;
1646
- if (!ci->target_class) { /* return from context modifying method (resume/yield) */
1629
+ mrb_assert(!mrb_break_p(v));
1630
+ if (!mrb_vm_ci_target_class(ci)) { /* return from context modifying method (resume/yield) */
1647
1631
  if (ci->acc == CI_ACC_RESUMED) {
1648
1632
  mrb->jmp = prev_jmp;
1649
1633
  return v;
@@ -1656,11 +1640,9 @@ RETRY_TRY_BLOCK:
1656
1640
  syms = irep->syms;
1657
1641
  }
1658
1642
  }
1659
- mrb->c->stack[0] = v;
1660
- /* pop stackpos */
1661
- mrb->c->stack = ci->stackent;
1643
+ mrb->c->ci->stack[0] = v;
1644
+ ci = cipop(mrb);
1662
1645
  pc = ci->pc;
1663
- cipop(mrb);
1664
1646
  JUMP;
1665
1647
  }
1666
1648
  else {
@@ -1668,7 +1650,7 @@ RETRY_TRY_BLOCK:
1668
1650
  ci->acc = a;
1669
1651
 
1670
1652
  /* setup environment for calling method */
1671
- proc = ci->proc = MRB_METHOD_PROC(m);
1653
+ mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));
1672
1654
  irep = proc->body.irep;
1673
1655
  pool = irep->pool;
1674
1656
  syms = irep->syms;
@@ -1679,18 +1661,18 @@ RETRY_TRY_BLOCK:
1679
1661
  }
1680
1662
 
1681
1663
  CASE(OP_ARGARY, BS) {
1682
- int m1 = (b>>11)&0x3f;
1683
- int r = (b>>10)&0x1;
1684
- int m2 = (b>>5)&0x1f;
1685
- int kd = (b>>4)&0x1;
1686
- int lv = (b>>0)&0xf;
1664
+ mrb_int m1 = (b>>11)&0x3f;
1665
+ mrb_int r = (b>>10)&0x1;
1666
+ mrb_int m2 = (b>>5)&0x1f;
1667
+ mrb_int kd = (b>>4)&0x1;
1668
+ mrb_int lv = (b>>0)&0xf;
1687
1669
  mrb_value *stack;
1688
1670
 
1689
- if (mrb->c->ci->mid == 0 || mrb->c->ci->target_class == NULL) {
1671
+ if (mrb->c->ci->mid == 0 || mrb_vm_ci_target_class(mrb->c->ci) == NULL) {
1690
1672
  mrb_value exc;
1691
1673
 
1692
1674
  L_NOSUPER:
1693
- exc = mrb_exc_new_str_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
1675
+ exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
1694
1676
  mrb_exc_set(mrb, exc);
1695
1677
  goto L_RAISE;
1696
1678
  }
@@ -1698,7 +1680,7 @@ RETRY_TRY_BLOCK:
1698
1680
  else {
1699
1681
  struct REnv *e = uvenv(mrb, lv-1);
1700
1682
  if (!e) goto L_NOSUPER;
1701
- if (MRB_ENV_STACK_LEN(e) <= m1+r+m2+kd+1)
1683
+ if (MRB_ENV_LEN(e) <= m1+r+m2+kd+1)
1702
1684
  goto L_NOSUPER;
1703
1685
  stack = e->stack + 1;
1704
1686
  }
@@ -1708,13 +1690,13 @@ RETRY_TRY_BLOCK:
1708
1690
  else {
1709
1691
  mrb_value *pp = NULL;
1710
1692
  struct RArray *rest;
1711
- int len = 0;
1693
+ mrb_int len = 0;
1712
1694
 
1713
1695
  if (mrb_array_p(stack[m1])) {
1714
1696
  struct RArray *ary = mrb_ary_ptr(stack[m1]);
1715
1697
 
1716
1698
  pp = ARY_PTR(ary);
1717
- len = (int)ARY_LEN(ary);
1699
+ len = ARY_LEN(ary);
1718
1700
  }
1719
1701
  regs[a] = mrb_ary_new_capa(mrb, m1+len+m2+kd);
1720
1702
  rest = mrb_ary_ptr(regs[a]);
@@ -1738,22 +1720,22 @@ RETRY_TRY_BLOCK:
1738
1720
  }
1739
1721
 
1740
1722
  CASE(OP_ENTER, W) {
1741
- int m1 = MRB_ASPEC_REQ(a);
1742
- int o = MRB_ASPEC_OPT(a);
1743
- int r = MRB_ASPEC_REST(a);
1744
- int m2 = MRB_ASPEC_POST(a);
1745
- int kd = (MRB_ASPEC_KEY(a) > 0 || MRB_ASPEC_KDICT(a))? 1 : 0;
1723
+ mrb_int m1 = MRB_ASPEC_REQ(a);
1724
+ mrb_int o = MRB_ASPEC_OPT(a);
1725
+ mrb_int r = MRB_ASPEC_REST(a);
1726
+ mrb_int m2 = MRB_ASPEC_POST(a);
1727
+ mrb_int kd = (MRB_ASPEC_KEY(a) > 0 || MRB_ASPEC_KDICT(a))? 1 : 0;
1746
1728
  /* unused
1747
1729
  int b = MRB_ASPEC_BLOCK(a);
1748
1730
  */
1749
- int argc = mrb->c->ci->argc;
1731
+ mrb_int argc = mrb->c->ci->argc;
1750
1732
  mrb_value *argv = regs+1;
1751
1733
  mrb_value * const argv0 = argv;
1752
- int const len = m1 + o + r + m2;
1753
- int const blk_pos = len + kd + 1;
1734
+ mrb_int const len = m1 + o + r + m2;
1735
+ mrb_int const blk_pos = len + kd + 1;
1754
1736
  mrb_value *blk = &argv[argc < 0 ? 1 : argc];
1755
- mrb_value kdict;
1756
- int kargs = kd;
1737
+ mrb_value kdict = mrb_nil_value();
1738
+ mrb_int kargs = kd;
1757
1739
 
1758
1740
  /* arguments is passed with Array */
1759
1741
  if (argc < 0) {
@@ -1805,7 +1787,7 @@ RETRY_TRY_BLOCK:
1805
1787
 
1806
1788
  /* no rest arguments */
1807
1789
  if (argc-kargs < len) {
1808
- int mlen = m2;
1790
+ mrb_int mlen = m2;
1809
1791
  if (argc < m1+m2) {
1810
1792
  mlen = m1 < argc ? argc - m1 : 0;
1811
1793
  }
@@ -1813,7 +1795,7 @@ RETRY_TRY_BLOCK:
1813
1795
  if (kd) regs[len + 1] = kdict;
1814
1796
 
1815
1797
  /* copy mandatory and optional arguments */
1816
- if (argv0 != argv) {
1798
+ if (argv0 != argv && argv) {
1817
1799
  value_move(&regs[1], argv, argc-mlen); /* m1 + o */
1818
1800
  }
1819
1801
  if (argc < m1) {
@@ -1826,16 +1808,16 @@ RETRY_TRY_BLOCK:
1826
1808
  if (mlen < m2) {
1827
1809
  stack_clear(&regs[len-m2+mlen+1], m2-mlen);
1828
1810
  }
1829
- /* initalize rest arguments with empty Array */
1811
+ /* initialize rest arguments with empty Array */
1830
1812
  if (r) {
1831
1813
  regs[m1+o+1] = mrb_ary_new_capa(mrb, 0);
1832
1814
  }
1833
- /* skip initailizer of passed arguments */
1815
+ /* skip initializer of passed arguments */
1834
1816
  if (o > 0 && argc-kargs > m1+m2)
1835
1817
  pc += (argc - kargs - m1 - m2)*3;
1836
1818
  }
1837
1819
  else {
1838
- int rnum = 0;
1820
+ mrb_int rnum = 0;
1839
1821
  if (argv0 != argv) {
1840
1822
  regs[blk_pos] = *blk; /* move block */
1841
1823
  if (kd) regs[len + 1] = kdict;
@@ -1861,7 +1843,7 @@ RETRY_TRY_BLOCK:
1861
1843
  }
1862
1844
 
1863
1845
  /* format arguments for generated code */
1864
- mrb->c->ci->argc = len + kd;
1846
+ mrb->c->ci->argc = (int16_t)(len + kd);
1865
1847
 
1866
1848
  /* clear local (but non-argument) variables */
1867
1849
  if (irep->nlocals-blk_pos-1 > 0) {
@@ -1921,13 +1903,7 @@ RETRY_TRY_BLOCK:
1921
1903
  c = OP_R_NORMAL;
1922
1904
  L_RETURN:
1923
1905
  {
1924
- mrb_callinfo *ci;
1925
-
1926
- #define ecall_adjust() do {\
1927
- ptrdiff_t cioff = ci - mrb->c->cibase;\
1928
- ecall(mrb);\
1929
- ci = mrb->c->cibase + cioff;\
1930
- } while (0)
1906
+ mrb_callinfo *ci;
1931
1907
 
1932
1908
  ci = mrb->c->ci;
1933
1909
  if (ci->mid) {
@@ -1943,42 +1919,38 @@ RETRY_TRY_BLOCK:
1943
1919
  struct RProc *p = mrb_proc_ptr(blk);
1944
1920
 
1945
1921
  if (!MRB_PROC_STRICT_P(p) &&
1946
- ci > mrb->c->cibase && MRB_PROC_ENV(p) == ci[-1].env) {
1922
+ ci > mrb->c->cibase && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {
1947
1923
  p->flags |= MRB_PROC_ORPHAN;
1948
1924
  }
1949
1925
  }
1950
1926
  }
1951
1927
 
1952
1928
  if (mrb->exc) {
1953
- mrb_callinfo *ci0;
1954
-
1955
1929
  L_RAISE:
1956
- ci0 = ci = mrb->c->ci;
1930
+ ci = mrb->c->ci;
1957
1931
  if (ci == mrb->c->cibase) {
1958
- if (ci->ridx == 0) goto L_FTOP;
1959
- goto L_RESCUE;
1932
+ ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);
1933
+ if (ch == NULL) goto L_FTOP;
1934
+ goto L_CATCH;
1960
1935
  }
1961
- while (ci[0].ridx == ci[-1].ridx) {
1962
- cipop(mrb);
1963
- mrb->c->stack = ci->stackent;
1964
- if (ci->acc == CI_ACC_SKIP && prev_jmp) {
1936
+ while ((ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL)) == NULL) {
1937
+ ci = cipop(mrb);
1938
+ if (ci[1].acc == CI_ACC_SKIP && prev_jmp) {
1965
1939
  mrb->jmp = prev_jmp;
1966
1940
  MRB_THROW(prev_jmp);
1967
1941
  }
1968
- ci = mrb->c->ci;
1942
+ pc = ci[0].pc;
1969
1943
  if (ci == mrb->c->cibase) {
1970
- if (ci->ridx == 0) {
1944
+ ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);
1945
+ if (ch == NULL) {
1971
1946
  L_FTOP: /* fiber top */
1972
1947
  if (mrb->c == mrb->root_c) {
1973
- mrb->c->stack = mrb->c->stbase;
1948
+ mrb->c->ci->stack = mrb->c->stbase;
1974
1949
  goto L_STOP;
1975
1950
  }
1976
1951
  else {
1977
1952
  struct mrb_context *c = mrb->c;
1978
1953
 
1979
- while (c->eidx > ci->epos) {
1980
- ecall_adjust();
1981
- }
1982
1954
  c->status = MRB_FIBER_TERMINATED;
1983
1955
  mrb->c = c->prev;
1984
1956
  c->prev = NULL;
@@ -1987,29 +1959,23 @@ RETRY_TRY_BLOCK:
1987
1959
  }
1988
1960
  break;
1989
1961
  }
1990
- /* call ensure only when we skip this callinfo */
1991
- if (ci[0].ridx == ci[-1].ridx) {
1992
- while (mrb->c->eidx > ci->epos) {
1993
- ecall_adjust();
1994
- }
1995
- }
1996
1962
  }
1997
- L_RESCUE:
1998
- if (ci->ridx == 0) goto L_STOP;
1963
+ L_CATCH:
1964
+ if (ch == NULL) goto L_STOP;
1965
+ if (FALSE) {
1966
+ L_CATCH_TAGGED_BREAK: /* from THROW_TAGGED_BREAK() or UNWIND_ENSURE() */
1967
+ ci = mrb->c->ci;
1968
+ }
1999
1969
  proc = ci->proc;
2000
1970
  irep = proc->body.irep;
2001
1971
  pool = irep->pool;
2002
1972
  syms = irep->syms;
2003
- if (ci < ci0) {
2004
- mrb->c->stack = ci[1].stackent;
2005
- }
2006
1973
  mrb_stack_extend(mrb, irep->nregs);
2007
- pc = irep->iseq+mrb->c->rescue[--ci->ridx];
1974
+ pc = irep->iseq + mrb_irep_catch_handler_unpack(ch->target);
2008
1975
  }
2009
1976
  else {
2010
- int acc;
1977
+ mrb_int acc;
2011
1978
  mrb_value v;
2012
- struct RProc *dst;
2013
1979
 
2014
1980
  ci = mrb->c->ci;
2015
1981
  v = regs[a];
@@ -2018,55 +1984,92 @@ RETRY_TRY_BLOCK:
2018
1984
  case OP_R_RETURN:
2019
1985
  /* Fall through to OP_R_NORMAL otherwise */
2020
1986
  if (ci->acc >=0 && MRB_PROC_ENV_P(proc) && !MRB_PROC_STRICT_P(proc)) {
2021
- mrb_callinfo *cibase = mrb->c->cibase;
1987
+ const struct RProc *dst;
1988
+ mrb_callinfo *cibase;
1989
+ cibase = mrb->c->cibase;
2022
1990
  dst = top_proc(mrb, proc);
2023
1991
 
2024
1992
  if (MRB_PROC_ENV_P(dst)) {
2025
1993
  struct REnv *e = MRB_PROC_ENV(dst);
2026
1994
 
2027
- if (!MRB_ENV_STACK_SHARED_P(e) || (e->cxt && e->cxt != mrb->c)) {
1995
+ if (!MRB_ENV_ONSTACK_P(e) || (e->cxt && e->cxt != mrb->c)) {
2028
1996
  localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
2029
1997
  goto L_RAISE;
2030
1998
  }
2031
1999
  }
2000
+ /* check jump destination */
2032
2001
  while (cibase <= ci && ci->proc != dst) {
2033
- if (ci->acc < 0) {
2002
+ if (ci->acc < 0) { /* jump cross C boudary */
2034
2003
  localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
2035
2004
  goto L_RAISE;
2036
2005
  }
2037
2006
  ci--;
2038
2007
  }
2039
- if (ci <= cibase) {
2008
+ if (ci <= cibase) { /* no jump destination */
2040
2009
  localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
2041
2010
  goto L_RAISE;
2042
2011
  }
2012
+ ci = mrb->c->ci;
2013
+ while (cibase <= ci && ci->proc != dst) {
2014
+ CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_BLOCK) {
2015
+ cibase = mrb->c->cibase;
2016
+ dst = top_proc(mrb, proc);
2017
+ }
2018
+ CHECKPOINT_MAIN(RBREAK_TAG_RETURN_BLOCK) {
2019
+ UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_BLOCK, proc, v);
2020
+ }
2021
+ CHECKPOINT_END(RBREAK_TAG_RETURN_BLOCK);
2022
+ ci = cipop(mrb);
2023
+ pc = ci->pc;
2024
+ }
2025
+ proc = ci->proc;
2026
+ mrb->exc = NULL; /* clear break object */
2043
2027
  break;
2044
2028
  }
2045
2029
  /* fallthrough */
2046
2030
  case OP_R_NORMAL:
2047
2031
  NORMAL_RETURN:
2048
2032
  if (ci == mrb->c->cibase) {
2049
- struct mrb_context *c = mrb->c;
2033
+ struct mrb_context *c;
2034
+ c = mrb->c;
2050
2035
 
2051
2036
  if (!c->prev) { /* toplevel return */
2052
2037
  regs[irep->nlocals] = v;
2053
- goto L_STOP;
2038
+ goto CHECKPOINT_LABEL_MAKE(RBREAK_TAG_STOP);
2054
2039
  }
2055
- if (c->prev->ci == c->prev->cibase) {
2056
- mrb_value exc = mrb_exc_new_str_lit(mrb, E_FIBER_ERROR, "double resume");
2040
+ if (!c->vmexec && c->prev->ci == c->prev->cibase) {
2041
+ mrb_value exc = mrb_exc_new_lit(mrb, E_FIBER_ERROR, "double resume");
2057
2042
  mrb_exc_set(mrb, exc);
2058
2043
  goto L_RAISE;
2059
2044
  }
2060
- while (c->eidx > 0) {
2061
- ecall(mrb);
2045
+ CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_TOPLEVEL) {
2046
+ c = mrb->c;
2047
+ }
2048
+ CHECKPOINT_MAIN(RBREAK_TAG_RETURN_TOPLEVEL) {
2049
+ UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_TOPLEVEL, proc, v);
2062
2050
  }
2051
+ CHECKPOINT_END(RBREAK_TAG_RETURN_TOPLEVEL);
2063
2052
  /* automatic yield at the end */
2064
2053
  c->status = MRB_FIBER_TERMINATED;
2065
2054
  mrb->c = c->prev;
2066
- c->prev = NULL;
2067
2055
  mrb->c->status = MRB_FIBER_RUNNING;
2056
+ c->prev = NULL;
2057
+ if (c->vmexec) {
2058
+ mrb_gc_arena_restore(mrb, ai);
2059
+ c->vmexec = FALSE;
2060
+ mrb->jmp = prev_jmp;
2061
+ return v;
2062
+ }
2068
2063
  ci = mrb->c->ci;
2069
2064
  }
2065
+ CHECKPOINT_RESTORE(RBREAK_TAG_RETURN) {
2066
+ /* do nothing */
2067
+ }
2068
+ CHECKPOINT_MAIN(RBREAK_TAG_RETURN) {
2069
+ UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN, proc, v);
2070
+ }
2071
+ CHECKPOINT_END(RBREAK_TAG_RETURN);
2072
+ mrb->exc = NULL; /* clear break object */
2070
2073
  break;
2071
2074
  case OP_R_BREAK:
2072
2075
  if (MRB_PROC_STRICT_P(proc)) goto NORMAL_RETURN;
@@ -2074,12 +2077,12 @@ RETRY_TRY_BLOCK:
2074
2077
  mrb_value exc;
2075
2078
 
2076
2079
  L_BREAK_ERROR:
2077
- exc = mrb_exc_new_str_lit(mrb, E_LOCALJUMP_ERROR,
2080
+ exc = mrb_exc_new_lit(mrb, E_LOCALJUMP_ERROR,
2078
2081
  "break from proc-closure");
2079
2082
  mrb_exc_set(mrb, exc);
2080
2083
  goto L_RAISE;
2081
2084
  }
2082
- if (!MRB_PROC_ENV_P(proc) || !MRB_ENV_STACK_SHARED_P(MRB_PROC_ENV(proc))) {
2085
+ if (!MRB_PROC_ENV_P(proc) || !MRB_ENV_ONSTACK_P(MRB_PROC_ENV(proc))) {
2083
2086
  goto L_BREAK_ERROR;
2084
2087
  }
2085
2088
  else {
@@ -2089,9 +2092,13 @@ RETRY_TRY_BLOCK:
2089
2092
  goto L_BREAK_ERROR;
2090
2093
  }
2091
2094
  }
2092
- while (mrb->c->eidx > mrb->c->ci->epos) {
2093
- ecall_adjust();
2095
+ CHECKPOINT_RESTORE(RBREAK_TAG_BREAK) {
2096
+ /* do nothing */
2094
2097
  }
2098
+ CHECKPOINT_MAIN(RBREAK_TAG_BREAK) {
2099
+ UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK, proc, v);
2100
+ }
2101
+ CHECKPOINT_END(RBREAK_TAG_BREAK);
2095
2102
  /* break from fiber block */
2096
2103
  if (ci == mrb->c->cibase && ci->pc) {
2097
2104
  struct mrb_context *c = mrb->c;
@@ -2101,61 +2108,77 @@ RETRY_TRY_BLOCK:
2101
2108
  ci = mrb->c->ci;
2102
2109
  }
2103
2110
  if (ci->acc < 0) {
2111
+ ci = cipop(mrb);
2104
2112
  mrb_gc_arena_restore(mrb, ai);
2105
2113
  mrb->c->vmexec = FALSE;
2106
- mrb->exc = (struct RObject*)break_new(mrb, proc, v);
2114
+ mrb->exc = (struct RObject*)break_new(mrb, RBREAK_TAG_BREAK, proc, v);
2107
2115
  mrb->jmp = prev_jmp;
2108
2116
  MRB_THROW(prev_jmp);
2109
2117
  }
2110
2118
  if (FALSE) {
2119
+ struct RBreak *brk;
2120
+
2111
2121
  L_BREAK:
2112
- v = mrb_break_value_get((struct RBreak*)mrb->exc);
2113
- proc = mrb_break_proc_get((struct RBreak*)mrb->exc);
2114
- mrb->exc = NULL;
2122
+ brk = (struct RBreak*)mrb->exc;
2123
+ proc = mrb_break_proc_get(brk);
2124
+ v = mrb_break_value_get(brk);
2115
2125
  ci = mrb->c->ci;
2126
+
2127
+ switch (mrb_break_tag_get(brk)) {
2128
+ #define DISPATCH_CHECKPOINTS(n, i) case n: goto CHECKPOINT_LABEL_MAKE(n);
2129
+ RBREAK_TAG_FOREACH(DISPATCH_CHECKPOINTS)
2130
+ #undef DISPATCH_CHECKPOINTS
2131
+ default:
2132
+ mrb_assert(!"wrong break tag");
2133
+ }
2116
2134
  }
2117
- mrb->c->stack = ci->stackent;
2118
- proc = proc->upper;
2119
- while (mrb->c->cibase < ci && ci[-1].proc != proc) {
2135
+ while (mrb->c->cibase < ci && ci[-1].proc != proc->upper) {
2120
2136
  if (ci[-1].acc == CI_ACC_SKIP) {
2121
- while (ci < mrb->c->ci) {
2122
- cipop(mrb);
2123
- }
2124
2137
  goto L_BREAK_ERROR;
2125
2138
  }
2126
- ci--;
2139
+ CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_UPPER) {
2140
+ /* do nothing */
2141
+ }
2142
+ CHECKPOINT_MAIN(RBREAK_TAG_BREAK_UPPER) {
2143
+ UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_UPPER, proc, v);
2144
+ }
2145
+ CHECKPOINT_END(RBREAK_TAG_BREAK_UPPER);
2146
+ ci = cipop(mrb);
2147
+ pc = ci->pc;
2148
+ }
2149
+ CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_INTARGET) {
2150
+ /* do nothing */
2151
+ }
2152
+ CHECKPOINT_MAIN(RBREAK_TAG_BREAK_INTARGET) {
2153
+ UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_INTARGET, proc, v);
2127
2154
  }
2155
+ CHECKPOINT_END(RBREAK_TAG_BREAK_INTARGET);
2128
2156
  if (ci == mrb->c->cibase) {
2129
2157
  goto L_BREAK_ERROR;
2130
2158
  }
2159
+ mrb->exc = NULL; /* clear break object */
2131
2160
  break;
2132
2161
  default:
2133
2162
  /* cannot happen */
2134
2163
  break;
2135
2164
  }
2136
- while (ci < mrb->c->ci) {
2137
- cipop(mrb);
2138
- }
2139
- ci[0].ridx = ci[-1].ridx;
2140
- while (mrb->c->eidx > ci->epos) {
2141
- ecall_adjust();
2142
- }
2143
- if (mrb->c->vmexec && !ci->target_class) {
2165
+ mrb_assert(ci == mrb->c->ci);
2166
+ mrb_assert(mrb->exc == NULL);
2167
+
2168
+ if (mrb->c->vmexec && !mrb_vm_ci_target_class(ci)) {
2144
2169
  mrb_gc_arena_restore(mrb, ai);
2145
2170
  mrb->c->vmexec = FALSE;
2146
2171
  mrb->jmp = prev_jmp;
2147
2172
  return v;
2148
2173
  }
2149
2174
  acc = ci->acc;
2150
- mrb->c->stack = ci->stackent;
2151
- cipop(mrb);
2175
+ ci = cipop(mrb);
2152
2176
  if (acc == CI_ACC_SKIP || acc == CI_ACC_DIRECT) {
2153
2177
  mrb_gc_arena_restore(mrb, ai);
2154
2178
  mrb->jmp = prev_jmp;
2155
2179
  return v;
2156
2180
  }
2157
- pc = ci->pc;
2158
- ci = mrb->c->ci;
2181
+ pc = ci[0].pc;
2159
2182
  DEBUG(fprintf(stderr, "from :%s\n", mrb_sym_name(mrb, ci->mid)));
2160
2183
  proc = mrb->c->ci->proc;
2161
2184
  irep = proc->body.irep;
@@ -2179,8 +2202,8 @@ RETRY_TRY_BLOCK:
2179
2202
  if (lv == 0) stack = regs + 1;
2180
2203
  else {
2181
2204
  struct REnv *e = uvenv(mrb, lv-1);
2182
- if (!e || (!MRB_ENV_STACK_SHARED_P(e) && e->mid == 0) ||
2183
- MRB_ENV_STACK_LEN(e) <= m1+r+m2+1) {
2205
+ if (!e || (!MRB_ENV_ONSTACK_P(e) && e->mid == 0) ||
2206
+ MRB_ENV_LEN(e) <= m1+r+m2+1) {
2184
2207
  localjump_error(mrb, LOCALJUMP_ERROR_YIELD);
2185
2208
  goto L_RAISE;
2186
2209
  }
@@ -2194,34 +2217,40 @@ RETRY_TRY_BLOCK:
2194
2217
  NEXT;
2195
2218
  }
2196
2219
 
2220
+ L_INT_OVERFLOW:
2221
+ {
2222
+ mrb_value exc = mrb_exc_new_lit(mrb, E_RANGE_ERROR, "integer overflow");
2223
+ mrb_exc_set(mrb, exc);
2224
+ }
2225
+ goto L_RAISE;
2226
+
2197
2227
  #define TYPES2(a,b) ((((uint16_t)(a))<<8)|(((uint16_t)(b))&0xff))
2198
2228
  #define OP_MATH(op_name) \
2199
2229
  /* need to check if op is overridden */ \
2200
2230
  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) { \
2201
- OP_MATH_CASE_FIXNUM(op_name); \
2202
- OP_MATH_CASE_FLOAT(op_name, fixnum, float); \
2203
- OP_MATH_CASE_FLOAT(op_name, float, fixnum); \
2231
+ OP_MATH_CASE_INTEGER(op_name); \
2232
+ OP_MATH_CASE_FLOAT(op_name, integer, float); \
2233
+ OP_MATH_CASE_FLOAT(op_name, float, integer); \
2204
2234
  OP_MATH_CASE_FLOAT(op_name, float, float); \
2205
2235
  OP_MATH_CASE_STRING_##op_name(); \
2206
2236
  default: \
2207
2237
  c = 1; \
2208
- mid = mrb_intern_lit(mrb, MRB_STRINGIZE(OP_MATH_OP_##op_name)); \
2238
+ mid = MRB_OPSYM(op_name); \
2209
2239
  goto L_SEND_SYM; \
2210
2240
  } \
2211
2241
  NEXT;
2212
- #define OP_MATH_CASE_FIXNUM(op_name) \
2213
- case TYPES2(MRB_TT_FIXNUM, MRB_TT_FIXNUM): \
2242
+ #define OP_MATH_CASE_INTEGER(op_name) \
2243
+ case TYPES2(MRB_TT_INTEGER, MRB_TT_INTEGER): \
2214
2244
  { \
2215
- mrb_int x = mrb_fixnum(regs[a]), y = mrb_fixnum(regs[a+1]), z; \
2245
+ mrb_int x = mrb_integer(regs[a]), y = mrb_integer(regs[a+1]), z; \
2216
2246
  if (mrb_int_##op_name##_overflow(x, y, &z)) \
2217
- OP_MATH_OVERFLOW_INT(op_name, x, y, z); \
2247
+ OP_MATH_OVERFLOW_INT(); \
2218
2248
  else \
2219
- SET_INT_VALUE(regs[a], z); \
2249
+ SET_INT_VALUE(mrb,regs[a], z); \
2220
2250
  } \
2221
2251
  break
2222
- #ifdef MRB_WITHOUT_FLOAT
2252
+ #ifdef MRB_NO_FLOAT
2223
2253
  #define OP_MATH_CASE_FLOAT(op_name, t1, t2) (void)0
2224
- #define OP_MATH_OVERFLOW_INT(op_name, x, y, z) SET_INT_VALUE(regs[a], z)
2225
2254
  #else
2226
2255
  #define OP_MATH_CASE_FLOAT(op_name, t1, t2) \
2227
2256
  case TYPES2(OP_MATH_TT_##t1, OP_MATH_TT_##t2): \
@@ -2230,9 +2259,8 @@ RETRY_TRY_BLOCK:
2230
2259
  SET_FLOAT_VALUE(mrb, regs[a], z); \
2231
2260
  } \
2232
2261
  break
2233
- #define OP_MATH_OVERFLOW_INT(op_name, x, y, z) \
2234
- SET_FLOAT_VALUE(mrb, regs[a], (mrb_float)x OP_MATH_OP_##op_name (mrb_float)y)
2235
2262
  #endif
2263
+ #define OP_MATH_OVERFLOW_INT() goto L_INT_OVERFLOW
2236
2264
  #define OP_MATH_CASE_STRING_add() \
2237
2265
  case TYPES2(MRB_TT_STRING, MRB_TT_STRING): \
2238
2266
  regs[a] = mrb_str_plus(mrb, regs[a], regs[a+1]); \
@@ -2243,8 +2271,8 @@ RETRY_TRY_BLOCK:
2243
2271
  #define OP_MATH_OP_add +
2244
2272
  #define OP_MATH_OP_sub -
2245
2273
  #define OP_MATH_OP_mul *
2246
- #define OP_MATH_TT_fixnum MRB_TT_FIXNUM
2247
- #define OP_MATH_TT_float MRB_TT_FLOAT
2274
+ #define OP_MATH_TT_integer MRB_TT_INTEGER
2275
+ #define OP_MATH_TT_float MRB_TT_FLOAT
2248
2276
 
2249
2277
  CASE(OP_ADD, B) {
2250
2278
  OP_MATH(add);
@@ -2259,31 +2287,30 @@ RETRY_TRY_BLOCK:
2259
2287
  }
2260
2288
 
2261
2289
  CASE(OP_DIV, B) {
2262
- #ifndef MRB_WITHOUT_FLOAT
2263
- double x, y, f;
2290
+ mrb_int mrb_num_div_int(mrb_state *mrb, mrb_int x, mrb_int y);
2291
+ #ifndef MRB_NO_FLOAT
2292
+ mrb_float mrb_num_div_flo(mrb_state *mrb, mrb_float x, mrb_float y);
2293
+ mrb_float x, y, f;
2264
2294
  #endif
2265
2295
 
2266
2296
  /* need to check if op is overridden */
2267
2297
  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {
2268
- case TYPES2(MRB_TT_FIXNUM,MRB_TT_FIXNUM):
2269
- #ifdef MRB_WITHOUT_FLOAT
2298
+ case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):
2270
2299
  {
2271
- mrb_int x = mrb_fixnum(regs[a]);
2272
- mrb_int y = mrb_fixnum(regs[a+1]);
2273
- SET_INT_VALUE(regs[a], y ? x / y : 0);
2300
+ mrb_int x = mrb_integer(regs[a]);
2301
+ mrb_int y = mrb_integer(regs[a+1]);
2302
+ mrb_int div = mrb_num_div_int(mrb, x, y);
2303
+ SET_INT_VALUE(mrb, regs[a], div);
2274
2304
  }
2275
- break;
2276
- #else
2277
- x = (mrb_float)mrb_fixnum(regs[a]);
2278
- y = (mrb_float)mrb_fixnum(regs[a+1]);
2279
- break;
2280
- case TYPES2(MRB_TT_FIXNUM,MRB_TT_FLOAT):
2281
- x = (mrb_float)mrb_fixnum(regs[a]);
2305
+ NEXT;
2306
+ #ifndef MRB_NO_FLOAT
2307
+ case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):
2308
+ x = (mrb_float)mrb_integer(regs[a]);
2282
2309
  y = mrb_float(regs[a+1]);
2283
2310
  break;
2284
- case TYPES2(MRB_TT_FLOAT,MRB_TT_FIXNUM):
2311
+ case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):
2285
2312
  x = mrb_float(regs[a]);
2286
- y = (mrb_float)mrb_fixnum(regs[a+1]);
2313
+ y = (mrb_float)mrb_integer(regs[a+1]);
2287
2314
  break;
2288
2315
  case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):
2289
2316
  x = mrb_float(regs[a]);
@@ -2292,19 +2319,12 @@ RETRY_TRY_BLOCK:
2292
2319
  #endif
2293
2320
  default:
2294
2321
  c = 1;
2295
- mid = mrb_intern_lit(mrb, "/");
2322
+ mid = MRB_OPSYM(div);
2296
2323
  goto L_SEND_SYM;
2297
2324
  }
2298
2325
 
2299
- #ifndef MRB_WITHOUT_FLOAT
2300
- if (y == 0) {
2301
- if (x > 0) f = INFINITY;
2302
- else if (x < 0) f = -INFINITY;
2303
- else /* if (x == 0) */ f = NAN;
2304
- }
2305
- else {
2306
- f = x / y;
2307
- }
2326
+ #ifndef MRB_NO_FLOAT
2327
+ f = mrb_num_div_flo(mrb, x, y);
2308
2328
  SET_FLOAT_VALUE(mrb, regs[a], f);
2309
2329
  #endif
2310
2330
  NEXT;
@@ -2313,26 +2333,26 @@ RETRY_TRY_BLOCK:
2313
2333
  #define OP_MATHI(op_name) \
2314
2334
  /* need to check if op is overridden */ \
2315
2335
  switch (mrb_type(regs[a])) { \
2316
- OP_MATHI_CASE_FIXNUM(op_name); \
2336
+ OP_MATHI_CASE_INTEGER(op_name); \
2317
2337
  OP_MATHI_CASE_FLOAT(op_name); \
2318
2338
  default: \
2319
- SET_INT_VALUE(regs[a+1], b); \
2339
+ SET_INT_VALUE(mrb,regs[a+1], b); \
2320
2340
  c = 1; \
2321
- mid = mrb_intern_lit(mrb, MRB_STRINGIZE(OP_MATH_OP_##op_name)); \
2341
+ mid = MRB_OPSYM(op_name); \
2322
2342
  goto L_SEND_SYM; \
2323
2343
  } \
2324
2344
  NEXT;
2325
- #define OP_MATHI_CASE_FIXNUM(op_name) \
2326
- case MRB_TT_FIXNUM: \
2345
+ #define OP_MATHI_CASE_INTEGER(op_name) \
2346
+ case MRB_TT_INTEGER: \
2327
2347
  { \
2328
- mrb_int x = mrb_fixnum(regs[a]), y = (mrb_int)b, z; \
2348
+ mrb_int x = mrb_integer(regs[a]), y = (mrb_int)b, z; \
2329
2349
  if (mrb_int_##op_name##_overflow(x, y, &z)) \
2330
- OP_MATH_OVERFLOW_INT(op_name, x, y, z); \
2350
+ OP_MATH_OVERFLOW_INT(); \
2331
2351
  else \
2332
- SET_INT_VALUE(regs[a], z); \
2352
+ SET_INT_VALUE(mrb,regs[a], z); \
2333
2353
  } \
2334
2354
  break
2335
- #ifdef MRB_WITHOUT_FLOAT
2355
+ #ifdef MRB_NO_FLOAT
2336
2356
  #define OP_MATHI_CASE_FLOAT(op_name) (void)0
2337
2357
  #else
2338
2358
  #define OP_MATHI_CASE_FLOAT(op_name) \
@@ -2354,17 +2374,17 @@ RETRY_TRY_BLOCK:
2354
2374
 
2355
2375
  #define OP_CMP_BODY(op,v1,v2) (v1(regs[a]) op v2(regs[a+1]))
2356
2376
 
2357
- #ifdef MRB_WITHOUT_FLOAT
2358
- #define OP_CMP(op) do {\
2377
+ #ifdef MRB_NO_FLOAT
2378
+ #define OP_CMP(op,sym) do {\
2359
2379
  int result;\
2360
2380
  /* need to check if - is overridden */\
2361
2381
  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\
2362
- case TYPES2(MRB_TT_FIXNUM,MRB_TT_FIXNUM):\
2382
+ case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\
2363
2383
  result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\
2364
2384
  break;\
2365
2385
  default:\
2366
2386
  c = 1;\
2367
- mid = mrb_intern_lit(mrb, # op);\
2387
+ mid = MRB_OPSYM(sym);\
2368
2388
  goto L_SEND_SYM;\
2369
2389
  }\
2370
2390
  if (result) {\
@@ -2375,17 +2395,17 @@ RETRY_TRY_BLOCK:
2375
2395
  }\
2376
2396
  } while(0)
2377
2397
  #else
2378
- #define OP_CMP(op) do {\
2398
+ #define OP_CMP(op, sym) do {\
2379
2399
  int result;\
2380
2400
  /* need to check if - is overridden */\
2381
2401
  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\
2382
- case TYPES2(MRB_TT_FIXNUM,MRB_TT_FIXNUM):\
2402
+ case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\
2383
2403
  result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\
2384
2404
  break;\
2385
- case TYPES2(MRB_TT_FIXNUM,MRB_TT_FLOAT):\
2405
+ case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):\
2386
2406
  result = OP_CMP_BODY(op,mrb_fixnum,mrb_float);\
2387
2407
  break;\
2388
- case TYPES2(MRB_TT_FLOAT,MRB_TT_FIXNUM):\
2408
+ case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):\
2389
2409
  result = OP_CMP_BODY(op,mrb_float,mrb_fixnum);\
2390
2410
  break;\
2391
2411
  case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\
@@ -2393,7 +2413,7 @@ RETRY_TRY_BLOCK:
2393
2413
  break;\
2394
2414
  default:\
2395
2415
  c = 1;\
2396
- mid = mrb_intern_lit(mrb, # op);\
2416
+ mid = MRB_OPSYM(sym);\
2397
2417
  goto L_SEND_SYM;\
2398
2418
  }\
2399
2419
  if (result) {\
@@ -2410,28 +2430,28 @@ RETRY_TRY_BLOCK:
2410
2430
  SET_TRUE_VALUE(regs[a]);
2411
2431
  }
2412
2432
  else {
2413
- OP_CMP(==);
2433
+ OP_CMP(==,eq);
2414
2434
  }
2415
2435
  NEXT;
2416
2436
  }
2417
2437
 
2418
2438
  CASE(OP_LT, B) {
2419
- OP_CMP(<);
2439
+ OP_CMP(<,lt);
2420
2440
  NEXT;
2421
2441
  }
2422
2442
 
2423
2443
  CASE(OP_LE, B) {
2424
- OP_CMP(<=);
2444
+ OP_CMP(<=,le);
2425
2445
  NEXT;
2426
2446
  }
2427
2447
 
2428
2448
  CASE(OP_GT, B) {
2429
- OP_CMP(>);
2449
+ OP_CMP(>,gt);
2430
2450
  NEXT;
2431
2451
  }
2432
2452
 
2433
2453
  CASE(OP_GE, B) {
2434
- OP_CMP(>=);
2454
+ OP_CMP(>=,ge);
2435
2455
  NEXT;
2436
2456
  }
2437
2457
 
@@ -2542,10 +2562,19 @@ RETRY_TRY_BLOCK:
2542
2562
  NEXT;
2543
2563
  }
2544
2564
 
2565
+ CASE(OP_STRING16, BS) {
2566
+ goto op_string;
2567
+ }
2545
2568
  CASE(OP_STRING, BB) {
2546
- mrb_value str = mrb_str_dup(mrb, pool[b]);
2547
-
2548
- regs[a] = str;
2569
+ size_t len;
2570
+ op_string:
2571
+ len = pool[b].tt >> 2;
2572
+ if (pool[b].tt & IREP_TT_SFLAG) {
2573
+ regs[a] = mrb_str_new_static(mrb, pool[b].u.str, len);
2574
+ }
2575
+ else {
2576
+ regs[a] = mrb_str_new(mrb, pool[b].u.str, len);
2577
+ }
2549
2578
  mrb_gc_arena_restore(mrb, ai);
2550
2579
  NEXT;
2551
2580
  }
@@ -2593,7 +2622,7 @@ RETRY_TRY_BLOCK:
2593
2622
  L_MAKE_LAMBDA:
2594
2623
  {
2595
2624
  struct RProc *p;
2596
- mrb_irep *nirep = irep->reps[b];
2625
+ const mrb_irep *nirep = irep->reps[b];
2597
2626
 
2598
2627
  if (c & OP_L_CAPTURE) {
2599
2628
  p = mrb_closure_new(mrb, nirep);
@@ -2615,6 +2644,18 @@ RETRY_TRY_BLOCK:
2615
2644
  c = OP_L_METHOD;
2616
2645
  goto L_MAKE_LAMBDA;
2617
2646
  }
2647
+ CASE(OP_LAMBDA16, BS) {
2648
+ c = OP_L_LAMBDA;
2649
+ goto L_MAKE_LAMBDA;
2650
+ }
2651
+ CASE(OP_BLOCK16, BS) {
2652
+ c = OP_L_BLOCK;
2653
+ goto L_MAKE_LAMBDA;
2654
+ }
2655
+ CASE(OP_METHOD16, BS) {
2656
+ c = OP_L_METHOD;
2657
+ goto L_MAKE_LAMBDA;
2658
+ }
2618
2659
 
2619
2660
  CASE(OP_RANGE_INC, B) {
2620
2661
  mrb_value val = mrb_range_new(mrb, regs[a], regs[a+1], FALSE);
@@ -2644,6 +2685,7 @@ RETRY_TRY_BLOCK:
2644
2685
  super = regs[a+1];
2645
2686
  if (mrb_nil_p(base)) {
2646
2687
  baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);
2688
+ if (!baseclass) baseclass = mrb->object_class;
2647
2689
  base = mrb_obj_value(baseclass);
2648
2690
  }
2649
2691
  c = mrb_vm_define_class(mrb, base, super, id);
@@ -2660,6 +2702,7 @@ RETRY_TRY_BLOCK:
2660
2702
  base = regs[a];
2661
2703
  if (mrb_nil_p(base)) {
2662
2704
  baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);
2705
+ if (!baseclass) baseclass = mrb->object_class;
2663
2706
  base = mrb_obj_value(baseclass);
2664
2707
  }
2665
2708
  cls = mrb_vm_define_module(mrb, base, id);
@@ -2668,11 +2711,14 @@ RETRY_TRY_BLOCK:
2668
2711
  NEXT;
2669
2712
  }
2670
2713
 
2671
- CASE(OP_EXEC, BB) {
2672
- mrb_callinfo *ci;
2714
+ CASE(OP_EXEC16, BS)
2715
+ goto L_EXEC;
2716
+ CASE(OP_EXEC, BB)
2717
+ L_EXEC:
2718
+ {
2673
2719
  mrb_value recv = regs[a];
2674
2720
  struct RProc *p;
2675
- mrb_irep *nirep = irep->reps[b];
2721
+ const mrb_irep *nirep = irep->reps[b];
2676
2722
 
2677
2723
  /* prepare closure */
2678
2724
  p = mrb_proc_new(mrb, nirep);
@@ -2682,19 +2728,7 @@ RETRY_TRY_BLOCK:
2682
2728
  p->flags |= MRB_PROC_SCOPE;
2683
2729
 
2684
2730
  /* prepare call stack */
2685
- ci = cipush(mrb);
2686
- ci->pc = pc;
2687
- ci->acc = a;
2688
- ci->mid = 0;
2689
- ci->stackent = mrb->c->stack;
2690
- ci->argc = 0;
2691
- ci->target_class = mrb_class_ptr(recv);
2692
-
2693
- /* prepare stack */
2694
- mrb->c->stack += a;
2695
-
2696
- /* setup block to call */
2697
- ci->proc = p;
2731
+ cipush(mrb, a, a, mrb_class_ptr(recv), p, 0, 0);
2698
2732
 
2699
2733
  irep = p->body.irep;
2700
2734
  pool = irep->pool;
@@ -2724,7 +2758,7 @@ RETRY_TRY_BLOCK:
2724
2758
 
2725
2759
  CASE(OP_TCLASS, B) {
2726
2760
  if (!check_target_class(mrb)) goto L_RAISE;
2727
- regs[a] = mrb_obj_value(mrb->c->ci->target_class);
2761
+ regs[a] = mrb_obj_value(mrb_vm_ci_target_class(mrb->c->ci));
2728
2762
  NEXT;
2729
2763
  }
2730
2764
 
@@ -2732,7 +2766,7 @@ RETRY_TRY_BLOCK:
2732
2766
  struct RClass *target;
2733
2767
 
2734
2768
  if (!check_target_class(mrb)) goto L_RAISE;
2735
- target = mrb->c->ci->target_class;
2769
+ target = mrb_vm_ci_target_class(mrb->c->ci);
2736
2770
  mrb_alias_method(mrb, target, syms[a], syms[b]);
2737
2771
  NEXT;
2738
2772
  }
@@ -2740,17 +2774,17 @@ RETRY_TRY_BLOCK:
2740
2774
  struct RClass *target;
2741
2775
 
2742
2776
  if (!check_target_class(mrb)) goto L_RAISE;
2743
- target = mrb->c->ci->target_class;
2777
+ target = mrb_vm_ci_target_class(mrb->c->ci);
2744
2778
  mrb_undef_method_id(mrb, target, syms[a]);
2745
2779
  NEXT;
2746
2780
  }
2747
2781
 
2748
2782
  CASE(OP_DEBUG, Z) {
2749
2783
  FETCH_BBB();
2750
- #ifdef MRB_ENABLE_DEBUG_HOOK
2784
+ #ifdef MRB_USE_DEBUG_HOOK
2751
2785
  mrb->debug_op_hook(mrb, irep, pc, regs);
2752
2786
  #else
2753
- #ifndef MRB_DISABLE_STDIO
2787
+ #ifndef MRB_NO_STDIO
2754
2788
  printf("OP_DEBUG %d %d %d\n", a, b, c);
2755
2789
  #else
2756
2790
  abort();
@@ -2760,56 +2794,32 @@ RETRY_TRY_BLOCK:
2760
2794
  }
2761
2795
 
2762
2796
  CASE(OP_ERR, B) {
2763
- mrb_value msg = mrb_str_dup(mrb, pool[a]);
2797
+ size_t len = pool[a].tt >> 2;
2764
2798
  mrb_value exc;
2765
2799
 
2766
- exc = mrb_exc_new_str(mrb, E_LOCALJUMP_ERROR, msg);
2767
- ERR_PC_SET(mrb);
2800
+ mrb_assert((pool[a].tt&IREP_TT_NFLAG)==0);
2801
+ exc = mrb_exc_new(mrb, E_LOCALJUMP_ERROR, pool[a].u.str, len);
2768
2802
  mrb_exc_set(mrb, exc);
2769
2803
  goto L_RAISE;
2770
2804
  }
2771
2805
 
2772
- CASE(OP_EXT1, Z) {
2773
- insn = READ_B();
2774
- switch (insn) {
2775
- #define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _1(); goto L_OP_ ## insn ## _BODY;
2776
- #include "mruby/ops.h"
2777
- #undef OPCODE
2778
- }
2779
- pc--;
2780
- NEXT;
2781
- }
2782
- CASE(OP_EXT2, Z) {
2783
- insn = READ_B();
2784
- switch (insn) {
2785
- #define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _2(); goto L_OP_ ## insn ## _BODY;
2786
- #include "mruby/ops.h"
2787
- #undef OPCODE
2788
- }
2789
- pc--;
2790
- NEXT;
2791
- }
2792
- CASE(OP_EXT3, Z) {
2793
- uint8_t insn = READ_B();
2794
- switch (insn) {
2795
- #define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _3(); goto L_OP_ ## insn ## _BODY;
2796
- #include "mruby/ops.h"
2797
- #undef OPCODE
2798
- }
2799
- pc--;
2806
+ CASE(OP_SENDVK, BB) { /* not yet implemented */
2800
2807
  NEXT;
2801
2808
  }
2802
2809
 
2803
2810
  CASE(OP_STOP, Z) {
2804
2811
  /* stop VM */
2805
- L_STOP:
2806
- while (mrb->c->eidx > 0) {
2807
- ecall(mrb);
2812
+ CHECKPOINT_RESTORE(RBREAK_TAG_STOP) {
2813
+ /* do nothing */
2814
+ }
2815
+ CHECKPOINT_MAIN(RBREAK_TAG_STOP) {
2816
+ UNWIND_ENSURE(mrb, mrb->c->ci, pc, RBREAK_TAG_STOP, proc, mrb_nil_value());
2808
2817
  }
2809
- mrb->c->cibase->ridx = 0;
2810
- ERR_PC_CLR(mrb);
2818
+ CHECKPOINT_END(RBREAK_TAG_STOP);
2819
+ L_STOP:
2811
2820
  mrb->jmp = prev_jmp;
2812
2821
  if (mrb->exc) {
2822
+ mrb_assert(mrb->exc->tt == MRB_TT_EXCEPTION);
2813
2823
  return mrb_obj_value(mrb->exc);
2814
2824
  }
2815
2825
  return regs[irep->nlocals];
@@ -2819,14 +2829,19 @@ RETRY_TRY_BLOCK:
2819
2829
  #undef regs
2820
2830
  }
2821
2831
  MRB_CATCH(&c_jmp) {
2832
+ mrb_callinfo *ci = mrb->c->ci;
2833
+ while (ci > mrb->c->cibase && ci->acc == CI_ACC_DIRECT) {
2834
+ ci = cipop(mrb);
2835
+ }
2822
2836
  exc_catched = TRUE;
2837
+ pc = ci->pc;
2823
2838
  goto RETRY_TRY_BLOCK;
2824
2839
  }
2825
2840
  MRB_END_EXC(&c_jmp);
2826
2841
  }
2827
2842
 
2828
- MRB_API mrb_value
2829
- mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
2843
+ static mrb_value
2844
+ mrb_run(mrb_state *mrb, const struct RProc *proc, mrb_value self)
2830
2845
  {
2831
2846
  if (mrb->c->ci->argc < 0) {
2832
2847
  return mrb_vm_run(mrb, proc, self, 3); /* receiver, args and block) */
@@ -2837,34 +2852,29 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
2837
2852
  }
2838
2853
 
2839
2854
  MRB_API mrb_value
2840
- mrb_top_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep)
2855
+ mrb_top_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int stack_keep)
2841
2856
  {
2842
- mrb_callinfo *ci;
2843
2857
  mrb_value v;
2844
2858
 
2845
2859
  if (!mrb->c->cibase) {
2846
2860
  return mrb_vm_run(mrb, proc, self, stack_keep);
2847
2861
  }
2848
2862
  if (mrb->c->ci == mrb->c->cibase) {
2849
- mrb->c->ci->env = NULL;
2863
+ mrb_vm_ci_env_set(mrb->c->ci, NULL);
2850
2864
  return mrb_vm_run(mrb, proc, self, stack_keep);
2851
2865
  }
2852
- ci = cipush(mrb);
2853
- ci->stackent = mrb->c->stack;
2854
- ci->mid = 0;
2855
- ci->acc = CI_ACC_SKIP;
2856
- ci->target_class = mrb->object_class;
2866
+ cipush(mrb, 0, CI_ACC_SKIP, mrb->object_class, NULL, 0, 0);
2857
2867
  v = mrb_vm_run(mrb, proc, self, stack_keep);
2858
2868
 
2859
2869
  return v;
2860
2870
  }
2861
2871
 
2862
- #if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
2863
- # if !defined(MRB_ENABLE_CXX_ABI)
2872
+ #if defined(MRB_USE_CXX_EXCEPTION) && defined(__cplusplus)
2873
+ # if !defined(MRB_USE_CXX_ABI)
2864
2874
  } /* end of extern "C" */
2865
2875
  # endif
2866
2876
  mrb_int mrb_jmpbuf::jmpbuf_id = 0;
2867
- # if !defined(MRB_ENABLE_CXX_ABI)
2877
+ # if !defined(MRB_USE_CXX_ABI)
2868
2878
  extern "C" {
2869
2879
  # endif
2870
2880
  #endif