wardite 1.2.0 → 1.2.2

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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -11
  3. data/benchmark/README.md +13 -5
  4. data/benchmark/call_cost_worker.rb +1 -1
  5. data/benchmark/compare.rb +2 -2
  6. data/benchmark/compare_engines.rb +1 -1
  7. data/benchmark/compare_mir_generation_builds.rb +66 -0
  8. data/benchmark/engine_phases.rb +1 -1
  9. data/benchmark/generate_mir_generation_fixtures.rb +44 -0
  10. data/benchmark/investigate_calls.rb +1 -1
  11. data/benchmark/measure_mir_generation.rb +52 -0
  12. data/benchmark/mir_copy_worker.rb +29 -0
  13. data/benchmark/mir_generation_worker.rb +50 -0
  14. data/benchmark/optimization_worker.rb +1 -1
  15. data/benchmark/prepare_mir_generation_profile.rb +80 -0
  16. data/benchmark/profile_inline_snapshots.rb +63 -0
  17. data/benchmark/profile_mir_generation_allocations.rb +73 -0
  18. data/benchmark/results/mir-generation-adr0014.json +1779 -0
  19. data/benchmark/results/mir-generation-adr0015.json +3132 -0
  20. data/benchmark/results/mir-generation-allocations.json +236 -0
  21. data/benchmark/results/mir-generation-coarse.json +909 -0
  22. data/benchmark/results/mir-generation-control.json +463 -0
  23. data/benchmark/results/mir-generation-detail.json +387 -0
  24. data/benchmark/results/mir-generation-scaling.json +2945 -0
  25. data/benchmark/validate_m4.rb +1 -1
  26. data/docs/adr/0014-efflorescence-mir-build-validation-and-decoding.md +136 -0
  27. data/docs/adr/0015-efflorescence-selective-inline-snapshots.md +150 -0
  28. data/docs/adr/0016-efflorescence-generation-tagged-copy-propagation.md +163 -0
  29. data/docs/efflorescence-ja.md +5 -6
  30. data/docs/efflorescence-mir-build-validation-and-decoding-results.md +93 -0
  31. data/docs/efflorescence-mir-generation-implementation.md +77 -0
  32. data/docs/efflorescence-mir-generation-performance.md +184 -0
  33. data/docs/efflorescence-selective-inline-snapshots-results.md +92 -0
  34. data/docs/efflorescence.md +8 -7
  35. data/lib/wardite/cli/cli.rb +7 -4
  36. data/lib/wardite/efflorescence/ir.rb +119 -37
  37. data/lib/wardite/efflorescence/optimizer.rb +65 -15
  38. data/lib/wardite/efflorescence/register_validation.rb +162 -32
  39. data/lib/wardite/instruction.rb +42 -1
  40. data/lib/wardite/leb128.rb +2 -5
  41. data/lib/wardite/load.rb +152 -74
  42. data/lib/wardite/version.rb +1 -1
  43. data/lib/wardite.rb +1 -1
  44. data/sig/generated/wardite/efflorescence/ir.rbs +29 -1
  45. data/sig/generated/wardite/efflorescence/optimizer.rbs +27 -3
  46. data/sig/generated/wardite/efflorescence/register_validation.rbs +45 -4
  47. data/sig/generated/wardite/instruction.rbs +23 -0
  48. data/sig/generated/wardite/load.rbs +61 -8
  49. metadata +23 -1
@@ -91,14 +91,26 @@ module Wardite
91
91
  def initialize: () -> void
92
92
  end
93
93
 
94
+ # The loader owns this result until a CodeBody exposes its mutable instructions.
95
+ class DecodedBody
96
+ attr_reader instructions: Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]]
97
+
98
+ attr_reader blocks: Array[Block]
99
+
100
+ attr_reader has_eh_instructions: bool
101
+
102
+ # @rbs instructions: Array[[Symbol, Symbol, Array[operandItem], Integer?, Integer?]]
103
+ # @rbs blocks: Array[Block]
104
+ # @rbs has_eh_instructions: bool
105
+ def initialize: (Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]] instructions, Array[Block] blocks, bool has_eh_instructions) -> untyped
106
+ end
107
+
94
108
  class CodeSection < Section
95
109
  class CodeBody
96
110
  attr_accessor locals_count: Array[Integer]
97
111
 
98
112
  attr_accessor locals_type: Array[Symbol]
99
113
 
100
- attr_writer instruction_bytes: String?
101
-
102
114
  attr_writer type_section: TypeSection?
103
115
 
104
116
  # @rbs &blk: (CodeBody) -> void
