wardite 0.9.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +191 -0
  3. data/Makefile +14 -0
  4. data/README.md +107 -2
  5. data/Rakefile +5 -0
  6. data/Steepfile +1 -0
  7. data/assets/wardite.svg +12 -0
  8. data/benchmark/README.md +500 -0
  9. data/benchmark/build_call_profile.rb +42 -0
  10. data/benchmark/call_cost_worker.rb +27 -0
  11. data/benchmark/compare.rb +93 -0
  12. data/benchmark/compare_call_types.rb +212 -0
  13. data/benchmark/compare_dispatch.rb +123 -0
  14. data/benchmark/compare_engines.rb +119 -0
  15. data/benchmark/compare_optimizations.rb +139 -0
  16. data/benchmark/engine_phases.rb +30 -0
  17. data/benchmark/figures/README.md +35 -0
  18. data/benchmark/figures/plot_spinel_comparison.py +137 -0
  19. data/benchmark/figures/spinel_new_vm_candlestick.png +0 -0
  20. data/benchmark/figures/spinel_new_vm_candlestick.svg +7615 -0
  21. data/benchmark/figures/spinel_new_vm_summary.csv +9 -0
  22. data/benchmark/figures/spinel_new_vm_summary.json +82 -0
  23. data/benchmark/float_m5.wat +42 -0
  24. data/benchmark/i32_call_arities.wat +89 -0
  25. data/benchmark/i32_calls.wat +174 -0
  26. data/benchmark/i32_memory.wat +58 -0
  27. data/benchmark/i32_mix.wat +80 -0
  28. data/benchmark/i64_m4.wat +55 -0
  29. data/benchmark/investigate_calls.rb +231 -0
  30. data/benchmark/investigate_generated_guards.rb +218 -0
  31. data/benchmark/m3_call_worker.rb +38 -0
  32. data/benchmark/measure_m1.rb +51 -0
  33. data/benchmark/measure_m2.rb +55 -0
  34. data/benchmark/measure_m3_calls.rb +89 -0
  35. data/benchmark/measure_m4.rb +134 -0
  36. data/benchmark/measure_m5_boundary.rb +41 -0
  37. data/benchmark/measure_mir_cache_verify.rb +58 -0
  38. data/benchmark/measure_ruby_wasm_cache_hit.rb +59 -0
  39. data/benchmark/measure_ruby_wasm_startup.rb +43 -0
  40. data/benchmark/measure_wasi_write.rb +75 -0
  41. data/benchmark/optimization_worker.rb +23 -0
  42. data/benchmark/results/call_arities_exploratory_2026-11-04.json +4320 -0
  43. data/benchmark/results/call_arities_spinel_2026-11-04.json +1200 -0
  44. data/benchmark/results/call_cost_spinel_2026-11-04.json +2392 -0
  45. data/benchmark/results/call_protocol_exploratory_2026-11-04.json +3947 -0
  46. data/benchmark/results/call_protocol_profile_2026-11-04.json +383 -0
  47. data/benchmark/results/call_protocol_ruby_2026-11-04.json +1213 -0
  48. data/benchmark/results/call_protocol_spinel_2026-11-04.json +913 -0
  49. data/benchmark/results/call_types_ruby_2026-11-04.json +1212 -0
  50. data/benchmark/results/call_types_spinel_2026-11-04.json +923 -0
  51. data/benchmark/results/efflorescence-m1-cruby.json +799 -0
  52. data/benchmark/results/efflorescence-m1-spinel.json +799 -0
  53. data/benchmark/results/efflorescence-m2-bulk-loop.json +820 -0
  54. data/benchmark/results/efflorescence-m2-i32-cruby.json +799 -0
  55. data/benchmark/results/efflorescence-m2-i32-spinel.json +799 -0
  56. data/benchmark/results/efflorescence-m2-memory.json +408 -0
  57. data/benchmark/results/efflorescence-mir2-cache-integrity.json +390 -0
  58. data/benchmark/results/efflorescence-unboxed-globals.json +3451 -0
  59. data/benchmark/results/generated_guards_exploratory_2026-11-04.json +1225 -0
  60. data/benchmark/results/generated_guards_profile_2026-11-04.json +592 -0
  61. data/benchmark/results/generated_guards_spinel_2026-11-04.json +1650 -0
  62. data/benchmark/results/generated_guards_validation_2026-11-04.json +256 -0
  63. data/benchmark/results/inlining_engines_2026-11-04.json +241 -0
  64. data/benchmark/results/inlining_ruby_2026-11-04.json +1213 -0
  65. data/benchmark/results/inlining_spinel_2026-11-04.json +893 -0
  66. data/benchmark/results/operand_decode_exploratory_2026-11-04.json +1319 -0
  67. data/benchmark/results/operand_decode_ruby_2026-11-04.json +1213 -0
  68. data/benchmark/results/operand_decode_spinel_2026-11-04.json +924 -0
  69. data/benchmark/results/selective_reset_spinel_2026-11-04.json +454 -0
  70. data/benchmark/results/selective_reset_spinel_2026-11-04_exploratory.json +2679 -0
  71. data/benchmark/results/spinel_fetch_root_patch_2026-11-04.json +4523 -0
  72. data/benchmark/results/while_final_compiler_comparison_2026-11-04.json +324 -0
  73. data/benchmark/results/while_patched_external_2026-11-04.json +220 -0
  74. data/benchmark/results/while_user_unpatched_2026-11-04.json +230 -0
  75. data/benchmark/summarize_call_profile.py +54 -0
  76. data/benchmark/validate_m1_eh.rb +34 -0
  77. data/benchmark/validate_m2.rb +119 -0
  78. data/benchmark/validate_m3.rb +44 -0
  79. data/benchmark/validate_m4.rb +95 -0
  80. data/benchmark/validate_m5.rb +108 -0
  81. data/docs/adr/0001-efflorescence-m1-control-and-eh.md +319 -0
  82. data/docs/adr/0002-efflorescence-m2-memory-and-globals.md +185 -0
  83. data/docs/adr/0003-efflorescence-m3-host-and-indirect-calls.md +228 -0
  84. data/docs/adr/0004-efflorescence-m4-i64.md +202 -0
  85. data/docs/adr/0005-efflorescence-m5-floating-point.md +127 -0
  86. data/docs/adr/0006-efflorescence-m6-coverage-parity.md +101 -0
  87. data/docs/adr/0007-efflorescence-ruby-wasm-phase1.md +75 -0
  88. data/docs/adr/0008-efflorescence-ruby-wasm-phase2.md +75 -0
  89. data/docs/adr/0009-efflorescence-mir2-cache-integrity-modes.md +77 -0
  90. data/docs/adr/0010-efflorescence-mir2-cache-function-restore.md +80 -0
  91. data/docs/adr/0011-efflorescence-unboxed-globals.md +89 -0
  92. data/docs/adr/0012-efflorescence-startup-snapshot.md +173 -0
  93. data/docs/adr/0013-efflorescence-frame-acquisition.md +114 -0
  94. data/docs/efflorescence-call-arities.md +115 -0
  95. data/docs/efflorescence-call-investigation.md +155 -0
  96. data/docs/efflorescence-call-transfer.md +128 -0
  97. data/docs/efflorescence-call-types.md +102 -0
  98. data/docs/efflorescence-coverage-ja.md +351 -0
  99. data/docs/efflorescence-generated-c-guards.md +410 -0
  100. data/docs/efflorescence-inlining.md +165 -0
  101. data/docs/efflorescence-ja.md +155 -0
  102. data/docs/efflorescence-m1.md +160 -0
  103. data/docs/efflorescence-m2.md +233 -0
  104. data/docs/efflorescence-m3.md +131 -0
  105. data/docs/efflorescence-m4.md +88 -0
  106. data/docs/efflorescence-m5.md +82 -0
  107. data/docs/efflorescence-m6.md +95 -0
  108. data/docs/efflorescence-mir2-cache.md +123 -0
  109. data/docs/efflorescence-operand-decoding.md +105 -0
  110. data/docs/efflorescence-phase2-ja.md +225 -0
  111. data/docs/efflorescence-phase2.md +240 -0
  112. data/docs/efflorescence-register-initialization.md +75 -0
  113. data/docs/efflorescence-ruby-wasm-phase1.md +90 -0
  114. data/docs/efflorescence-spinel-linear-memory.md +72 -0
  115. data/docs/efflorescence-startup-snapshot.md +60 -0
  116. data/docs/efflorescence-unboxed-globals.md +61 -0
  117. data/docs/efflorescence.md +144 -0
  118. data/docs/spinel-string-aset-inplace-proposal.md +200 -0
  119. data/lib/wardite/alu_f32.generated.rb +11 -2
  120. data/lib/wardite/alu_f64.generated.rb +11 -2
  121. data/lib/wardite/alu_i32.generated.rb +54 -17
  122. data/lib/wardite/alu_i64.generated.rb +73 -31
  123. data/lib/wardite/cli/cli.rb +112 -29
  124. data/lib/wardite/const.rb +1 -0
  125. data/lib/wardite/efflorescence/float_arithmetic.rb +216 -0
  126. data/lib/wardite/efflorescence/i64_arithmetic.rb +257 -0
  127. data/lib/wardite/efflorescence/inspection.rb +165 -0
  128. data/lib/wardite/efflorescence/ir.rb +1164 -0
  129. data/lib/wardite/efflorescence/mir_cache.rb +657 -0
  130. data/lib/wardite/efflorescence/optimizer.rb +580 -0
  131. data/lib/wardite/efflorescence/register_validation.rb +362 -0
  132. data/lib/wardite/efflorescence/snapshot.rb +229 -0
  133. data/lib/wardite/efflorescence/store_access.rb +366 -0
  134. data/lib/wardite/efflorescence/translator.rb +866 -0
  135. data/lib/wardite/efflorescence/vm.rb +1170 -0
  136. data/lib/wardite/efflorescence/wasi.rb +52 -0
  137. data/lib/wardite/efflorescence.rb +17 -0
  138. data/lib/wardite/errors.rb +20 -0
  139. data/lib/wardite/float_bits.rb +46 -0
  140. data/lib/wardite/instruction.rb +35 -4
  141. data/lib/wardite/leb128.rb +33 -12
  142. data/lib/wardite/load.rb +292 -143
  143. data/lib/wardite/value.rb +169 -175
  144. data/lib/wardite/version.rb +1 -1
  145. data/lib/wardite/wasi/consts.rb +1 -0
  146. data/lib/wardite/wasi/spinel.rb +41 -0
  147. data/lib/wardite/wasi.rb +483 -268
  148. data/lib/wardite/wasm_module.rb +6 -3
  149. data/lib/wardite.rb +360 -98
  150. data/rbs_collection.lock.yaml +36 -96
  151. data/scripts/gen_alu.rb +121 -21
  152. data/scripts/verify_ruby_wasm.rb +70 -0
  153. data/sig/generated/wardite/cli/cli.rbs +23 -6
  154. data/sig/generated/wardite/const.rbs +2 -0
  155. data/sig/generated/wardite/efflorescence/float_arithmetic.rbs +65 -0
  156. data/sig/generated/wardite/efflorescence/i64_arithmetic.rbs +99 -0
  157. data/sig/generated/wardite/efflorescence/inspection.rbs +64 -0
  158. data/sig/generated/wardite/efflorescence/ir.rbs +888 -0
  159. data/sig/generated/wardite/efflorescence/mir_cache.rbs +236 -0
  160. data/sig/generated/wardite/efflorescence/optimizer.rbs +189 -0
  161. data/sig/generated/wardite/efflorescence/register_validation.rbs +104 -0
  162. data/sig/generated/wardite/efflorescence/snapshot.rbs +83 -0
  163. data/sig/generated/wardite/efflorescence/store_access.rbs +145 -0
  164. data/sig/generated/wardite/efflorescence/translator.rbs +218 -0
  165. data/sig/generated/wardite/efflorescence/vm.rbs +240 -0
  166. data/sig/generated/wardite/efflorescence/wasi.rbs +34 -0
  167. data/sig/generated/wardite/errors.rbs +12 -0
  168. data/sig/generated/wardite/float_bits.rbs +30 -0
  169. data/sig/generated/wardite/instruction.rbs +22 -1
  170. data/sig/generated/wardite/leb128.rbs +3 -1
  171. data/sig/generated/wardite/load.rbs +59 -7
  172. data/sig/generated/wardite/value.rbs +70 -11
  173. data/sig/generated/wardite/wasi/consts.rbs +2 -0
  174. data/sig/generated/wardite/wasi/spinel.rbs +15 -0
  175. data/sig/generated/wardite/wasi.rbs +111 -4
  176. data/sig/generated/wardite.rbs +114 -13
  177. data/sig/mir_cache_stdlib.rbs +5 -0
  178. data/sig/vernier.rbs +2 -2
  179. data/spinel/README.md +30 -0
  180. data/spinel/bin/wardite.rb +6 -0
  181. data/spinel/patches/0001-io-buffer-string-view.patch +699 -0
  182. data/spinel/patches/0002-io-buffer-allocation-error.patch +47 -0
  183. data/spinel/spin.toml +7 -0
  184. metadata +154 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed01a146affa721cec03c8751baded66418e2f62d6b42a878c6a8a60d8bdf270
