wardite 1.1.0 → 1.2.1

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +9 -1
  3. data/README.md +36 -4
  4. data/benchmark/README.md +8 -0
  5. data/benchmark/compare_mir_generation_builds.rb +66 -0
  6. data/benchmark/count_ruby_wasm_functions.rb +37 -0
  7. data/benchmark/generate_mir_generation_fixtures.rb +44 -0
  8. data/benchmark/measure_mir_cache_restore.rb +59 -0
  9. data/benchmark/measure_mir_generation.rb +52 -0
  10. data/benchmark/mir_copy_worker.rb +29 -0
  11. data/benchmark/mir_generation_worker.rb +50 -0
  12. data/benchmark/prepare_mir_generation_profile.rb +80 -0
  13. data/benchmark/profile_inline_snapshots.rb +63 -0
  14. data/benchmark/profile_mir_generation_allocations.rb +73 -0
  15. data/benchmark/results/efflorescence-mir2-function-restore.json +480 -0
  16. data/benchmark/results/mir-generation-adr0014.json +1779 -0
  17. data/benchmark/results/mir-generation-adr0015.json +3132 -0
  18. data/benchmark/results/mir-generation-allocations.json +236 -0
  19. data/benchmark/results/mir-generation-coarse.json +909 -0
  20. data/benchmark/results/mir-generation-control.json +463 -0
  21. data/benchmark/results/mir-generation-detail.json +387 -0
  22. data/benchmark/results/mir-generation-scaling.json +2945 -0
  23. data/docs/adr/0009-efflorescence-mir2-cache-integrity-modes.md +1 -1
  24. data/docs/adr/0010-efflorescence-mir2-cache-function-restore.md +1 -1
  25. data/docs/adr/0014-efflorescence-mir-build-validation-and-decoding.md +136 -0
  26. data/docs/adr/0015-efflorescence-selective-inline-snapshots.md +150 -0
  27. data/docs/adr/0016-efflorescence-generation-tagged-copy-propagation.md +163 -0
  28. data/docs/efflorescence-mir-build-validation-and-decoding-results.md +93 -0
  29. data/docs/efflorescence-mir-generation-implementation.md +77 -0
  30. data/docs/efflorescence-mir-generation-performance.md +184 -0
  31. data/docs/efflorescence-mir2-cache.md +31 -2
  32. data/docs/efflorescence-selective-inline-snapshots-results.md +92 -0
  33. data/docs/efflorescence-spinel-linear-memory.md +6 -4
  34. data/lib/wardite/cli/cli.rb +3 -1
  35. data/lib/wardite/efflorescence/ir.rb +131 -40
  36. data/lib/wardite/efflorescence/mir_cache.rb +165 -73
  37. data/lib/wardite/efflorescence/optimizer.rb +65 -15
  38. data/lib/wardite/efflorescence/register_validation.rb +162 -32
  39. data/lib/wardite/efflorescence/snapshot.rb +5 -2
  40. data/lib/wardite/efflorescence/vm.rb +4 -3
  41. data/lib/wardite/instruction.rb +42 -1
  42. data/lib/wardite/leb128.rb +2 -5
  43. data/lib/wardite/load.rb +154 -75
  44. data/lib/wardite/version.rb +1 -1
  45. data/lib/wardite.rb +1 -1
  46. data/scripts/build_spinel_zig.rb +121 -0
  47. data/sig/generated/wardite/efflorescence/ir.rbs +34 -3
  48. data/sig/generated/wardite/efflorescence/mir_cache.rbs +41 -14
  49. data/sig/generated/wardite/efflorescence/optimizer.rbs +27 -3
  50. data/sig/generated/wardite/efflorescence/register_validation.rbs +45 -4
  51. data/sig/generated/wardite/efflorescence/snapshot.rbs +2 -1
  52. data/sig/generated/wardite/instruction.rbs +23 -0
  53. data/sig/generated/wardite/load.rbs +63 -9
  54. data/sig/io_buffer.rbs +7 -0
  55. metadata +28 -3
  56. data/spinel/patches/0001-io-buffer-string-view.patch +0 -699
  57. data/spinel/patches/0002-io-buffer-allocation-error.patch +0 -47