@@ -112,6 +124,14 @@ module Wardite
112
124
  # @rbs return: void
113
125
  def body=: (Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]] instructions) -> void
114
126
 
127
+ # @rbs bytes: String?
128
+ # @rbs return: void
129
+ def instruction_bytes=: (String? bytes) -> void
130
+
131
+ # @rbs buf: File|StringIO
132
+ # @rbs return: void
133
+ def decode_from: (File | StringIO buf) -> void
134
+
115
135
  # @rbs types: TypeSection?
116
136
  # @rbs stack: bool
117
137
  # @rbs return: void
@@ -119,11 +139,27 @@ module Wardite
119
139
 
120
140
  private
121
141
 
142
+ # @rbs decoded: DecodedBody
143
+ # @rbs return: void
144
+ def install_decoded: (DecodedBody decoded) -> void
145
+
146
+ # @rbs decoded: DecodedBody
147
+ # @rbs types: TypeSection?
148
+ # @rbs stack: bool
149
+ # @rbs return: void
150
+ def check_decoded: (DecodedBody decoded, TypeSection? types, bool stack) -> void
151
+
122
152
  # @rbs instructions: Array[[Symbol, Symbol, Array[operandItem], Integer?, Integer?]]
123
153
  # @rbs types: TypeSection?
124
154
  # @rbs stack: bool
125
155
  # @rbs return: void
126
156
  def check_instructions: (Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]] instructions, TypeSection? types, bool stack) -> void
157
+
158
+ # @rbs block: Block
159
+ # @rbs types: TypeSection?
160
+ # @rbs stack: bool
161
+ # @rbs return: void
162
+ def check_block: (Block block, TypeSection? types, bool stack) -> void
127
163
  end
128
164
 
129
165
  attr_accessor func_codes: Array[CodeBody]
@@ -259,19 +295,32 @@ module Wardite
259
295
  # @rbs return: CodeSection::CodeBody
260
296
  def self.read_function_body: (StringIO sbuf, ?bool defer_code) -> CodeSection::CodeBody
261
297
 
262
- # @rbs buf: StringIO
298
+ # @rbs buf: File|StringIO
263
299
  # @rbs return: Array[[Symbol, Symbol, Array[operandItem], Integer?, Integer?]]
264
- def self.code_body: (StringIO buf) -> Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]]
300
+ def self.code_body: (File | StringIO buf) -> Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]]
301
+
302
+ # @rbs buf: File|StringIO
303
+ # @rbs return: DecodedBody
304
+ def self.decode_body: (File | StringIO buf) -> DecodedBody
305
+
306
+ # @rbs code: Symbol
307
+ # @rbs return: bool
308
+ def self.eh_instruction?: (Symbol code) -> bool
265
309
 
266
310
  # Decode s33, distinguishing the one-byte value/void forms from indices.
267
- # @rbs buf: StringIO
311
+ # @rbs buf: File|StringIO
268
312
  # @rbs return: Block
269
- def self.read_blocktype: (StringIO buf) -> Block
313
+ def self.read_blocktype: (File | StringIO buf) -> Block
270
314
 
271
315
  # @rbs c: String
272
- # @rbs buf: StringIO
316
+ # @rbs buf: File|StringIO
273
317
  # @rbs return: [Symbol, Symbol, Array[Symbol]]
274
- def self.resolve_code: (String c, StringIO buf) -> [ Symbol, Symbol, Array[Symbol] ]
318
+ def self.resolve_code: (String c, File | StringIO buf) -> [ Symbol, Symbol, Array[Symbol] ]
319
+
320
+ # @rbs opcode: Integer
321
+ # @rbs buf: File|StringIO
322
+ # @rbs return: Op::DecodeSpec
323
+ def self.resolve_spec: (Integer opcode, File | StringIO buf) -> Op::DecodeSpec
275
324
 
276
325
  # @rbs return: DataSection
277
326
  def self.data_section: () -> DataSection
@@ -298,6 +347,10 @@ module Wardite
298
347
  # @rbs return: nil
299
348
  def self.unimplemented_skip_section: (Integer code) -> nil
300
349
 
350
+ # @rbs sbuf: File|StringIO
351
+ # @rbs return: Integer
352
+ def self.assert_byte: (File | StringIO sbuf) -> Integer
353
+
301
354
  # @rbs sbuf: File|StringIO
302
355
  # @rbs n: Integer
303
356
  # @rbs return: String
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wardite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uchio Kondo
@@ -30,6 +30,7 @@ files:
30
30
  - benchmark/compare_call_types.rb