4
- data.tar.gz: 84fdcdfb8127d32a40f95f629065b6ce9c65f30e9f79c854003b9de05ee45b14
3
+ metadata.gz: e8542bfea8c7d257afcc7c5d9fa9f97dc816f18d462eadbee9ea6f2298c8f0f8
4
+ data.tar.gz: 4dd3f1a5661c85295c1c38d07c424bfd5d1e979b6a8fa5d5efeb30a920696c85
5
5
  SHA512:
6
- metadata.gz: 538b3e0a4b50fc5b4e109a39d1c243a5751d877859d1fe9942e8e5e52633ecf62ba55b2a99b0ffd80102c3b5cb7de258c8d0e878a8738b0bced8d4c9823e4052
7
- data.tar.gz: 343459f70f34ebe76916058adc10d4db338d2594a39c4dca364fa8387b6c72393939e827517364965a8da14cf64ebf129198c9dbcfab9cf89dc0f17c766a752a
6
+ metadata.gz: 440f1234f039438fd744c46bbac0fc9280e7324863130dee3930474a20ace221d35c6e6437d2dec2e2d7c8568738d664982c84bcfe76440c12a9021c4cf07f5a
7
+ data.tar.gz: dc114ee14a8412a674e724942a7ad6d8eaaad5af9debeeef2ef9a43dd5ee6322bd5e5ed32a87a75b02801f55081d15e0d6f2c1be262ea25783756234f7e85112
data/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, provided
115
+ that the attribution is reasonably visible to all users that
116
+ use the Derivative Works. You may add Your own attribution
117
+ notices within Derivative Works that You distribute, alongside
118
+ or as an addendum to the NOTICE text from the Work, provided
119
+ that such additional attribution notices cannot be construed
120
+ as modifying the License.
121
+
122
+ You may add Your own copyright statement to Your modifications and
123
+ may provide additional or different license terms and conditions
124
+ for use, reproduction, or distribution of Your modifications, or
125
+ for any such Derivative Works as a whole, provided Your use,
126
+ reproduction, and distribution of the Work otherwise complies with
127
+ the conditions stated in this License.
128
+
129
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
130
+ any Contribution intentionally submitted for inclusion in the Work
131
+ by You to the Licensor shall be under the terms and conditions of
132
+ this License, without any additional terms or conditions.
133
+ Notwithstanding the above, nothing herein shall supersede or modify
134
+ the terms of any separate license agreement you may have executed
135
+ with Licensor regarding such Contributions.
136
+
137
+ 6. Trademarks. This License does not grant permission to use the trade
138
+ names, trademarks, service marks, or product names of the Licensor,
139
+ except as required for describing the origin of the Work and
140
+ reproducing the content of the NOTICE file.
141
+
142
+ 7. Disclaimer of Warranty. Unless required by applicable law or
143
+ agreed to in writing, Licensor provides the Work (and each
144
+ Contributor provides its Contributions) on an "AS IS" BASIS,
145
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
146
+ implied, including, without limitation, any warranties or conditions
147
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
148
+ PARTICULAR PURPOSE. You are solely responsible for determining the
149
+ appropriateness of using or redistributing the Work and assume any
150
+ risks associated with Your exercise of permissions under this License.
151
+
152
+ 8. Limitation of Liability. In no event and under no legal theory,
153
+ whether in tort (including negligence), contract, or otherwise,
154
+ unless required by applicable law (such as deliberate and grossly
155
+ negligent acts) or agreed to in writing, shall any Contributor be
156
+ liable to You for damages, including any direct, indirect, special,
157
+ incidental, or consequential damages of any character arising as a
158
+ result of this License or out of the use or inability to use the
159
+ Work (including but not limited to damages for loss of goodwill,
160
+ work stoppage, computer failure or malfunction, or any and all
161
+ other commercial damages or losses), even if such Contributor
162
+ has been advised of the possibility of such damages.
163
+
164
+ 9. Accepting the License. You accept and agree to be bound by the
165
+ terms of this License by copying, modifying, or distributing the
166
+ Work (or works based on the Work).
167
+
168
+ APPENDIX: How to apply the Apache License to your work.
169
+
170
+ To apply the Apache License to your work, attach the following
171
+ boilerplate notice, with the fields enclosed by brackets "[]"
172
+ replaced with your own identifying information. (Don't include
173
+ the brackets!) The text should be enclosed in the appropriate
174
+ comment syntax for the file format. We also recommend that a
175
+ file or class name and description of purpose be included on the
176
+ same "printed page" as the copyright notice for easier
177
+ identification within third-party archives.
178
+
179
+ Copyright 2025 Uchio Kondo
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
data/Makefile ADDED
@@ -0,0 +1,14 @@
1
+ SPINEL ?= spinel
2
+ SPINELFLAGS ?= -O2
3
+ RUBY ?= ruby
4
+ BUILD_DIR ?= build
5
+
6
+ .PHONY: spinel spinel-test
7
+
8
+ # Keep inline RBS and the compiler's default integer overflow checks enabled.
9
+ spinel:
10
+ mkdir -p $(BUILD_DIR)
11
+ $(SPINEL) -I lib --strict-require $(SPINELFLAGS) exe/wardite -o $(BUILD_DIR)/wardite
12
+
13
+ spinel-test: spinel
14
+ WARDITE_SPINEL_BIN="$(abspath $(BUILD_DIR)/wardite)" $(RUBY) -Ilib:test -e 'Dir["test/e2e/spinel*_test.rb"].each { |path| require_relative path }'
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Wardite
2
2
 
