wardite 1.2.1 → 1.3.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 (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -16
  3. data/Rakefile +0 -177
  4. data/benchmark/README.md +11 -37
  5. data/benchmark/call_cost_worker.rb +3 -2
  6. data/benchmark/compare.rb +1 -2
  7. data/benchmark/compare_linear_memory_loads.py +144 -0
  8. data/benchmark/i32_memory.wat +5 -1
  9. data/benchmark/investigate_calls.rb +3 -3
  10. data/benchmark/linear_memory_loads.wat +52 -0
  11. data/benchmark/optimization_worker.rb +3 -2
  12. data/benchmark/patches/adr0017-spinel-signed64.patch +190 -0
  13. data/benchmark/patches/adr0017-wardite-split-load64.patch +70 -0
  14. data/benchmark/results/adr0019-startup.json +1687 -0
  15. data/benchmark/results/adr0020-i64.json +2034 -0
  16. data/benchmark/results/adr0021-optimizer.json +5798 -0
  17. data/benchmark/results/adr0022-lazy-mir.json +3057 -0
  18. data/benchmark/results/crc8-stream-repeat.csv +89 -0
  19. data/benchmark/results/crc8-stream.csv +89 -0
  20. data/benchmark/results/linear-memory-loads-a2aa05227.csv +793 -0
  21. data/benchmark/results/linear-memory-loads-stage-b.csv +353 -0
  22. data/benchmark/results/linear-memory-loads.csv +1057 -0
  23. data/benchmark/results/real-workloads-baseline-2026-11-18.json +1741 -0
  24. data/benchmark/results/stack-vm-removal.json +334 -0
  25. data/benchmark/validate_m4.rb +0 -2
  26. data/docs/adr/0017-efflorescence-linear-memory-loads.md +90 -0
  27. data/docs/adr/0018-efflorescence-real-workload-measurement.md +126 -0
  28. data/docs/adr/0019-efflorescence-startup-quick-wins.md +85 -0
  29. data/docs/adr/0020-efflorescence-inline-i64-bit-operations.md +89 -0
  30. data/docs/adr/0021-efflorescence-optimize-real-functions.md +133 -0
  31. data/docs/adr/0022-efflorescence-lazy-function-build.md +111 -0
  32. data/docs/adr/0023-efflorescence-byte-sequences-and-copy-coalescing.md +56 -0
  33. data/docs/efflorescence-ja.md +6 -9
  34. data/docs/efflorescence-linear-memory-loads.md +134 -0
  35. data/docs/efflorescence-m6.md +1 -1
  36. data/docs/efflorescence-mir2-cache.md +7 -0
  37. data/docs/efflorescence-real-workloads.md +312 -0
  38. data/docs/efflorescence-spinel-linear-memory.md +2 -2
  39. data/docs/efflorescence.md +7 -8
  40. data/docs/stack-vm-removal.md +49 -0
  41. data/lib/wardite/cli/cli.rb +24 -21
  42. data/lib/wardite/efflorescence/byte_sequences.rb +80 -0
  43. data/lib/wardite/efflorescence/function_preparer.rb +64 -0
  44. data/lib/wardite/efflorescence/i64_arithmetic.rb +31 -0
  45. data/lib/wardite/efflorescence/inspection.rb +44 -12
  46. data/lib/wardite/efflorescence/ir.rb +33 -10
  47. data/lib/wardite/efflorescence/mir_cache.rb +10 -1
  48. data/lib/wardite/efflorescence/optimizer.rb +151 -42
  49. data/lib/wardite/efflorescence/store_access.rb +17 -0
  50. data/lib/wardite/efflorescence/translation_source.rb +50 -0
  51. data/lib/wardite/efflorescence/translator.rb +43 -13
  52. data/lib/wardite/efflorescence/vm.rb +116 -48
  53. data/lib/wardite/efflorescence.rb +3 -0
  54. data/lib/wardite/load.rb +47 -63
  55. data/lib/wardite/version.rb +1 -1
  56. data/lib/wardite.rb +21 -757
  57. data/scripts/build_spinel_zig.rb +1 -1
  58. data/sig/generated/wardite/cli/cli.rbs +4 -2
  59. data/sig/generated/wardite/efflorescence/byte_sequences.rbs +33 -0
  60. data/sig/generated/wardite/efflorescence/function_preparer.rbs +25 -0
  61. data/sig/generated/wardite/efflorescence/i64_arithmetic.rbs +19 -0
  62. data/sig/generated/wardite/efflorescence/inspection.rbs +8 -0
  63. data/sig/generated/wardite/efflorescence/ir.rbs +18 -2
  64. data/sig/generated/wardite/efflorescence/optimizer.rbs +41 -3
  65. data/sig/generated/wardite/efflorescence/store_access.rbs +5 -0
  66. data/sig/generated/wardite/efflorescence/translation_source.rbs +34 -0
  67. data/sig/generated/wardite/efflorescence/translator.rbs +11 -1
  68. data/sig/generated/wardite/efflorescence/vm.rbs +19 -9
  69. data/sig/generated/wardite/load.rbs +18 -18
  70. data/sig/generated/wardite.rbs +4 -155
  71. metadata +32 -17
  72. data/benchmark/compare_engines.rb +0 -119
  73. data/benchmark/engine_phases.rb +0 -30
  74. data/lib/wardite/alu_f32.generated.rb +0 -261
  75. data/lib/wardite/alu_f64.generated.rb +0 -261
  76. data/lib/wardite/alu_i32.generated.rb +0 -510
  77. data/lib/wardite/alu_i64.generated.rb +0 -572
  78. data/lib/wardite/convert.generated.rb +0 -340
  79. data/scripts/gen_alu.rb +0 -864
  80. data/scripts/gen_conv.rb +0 -86
  81. data/scripts/templates/alu_module.rb.tmpl +0 -20
  82. data/scripts/templates/conv_module.rb.tmpl +0 -20
  83. data/sig/generated/wardite/alu_f32.generated.rbs +0 -12
  84. data/sig/generated/wardite/alu_f64.generated.rbs +0 -12
  85. data/sig/generated/wardite/alu_i32.generated.rbs +0 -12
  86. data/sig/generated/wardite/alu_i64.generated.rbs +0 -12
  87. data/sig/generated/wardite/convert.generated.rbs +0 -12
@@ -1,340 +0,0 @@
1
- # rbs_inline: enabled
2
- require_relative "value"
3
-
4
- module Wardite
5
- module Evaluator
6
- # @rbs runtime: Runtime
7
- # @rbs frame: Frame
8
- # @rbs code: Symbol
9
- # @rbs operand: Array[operandItem]
10
- # @rbs return: bool?
11
- def self.convert_eval_insn(runtime, frame, code, operand)
12
- case code
13
-
14
- when :i32_wrap_i64
15
- from = runtime.stack.pop
16
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I64)
17
- to = from.wrap(to: :i32)
18
- raise EvalError, "failed to convert type" if !to.is_a?(I32)
19
- runtime.stack.push(to)
20
-
21
-
22
- when :i32_trunc_f32_s
23
- from = runtime.stack.pop
24
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F32)
25
- to = from.trunc_s(to: :i32)
26
- raise EvalError, "failed to convert type" if !to.is_a?(I32)
27
- runtime.stack.push(to)
28
-
29
-
30
- when :i32_trunc_f64_s
31
- from = runtime.stack.pop
32
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F64)
33
- to = from.trunc_s(to: :i32)
34
- raise EvalError, "failed to convert type" if !to.is_a?(I32)
35
- runtime.stack.push(to)
36
-
37
-
38
- when :i32_trunc_f32_u
39
- from = runtime.stack.pop
40
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F32)
41
- to = from.trunc_u(to: :i32)
42
- raise EvalError, "failed to convert type" if !to.is_a?(I32)
43
- runtime.stack.push(to)
44
-
45
-
46
- when :i32_trunc_f64_u
47
- from = runtime.stack.pop
48
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F64)
49
- to = from.trunc_u(to: :i32)
50
- raise EvalError, "failed to convert type" if !to.is_a?(I32)
51
- runtime.stack.push(to)
52
-
53
-
54
- when :i32_reinterpret_f32
55
- from = runtime.stack.pop
56
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F32)
57
- to = from.reinterpret(to: :i32)
58
- raise EvalError, "failed to convert type" if !to.is_a?(I32)
59
- runtime.stack.push(to)
60
-
61
-
62
- when :i32_extend8_s
63
- from = runtime.stack.pop
64
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
65
- to = from.extendN_s(to: :i32, from: :i8)
66
- raise EvalError, "failed to convert type" if !to.is_a?(I32)
67
- runtime.stack.push(to)
68
-
69
-
70
- when :i32_extend16_s
71
- from = runtime.stack.pop
72
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
73
- to = from.extendN_s(to: :i32, from: :i16)
74
- raise EvalError, "failed to convert type" if !to.is_a?(I32)
75
- runtime.stack.push(to)
76
-
77
-
78
- when :i32_trunc_sat_f32_s
79
- from = runtime.stack.pop
80
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F32)
81
- to = from.trunc_sat_s(to: :i32)
82
- raise EvalError, "failed to convert type" if !to.is_a?(I32)
83
- runtime.stack.push(to)
84
-
85
-
86
- when :i32_trunc_sat_f64_s
87
- from = runtime.stack.pop
88
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F64)
89
- to = from.trunc_sat_s(to: :i32)
90
- raise EvalError, "failed to convert type" if !to.is_a?(I32)
91
- runtime.stack.push(to)
92
-
93
-
94
- when :i32_trunc_sat_f32_u
95
- from = runtime.stack.pop
96
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F32)
97
- to = from.trunc_sat_u(to: :i32)
98
- raise EvalError, "failed to convert type" if !to.is_a?(I32)
99
- runtime.stack.push(to)
100
-
101
-
102
- when :i32_trunc_sat_f64_u
103
- from = runtime.stack.pop
104
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F64)
105
- to = from.trunc_sat_u(to: :i32)
106
- raise EvalError, "failed to convert type" if !to.is_a?(I32)
107
- runtime.stack.push(to)
108
-
109
-
110
- when :i64_extend_i32_s
111
- from = runtime.stack.pop
112
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
113
- to = from.extend_s(to: :i64)
114
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
115
- runtime.stack.push(to)
116
-
117
-
118
- when :i64_extend_i64_s
119
- from = runtime.stack.pop
120
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I64)
121
- to = from.extend_s(to: :i64)
122
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
123
- runtime.stack.push(to)
124
-
125
-
126
- when :i64_extend_i32_u
127
- from = runtime.stack.pop
128
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
129
- to = from.extend_u(to: :i64)
130
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
131
- runtime.stack.push(to)
132
-
133
-
134
- when :i64_extend_i64_u
135
- from = runtime.stack.pop
136
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I64)
137
- to = from.extend_u(to: :i64)
138
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
139
- runtime.stack.push(to)
140
-
141
-
142
- when :i64_trunc_f32_s
143
- from = runtime.stack.pop
144
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F32)
145
- to = from.trunc_s(to: :i64)
146
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
147
- runtime.stack.push(to)
148
-
149
-
150
- when :i64_trunc_f64_s
151
- from = runtime.stack.pop
152
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F64)
153
- to = from.trunc_s(to: :i64)
154
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
155
- runtime.stack.push(to)
156
-
157
-
158
- when :i64_trunc_f32_u
159
- from = runtime.stack.pop
160
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F32)
161
- to = from.trunc_u(to: :i64)
162
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
163
- runtime.stack.push(to)
164
-
165
-
166
- when :i64_trunc_f64_u
167
- from = runtime.stack.pop
168
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F64)
169
- to = from.trunc_u(to: :i64)
170
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
171
- runtime.stack.push(to)
172
-
173
-
174
- when :i64_reinterpret_f64
175
- from = runtime.stack.pop
176
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F64)
177
- to = from.reinterpret(to: :i64)
178
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
179
- runtime.stack.push(to)
180
-
181
-
182
- when :i64_extend8_s
183
- from = runtime.stack.pop
184
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
185
- to = from.extendN_s(to: :i64, from: :i8)
186
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
187
- runtime.stack.push(to)
188
-
189
-
190
- when :i64_extend16_s
191
- from = runtime.stack.pop
192
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
193
- to = from.extendN_s(to: :i64, from: :i16)
194
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
195
- runtime.stack.push(to)
196
-
197
-
198
- when :i64_extend32_s
199
- from = runtime.stack.pop
200
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
201
- to = from.extendN_s(to: :i64, from: :i32)
202
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
203
- runtime.stack.push(to)
204
-
205
-
206
- when :i64_trunc_sat_f32_s
207
- from = runtime.stack.pop
208
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F32)
209
- to = from.trunc_sat_s(to: :i64)
210
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
211
- runtime.stack.push(to)
212
-
213
-
214
- when :i64_trunc_sat_f64_s
215
- from = runtime.stack.pop
216
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F64)
217
- to = from.trunc_sat_s(to: :i64)
218
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
219
- runtime.stack.push(to)
220
-
221
-
222
- when :i64_trunc_sat_f32_u
223
- from = runtime.stack.pop
224
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F32)
225
- to = from.trunc_sat_u(to: :i64)
226
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
227
- runtime.stack.push(to)
228
-
229
-
230
- when :i64_trunc_sat_f64_u
231
- from = runtime.stack.pop
232
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F64)
233
- to = from.trunc_sat_u(to: :i64)
234
- raise EvalError, "failed to convert type" if !to.is_a?(I64)
235
- runtime.stack.push(to)
236
-
237
-
238
- when :f32_convert_i32_s
239
- from = runtime.stack.pop
240
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
241
- to = from.convert_s(to: :f32)
242
- raise EvalError, "failed to convert type" if !to.is_a?(F32)
243
- runtime.stack.push(to)
244
-
245
-
246
- when :f32_convert_i64_s
247
- from = runtime.stack.pop
248
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I64)
249
- to = from.convert_s(to: :f32)
250
- raise EvalError, "failed to convert type" if !to.is_a?(F32)
251
- runtime.stack.push(to)
252
-
253
-
254
- when :f32_convert_i32_u
255
- from = runtime.stack.pop
256
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
257
- to = from.convert_u(to: :f32)
258
- raise EvalError, "failed to convert type" if !to.is_a?(F32)
259
- runtime.stack.push(to)
260
-
261
-
262
- when :f32_convert_i64_u
263
- from = runtime.stack.pop
264
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I64)
265
- to = from.convert_u(to: :f32)
266
- raise EvalError, "failed to convert type" if !to.is_a?(F32)
267
- runtime.stack.push(to)
268
-
269
-
270
- when :f32_demote_f64
271
- from = runtime.stack.pop
272
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F64)
273
- to = from.demote(to: :f32)
274
- raise EvalError, "failed to convert type" if !to.is_a?(F32)
275
- runtime.stack.push(to)
276
-
277
-
278
- when :f32_reinterpret_i32
279
- from = runtime.stack.pop
280
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
281
- to = from.reinterpret(to: :f32)
282
- raise EvalError, "failed to convert type" if !to.is_a?(F32)
283
- runtime.stack.push(to)
284
-
285
-
286
- when :f64_convert_i32_s
287
- from = runtime.stack.pop
288
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
289
- to = from.convert_s(to: :f64)
290
- raise EvalError, "failed to convert type" if !to.is_a?(F64)
291
- runtime.stack.push(to)
292
-
293
-
294
- when :f64_convert_i64_s
295
- from = runtime.stack.pop
296
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I64)
297
- to = from.convert_s(to: :f64)
298
- raise EvalError, "failed to convert type" if !to.is_a?(F64)
299
- runtime.stack.push(to)
300
-
301
-
302
- when :f64_convert_i32_u
303
- from = runtime.stack.pop
304
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
305
- to = from.convert_u(to: :f64)
306
- raise EvalError, "failed to convert type" if !to.is_a?(F64)
307
- runtime.stack.push(to)
308
-
309
-
310
- when :f64_convert_i64_u
311
- from = runtime.stack.pop
312
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I64)
313
- to = from.convert_u(to: :f64)
314
- raise EvalError, "failed to convert type" if !to.is_a?(F64)
315
- runtime.stack.push(to)
316
-
317
-
318
- when :f64_promote_f32
319
- from = runtime.stack.pop
320
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(F32)
321
- to = from.promote(to: :f64)
322
- raise EvalError, "failed to convert type" if !to.is_a?(F64)
323
- runtime.stack.push(to)
324
-
325
-
326
- when :f64_reinterpret_i64
327
- from = runtime.stack.pop
328
- raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I64)
329
- to = from.reinterpret(to: :f64)
330
- raise EvalError, "failed to convert type" if !to.is_a?(F64)
331
- runtime.stack.push(to)
332
-
333
-
334
- else
335
- return
336
- end
337
- return true
338
- end
339
- end
340
- end