31
31
  - benchmark/compare_dispatch.rb
32
32
  - benchmark/compare_engines.rb
33
+ - benchmark/compare_mir_generation_builds.rb
33
34
  - benchmark/compare_optimizations.rb
34
35
  - benchmark/count_ruby_wasm_functions.rb
35
36
  - benchmark/engine_phases.rb
@@ -40,6 +41,7 @@ files:
40
41
  - benchmark/figures/spinel_new_vm_summary.csv
41
42
  - benchmark/figures/spinel_new_vm_summary.json
42
43
  - benchmark/float_m5.wat
44
+ - benchmark/generate_mir_generation_fixtures.rb
43
45
  - benchmark/i32_call_arities.wat
44
46
  - benchmark/i32_calls.wat
45
47
  - benchmark/i32_memory.wat
@@ -55,10 +57,16 @@ files:
55
57
  - benchmark/measure_m5_boundary.rb
56
58
  - benchmark/measure_mir_cache_restore.rb
57
59
  - benchmark/measure_mir_cache_verify.rb
60
+ - benchmark/measure_mir_generation.rb
58
61
  - benchmark/measure_ruby_wasm_cache_hit.rb
59
62
  - benchmark/measure_ruby_wasm_startup.rb
60
63
  - benchmark/measure_wasi_write.rb
64
+ - benchmark/mir_copy_worker.rb
65
+ - benchmark/mir_generation_worker.rb
61
66
  - benchmark/optimization_worker.rb
67
+ - benchmark/prepare_mir_generation_profile.rb
68
+ - benchmark/profile_inline_snapshots.rb
69
+ - benchmark/profile_mir_generation_allocations.rb
62
70
  - benchmark/results/call_arities_exploratory_2026-11-04.json
63
71
  - benchmark/results/call_arities_spinel_2026-11-04.json
64
72
  - benchmark/results/call_cost_spinel_2026-11-04.json
@@ -84,6 +92,13 @@ files:
84
92
  - benchmark/results/inlining_engines_2026-11-04.json
85
93
  - benchmark/results/inlining_ruby_2026-11-04.json
86
94
  - benchmark/results/inlining_spinel_2026-11-04.json
95
+ - benchmark/results/mir-generation-adr0014.json
96
+ - benchmark/results/mir-generation-adr0015.json
97
+ - benchmark/results/mir-generation-allocations.json
98
+ - benchmark/results/mir-generation-coarse.json
99
+ - benchmark/results/mir-generation-control.json
100
+ - benchmark/results/mir-generation-detail.json
101
+ - benchmark/results/mir-generation-scaling.json
87
102
  - benchmark/results/operand_decode_exploratory_2026-11-04.json
88
103
  - benchmark/results/operand_decode_ruby_2026-11-04.json
89
104
  - benchmark/results/operand_decode_spinel_2026-11-04.json
@@ -112,6 +127,9 @@ files:
112
127
  - docs/adr/0011-efflorescence-unboxed-globals.md
113
128
  - docs/adr/0012-efflorescence-startup-snapshot.md
114
129
  - docs/adr/0013-efflorescence-frame-acquisition.md
130
+ - docs/adr/0014-efflorescence-mir-build-validation-and-decoding.md
131
+ - docs/adr/0015-efflorescence-selective-inline-snapshots.md
132
+ - docs/adr/0016-efflorescence-generation-tagged-copy-propagation.md
115
133
  - docs/efflorescence-call-arities.md
116
134
  - docs/efflorescence-call-investigation.md
117
135
  - docs/efflorescence-call-transfer.md
@@ -126,12 +144,16 @@ files:
126
144
  - docs/efflorescence-m4.md
127
145
  - docs/efflorescence-m5.md
128
146
  - docs/efflorescence-m6.md
147
+ - docs/efflorescence-mir-build-validation-and-decoding-results.md
148
+ - docs/efflorescence-mir-generation-implementation.md
149
+ - docs/efflorescence-mir-generation-performance.md
129
150
  - docs/efflorescence-mir2-cache.md
130
151
  - docs/efflorescence-operand-decoding.md
131
152
  - docs/efflorescence-phase2-ja.md
132
153
  - docs/efflorescence-phase2.md
133
154
  - docs/efflorescence-register-initialization.md
134
155
  - docs/efflorescence-ruby-wasm-phase1.md
156
+ - docs/efflorescence-selective-inline-snapshots-results.md
135
157
  - docs/efflorescence-spinel-linear-memory.md
136
158
  - docs/efflorescence-startup-snapshot.md
137
159
  - docs/efflorescence-unboxed-globals.md