3
- [![workflow](https://github.com/udzura/wardite/actions/workflows/main.yml/badge.svg)](https://github.com/udzura/wardite/actions) [![gem version](https://badge.fury.io/rb/wardite.svg)](https://rubygems.org/gems/wardite)
3
+ <img src="assets/wardite.svg" alt="Wardite logo" width="160">
4
+
5
+ [![Test CRuby and Spinel](https://github.com/udzura/wardite/actions/workflows/runtime-tests.yml/badge.svg)](https://github.com/udzura/wardite/actions/workflows/runtime-tests.yml) [![Test Wardite](https://github.com/udzura/wardite/actions/workflows/spec.yml/badge.svg)](https://github.com/udzura/wardite/actions/workflows/spec.yml) [![gem version](https://badge.fury.io/rb/wardite.svg)](https://rubygems.org/gems/wardite)
4
6
 
5
7
  A pure-ruby webassembly runtime.
6
8
 
@@ -58,12 +60,115 @@ $ wardite examples/test.wasm
58
60
  #=> Test!
59
61
  ```
60
62
 
63
+ ### Efflorescence register VM (experimental)
64
+
65
+ Use `--new-engine` to select the MIR-based register engine. The stack VM is the
66
+ default. The same option is available in Spinel builds.
67
+
68
+ ```sh
69
+ wardite --new-engine --no-wasi --invoke add test/add.wasm 100 200
70
+ # return value: I32(300)
71
+ ```
72
+
73
+ In Ruby, pass `engine: :efflorescence` to `Wardite.new` or
74
+ `BinaryLoader.load_from_buffer`. Unsupported instructions raise an explicit
75
+ exception. See the [design, supported subset and tests](docs/efflorescence.md)
76
+ and [engine comparison benchmark](benchmark/README.md).
77
+
78
+ Efflorescence now includes independent COPY/immediate/branch/fusion passes,
79
+ flat integer bytecode and frame reuse. Execution always uses flat bytecode,
80
+ including with `--mir-disable all`; there is no `flat` optimization switch.
81
+ Use `--mir-disable NAME` to compare
82
+ individual features, `--mir-dump` to inspect MIR and `--mir-profile` for counters.
83
+ See [Phase 2](docs/efflorescence-phase2.md) ([日本語](docs/efflorescence-phase2-ja.md)).
84
+
85
+ On CRuby and Spinel, pass `--mir-cache DIR` with `--new-engine` to reuse lowered
86
+ MIR across processes. Use a local directory you control. Each run still decodes
87
+ the Wasm, links imports, and initializes a fresh instance. `--mir-dump` and
88
+ `--mir-profile` build MIR normally. Ruby callers can pass `mir_cache: dir` with
89
+ `engine: :efflorescence`. CRuby and Spinel use different cache keys.
90
+
91
+ The default `--mir-cache-verify checksum` checks the payload size and samples
92
+ blocks. Use `--mir-cache-verify sha256` or Ruby's `mir_cache_verify: :sha256`
93
+ to check the whole payload. Both modes use the same cache file and check MIR
94
+ structure. Corruption outside the sampled blocks can go undetected in checksum
95
+ mode, including changes that leave the MIR structurally valid.
96
+ [MIR2 cache measurements](docs/efflorescence-mir2-cache.md)
97
+
98
+ For WASI commands, `--snapshot DIR` (with `--new-engine --mir-cache DIR`) saves
99
+ the guest state just before its first WASI call that reads files or writes output,
100
+ and later runs with the same Wasm, arguments, environment, preopens and stdio
101
+ kinds resume from there. Clock values and random bytes read before that point
102
+ are frozen into the snapshot, so every resumed run sees the same values (for Ruby, the same hash
103
+ seed). Do not use it where that matters, such as hashing untrusted keys.
104
+ [ADR 0012](docs/adr/0012-efflorescence-startup-snapshot.md)
105
+
106
+ [M1](docs/efflorescence-m1.md) adds the remaining basic i32 operations,
107
+ if/else/select/br_table, and new exception handling (try_table/throw/throw_ref).
108
+ Tags can carry numeric payloads. Nullable exnref locals and multi-result blocks carry
109
+ caught values. Uncaught exceptions expose their tag and payload through
110
+ `Wardite::UncaughtWasmException`. EH remains exclusive to Efflorescence.
111
+
112
+ [M2](docs/efflorescence-m2.md) adds i32 loads/stores, mutable i32 globals and
113
+ memory.size/grow/init/copy/fill. All state stays in the shared Store, with
114
+ checked byte ranges and instance-local runtime data segments.
115
+
116
+ [M3](docs/efflorescence-m3.md) adds i32 function imports, imported reexports,
117
+ and typed `call_indirect` through funcref table 0. Host callbacks share the
118
+ instance Store and can re-enter the VM. On CRuby, Efflorescence runs built-in
119
+ WASI `fd_write` and `proc_exit` with unboxed i32 arguments. Spinel supports
120
+ regular host callbacks.
121
+
122
+ [M4](docs/efflorescence-m4.md) adds i64 and integer conversions, including
123
+ mixed signatures, memory, globals and exception payloads. For an i64 result,
124
+ `runtime.call` returns a `Wardite::I64` and `runtime.call_unboxed` returns a
125
+ signed 64-bit Integer. The i32 unboxed result remains unsigned.
126
+
127
+ [M5](docs/efflorescence-m5.md) adds f32 and f64 arithmetic, conversions, memory,
128
+ globals, calls and exception payloads. Float arguments accept Ruby Float or the
129
+ matching wrapper. Float results are Ruby Float from `call_unboxed` and
130
+ `Wardite::F32` or `Wardite::F64` from `call`.
131
+
132
+ [M6](docs/efflorescence-m6.md) verifies the 188 opcodes in the M0 legacy coverage
133
+ baseline and three additional EH opcodes on CRuby and Spinel. Run
134
+ `bundle exec rake parity` with Spinel, wasm-tools and Wasmtime installed.
135
+
61
136
  ## Development
62
137
 
63
138
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
64
139
 
65
140
  Additionaly, you can run `bundle exec rake check` to generate rbs files from annotations and run `steep check`.
66
141
 
142
+ ### Native executable with Spinel
143
+
144
+ A `spin.toml` application is also available under [`spinel/`](spinel/README.md),
145
+ using `lib/` as a local source dependency and the same CLI as the RubyGem.
146
+
147
+ With `spinel` and a C compiler on your PATH, build the existing CLI:
148
+
149
+ ```console
150
+ $ make spinel
151
+ $ build/wardite --no-wasi --invoke add test/add.wasm 100 200
152
+ return value: I32(300)
153
+ $ make spinel-test
154
+ ```
155
+
156
+ The executable enables the shared WASI Preview 1 host by default. Use
157
+ `--no-wasi` to disable it. To boot a Ruby 4.0.9 WASI binary, run
158
+ `build/wardite --new-engine -- "$ruby_wasm" --disable-gems -e 'puts 6*7'`.
159
+ See the [ruby.wasm verification record](docs/efflorescence-ruby-wasm-phase1.md)
160
+ for the build and file-loading commands. Vernier profiling is available in the
161
+ CRuby build. Ruby's dynamic export helpers (`instance.add(...)` and
162
+ `runtime.add(...)`) rely on `method_missing`; use `instance.runtime.call("add",
163
+ [100, 200])` when compiling an application with Spinel.
164
+
165
+ The build leaves inline RBS and Spinel's default integer overflow checks enabled.
166
+ Wasm integer operations bound their intermediate values, so
167
+ `--int-overflow=promote` is not required.
168
+ The pinned Spinel build applies the IO::Buffer patches under `spinel/patches`.
169
+ See the [build instructions and host memory API](docs/efflorescence-spinel-linear-memory.md).
170
+ Override `SPINEL`, `SPINELFLAGS`, `BUILD_DIR`, or `RUBY` when needed.
171
+
67
172
  ## Contributing
68
173
 
69
174
  Bug reports and pull requests are welcome on GitHub at https://github.com/udzura/wardite.
@@ -76,4 +181,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/udzura
76
181
  - https://github.com/skanehira/chibiwasm
77
182
  - Small and consise implementation in Rust
78
183
  - Wardite was first built upon [its development tutorial](https://skanehira.github.io/writing-a-wasm-runtime-in-rust/). Thanks!
79
- - Many of test wat files under [`examples/`](./examples/) are borrowed from chibiwasm project
184
+ - Many of test wat files under [`examples/`](./examples/) are borrowed from chibiwasm project
data/Rakefile CHANGED
@@ -9,6 +9,11 @@ Rake::TestTask.new(:test) do |t|
9
9
  t.test_files = FileList["test/**/*_test.rb"]
10
10
  end
11
11
 
12
+ desc "Verify Efflorescence opcode parity with CRuby, Spinel and Wasmtime"
13
+ task :parity do
14
+ sh "bundle exec ruby -Ilib test/support/run_efflorescence_manifest.rb"
15
+ end
16
+
12
17
  desc "Run rbs-inline and steep"
13
18
  task :check do
14
19
  sh "bundle exec rbs-inline --output lib/"
data/Steepfile CHANGED
@@ -6,6 +6,7 @@ target :lib do
6
6
  library "pp"
7
7
  library "securerandom"
8
8
  library "optparse"
9
+ library "fileutils"
9
10
  # configure_code_diagnostics(Steep::Diagnostic::Ruby.strict)
10
11
  end
11
12
 
@@ -0,0 +1,12 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" role="img" aria-labelledby="title description">
2
+ <title id="title">Wardite icon</title>
3
+ <desc id="description">A white W carved into a faceted teal mineral, with a dark offset shadow.</desc>
4
+ <rect width="1024" height="1024" fill="#f8f5f0"/>
5
+ <path fill="#17141f" d="M418 230h324l136 136v324L742 826H324l-42-110V366Z"/>
6
+ <path fill="#287a78" d="M350 162h324l136 136v324L674 758H256l-42-110V298Z"/>
7
+ <path fill="#65aaa0" d="M350 162h324l-62 110H384l-170 26Z"/>
8
+ <path fill="#398f88" d="m214 298 170-26-70 328-58 158-42-110Z"/>
9
+ <path fill="#1d5b60" d="m674 162 136 136v324L674 758l-42-154 78-260Z"/>
10
+ <path fill="#226b6b" d="m314 600 318 4 42 154H256Z"/>
11
+ <path d="M326 350h66l38 172 60-130h48l34 130 68-172h66L600 602h-60l-34-128-60 128h-60Z" fill="#fff"/>
12
+ </svg>