wardite 0.8.2 → 1.0.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.
- checksums.yaml +4 -4
- data/LICENSE +191 -0
- data/Makefile +14 -0
- data/README.md +80 -1
- data/Rakefile +5 -0
- data/benchmark/README.md +500 -0
- data/benchmark/build_call_profile.rb +42 -0
- data/benchmark/call_cost_worker.rb +27 -0
- data/benchmark/compare.rb +93 -0
- data/benchmark/compare_call_types.rb +212 -0
- data/benchmark/compare_dispatch.rb +123 -0
- data/benchmark/compare_engines.rb +119 -0
- data/benchmark/compare_optimizations.rb +139 -0
- data/benchmark/engine_phases.rb +30 -0
- data/benchmark/figures/README.md +35 -0
- data/benchmark/figures/plot_spinel_comparison.py +137 -0
- data/benchmark/figures/spinel_new_vm_candlestick.png +0 -0
- data/benchmark/figures/spinel_new_vm_candlestick.svg +7615 -0
- data/benchmark/figures/spinel_new_vm_summary.csv +9 -0
- data/benchmark/figures/spinel_new_vm_summary.json +82 -0
- data/benchmark/float_m5.wat +42 -0
- data/benchmark/i32_call_arities.wat +89 -0
- data/benchmark/i32_calls.wat +174 -0
- data/benchmark/i32_memory.wat +58 -0
- data/benchmark/i32_mix.wat +80 -0
- data/benchmark/i64_m4.wat +55 -0
- data/benchmark/investigate_calls.rb +231 -0
- data/benchmark/investigate_generated_guards.rb +218 -0
- data/benchmark/m3_call_worker.rb +38 -0
- data/benchmark/measure_m1.rb +51 -0
- data/benchmark/measure_m2.rb +55 -0
- data/benchmark/measure_m3_calls.rb +89 -0
- data/benchmark/measure_m4.rb +134 -0
- data/benchmark/measure_m5_boundary.rb +41 -0
- data/benchmark/measure_wasi_write.rb +75 -0
- data/benchmark/optimization_worker.rb +23 -0
- data/benchmark/results/call_arities_exploratory_2026-11-04.json +4320 -0
- data/benchmark/results/call_arities_spinel_2026-11-04.json +1200 -0
- data/benchmark/results/call_cost_spinel_2026-11-04.json +2392 -0
- data/benchmark/results/call_protocol_exploratory_2026-11-04.json +3947 -0
- data/benchmark/results/call_protocol_profile_2026-11-04.json +383 -0
- data/benchmark/results/call_protocol_ruby_2026-11-04.json +1213 -0
- data/benchmark/results/call_protocol_spinel_2026-11-04.json +913 -0
- data/benchmark/results/call_types_ruby_2026-11-04.json +1212 -0
- data/benchmark/results/call_types_spinel_2026-11-04.json +923 -0
- data/benchmark/results/efflorescence-m1-cruby.json +799 -0
- data/benchmark/results/efflorescence-m1-spinel.json +799 -0
- data/benchmark/results/efflorescence-m2-bulk-loop.json +820 -0
- data/benchmark/results/efflorescence-m2-i32-cruby.json +799 -0
- data/benchmark/results/efflorescence-m2-i32-spinel.json +799 -0
- data/benchmark/results/efflorescence-m2-memory.json +408 -0
- data/benchmark/results/generated_guards_exploratory_2026-11-04.json +1225 -0
- data/benchmark/results/generated_guards_profile_2026-11-04.json +592 -0
- data/benchmark/results/generated_guards_spinel_2026-11-04.json +1650 -0
- data/benchmark/results/generated_guards_validation_2026-11-04.json +256 -0
- data/benchmark/results/inlining_engines_2026-11-04.json +241 -0
- data/benchmark/results/inlining_ruby_2026-11-04.json +1213 -0
- data/benchmark/results/inlining_spinel_2026-11-04.json +893 -0
- data/benchmark/results/operand_decode_exploratory_2026-11-04.json +1319 -0
- data/benchmark/results/operand_decode_ruby_2026-11-04.json +1213 -0
- data/benchmark/results/operand_decode_spinel_2026-11-04.json +924 -0
- data/benchmark/results/selective_reset_spinel_2026-11-04.json +454 -0
- data/benchmark/results/selective_reset_spinel_2026-11-04_exploratory.json +2679 -0
- data/benchmark/results/spinel_fetch_root_patch_2026-11-04.json +4523 -0
- data/benchmark/results/while_final_compiler_comparison_2026-11-04.json +324 -0
- data/benchmark/results/while_patched_external_2026-11-04.json +220 -0
- data/benchmark/results/while_user_unpatched_2026-11-04.json +230 -0
- data/benchmark/summarize_call_profile.py +54 -0
- data/benchmark/validate_m1_eh.rb +34 -0
- data/benchmark/validate_m2.rb +119 -0
- data/benchmark/validate_m3.rb +44 -0
- data/benchmark/validate_m4.rb +95 -0
- data/benchmark/validate_m5.rb +108 -0
- data/docs/adr/0001-efflorescence-m1-control-and-eh.md +319 -0
- data/docs/adr/0002-efflorescence-m2-memory-and-globals.md +185 -0
- data/docs/adr/0003-efflorescence-m3-host-and-indirect-calls.md +228 -0
- data/docs/adr/0004-efflorescence-m4-i64.md +202 -0
- data/docs/adr/0005-efflorescence-m5-floating-point.md +127 -0
- data/docs/adr/0006-efflorescence-m6-coverage-parity.md +101 -0
- data/docs/efflorescence-call-arities.md +115 -0
- data/docs/efflorescence-call-investigation.md +155 -0
- data/docs/efflorescence-call-transfer.md +128 -0
- data/docs/efflorescence-call-types.md +102 -0
- data/docs/efflorescence-coverage-ja.md +351 -0
- data/docs/efflorescence-generated-c-guards.md +405 -0
- data/docs/efflorescence-inlining.md +165 -0
- data/docs/efflorescence-ja.md +155 -0
- data/docs/efflorescence-m1.md +160 -0
- data/docs/efflorescence-m2.md +233 -0
- data/docs/efflorescence-m3.md +131 -0
- data/docs/efflorescence-m4.md +88 -0
- data/docs/efflorescence-m5.md +82 -0
- data/docs/efflorescence-m6.md +95 -0
- data/docs/efflorescence-operand-decoding.md +105 -0
- data/docs/efflorescence-phase2-ja.md +225 -0
- data/docs/efflorescence-phase2.md +240 -0
- data/docs/efflorescence-register-initialization.md +75 -0
- data/docs/efflorescence.md +144 -0
- data/docs/spinel-string-aset-inplace-proposal.md +200 -0
- data/examples/load_perf.rb +24 -0
- data/lib/wardite/alu_f32.generated.rb +13 -10
- data/lib/wardite/alu_f64.generated.rb +13 -10
- data/lib/wardite/alu_i32.generated.rb +38 -31
- data/lib/wardite/alu_i64.generated.rb +48 -48
- data/lib/wardite/cli/cli.rb +73 -22
- data/lib/wardite/const.rb +1 -0
- data/lib/wardite/convert.generated.rb +7 -5
- data/lib/wardite/efflorescence/float_arithmetic.rb +216 -0
- data/lib/wardite/efflorescence/i64_arithmetic.rb +257 -0
- data/lib/wardite/efflorescence/inspection.rb +165 -0
- data/lib/wardite/efflorescence/ir.rb +1151 -0
- data/lib/wardite/efflorescence/optimizer.rb +580 -0
- data/lib/wardite/efflorescence/register_validation.rb +290 -0
- data/lib/wardite/efflorescence/store_access.rb +271 -0
- data/lib/wardite/efflorescence/translator.rb +859 -0
- data/lib/wardite/efflorescence/vm.rb +1006 -0
- data/lib/wardite/efflorescence/wasi.rb +108 -0
- data/lib/wardite/efflorescence.rb +11 -0
- data/lib/wardite/errors.rb +20 -0
- data/lib/wardite/float_bits.rb +46 -0
- data/lib/wardite/instruction.rb +460 -69
- data/lib/wardite/leb128.rb +35 -17
- data/lib/wardite/load.rb +260 -159
- data/lib/wardite/revisitor.rb +12 -4
- data/lib/wardite/value.rb +169 -175
- data/lib/wardite/version.rb +1 -1
- data/lib/wardite/wasi/consts.rb +1 -0
- data/lib/wardite/wasm_module.rb +6 -3
- data/lib/wardite.rb +220 -105
- data/rbs_collection.lock.yaml +36 -96
- data/scripts/gen_alu.rb +90 -34
- data/scripts/templates/alu_module.rb.tmpl +7 -5
- data/scripts/templates/conv_module.rb.tmpl +7 -5
- data/sig/generated/wardite/alu_f32.generated.rbs +4 -3
- data/sig/generated/wardite/alu_f64.generated.rbs +4 -3
- data/sig/generated/wardite/alu_i32.generated.rbs +4 -3
- data/sig/generated/wardite/alu_i64.generated.rbs +4 -3
- data/sig/generated/wardite/cli/cli.rbs +13 -6
- data/sig/generated/wardite/const.rbs +2 -0
- data/sig/generated/wardite/convert.generated.rbs +4 -3
- data/sig/generated/wardite/efflorescence/float_arithmetic.rbs +65 -0
- data/sig/generated/wardite/efflorescence/i64_arithmetic.rbs +99 -0
- data/sig/generated/wardite/efflorescence/inspection.rbs +64 -0
- data/sig/generated/wardite/efflorescence/ir.rbs +881 -0
- data/sig/generated/wardite/efflorescence/optimizer.rbs +189 -0
- data/sig/generated/wardite/efflorescence/register_validation.rbs +76 -0
- data/sig/generated/wardite/efflorescence/store_access.rbs +134 -0
- data/sig/generated/wardite/efflorescence/translator.rbs +214 -0
- data/sig/generated/wardite/efflorescence/vm.rbs +179 -0
- data/sig/generated/wardite/efflorescence/wasi.rbs +47 -0
- data/sig/generated/wardite/errors.rbs +12 -0
- data/sig/generated/wardite/float_bits.rbs +30 -0
- data/sig/generated/wardite/instruction.rbs +35 -10
- data/sig/generated/wardite/leb128.rbs +3 -1
- data/sig/generated/wardite/load.rbs +38 -13
- data/sig/generated/wardite/value.rbs +70 -11
- data/sig/generated/wardite/wasi/consts.rbs +2 -0
- data/sig/generated/wardite.rbs +55 -18
- data/sig/vernier.rbs +3 -0
- data/spinel/README.md +30 -0
- data/spinel/bin/wardite.rb +6 -0
- data/spinel/spin.toml +7 -0
- metadata +128 -3
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Generated from lib/wardite/efflorescence/optimizer.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Wardite
|
|
4
|
+
module Efflorescence
|
|
5
|
+
class Configuration
|
|
6
|
+
FEATURES: untyped
|
|
7
|
+
|
|
8
|
+
attr_reader disabled: Array[Symbol]
|
|
9
|
+
|
|
10
|
+
# @rbs disabled: Array[Symbol]
|
|
11
|
+
def initialize: (Array[Symbol] disabled) -> untyped
|
|
12
|
+
|
|
13
|
+
# @rbs feature: Symbol
|
|
14
|
+
# @rbs return: bool
|
|
15
|
+
def enabled?: (Symbol feature) -> bool
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# All transformations use instruction ordinals. Only the final lowering
|
|
19
|
+
# changes PCs to integer-array offsets. Every rewrite repairs branch edges.
|
|
20
|
+
class Rewrite
|
|
21
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
22
|
+
def initialize: (Wardite::Efflorescence::Function function) -> untyped
|
|
23
|
+
|
|
24
|
+
# @rbs pc: Integer
|
|
25
|
+
# @rbs return: void
|
|
26
|
+
def mark: (Integer pc) -> void
|
|
27
|
+
|
|
28
|
+
# @rbs instruction: Wardite::Efflorescence::Instruction
|
|
29
|
+
# @rbs return: void
|
|
30
|
+
def emit: (Wardite::Efflorescence::Instruction instruction) -> void
|
|
31
|
+
|
|
32
|
+
# @rbs return: void
|
|
33
|
+
def finish: () -> void
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# A shared CFG includes exceptional edges with their edge-local writes.
|
|
37
|
+
# Handler shapes are checked independently of definite assignment.
|
|
38
|
+
class FlowGraph
|
|
39
|
+
attr_reader normal: Array[Array[Integer]]
|
|
40
|
+
|
|
41
|
+
attr_reader exceptional: Array[Array[Wardite::Efflorescence::CatchTarget]]
|
|
42
|
+
|
|
43
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
44
|
+
def initialize: (Wardite::Efflorescence::Function function) -> untyped
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
# @rbs pc: Integer
|
|
49
|
+
# @rbs stack: Array[Integer]
|
|
50
|
+
# @rbs return: void
|
|
51
|
+
def merge: (Integer pc, Array[Integer] stack) -> void
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class Analysis
|
|
55
|
+
# @rbs @flow: Wardite::Efflorescence::FlowGraph?
|
|
56
|
+
attr_reader leaders: Array[Integer]
|
|
57
|
+
|
|
58
|
+
attr_reader reads: Array[Integer]
|
|
59
|
+
|
|
60
|
+
attr_reader writes: Array[Integer]
|
|
61
|
+
|
|
62
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
63
|
+
def initialize: (Wardite::Efflorescence::Function function) -> untyped
|
|
64
|
+
|
|
65
|
+
# Ordinary optimization passes need only the summary above. Build the full
|
|
66
|
+
# normal CFG once for validation; EH summaries also need it for leaders.
|
|
67
|
+
# @rbs return: Wardite::Efflorescence::FlowGraph
|
|
68
|
+
def flow: () -> Wardite::Efflorescence::FlowGraph
|
|
69
|
+
|
|
70
|
+
# @rbs register: Integer
|
|
71
|
+
# @rbs return: bool
|
|
72
|
+
def single_use?: (Integer register) -> bool
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
module Passes
|
|
76
|
+
# Expand only small, straight-line leaves from a snapshot of the IR.
|
|
77
|
+
# One round avoids transitive/exponential expansion and keeps recursion
|
|
78
|
+
# on the ordinary CALL path. Existing local passes clean up the copies.
|
|
79
|
+
class Inlining
|
|
80
|
+
MAX_INSTRUCTIONS: ::Integer
|
|
81
|
+
|
|
82
|
+
MAX_REGISTERS: ::Integer
|
|
83
|
+
|
|
84
|
+
MAX_ADDED_INSTRUCTIONS: ::Integer
|
|
85
|
+
|
|
86
|
+
MAX_ADDED_REGISTERS: ::Integer
|
|
87
|
+
|
|
88
|
+
# @rbs ir: Wardite::Efflorescence::IR
|
|
89
|
+
# @rbs return: Array[Integer]
|
|
90
|
+
def run: (Wardite::Efflorescence::IR ir) -> Array[Integer]
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
|
|
94
|
+
# Explicit whitelist: new opcodes must opt into inlining. In particular,
|
|
95
|
+
# traps, profiling records, control flow and nested calls stay intact.
|
|
96
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
97
|
+
# @rbs return: bool
|
|
98
|
+
def eligible?: (Wardite::Efflorescence::Function function) -> bool
|
|
99
|
+
|
|
100
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
101
|
+
# @rbs callees: Wardite::Efflorescence::IR
|
|
102
|
+
# @rbs return: bool
|
|
103
|
+
def expand_calls: (Wardite::Efflorescence::Function function, Wardite::Efflorescence::IR callees) -> bool
|
|
104
|
+
|
|
105
|
+
# @rbs caller: Wardite::Efflorescence::Function
|
|
106
|
+
# @rbs callee: Wardite::Efflorescence::Function
|
|
107
|
+
# @rbs call: Wardite::Efflorescence::Instruction
|
|
108
|
+
# @rbs rewrite: Wardite::Efflorescence::Rewrite
|
|
109
|
+
# @rbs return: void
|
|
110
|
+
def expand: (Wardite::Efflorescence::Function caller, Wardite::Efflorescence::Function callee, Wardite::Efflorescence::Instruction call, Wardite::Efflorescence::Rewrite rewrite) -> void
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
class CopyPropagation
|
|
114
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
115
|
+
# @rbs return: void
|
|
116
|
+
def run: (Wardite::Efflorescence::Function function) -> void
|
|
117
|
+
|
|
118
|
+
private
|
|
119
|
+
|
|
120
|
+
# Redirect an adjacent producer into the COPY destination. The producer
|
|
121
|
+
# temporary has one definition and one use in the entire function, and
|
|
122
|
+
# nobody can enter at the COPY. No value is moved across another op.
|
|
123
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
124
|
+
# @rbs return: void
|
|
125
|
+
def coalesce_results: (Wardite::Efflorescence::Function function) -> void
|
|
126
|
+
|
|
127
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
128
|
+
# @rbs return: void
|
|
129
|
+
def propagate: (Wardite::Efflorescence::Function function) -> void
|
|
130
|
+
|
|
131
|
+
# Backward liveness inside each basic block removes copies overwritten
|
|
132
|
+
# before any read (e.g. an inlined parameter initializer). All registers
|
|
133
|
+
# are conservatively live across edges; no value moves across a branch.
|
|
134
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
135
|
+
# @rbs return: void
|
|
136
|
+
def remove_overwritten_copies: (Wardite::Efflorescence::Function function) -> void
|
|
137
|
+
|
|
138
|
+
# Keep snapshot and join copies unless their destination has no reads
|
|
139
|
+
# anywhere. Iteration also removes copies feeding another dead copy.
|
|
140
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
141
|
+
# @rbs return: void
|
|
142
|
+
def remove_dead_copies: (Wardite::Efflorescence::Function function) -> void
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
class ImmediateSpecialization
|
|
146
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
147
|
+
# @rbs return: void
|
|
148
|
+
def run: (Wardite::Efflorescence::Function function) -> void
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
class BranchFusion
|
|
152
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
153
|
+
# @rbs return: void
|
|
154
|
+
def run: (Wardite::Efflorescence::Function function) -> void
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
class Superinstructions
|
|
158
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
159
|
+
# @rbs return: void
|
|
160
|
+
def run: (Wardite::Efflorescence::Function function) -> void
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
class Optimizer
|
|
165
|
+
# @rbs configuration: Wardite::Efflorescence::Configuration
|
|
166
|
+
def initialize: (Wardite::Efflorescence::Configuration configuration) -> untyped
|
|
167
|
+
|
|
168
|
+
# Never mutate the translator's semantic MIR; retain it for inspection
|
|
169
|
+
# and differential execution. Each pass can also be run independently.
|
|
170
|
+
# @rbs ir: Wardite::Efflorescence::IR
|
|
171
|
+
# @rbs return: Wardite::Efflorescence::IR
|
|
172
|
+
def optimize: (Wardite::Efflorescence::IR ir) -> Wardite::Efflorescence::IR
|
|
173
|
+
|
|
174
|
+
private
|
|
175
|
+
|
|
176
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
177
|
+
# @rbs return: void
|
|
178
|
+
def optimize_function: (Wardite::Efflorescence::Function function) -> void
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
class Lowerer
|
|
182
|
+
WIDTH: ::Integer
|
|
183
|
+
|
|
184
|
+
# @rbs ir: Wardite::Efflorescence::IR
|
|
185
|
+
# @rbs return: void
|
|
186
|
+
def compile: (Wardite::Efflorescence::IR ir) -> void
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Generated from lib/wardite/efflorescence/register_validation.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Wardite
|
|
4
|
+
module Efflorescence
|
|
5
|
+
# Verify definite assignment once, after optimization and before execution.
|
|
6
|
+
# This makes stale temporary slots harmless when a frame is reused. Keep
|
|
7
|
+
# states per basic block, rather than per instruction, to bound their size.
|
|
8
|
+
class RegisterValidation
|
|
9
|
+
class Block
|
|
10
|
+
attr_reader first: Integer
|
|
11
|
+
|
|
12
|
+
attr_reader limit: Integer
|
|
13
|
+
|
|
14
|
+
attr_reader defined: Array[Integer]
|
|
15
|
+
|
|
16
|
+
# @rbs first: Integer
|
|
17
|
+
# @rbs limit: Integer
|
|
18
|
+
# @rbs register_count: Integer
|
|
19
|
+
def initialize: (Integer first, Integer limit, Integer register_count) -> untyped
|
|
20
|
+
|
|
21
|
+
# Incoming facts only lose definitions after the first reachable edge.
|
|
22
|
+
# A backedge cannot establish a definition missing on initial entry.
|
|
23
|
+
# @rbs incoming: Array[Integer]
|
|
24
|
+
# @rbs return: bool
|
|
25
|
+
def merge: (Array[Integer] incoming) -> bool
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
29
|
+
# @rbs return: void
|
|
30
|
+
# @rbs ir: Wardite::Efflorescence::IR?
|
|
31
|
+
# @rbs tags: Array[Wardite::Efflorescence::Tag]?
|
|
32
|
+
def validate: (Wardite::Efflorescence::Function function, ?Wardite::Efflorescence::IR? ir, ?tags: Array[Wardite::Efflorescence::Tag]?) -> void
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
# Validate all registers, including unreachable instructions and table-only
|
|
37
|
+
# operands. Numeric registers are checked before flat execution.
|
|
38
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
39
|
+
# @rbs return: void
|
|
40
|
+
# @rbs ir: Wardite::Efflorescence::IR?
|
|
41
|
+
# @rbs tags: Array[Wardite::Efflorescence::Tag]?
|
|
42
|
+
def validate_types: (Wardite::Efflorescence::Function function, Wardite::Efflorescence::IR? ir, Array[Wardite::Efflorescence::Tag]? tags) -> void
|
|
43
|
+
|
|
44
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
45
|
+
# @rbs instruction: Wardite::Efflorescence::Instruction
|
|
46
|
+
# @rbs reads: Array[Integer]
|
|
47
|
+
# @rbs destination: Integer
|
|
48
|
+
# @rbs return: void
|
|
49
|
+
def validate_extended_instruction: (Wardite::Efflorescence::Function function, Wardite::Efflorescence::Instruction instruction, Array[Integer] reads, Integer destination) -> void
|
|
50
|
+
|
|
51
|
+
# @rbs tags: Array[Wardite::Efflorescence::Tag]?
|
|
52
|
+
# @rbs index: Integer
|
|
53
|
+
# @rbs size: Integer
|
|
54
|
+
# @rbs return: Array[Symbol]
|
|
55
|
+
def payload_types: (Array[Wardite::Efflorescence::Tag]? tags, Integer index, Integer size) -> Array[Symbol]
|
|
56
|
+
|
|
57
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
58
|
+
# @rbs register: Integer
|
|
59
|
+
# @rbs types: Array[Symbol]
|
|
60
|
+
# @rbs return: void
|
|
61
|
+
def check_result: (Wardite::Efflorescence::Function function, Integer register, Array[Symbol] types) -> void
|
|
62
|
+
|
|
63
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
64
|
+
# @rbs register: Integer
|
|
65
|
+
# @rbs type: Symbol
|
|
66
|
+
# @rbs return: void
|
|
67
|
+
def check_register: (Wardite::Efflorescence::Function function, Integer register, Symbol type) -> void
|
|
68
|
+
|
|
69
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
70
|
+
# @rbs register: Integer
|
|
71
|
+
# @rbs type: Symbol
|
|
72
|
+
# @rbs return: void
|
|
73
|
+
def check_destination: (Wardite::Efflorescence::Function function, Integer register, Symbol type) -> void
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Generated from lib/wardite/efflorescence/store_access.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Wardite
|
|
4
|
+
module Efflorescence
|
|
5
|
+
# Checked byte operations live off the integer dispatch path. Store remains
|
|
6
|
+
# the owner of all state; never retain a Memory#data buffer across a call.
|
|
7
|
+
class StoreAccess
|
|
8
|
+
PAGE_SIZE: ::Integer
|
|
9
|
+
|
|
10
|
+
MAX_PAGES: ::Integer
|
|
11
|
+
|
|
12
|
+
# @rbs start: Integer
|
|
13
|
+
# @rbs length: Integer
|
|
14
|
+
# @rbs size: Integer
|
|
15
|
+
# @rbs return: void
|
|
16
|
+
def self.check_range: (Integer start, Integer length, Integer size) -> void
|
|
17
|
+
|
|
18
|
+
# @rbs store: Wardite::Store
|
|
19
|
+
def initialize: (Wardite::Store store) -> untyped
|
|
20
|
+
|
|
21
|
+
# @rbs index: Integer
|
|
22
|
+
# @rbs return: Wardite::Global
|
|
23
|
+
def global_at: (Integer index) -> Wardite::Global
|
|
24
|
+
|
|
25
|
+
# @rbs index: Integer
|
|
26
|
+
# @rbs return: Integer
|
|
27
|
+
def global_get: (Integer index) -> Integer
|
|
28
|
+
|
|
29
|
+
# @rbs index: Integer
|
|
30
|
+
# @rbs return: Integer
|
|
31
|
+
def global_get_i64: (Integer index) -> Integer
|
|
32
|
+
|
|
33
|
+
# @rbs index: Integer
|
|
34
|
+
# @rbs type: Symbol
|
|
35
|
+
# @rbs return: Integer
|
|
36
|
+
def global_get_float: (Integer index, Symbol type) -> Integer
|
|
37
|
+
|
|
38
|
+
# @rbs index: Integer
|
|
39
|
+
# @rbs type: Symbol
|
|
40
|
+
# @rbs value: Integer
|
|
41
|
+
# @rbs return: void
|
|
42
|
+
def global_set_float: (Integer index, Symbol type, Integer value) -> void
|
|
43
|
+
|
|
44
|
+
# Boxing is confined to the shared Store boundary. Existing register
|
|
45
|
+
# snapshots contain independent integers, never a mutable Global object.
|
|
46
|
+
# @rbs index: Integer
|
|
47
|
+
# @rbs value: Integer
|
|
48
|
+
# @rbs return: void
|
|
49
|
+
def global_set: (Integer index, Integer value) -> void
|
|
50
|
+
|
|
51
|
+
# @rbs index: Integer
|
|
52
|
+
# @rbs value: Integer
|
|
53
|
+
# @rbs return: void
|
|
54
|
+
def global_set_i64: (Integer index, Integer value) -> void
|
|
55
|
+
|
|
56
|
+
# @rbs address: Integer
|
|
57
|
+
# @rbs offset: Integer
|
|
58
|
+
# @rbs width: Integer
|
|
59
|
+
# @rbs signed: bool
|
|
60
|
+
# @rbs return: Integer
|
|
61
|
+
def load: (Integer address, Integer offset, Integer width, bool signed) -> Integer
|
|
62
|
+
|
|
63
|
+
# @rbs address: Integer
|
|
64
|
+
# @rbs offset: Integer
|
|
65
|
+
# @rbs width: Integer
|
|
66
|
+
# @rbs signed: bool
|
|
67
|
+
# @rbs return: Integer
|
|
68
|
+
def load_i64: (Integer address, Integer offset, Integer width, bool signed) -> Integer
|
|
69
|
+
|
|
70
|
+
# Check the whole access before the first write. Effective addresses are
|
|
71
|
+
# wide integers; the static offset never wraps back into memory32.
|
|
72
|
+
# @rbs address: Integer
|
|
73
|
+
# @rbs offset: Integer
|
|
74
|
+
# @rbs width: Integer
|
|
75
|
+
# @rbs value: Integer
|
|
76
|
+
# @rbs return: void
|
|
77
|
+
def store: (Integer address, Integer offset, Integer width, Integer value) -> void
|
|
78
|
+
|
|
79
|
+
# @rbs return: Integer
|
|
80
|
+
def size: () -> Integer
|
|
81
|
+
|
|
82
|
+
# Only the buffer preparation boundary handles allocation failure. Ruby
|
|
83
|
+
# implementation errors and traps must propagate rather than look like a
|
|
84
|
+
# successful Wasm instruction returning -1.
|
|
85
|
+
# @rbs delta: Integer
|
|
86
|
+
# @rbs return: Integer
|
|
87
|
+
def grow: (Integer delta) -> Integer
|
|
88
|
+
|
|
89
|
+
# Kept separate so tests can inject allocation failure without requesting
|
|
90
|
+
# gigabytes or depending on the process's available resources.
|
|
91
|
+
# @rbs target: Wardite::Memory
|
|
92
|
+
# @rbs delta: Integer
|
|
93
|
+
# @rbs return: String
|
|
94
|
+
def grown_buffer: (Wardite::Memory target, Integer delta) -> String
|
|
95
|
+
|
|
96
|
+
# Resolve table operands off the hot dispatch path. In particular do not
|
|
97
|
+
# widen its b/c integer-word locals with nullable array reads.
|
|
98
|
+
# @rbs opcode: Integer
|
|
99
|
+
# @rbs site: Wardite::Efflorescence::MemorySite
|
|
100
|
+
# @rbs registers: Array[Integer]
|
|
101
|
+
# @rbs return: void
|
|
102
|
+
def bulk: (Integer opcode, Wardite::Efflorescence::MemorySite site, Array[Integer] registers) -> void
|
|
103
|
+
|
|
104
|
+
# @rbs destination: Integer
|
|
105
|
+
# @rbs source: Integer
|
|
106
|
+
# @rbs length: Integer
|
|
107
|
+
# @rbs return: void
|
|
108
|
+
def copy: (Integer destination, Integer source, Integer length) -> void
|
|
109
|
+
|
|
110
|
+
# @rbs destination: Integer
|
|
111
|
+
# @rbs value: Integer
|
|
112
|
+
# @rbs length: Integer
|
|
113
|
+
# @rbs return: void
|
|
114
|
+
def fill: (Integer destination, Integer value, Integer length) -> void
|
|
115
|
+
|
|
116
|
+
# @rbs index: Integer
|
|
117
|
+
# @rbs destination: Integer
|
|
118
|
+
# @rbs source: Integer
|
|
119
|
+
# @rbs length: Integer
|
|
120
|
+
# @rbs return: void
|
|
121
|
+
def init: (Integer index, Integer destination, Integer source, Integer length) -> void
|
|
122
|
+
|
|
123
|
+
# Read up to four checked little-endian bytes as an unsigned limb.
|
|
124
|
+
# @rbs data: String
|
|
125
|
+
# @rbs start: Integer
|
|
126
|
+
# @rbs width: Integer
|
|
127
|
+
# @rbs return: Integer
|
|
128
|
+
def read_word: (String data, Integer start, Integer width) -> Integer
|
|
129
|
+
|
|
130
|
+
# @rbs return: Wardite::Memory
|
|
131
|
+
def memory: () -> Wardite::Memory
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Generated from lib/wardite/efflorescence/translator.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Wardite
|
|
4
|
+
module Efflorescence
|
|
5
|
+
# The operand/control stacks exist only during translation. Execution uses
|
|
6
|
+
# typed register banks, absolute PCs and explicit per-frame handler stacks.
|
|
7
|
+
class Translator
|
|
8
|
+
class Control
|
|
9
|
+
attr_reader kind: Symbol
|
|
10
|
+
|
|
11
|
+
attr_reader entry_stack: Array[Integer]
|
|
12
|
+
|
|
13
|
+
attr_reader start_pc: Integer
|
|
14
|
+
|
|
15
|
+
attr_reader result_types: Array[Symbol]
|
|
16
|
+
|
|
17
|
+
attr_reader result_registers: Array[Integer]
|
|
18
|
+
|
|
19
|
+
attr_reader patches: Array[Integer]
|
|
20
|
+
|
|
21
|
+
attr_reader catch_patches: Array[Wardite::Efflorescence::CatchTarget]
|
|
22
|
+
|
|
23
|
+
attr_reader handler_depth: Integer
|
|
24
|
+
|
|
25
|
+
attr_reader entry_reachable: bool
|
|
26
|
+
|
|
27
|
+
attr_accessor polymorphic: bool
|
|
28
|
+
|
|
29
|
+
attr_accessor has_branch: bool
|
|
30
|
+
|
|
31
|
+
attr_accessor false_patch: Integer
|
|
32
|
+
|
|
33
|
+
attr_accessor else_seen: bool
|
|
34
|
+
|
|
35
|
+
attr_accessor then_reachable: bool
|
|
36
|
+
|
|
37
|
+
# @rbs kind: Symbol
|
|
38
|
+
# @rbs entry_stack: Array[Integer]
|
|
39
|
+
# @rbs start_pc: Integer
|
|
40
|
+
# @rbs result_types: Array[Symbol]
|
|
41
|
+
# @rbs result_registers: Array[Integer]
|
|
42
|
+
# @rbs handler_depth: Integer
|
|
43
|
+
# @rbs reachable: bool
|
|
44
|
+
def initialize: (Symbol kind, Array[Integer] entry_stack, Integer start_pc, Array[Symbol] result_types, Array[Integer] result_registers, Integer handler_depth, bool reachable) -> untyped
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
BINARY: untyped
|
|
48
|
+
|
|
49
|
+
UNARY: untyped
|
|
50
|
+
|
|
51
|
+
I64_ALU: untyped
|
|
52
|
+
|
|
53
|
+
# Natural alignment exponents; alignment is a hint, not an address rule.
|
|
54
|
+
FLOAT_ALU: Hash[Symbol, Integer]
|
|
55
|
+
|
|
56
|
+
MEMORY_WIDTHS: untyped
|
|
57
|
+
|
|
58
|
+
MEMORY_OPCODES: untyped
|
|
59
|
+
|
|
60
|
+
STORE_CODES: untyped
|
|
61
|
+
|
|
62
|
+
@instance: Wardite::Instance
|
|
63
|
+
|
|
64
|
+
@entries: Array[Wardite::Efflorescence::FunctionEntry]
|
|
65
|
+
|
|
66
|
+
@stack: Array[Integer]
|
|
67
|
+
|
|
68
|
+
@controls: Array[Wardite::Efflorescence::Translator::Control]
|
|
69
|
+
|
|
70
|
+
@constants: Hash[Integer, Integer]
|
|
71
|
+
|
|
72
|
+
@i64_constants: Hash[Integer, Integer]?
|
|
73
|
+
|
|
74
|
+
@f32_constants: Hash[Integer, Integer]?
|
|
75
|
+
|
|
76
|
+
@f64_constants: Hash[Integer, Integer]?
|
|
77
|
+
|
|
78
|
+
@function: Wardite::Efflorescence::Function
|
|
79
|
+
|
|
80
|
+
@reachable: bool
|
|
81
|
+
|
|
82
|
+
@wasm_pc: Integer
|
|
83
|
+
|
|
84
|
+
@handler_depth: Integer
|
|
85
|
+
|
|
86
|
+
# @rbs instance: Wardite::Instance
|
|
87
|
+
def initialize: (Wardite::Instance instance) -> untyped
|
|
88
|
+
|
|
89
|
+
# @rbs return: Wardite::Efflorescence::IR
|
|
90
|
+
def translate: () -> Wardite::Efflorescence::IR
|
|
91
|
+
|
|
92
|
+
# @rbs wasm: Wardite::WasmFunction
|
|
93
|
+
# @rbs index: Integer
|
|
94
|
+
# @rbs pool_index: Integer
|
|
95
|
+
# @rbs return: Wardite::Efflorescence::Function
|
|
96
|
+
def translate_function: (Wardite::WasmFunction wasm, Integer index, Integer pool_index) -> Wardite::Efflorescence::Function
|
|
97
|
+
|
|
98
|
+
private
|
|
99
|
+
|
|
100
|
+
# Validate even dead instructions before deciding whether to emit MIR.
|
|
101
|
+
# @rbs code: Symbol
|
|
102
|
+
# @rbs operands: Array[Wardite::operandItem]
|
|
103
|
+
# @rbs return: void
|
|
104
|
+
def validate_store_instruction: (Symbol code, Array[Wardite::operandItem] operands) -> void
|
|
105
|
+
|
|
106
|
+
# @rbs index: Integer
|
|
107
|
+
# @rbs return: void
|
|
108
|
+
def check_memory_index: (Integer index) -> void
|
|
109
|
+
|
|
110
|
+
# @rbs value: Wardite::operandItem?
|
|
111
|
+
# @rbs return: Integer
|
|
112
|
+
def integer_operand: (Wardite::operandItem? value) -> Integer
|
|
113
|
+
|
|
114
|
+
# @rbs type: Symbol
|
|
115
|
+
# @rbs return: Integer
|
|
116
|
+
def register: (?Symbol type) -> Integer
|
|
117
|
+
|
|
118
|
+
# @rbs value: Integer
|
|
119
|
+
# @rbs return: Integer
|
|
120
|
+
# @rbs type: Symbol
|
|
121
|
+
def constant: (Integer value, ?Symbol type) -> Integer
|
|
122
|
+
|
|
123
|
+
# @rbs kind: Symbol
|
|
124
|
+
# @rbs types: Array[Symbol]
|
|
125
|
+
# @rbs return: Wardite::Efflorescence::Translator::Control
|
|
126
|
+
def new_control: (Symbol kind, Array[Symbol] types) -> Wardite::Efflorescence::Translator::Control
|
|
127
|
+
|
|
128
|
+
# @rbs instruction: Array[Integer]
|
|
129
|
+
# @rbs return: Integer
|
|
130
|
+
def emit: (Array[Integer] instruction) -> Integer
|
|
131
|
+
|
|
132
|
+
# @rbs pc: Integer
|
|
133
|
+
# @rbs target: Integer
|
|
134
|
+
# @rbs return: void
|
|
135
|
+
def patch: (Integer pc, Integer target) -> void
|
|
136
|
+
|
|
137
|
+
# @rbs return: Integer
|
|
138
|
+
def pop_value: () -> Integer
|
|
139
|
+
|
|
140
|
+
# @rbs register: Integer
|
|
141
|
+
# @rbs return: Symbol
|
|
142
|
+
def type_of: (Integer register) -> Symbol
|
|
143
|
+
|
|
144
|
+
# @rbs type: Symbol
|
|
145
|
+
# @rbs return: Integer
|
|
146
|
+
def pop_typed: (Symbol type) -> Integer
|
|
147
|
+
|
|
148
|
+
# @rbs destination: Integer
|
|
149
|
+
# @rbs source: Integer
|
|
150
|
+
# @rbs return: void
|
|
151
|
+
def copy_value: (Integer destination, Integer source) -> void
|
|
152
|
+
|
|
153
|
+
# @rbs destinations: Array[Integer]
|
|
154
|
+
# @rbs sources: Array[Integer]
|
|
155
|
+
# @rbs return: void
|
|
156
|
+
def parallel_copy: (Array[Integer] destinations, Array[Integer] sources) -> void
|
|
157
|
+
|
|
158
|
+
# @rbs local: Integer
|
|
159
|
+
# @rbs return: void
|
|
160
|
+
def preserve_local: (Integer local) -> void
|
|
161
|
+
|
|
162
|
+
# @rbs return: void
|
|
163
|
+
def snapshot_locals: () -> void
|
|
164
|
+
|
|
165
|
+
# @rbs depth: Integer
|
|
166
|
+
# @rbs return: Wardite::Efflorescence::Translator::Control
|
|
167
|
+
def label: (Integer depth) -> Wardite::Efflorescence::Translator::Control
|
|
168
|
+
|
|
169
|
+
# @rbs target: Wardite::Efflorescence::Translator::Control
|
|
170
|
+
# @rbs return: Array[Symbol]
|
|
171
|
+
def label_types: (Wardite::Efflorescence::Translator::Control target) -> Array[Symbol]
|
|
172
|
+
|
|
173
|
+
# @rbs types: Array[Symbol]
|
|
174
|
+
# @rbs return: Array[Integer]
|
|
175
|
+
def top_values: (Array[Symbol] types) -> Array[Integer]
|
|
176
|
+
|
|
177
|
+
# @rbs target: Wardite::Efflorescence::Translator::Control
|
|
178
|
+
# @rbs sources: Array[Integer]
|
|
179
|
+
# @rbs condition: Integer
|
|
180
|
+
# @rbs return: void
|
|
181
|
+
def branch: (Wardite::Efflorescence::Translator::Control target, Array[Integer] sources, ?Integer condition) -> void
|
|
182
|
+
|
|
183
|
+
# @rbs index: Integer
|
|
184
|
+
# @rbs return: Wardite::Efflorescence::Tag
|
|
185
|
+
def tag_at: (Integer index) -> Wardite::Efflorescence::Tag
|
|
186
|
+
|
|
187
|
+
# Catch labels resolve before pushing the try_table's own label.
|
|
188
|
+
# @rbs clauses: Array[Integer]
|
|
189
|
+
# @rbs return: Wardite::Efflorescence::HandlerDescriptor
|
|
190
|
+
def make_handler: (Array[Integer] clauses) -> Wardite::Efflorescence::HandlerDescriptor
|
|
191
|
+
|
|
192
|
+
# @rbs control: Wardite::Efflorescence::Translator::Control
|
|
193
|
+
# @rbs return: void
|
|
194
|
+
def finish_arm: (Wardite::Efflorescence::Translator::Control control) -> void
|
|
195
|
+
|
|
196
|
+
# @rbs return: void
|
|
197
|
+
def else_control: () -> void
|
|
198
|
+
|
|
199
|
+
# @rbs return: void
|
|
200
|
+
def end_control: () -> void
|
|
201
|
+
|
|
202
|
+
# @rbs return: void
|
|
203
|
+
def mark_unreachable: () -> void
|
|
204
|
+
|
|
205
|
+
# @rbs message: String
|
|
206
|
+
# @rbs return: String
|
|
207
|
+
def context: (String message) -> String
|
|
208
|
+
|
|
209
|
+
# @rbs message: String
|
|
210
|
+
# @rbs return: bot
|
|
211
|
+
def fail_translation: (String message) -> bot
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|