@@ -0,0 +1,236 @@
1
+ {
2
+ "ruby": "ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [arm64-darwin27]",
3
+ "phases_inclusive": {
4
+ "sections": {
5
+ "seconds": 4.001256999996258,
6
+ "objects": 22488536,
7
+ "calls": 1
8
+ },
9
+ "features": {
10
+ "seconds": 0.5296190001317882,
11
+ "objects": 8,
12
+ "calls": 8161
13
+ },
14
+ "translate": {
15
+ "seconds": 3.9558280000055674,
16
+ "objects": 7597524,
17
+ "calls": 1
18
+ },
19
+ "ir_copy": {
20
+ "seconds": 5.477874999996857,
21
+ "objects": 9833408,
22
+ "calls": 2
23
+ },
24
+ "analysis": {
25
+ "seconds": 4.480604000367748,
26
+ "objects": 6768138,
27
+ "calls": 10096
28
+ },
29
+ "optimize": {
30
+ "seconds": 5.588268999999855,
31
+ "objects": 9993792,
32
+ "calls": 1
33
+ },
34
+ "validate_types": {
35
+ "seconds": 3.818418999981077,
36
+ "objects": 4563725,
37
+ "calls": 8161
38
+ },
39
+ "flow_graph": {
40
+ "seconds": 2.7525010000244947,
41
+ "objects": 10992183,
42
+ "calls": 8161
43
+ },
44
+ "validate": {
45
+ "seconds": 19.285403999921982,
46
+ "objects": 30862889,
47
+ "calls": 8161
48
+ },
49
+ "lower": {
50
+ "seconds": 1.1596910000007483,
51
+ "objects": 164014,
52
+ "calls": 1
53
+ }
54
+ },
55
+ "gc_delta": {
56
+ "count": 52,
57
+ "time": 6774,
58
+ "marking_time": 5703,
59
+ "sweeping_time": 1071,
60
+ "heap_allocated_pages": 18305,
61
+ "heap_empty_pages": 1974,
62
+ "heap_allocatable_slots": 2006782,
63
+ "heap_available_slots": 21772271,
64
+ "heap_live_slots": 17435706,
65
+ "heap_free_slots": 4336565,
66
+ "heap_final_slots": 0,
67
+ "heap_marked_slots": 17337901,
68
+ "heap_eden_pages": 16331,
69
+ "total_allocated_pages": 18305,
70
+ "total_freed_pages": 0,
71
+ "total_allocated_objects": 71257138,
72
+ "total_freed_objects": 53821432,
73
+ "malloc_increase_bytes": 7643059,
74
+ "malloc_increase_bytes_limit": 16777216,
75
+ "minor_gc_count": 37,
76
+ "major_gc_count": 15,
77
+ "compact_count": 0,
78
+ "read_barrier_faults": 0,
79
+ "total_moved_objects": 0,
80
+ "remembered_wb_unprotected_objects": 0,
81
+ "remembered_wb_unprotected_objects_limit": 171948,
82
+ "old_objects": 17195506,
83
+ "old_objects_limit": 34389562,
84
+ "oldmalloc_increase_bytes": 41202371,
85
+ "oldmalloc_increase_bytes_limit": 33319278
86
+ },
87
+ "slowest_validation": [
88
+ {
89
+ "index": 63,
90
+ "seconds": 0.7574010000025737,
91
+ "objects": 566179,
92
+ "instructions": 39580,
93
+ "registers": 23011
94
+ },
95
+ {
96
+ "index": 7739,
97
+ "seconds": 0.6230239999931655,
98
+ "objects": 575041,
99
+ "instructions": 40547,
100
+ "registers": 24568
101
+ },
102
+ {
103
+ "index": 8124,
104
+ "seconds": 0.5626529999935883,
105
+ "objects": 454,
106
+ "instructions": 32,
107
+ "registers": 40
108
+ },
109
+ {
110
+ "index": 5065,
111
+ "seconds": 0.5620380000036675,
112
+ "objects": 62664,
113
+ "instructions": 4274,
114
+ "registers": 2300
115
+ },
116
+ {
117
+ "index": 394,
118
+ "seconds": 0.40218800000002375,
119
+ "objects": 2598,
120
+ "instructions": 182,
121
+ "registers": 131
122
+ },
123
+ {
124
+ "index": 3616,
125
+ "seconds": 0.3787179999999353,
126
+ "objects": 394043,
127
+ "instructions": 26788,
128
+ "registers": 17375
129
+ },
130
+ {
131
+ "index": 3961,
132
+ "seconds": 0.29704900000069756,
133
+ "objects": 354204,
134
+ "instructions": 24686,
135
+ "registers": 13806
136
+ },
137
+ {
138
+ "index": 7357,
139
+ "seconds": 0.29401099999813596,
140
+ "objects": 376461,
141
+ "instructions": 24713,
142
+ "registers": 13024
143
+ },
144
+ {
145
+ "index": 3966,
146
+ "seconds": 0.26528899999539135,
147
+ "objects": 297154,
148
+ "instructions": 20129,
149
+ "registers": 11411
150
+ },
151
+ {
152
+ "index": 7522,
153
+ "seconds": 0.2633289999939734,
154
+ "objects": 286233,
155
+ "instructions": 19692,
156
+ "registers": 10751
157
+ },
158
+ {
159
+ "index": 65,
160
+ "seconds": 0.24093599999469006,
161
+ "objects": 297154,
162
+ "instructions": 20129,
163
+ "registers": 11411
164
+ },
165
+ {
166
+ "index": 7475,
167
+ "seconds": 0.1766090000019176,
168
+ "objects": 242094,
169
+ "instructions": 16883,
170
+ "registers": 8639
171
+ },
172
+ {
173
+ "index": 3125,
174
+ "seconds": 0.1261690000028466,
175
+ "objects": 187237,
176
+ "instructions": 13123,
177
+ "registers": 7429
178
+ },
179
+ {
180
+ "index": 5024,
181
+ "seconds": 0.12118200000259094,
182
+ "objects": 178384,
183
+ "instructions": 12893,
184
+ "registers": 6708
185
+ },
186
+ {
187
+ "index": 6523,
188
+ "seconds": 0.12038200000097277,
189
+ "objects": 184099,
190
+ "instructions": 13002,
191
+ "registers": 7260
192
+ },
193
+ {
194
+ "index": 64,
195
+ "seconds": 0.11373299999831943,
196
+ "objects": 174173,
197
+ "instructions": 12063,
198
+ "registers": 6554
199
+ },
200
+ {
201
+ "index": 6029,
202
+ "seconds": 0.1132179999985965,
203
+ "objects": 175785,
204
+ "instructions": 12375,
205
+ "registers": 6866
206
+ },
207
+ {
208
+ "index": 7439,
209
+ "seconds": 0.11218100000405684,
210
+ "objects": 172112,
211
+ "instructions": 11629,
212
+ "registers": 6542
213
+ },
214
+ {
215
+ "index": 3963,
216
+ "seconds": 0.1030449999962002,
217
+ "objects": 158493,
218
+ "instructions": 10971,
219
+ "registers": 5869
220
+ },
221
+ {
222
+ "index": 3115,
223
+ "seconds": 0.08617799999774434,
224
+ "objects": 143668,
225
+ "instructions": 10420,
226
+ "registers": 5855
227
+ }
228
+ ],
229
+ "top_self_samples": "+---------+------+---------------------------------------------------------------------------+\n| Samples | % | name |\n+---------+------+---------------------------------------------------------------------------+\n| 5786 | 10.4 | Wardite::Efflorescence::Opcode.read_positions |\n| 5407 | 9.7 | Array#include? |\n| 3604 | 6.5 | Wardite::Efflorescence::Instruction#[] |\n| 3604 | 6.5 | Array#fetch |\n| 2998 | 5.4 | Wardite::Efflorescence::RegisterValidation::Block#merge |\n| 1930 | 3.5 | Array#each |\n| 1781 | 3.2 | Wardite::Efflorescence::Translator#translate_function |\n| 1635 | 2.9 | Wardite::BinaryLoader.code_body |\n| 1594 | 2.9 | Integer#=== |\n| 1541 | 2.8 | Wardite::Efflorescence::Function#reads |\n| 1500 | 2.7 | Wardite::Efflorescence::Opcode.destination |\n| 1431 | 2.6 | Wardite::Efflorescence::FlowGraph#initialize |\n| 1416 | 2.5 | Wardite::Efflorescence::RegisterValidation#validate |\n| 1084 | 1.9 | Wardite::Efflorescence::RegisterValidation#validate_types |\n| 1030 | 1.8 | Kernel#dup |\n| 924 | 1.7 | Wardite::Efflorescence::Analysis#initialize |\n| 905 | 1.6 | Kernel#Integer |\n| 860 | 1.5 | Wardite::Efflorescence::Opcode.target_position |\n| 856 | 1.5 | Wardite::Efflorescence::Lowerer#compile |\n| 848 | 1.5 | Array#map |\n| 749 | 1.3 | Wardite::Efflorescence::Opcode.dynamic_call? |\n| 691 | 1.2 | Wardite::Efflorescence::RegisterValidation#reverse_postorder |\n| 660 | 1.2 | Wardite::Efflorescence::Opcode.memory_site? |\n| 574 | 1.0 | StringIO#read |\n| 562 | 1.0 | Enumerable#each_with_index |\n| 552 | 1.0 | Wardite::Efflorescence::Function#copy |\n| 516 | 0.9 | Wardite::Efflorescence::Function#allocate_register |\n| 512 | 0.9 | Wardite::BinaryLoader.resolve_code |\n| 493 | 0.9 | Wardite::CodeSection::CodeBody#check_instructions |\n| 441 | 0.8 | Wardite::Efflorescence::Opcode.terminal? |\n| 426 | 0.8 | Wardite::Efflorescence::RegisterValidation#marked? |\n| 410 | 0.7 | Kernel#initialize_dup |\n| 401 | 0.7 | Wardite::Leb128Helper#fetch_sleb128 |\n| 396 | 0.7 | Wardite::Efflorescence::Instruction#copy |\n| 392 | 0.7 | Wardite::Efflorescence::Translator#emit |\n| 374 | 0.7 | Wardite::Op.operand_of |\n| 367 | 0.7 | Wardite::Efflorescence::RegisterValidation#mark |\n| 355 | 0.6 | Wardite::Efflorescence::FlowGraph#merge |\n| 343 | 0.6 | Array#initialize |\n| 334 | 0.6 | Wardite::Leb128Helper#fetch_uleb128 |\n| 329 | 0.6 | Array#initialize_copy |\n| 290 | 0.5 | Wardite::Efflorescence::Translator#pop_value |\n| 256 | 0.5 | Wardite::Efflorescence::Instruction#initialize |\n| 248 | 0.4 | Wardite::Efflorescence::Translator#type_of |\n| 240 | 0.4 | Wardite::Efflorescence::RegisterValidation#check_register |\n| 236 | 0.4 | Wardite::FloatBits.float_type? |\n| 230 | 0.4 | Wardite::Efflorescence::Translator#validate_store_instruction |\n| 201 | 0.4 | Wardite::Efflorescence::Translator#integer_operand |\n| 198 | 0.4 | Wardite::Efflorescence::Opcode.may_throw? |\n| 197 | 0.4 | Hash#key? |\n| 196 | 0.4 | Wardite::Efflorescence::Translator#pop_typed |\n| 183 | 0.3 | Wardite::Efflorescence::Instruction#size |\n| 150 | 0.3 | Wardite::Efflorescence::Translator#end_control |\n| 140 | 0.3 | Range#each |\n| 125 | 0.2 | String#ord |\n| 117 | 0.2 | Integer#times |\n| 111 | 0.2 | Wardite::Efflorescence::Translator::Control#initialize |\n| 105 | 0.2 | Wardite::Efflorescence::Translator#register |\n| 90 | 0.2 | Wardite::Efflorescence::Function#initial_value |\n| 89 | 0.2 | Wardite::Efflorescence::Translator#constant |\n| 89 | 0.2 | Array#pop |\n| 83 | 0.1 | Integer#<< |\n| 82 | 0.1 | Wardite::Efflorescence::Translator#branch |\n| 79 | 0.1 | Wardite::Efflorescence::Translator#copy_value |\n| 79 | 0.1 | Wardite::Efflorescence::RegisterValidation::Block#initialize |\n| 70 | 0.1 | Array#== |\n| 64 | 0.1 | Integer#>> |\n| 63 | 0.1 | Wardite::Efflorescence::Function#register_count |\n| 63 | 0.1 | Wardite::Efflorescence::Translator#patch |\n| 63 | 0.1 | Wardite::Efflorescence::Function#allocate_constant |\n| 61 | 0.1 | Array#reverse_each |\n| 55 | 0.1 | Wardite::Efflorescence::Translator#top_values |\n| 55 | 0.1 | Wardite::Efflorescence::Function#initialize |\n| 52 | 0.1 | Kernel#is_a? |\n| 51 | 0.1 | Wardite::Efflorescence::Translator#finish_arm |\n| 47 | 0.1 | Wardite::BinaryLoader.read_blocktype |\n| 45 | 0.1 | block (2 levels) in wrap |\n| 44 | 0.1 | Enumerable#to_a |\n| 42 | 0.1 | Wardite::Efflorescence::Translator#new_control |\n| 40 | 0.1 | Array.new |\n| 37 | 0.1 | Wardite::Block#initialize |\n| 32 | 0.1 | Wardite::Efflorescence::Instruction#[]= |\n| 32 | 0.1 | Hash#fetch |\n| 29 | 0.1 | Array#all? |\n| 28 | 0.1 | Wardite::Efflorescence::FunctionEntry.check_signature |\n| 28 | 0.1 | Wardite::Block.void |\n| 25 | 0.0 | Wardite::Efflorescence::Translator#label |\n| 24 | 0.0 | Wardite::Efflorescence::FunctionEntry.numeric_type? |\n| 22 | 0.0 | Wardite::Efflorescence::Translator#parallel_copy |\n| 20 | 0.0 | Wardite::Efflorescence::Opcode.extended_alu_types |\n| 19 | 0.0 | Wardite::Efflorescence::Function#parameter_count |\n| 18 | 0.0 | Wardite::Efflorescence::Translator#label_types |\n| 17 | 0.0 | Wardite::BinaryLoader.read_function_body |\n| 16 | 0.0 | Wardite::Efflorescence::Passes::CopyPropagation#propagate |\n| 15 | 0.0 | Wardite::Efflorescence::IR#entry_at |\n| 15 | 0.0 | Wardite::Efflorescence::Translator#snapshot_locals |\n| 14 | 0.0 | Kernel.require |\n| 14 | 0.0 | Wardite::Efflorescence::Translator#preserve_local |\n| 13 | 0.0 | IO#read |\n| 12 | 0.0 | Array#any? |\n| 9 | 0.0 | GC.stat |\n| 9 | 0.0 | Range#to_a |\n| 9 | 0.0 | Wardite::Efflorescence::Translator#mark_unreachable |\n| 9 | 0.0 | String#[]= |\n| 9 | 0.0 | Wardite::BinaryLoader.assert_read |\n| 8 | 0.0 | Wardite::Efflorescence::RegisterValidation#check_result |\n| 8 | 0.0 | Wardite::Efflorescence::CallSite#initialize |\n| 7 | 0.0 | Process.clock_gettime |\n| 7 | 0.0 | Array#reverse |\n| 7 | 0.0 | StringIO#pos |\n| 6 | 0.0 | Wardite::Efflorescence::IR#defined_at |\n| 6 | 0.0 | Class#new |\n| 6 | 0.0 | Wardite::Efflorescence::VM#initialize |\n| 6 | 0.0 | Wardite::WasmFunction#locals_type |\n| 4 | 0.0 | Wardite::WasmFunction#body |\n| 4 | 0.0 | Array#[] |\n| 4 | 0.0 | Wardite::Store#initialize |\n| 4 | 0.0 | Wardite::Efflorescence::FunctionEntry#copy |\n| 4 | 0.0 | Wardite::Efflorescence::Analysis#flow |\n| 4 | 0.0 | Wardite::Efflorescence::RegisterValidation#validate_extended_instruction |\n| 4 | 0.0 | Wardite::Efflorescence::Translator#else_control |\n| 3 | 0.0 | Array#last |\n| 3 | 0.0 | Wardite::Efflorescence::I64Arithmetic.join |\n| 3 | 0.0 | Wardite::Op.i2type |\n| 3 | 0.0 | Wardite::Efflorescence::DynamicCallSite#copy |\n| 3 | 0.0 | Wardite::Instance#check_memory_initialization |\n| 3 | 0.0 | Wardite::Efflorescence::Optimizer#optimize |\n| 2 | 0.0 | StringIO.new |\n| 2 | 0.0 | Wardite::CodeSection::CodeBody#initialize |\n| 2 | 0.0 | Wardite::Efflorescence::IR#function_at |\n| 2 | 0.0 | Wardite::Efflorescence::Passes::Inlining#run |\n| 2 | 0.0 | Wardite::Efflorescence::Passes::Superinstructions#run |\n| 2 | 0.0 | Wardite::Efflorescence::FunctionEntry#initialize |\n| 2 | 0.0 | Wardite::CodeSection::CodeBody#body |\n| 2 | 0.0 | Wardite::WasmFunction#locals_count |\n| 2 | 0.0 | Wardite::Memory#write_bytes |\n| 2 | 0.0 | Wardite::Instance#initialize |\n| 2 | 0.0 | Wardite::CodeSection::CodeBody#check_features |\n| 2 | 0.0 | Wardite::Instance#each_defined_function |\n| 2 | 0.0 | Wardite::Memory#bytesize |\n| 2 | 0.0 | Wardite::WasmFunction#initialize |\n| 1 | 0.0 | File#initialize |\n| 1 | 0.0 | Wardite::Efflorescence::Function#dynamic_site |\n| 1 | 0.0 | Wardite::Efflorescence::VM#build_mir |\n| 1 | 0.0 | Wardite::Efflorescence::Function#remap_targets! |\n| 1 | 0.0 | Wardite::Efflorescence::Rewrite#emit |\n| 1 | 0.0 | Wardite::Efflorescence::Function#remap_handler_targets! |\n| 1 | 0.0 | Array#fill |\n| 1 | 0.0 | Wardite::Efflorescence::Passes::ImmediateSpecialization#run |\n| 1 | 0.0 | Wardite::Efflorescence::Rewrite#initialize |\n| 1 | 0.0 | Wardite::Efflorescence::Passes::CopyPropagation#remove_overwritten_copies |\n| 1 | 0.0 | Wardite::Efflorescence::Optimizer#optimize_function |\n| 1 | 0.0 | Wardite::Efflorescence::Rewrite#mark |\n| 1 | 0.0 | Wardite::Efflorescence::Function#replace_instructions |\n| 1 | 0.0 | Wardite::Efflorescence::I64Arithmetic.normalize |\n| 1 | 0.0 | Wardite::Efflorescence::Translator#translate |\n| 1 | 0.0 | Integer#| |\n| 1 | 0.0 | Wardite::BinaryLoader.decode_expr |\n| 1 | 0.0 | Wardite::Efflorescence::Translator#link |\n| 1 | 0.0 | Wardite::Table#set |\n| 1 | 0.0 | Wardite::Memory#range? |\n| 1 | 0.0 | StringIO#pos= |\n| 1 | 0.0 | StringIO#initialize |\n| 1 | 0.0 | String#[] |\n| 1 | 0.0 | String#bytesize |\n| 1 | 0.0 | Wardite::BinaryLoader.data_section |\n+---------+------+---------------------------------------------------------------------------+",
230
+ "fixture": {
231
+ "path": "/Users/udzura/ghq/github.com/udzura/wardite/tmp/ruby.wasm",
232
+ "sha256": "1ac460e944a54c17529aa05e6cad4575aab6d3d2466745f935237f7a46351e98"
233
+ },
234
+ "revision": "1de771dcf6024792e053aa2ed9214df3a9613d8f",
235
+ "vernier": "1.8.0"
236
+ }