wardite 1.2.2 → 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.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/Rakefile +0 -177
- data/benchmark/README.md +10 -36
- data/benchmark/call_cost_worker.rb +3 -2
- data/benchmark/compare.rb +1 -2
- data/benchmark/compare_linear_memory_loads.py +144 -0
- data/benchmark/i32_memory.wat +5 -1
- data/benchmark/investigate_calls.rb +4 -4
- data/benchmark/linear_memory_loads.wat +52 -0
- data/benchmark/optimization_worker.rb +3 -2
- data/benchmark/patches/adr0017-spinel-signed64.patch +190 -0
- data/benchmark/patches/adr0017-wardite-split-load64.patch +70 -0
- data/benchmark/results/adr0019-startup.json +1687 -0
- data/benchmark/results/adr0020-i64.json +2034 -0
- data/benchmark/results/adr0021-optimizer.json +5798 -0
- data/benchmark/results/adr0022-lazy-mir.json +3057 -0
- data/benchmark/results/crc8-stream-repeat.csv +89 -0
- data/benchmark/results/crc8-stream.csv +89 -0
- data/benchmark/results/linear-memory-loads-a2aa05227.csv +793 -0
- data/benchmark/results/linear-memory-loads-stage-b.csv +353 -0
- data/benchmark/results/linear-memory-loads.csv +1057 -0
- data/benchmark/results/real-workloads-baseline-2026-11-18.json +1741 -0
- data/benchmark/results/stack-vm-removal.json +334 -0
- data/benchmark/validate_m4.rb +0 -2
- data/docs/adr/0017-efflorescence-linear-memory-loads.md +90 -0
- data/docs/adr/0018-efflorescence-real-workload-measurement.md +126 -0
- data/docs/adr/0019-efflorescence-startup-quick-wins.md +85 -0
- data/docs/adr/0020-efflorescence-inline-i64-bit-operations.md +89 -0
- data/docs/adr/0021-efflorescence-optimize-real-functions.md +133 -0
- data/docs/adr/0022-efflorescence-lazy-function-build.md +111 -0
- data/docs/adr/0023-efflorescence-byte-sequences-and-copy-coalescing.md +56 -0
- data/docs/efflorescence-ja.md +3 -5
- data/docs/efflorescence-linear-memory-loads.md +134 -0
- data/docs/efflorescence-m6.md +1 -1
- data/docs/efflorescence-mir2-cache.md +7 -0
- data/docs/efflorescence-real-workloads.md +312 -0
- data/docs/efflorescence-spinel-linear-memory.md +2 -2
- data/docs/efflorescence.md +3 -5
- data/docs/stack-vm-removal.md +49 -0
- data/lib/wardite/cli/cli.rb +24 -24
- data/lib/wardite/efflorescence/byte_sequences.rb +80 -0
- data/lib/wardite/efflorescence/function_preparer.rb +64 -0
- data/lib/wardite/efflorescence/i64_arithmetic.rb +31 -0
- data/lib/wardite/efflorescence/inspection.rb +44 -12
- data/lib/wardite/efflorescence/ir.rb +33 -10
- data/lib/wardite/efflorescence/mir_cache.rb +10 -1
- data/lib/wardite/efflorescence/optimizer.rb +151 -42
- data/lib/wardite/efflorescence/store_access.rb +17 -0
- data/lib/wardite/efflorescence/translation_source.rb +50 -0
- data/lib/wardite/efflorescence/translator.rb +43 -13
- data/lib/wardite/efflorescence/vm.rb +116 -48
- data/lib/wardite/efflorescence.rb +3 -0
- data/lib/wardite/load.rb +46 -62
- data/lib/wardite/version.rb +1 -1
- data/lib/wardite.rb +21 -757
- data/scripts/build_spinel_zig.rb +1 -1
- data/sig/generated/wardite/cli/cli.rbs +4 -2
- data/sig/generated/wardite/efflorescence/byte_sequences.rbs +33 -0
- data/sig/generated/wardite/efflorescence/function_preparer.rbs +25 -0
- data/sig/generated/wardite/efflorescence/i64_arithmetic.rbs +19 -0
- data/sig/generated/wardite/efflorescence/inspection.rbs +8 -0
- data/sig/generated/wardite/efflorescence/ir.rbs +18 -2
- data/sig/generated/wardite/efflorescence/optimizer.rbs +41 -3
- data/sig/generated/wardite/efflorescence/store_access.rbs +5 -0
- data/sig/generated/wardite/efflorescence/translation_source.rbs +34 -0
- data/sig/generated/wardite/efflorescence/translator.rbs +11 -1
- data/sig/generated/wardite/efflorescence/vm.rbs +19 -9
- data/sig/generated/wardite/load.rbs +18 -18
- data/sig/generated/wardite.rbs +4 -155
- metadata +32 -17
- data/benchmark/compare_engines.rb +0 -119
- data/benchmark/engine_phases.rb +0 -30
- data/lib/wardite/alu_f32.generated.rb +0 -261
- data/lib/wardite/alu_f64.generated.rb +0 -261
- data/lib/wardite/alu_i32.generated.rb +0 -510
- data/lib/wardite/alu_i64.generated.rb +0 -572
- data/lib/wardite/convert.generated.rb +0 -340
- data/scripts/gen_alu.rb +0 -864
- data/scripts/gen_conv.rb +0 -86
- data/scripts/templates/alu_module.rb.tmpl +0 -20
- data/scripts/templates/conv_module.rb.tmpl +0 -20
- data/sig/generated/wardite/alu_f32.generated.rbs +0 -12
- data/sig/generated/wardite/alu_f64.generated.rbs +0 -12
- data/sig/generated/wardite/alu_i32.generated.rbs +0 -12
- data/sig/generated/wardite/alu_i64.generated.rbs +0 -12
- data/sig/generated/wardite/convert.generated.rbs +0 -12
data/scripts/build_spinel_zig.rb
CHANGED
|
@@ -33,7 +33,7 @@ elsif ARGV.first == "ar"
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# Keep this revision in sync with the Spinel job in runtime-tests.yml.
|
|
36
|
-
SPINEL_REF = "
|
|
36
|
+
SPINEL_REF = "a2aa0522761482cd83c09fc289eb1e91609e433a"
|
|
37
37
|
|
|
38
38
|
def run(*command, **options)
|
|
39
39
|
system(*command, **options, exception: true)
|
|
@@ -23,8 +23,6 @@ module Wardite
|
|
|
23
23
|
|
|
24
24
|
attr_reader yjit: bool
|
|
25
25
|
|
|
26
|
-
attr_reader new_engine: bool
|
|
27
|
-
|
|
28
26
|
attr_reader disabled_optimizations: Array[Symbol]
|
|
29
27
|
|
|
30
28
|
attr_reader mir_dump: bool
|
|
@@ -56,6 +54,10 @@ module Wardite
|
|
|
56
54
|
# @rbs return: void
|
|
57
55
|
def invoke_function: () -> void
|
|
58
56
|
|
|
57
|
+
# @rbs metrics: Wardite::Efflorescence::Metrics
|
|
58
|
+
# @rbs return: void
|
|
59
|
+
def print_mir_profile: (Wardite::Efflorescence::Metrics metrics) -> void
|
|
60
|
+
|
|
59
61
|
# @rbs return: void
|
|
60
62
|
def invoke_wasi: () -> void
|
|
61
63
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Generated from lib/wardite/efflorescence/byte_sequences.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Wardite
|
|
4
|
+
module Efflorescence
|
|
5
|
+
# Select four-instruction sequences after register validation. Keeping all
|
|
6
|
+
# operand slots preserves PCs for branches, catches, and snapshot frames.
|
|
7
|
+
class ByteSequences
|
|
8
|
+
include Opcode
|
|
9
|
+
|
|
10
|
+
LENGTH: ::Integer
|
|
11
|
+
|
|
12
|
+
# Indexed in the same order as Opcode::SEQUENCE_HEADS.
|
|
13
|
+
FORWARDED_READS: Array[Integer]
|
|
14
|
+
|
|
15
|
+
# @rbs function: Function
|
|
16
|
+
# @rbs return: void
|
|
17
|
+
def self.fuse: (Function function) -> void
|
|
18
|
+
|
|
19
|
+
# Used both when lowering and when checking a restored bytecode body.
|
|
20
|
+
# @rbs head: Integer
|
|
21
|
+
# @rbs first: Instruction
|
|
22
|
+
# @rbs second: Instruction
|
|
23
|
+
# @rbs third: Instruction
|
|
24
|
+
# @rbs fourth: Instruction
|
|
25
|
+
# @rbs return: Integer
|
|
26
|
+
def self.match: (Integer head, Instruction first, Instruction second, Instruction third, Instruction fourth) -> Integer
|
|
27
|
+
|
|
28
|
+
# @rbs function: Function
|
|
29
|
+
# @rbs return: Array[bool]
|
|
30
|
+
def self.entry_points: (Function function) -> Array[bool]
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Generated from lib/wardite/efflorescence/function_preparer.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Wardite
|
|
4
|
+
module Efflorescence
|
|
5
|
+
class FunctionPreparer
|
|
6
|
+
# @rbs ir: IR
|
|
7
|
+
# @rbs configuration: Configuration
|
|
8
|
+
# @rbs tags: Array[Tag]
|
|
9
|
+
# @rbs profile: bool
|
|
10
|
+
# @rbs cache: MIRCache?
|
|
11
|
+
def initialize: (IR ir, Configuration configuration, Array[Tag] tags, bool profile, MIRCache? cache) -> untyped
|
|
12
|
+
|
|
13
|
+
# @rbs function: Function
|
|
14
|
+
# @rbs return: void
|
|
15
|
+
def prepare: (Function function) -> void
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
# Preserve the pre-inlining leaf even if its own invocation happens first.
|
|
20
|
+
# @rbs function: Function
|
|
21
|
+
# @rbs return: Function
|
|
22
|
+
def optimize_local: (Function function) -> Function
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -7,6 +7,25 @@ module Wardite
|
|
|
7
7
|
|
|
8
8
|
MIN: Integer
|
|
9
9
|
|
|
10
|
+
MAX: ::Integer
|
|
11
|
+
|
|
12
|
+
# Keep the sign bit out of the left shift so its result fits in an i64.
|
|
13
|
+
# Counts passed by the VM are already reduced modulo 64.
|
|
14
|
+
# @rbs value: Integer
|
|
15
|
+
# @rbs count: Integer
|
|
16
|
+
# @rbs return: Integer
|
|
17
|
+
def self.flat_shl: (Integer value, Integer count) -> Integer
|
|
18
|
+
|
|
19
|
+
# @rbs value: Integer
|
|
20
|
+
# @rbs count: Integer
|
|
21
|
+
# @rbs return: Integer
|
|
22
|
+
def self.flat_shr_u: (Integer value, Integer count) -> Integer
|
|
23
|
+
|
|
24
|
+
# @rbs value: Integer
|
|
25
|
+
# @rbs count: Integer
|
|
26
|
+
# @rbs return: Integer
|
|
27
|
+
def self.flat_rotl: (Integer value, Integer count) -> Integer
|
|
28
|
+
|
|
10
29
|
# @rbs value: Integer
|
|
11
30
|
# @rbs return: Integer
|
|
12
31
|
def self.low: (Integer value) -> Integer
|
|
@@ -41,6 +41,10 @@ module Wardite
|
|
|
41
41
|
|
|
42
42
|
# @rbs return: String
|
|
43
43
|
def report: () -> String
|
|
44
|
+
|
|
45
|
+
# One "opcode NAME COUNT" line per executed opcode, in opcode order.
|
|
46
|
+
# @rbs return: String
|
|
47
|
+
def opcode_report: () -> String
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
# Profiling is compiled into a separate instrumented MIR. The ordinary
|
|
@@ -49,6 +53,10 @@ module Wardite
|
|
|
49
53
|
# @rbs ir: Wardite::Efflorescence::IR
|
|
50
54
|
# @rbs return: Wardite::Efflorescence::IR
|
|
51
55
|
def instrument: (Wardite::Efflorescence::IR ir) -> Wardite::Efflorescence::IR
|
|
56
|
+
|
|
57
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
58
|
+
# @rbs return: void
|
|
59
|
+
def instrument_function: (Wardite::Efflorescence::Function function) -> void
|
|
52
60
|
end
|
|
53
61
|
|
|
54
62
|
class Inspection
|
|
@@ -399,6 +399,17 @@ module Wardite
|
|
|
399
399
|
|
|
400
400
|
F64_GLOBAL_SET: ::Integer
|
|
401
401
|
|
|
402
|
+
I32_TABLE_STORE8: ::Integer
|
|
403
|
+
|
|
404
|
+
I64_BYTE_LOOKUP: ::Integer
|
|
405
|
+
|
|
406
|
+
I32_BYTE_MUL_ADD: ::Integer
|
|
407
|
+
|
|
408
|
+
I32_BYTE_ADD_STORE: ::Integer
|
|
409
|
+
|
|
410
|
+
# The remaining three instructions retain their ordinary four-word slots.
|
|
411
|
+
SEQUENCE_HEADS: Array[Integer]
|
|
412
|
+
|
|
402
413
|
NAMES: untyped
|
|
403
414
|
|
|
404
415
|
# Each signature lists the destination type followed by the source types.
|
|
@@ -735,6 +746,11 @@ module Wardite
|
|
|
735
746
|
# @rbs return: Array[Integer]
|
|
736
747
|
def reads: (Wardite::Efflorescence::Instruction instruction) -> Array[Integer]
|
|
737
748
|
|
|
749
|
+
# Publish a complete body on the existing CallSite / FramePool target.
|
|
750
|
+
# @rbs body: Wardite::Efflorescence::Function
|
|
751
|
+
# @rbs return: void
|
|
752
|
+
def install_prepared: (Wardite::Efflorescence::Function body) -> void
|
|
753
|
+
|
|
738
754
|
# @rbs return: Wardite::Efflorescence::Function
|
|
739
755
|
def copy: () -> Wardite::Efflorescence::Function
|
|
740
756
|
end
|
|
@@ -904,8 +920,8 @@ module Wardite
|
|
|
904
920
|
|
|
905
921
|
# @rbs function: Wardite::Efflorescence::Function
|
|
906
922
|
# @rbs reuse: bool
|
|
907
|
-
# @rbs
|
|
908
|
-
def initialize: (Wardite::Efflorescence::Function function, bool reuse, ?Wardite::Efflorescence::
|
|
923
|
+
# @rbs preparer: Wardite::Efflorescence::FunctionPreparer?
|
|
924
|
+
def initialize: (Wardite::Efflorescence::Function function, bool reuse, ?Wardite::Efflorescence::FunctionPreparer? preparer) -> untyped
|
|
909
925
|
|
|
910
926
|
# @rbs destination: Integer
|
|
911
927
|
# @rbs return: Wardite::Efflorescence::Frame
|
|
@@ -15,6 +15,27 @@ module Wardite
|
|
|
15
15
|
def enabled?: (Symbol feature) -> bool
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
# Keep setup bounded for mixed functions. A larger call-free loop can
|
|
19
|
+
# amortize preparation over repeated arithmetic and memory operations.
|
|
20
|
+
class OptimizationScope
|
|
21
|
+
SMALL_FUNCTION: ::Integer
|
|
22
|
+
|
|
23
|
+
SHORT_LOOP_FUNCTION: ::Integer
|
|
24
|
+
|
|
25
|
+
MAX_LOOP_FUNCTION: ::Integer
|
|
26
|
+
|
|
27
|
+
LONG_LOOP: ::Integer
|
|
28
|
+
|
|
29
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
30
|
+
# @rbs return: bool
|
|
31
|
+
def self.caller?: (Wardite::Efflorescence::Function function) -> bool
|
|
32
|
+
|
|
33
|
+
# @rbs instructions: Array[Instruction]
|
|
34
|
+
# @rbs minimum: Integer
|
|
35
|
+
# @rbs return: bool
|
|
36
|
+
def self.call_free_loop?: (Array[Instruction] instructions, Integer minimum) -> bool
|
|
37
|
+
end
|
|
38
|
+
|
|
18
39
|
# All transformations use instruction ordinals. Only the final lowering
|
|
19
40
|
# changes PCs to integer-array offsets. Every rewrite repairs branch edges.
|
|
20
41
|
class Rewrite
|
|
@@ -89,7 +110,10 @@ module Wardite
|
|
|
89
110
|
# @rbs return: Array[Integer]
|
|
90
111
|
def run: (Wardite::Efflorescence::IR ir) -> Array[Integer]
|
|
91
112
|
|
|
92
|
-
|
|
113
|
+
# These bounds cannot improve during local optimization.
|
|
114
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
115
|
+
# @rbs return: bool
|
|
116
|
+
def candidate?: (Wardite::Efflorescence::Function function) -> bool
|
|
93
117
|
|
|
94
118
|
# Explicit whitelist: new opcodes must opt into inlining. In particular,
|
|
95
119
|
# traps, profiling records, control flow and nested calls stay intact.
|
|
@@ -103,6 +127,8 @@ module Wardite
|
|
|
103
127
|
# @rbs return: bool
|
|
104
128
|
def expand_calls: (Wardite::Efflorescence::Function function, Wardite::Efflorescence::IR ir, Hash[Integer, Wardite::Efflorescence::Function] callees) -> bool
|
|
105
129
|
|
|
130
|
+
private
|
|
131
|
+
|
|
106
132
|
# @rbs function: Wardite::Efflorescence::Function
|
|
107
133
|
# @rbs ir: Wardite::Efflorescence::IR
|
|
108
134
|
# @rbs callees: Hash[Integer, Wardite::Efflorescence::Function]
|
|
@@ -137,7 +163,8 @@ module Wardite
|
|
|
137
163
|
class CopyPropagation
|
|
138
164
|
# @rbs function: Wardite::Efflorescence::Function
|
|
139
165
|
# @rbs return: void
|
|
140
|
-
|
|
166
|
+
# @rbs coalesce_only: bool
|
|
167
|
+
def run: (Wardite::Efflorescence::Function function, ?coalesce_only: bool) -> void
|
|
141
168
|
|
|
142
169
|
private
|
|
143
170
|
|
|
@@ -195,7 +222,13 @@ module Wardite
|
|
|
195
222
|
# @rbs return: Wardite::Efflorescence::IR
|
|
196
223
|
def optimize: (Wardite::Efflorescence::IR ir) -> Wardite::Efflorescence::IR
|
|
197
224
|
|
|
198
|
-
|
|
225
|
+
# @rbs output: Wardite::Efflorescence::IR
|
|
226
|
+
# @rbs return: Wardite::Efflorescence::IR
|
|
227
|
+
def optimize_in_place: (Wardite::Efflorescence::IR output) -> Wardite::Efflorescence::IR
|
|
228
|
+
|
|
229
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
230
|
+
# @rbs return: void
|
|
231
|
+
def fuse_byte_sequences: (Wardite::Efflorescence::Function function) -> void
|
|
199
232
|
|
|
200
233
|
# @rbs function: Wardite::Efflorescence::Function
|
|
201
234
|
# @rbs return: void
|
|
@@ -208,6 +241,11 @@ module Wardite
|
|
|
208
241
|
# @rbs ir: Wardite::Efflorescence::IR
|
|
209
242
|
# @rbs return: void
|
|
210
243
|
def compile: (Wardite::Efflorescence::IR ir) -> void
|
|
244
|
+
|
|
245
|
+
# @rbs function: Wardite::Efflorescence::Function
|
|
246
|
+
# @rbs ir: Wardite::Efflorescence::IR
|
|
247
|
+
# @rbs return: void
|
|
248
|
+
def compile_function: (Wardite::Efflorescence::Function function, Wardite::Efflorescence::IR ir) -> void
|
|
211
249
|
end
|
|
212
250
|
end
|
|
213
251
|
end
|
|
@@ -64,6 +64,11 @@ module Wardite
|
|
|
64
64
|
# @rbs return: void
|
|
65
65
|
def write_global_bits: (Integer index, Symbol type, Integer value) -> void
|
|
66
66
|
|
|
67
|
+
# @rbs address: Integer
|
|
68
|
+
# @rbs offset: Integer
|
|
69
|
+
# @rbs return: Integer
|
|
70
|
+
def load8_u: (Integer address, Integer offset) -> Integer
|
|
71
|
+
|
|
67
72
|
# @rbs address: Integer
|
|
68
73
|
# @rbs offset: Integer
|
|
69
74
|
# @rbs width: Integer
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Generated from lib/wardite/efflorescence/translation_source.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Wardite
|
|
4
|
+
module Efflorescence
|
|
5
|
+
class Translator
|
|
6
|
+
# Declaration data used by translation, independent of mutable runtime
|
|
7
|
+
# slots. Keep only encoded code and declaration shapes for inspection.
|
|
8
|
+
class ModuleSource
|
|
9
|
+
attr_reader code: String?
|
|
10
|
+
|
|
11
|
+
attr_reader globals: Array[Wardite::Global]
|
|
12
|
+
|
|
13
|
+
attr_reader types: Array[Wardite::Type]
|
|
14
|
+
|
|
15
|
+
attr_reader tags: Array[Wardite::Efflorescence::Tag]
|
|
16
|
+
|
|
17
|
+
attr_reader has_memory: bool
|
|
18
|
+
|
|
19
|
+
attr_reader funcref_table: bool
|
|
20
|
+
|
|
21
|
+
attr_reader has_data_count: bool
|
|
22
|
+
|
|
23
|
+
attr_reader data_segments: Integer
|
|
24
|
+
|
|
25
|
+
# @rbs instance: Wardite::Instance
|
|
26
|
+
# @rbs code: String?
|
|
27
|
+
def initialize: (Wardite::Instance instance, ?String? code) -> untyped
|
|
28
|
+
|
|
29
|
+
# @rbs return: Wardite::TypeSection
|
|
30
|
+
def block_types: () -> Wardite::TypeSection
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -59,6 +59,8 @@ module Wardite
|
|
|
59
59
|
|
|
60
60
|
STORE_CODES: untyped
|
|
61
61
|
|
|
62
|
+
@source: Wardite::Efflorescence::Translator::ModuleSource
|
|
63
|
+
|
|
62
64
|
@instance: Wardite::Instance
|
|
63
65
|
|
|
64
66
|
@entries: Array[Wardite::Efflorescence::FunctionEntry]
|
|
@@ -84,7 +86,8 @@ module Wardite
|
|
|
84
86
|
@handler_depth: Integer
|
|
85
87
|
|
|
86
88
|
# @rbs instance: Wardite::Instance
|
|
87
|
-
|
|
89
|
+
# @rbs source: ModuleSource
|
|
90
|
+
def initialize: (Wardite::Instance instance, ?ModuleSource source) -> untyped
|
|
88
91
|
|
|
89
92
|
# @rbs return: Wardite::Efflorescence::IR
|
|
90
93
|
def link: () -> Wardite::Efflorescence::IR
|
|
@@ -93,6 +96,13 @@ module Wardite
|
|
|
93
96
|
# @rbs return: Wardite::Efflorescence::IR
|
|
94
97
|
def translate: (?Wardite::Efflorescence::IR linked) -> Wardite::Efflorescence::IR
|
|
95
98
|
|
|
99
|
+
# Replay the original declarations without re-linking host functions,
|
|
100
|
+
# executing start, or consulting live global/memory/table slots.
|
|
101
|
+
# @rbs linked: IR
|
|
102
|
+
# @rbs bytes: String
|
|
103
|
+
# @rbs return: IR
|
|
104
|
+
def translate_source: (IR linked, String bytes) -> IR
|
|
105
|
+
|
|
96
106
|
# @rbs wasm: Wardite::WasmFunction
|
|
97
107
|
# @rbs index: Integer
|
|
98
108
|
# @rbs pool_index: Integer
|
|
@@ -5,8 +5,7 @@ module Wardite
|
|
|
5
5
|
class VM
|
|
6
6
|
attr_reader instance: Wardite::Instance
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
# @rbs @preparer: FunctionPreparer?
|
|
10
9
|
attr_reader metrics: Wardite::Efflorescence::Metrics
|
|
11
10
|
|
|
12
11
|
attr_reader mir_cache_hit: bool
|
|
@@ -22,16 +21,27 @@ module Wardite
|
|
|
22
21
|
|
|
23
22
|
@semantic_ir: Wardite::Efflorescence::IR?
|
|
24
23
|
|
|
24
|
+
@inspection_links: Wardite::Efflorescence::IR?
|
|
25
|
+
|
|
25
26
|
# @rbs instance: Wardite::Instance
|
|
26
27
|
# @rbs disabled_optimizations: Array[Symbol]
|
|
27
28
|
# @rbs profile: bool
|
|
28
29
|
# @rbs mir_cache: Wardite::Efflorescence::MIRCache?
|
|
29
30
|
# @rbs cached_functions: Array[Function]?
|
|
31
|
+
# @rbs source_code: String?
|
|
32
|
+
# @rbs eager_mir: bool
|
|
30
33
|
# @rbs cache_checked: bool
|
|
31
|
-
def initialize: (Wardite::Instance instance, ?disabled_optimizations: Array[Symbol], ?profile: bool, ?mir_cache: Wardite::Efflorescence::MIRCache?, ?cached_functions: Array[Function]?, ?cache_checked: bool) -> untyped
|
|
34
|
+
def initialize: (Wardite::Instance instance, ?disabled_optimizations: Array[Symbol], ?profile: bool, ?mir_cache: Wardite::Efflorescence::MIRCache?, ?cached_functions: Array[Function]?, ?cache_checked: bool, ?source_code: String?, ?eager_mir: bool) -> untyped
|
|
35
|
+
|
|
36
|
+
# Inspecting the executable IR requests every uncached function body.
|
|
37
|
+
# MIR2 consumers can still inspect pending cache slots individually.
|
|
38
|
+
# @rbs return: Wardite::Efflorescence::IR
|
|
39
|
+
def ir: () -> Wardite::Efflorescence::IR
|
|
40
|
+
|
|
41
|
+
# @rbs return: void
|
|
42
|
+
def prepare_all: () -> void
|
|
32
43
|
|
|
33
|
-
#
|
|
34
|
-
# intermediate forms. Execution continues to use the restored MIR2.
|
|
44
|
+
# Build both inspection views on first access. Execution keeps its own IR.
|
|
35
45
|
# @rbs return: Wardite::Efflorescence::IR
|
|
36
46
|
def semantic_ir: () -> Wardite::Efflorescence::IR
|
|
37
47
|
|
|
@@ -42,7 +52,7 @@ module Wardite
|
|
|
42
52
|
# @rbs return: bool
|
|
43
53
|
def callable?: (String | Symbol name) -> bool
|
|
44
54
|
|
|
45
|
-
#
|
|
55
|
+
# Box the result once, at the Ruby boundary.
|
|
46
56
|
# @rbs name: String|Symbol
|
|
47
57
|
# @rbs arguments: Array[Object]
|
|
48
58
|
# @rbs return: Wardite::wasmValue?
|
|
@@ -75,11 +85,11 @@ module Wardite
|
|
|
75
85
|
|
|
76
86
|
private
|
|
77
87
|
|
|
78
|
-
# @rbs
|
|
79
|
-
# @rbs linked: Wardite::Efflorescence::IR
|
|
88
|
+
# @rbs semantic: Wardite::Efflorescence::IR
|
|
80
89
|
# @rbs profile: bool
|
|
90
|
+
# @rbs inspect: bool
|
|
81
91
|
# @rbs return: Wardite::Efflorescence::IR
|
|
82
|
-
def build_mir: (Wardite::Efflorescence::
|
|
92
|
+
def build_mir: (Wardite::Efflorescence::IR semantic, bool profile, bool inspect) -> Wardite::Efflorescence::IR
|
|
83
93
|
|
|
84
94
|
# @rbs return: void
|
|
85
95
|
def restore_inspection_ir: () -> void
|
|
@@ -97,12 +97,9 @@ module Wardite
|
|
|
97
97
|
|
|
98
98
|
attr_reader blocks: Array[Block]
|
|
99
99
|
|
|
100
|
-
attr_reader has_eh_instructions: bool
|
|
101
|
-
|
|
102
100
|
# @rbs instructions: Array[[Symbol, Symbol, Array[operandItem], Integer?, Integer?]]
|
|
103
101
|
# @rbs blocks: Array[Block]
|
|
104
|
-
|
|
105
|
-
def initialize: (Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]] instructions, Array[Block] blocks, bool has_eh_instructions) -> untyped
|
|
102
|
+
def initialize: (Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]] instructions, Array[Block] blocks) -> untyped
|
|
106
103
|
end
|
|
107
104
|
|
|
108
105
|
class CodeSection < Section
|
|
@@ -133,9 +130,8 @@ module Wardite
|
|
|
133
130
|
def decode_from: (File | StringIO buf) -> void
|
|
134
131
|
|
|
135
132
|
# @rbs types: TypeSection?
|
|
136
|
-
# @rbs stack: bool
|
|
137
133
|
# @rbs return: void
|
|
138
|
-
def check_features: (TypeSection? types
|
|
134
|
+
def check_features: (TypeSection? types) -> void
|
|
139
135
|
|
|
140
136
|
private
|
|
141
137
|
|
|
@@ -145,23 +141,24 @@ module Wardite
|
|
|
145
141
|
|
|
146
142
|
# @rbs decoded: DecodedBody
|
|
147
143
|
# @rbs types: TypeSection?
|
|
148
|
-
# @rbs stack: bool
|
|
149
144
|
# @rbs return: void
|
|
150
|
-
def check_decoded: (DecodedBody decoded, TypeSection? types
|
|
145
|
+
def check_decoded: (DecodedBody decoded, TypeSection? types) -> void
|
|
151
146
|
|
|
152
147
|
# @rbs instructions: Array[[Symbol, Symbol, Array[operandItem], Integer?, Integer?]]
|
|
153
148
|
# @rbs types: TypeSection?
|
|
154
|
-
# @rbs stack: bool
|
|
155
149
|
# @rbs return: void
|
|
156
|
-
def check_instructions: (Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]] instructions, TypeSection? types
|
|
150
|
+
def check_instructions: (Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]] instructions, TypeSection? types) -> void
|
|
157
151
|
|
|
158
152
|
# @rbs block: Block
|
|
159
153
|
# @rbs types: TypeSection?
|
|
160
|
-
# @rbs stack: bool
|
|
161
154
|
# @rbs return: void
|
|
162
|
-
def check_block: (Block block, TypeSection? types
|
|
155
|
+
def check_block: (Block block, TypeSection? types) -> void
|
|
163
156
|
end
|
|
164
157
|
|
|
158
|
+
# Keep the code section for on-demand MIR inspection after the host has
|
|
159
|
+
# accessed the mutable decoded bodies or edited the store.
|
|
160
|
+
attr_accessor source_bytes: String?
|
|
161
|
+
|
|
165
162
|
attr_accessor func_codes: Array[CodeBody]
|
|
166
163
|
|
|
167
164
|
# @rbs return: void
|
|
@@ -256,8 +253,9 @@ module Wardite
|
|
|
256
253
|
def self.preamble: () -> Integer
|
|
257
254
|
|
|
258
255
|
# @rbs defer_code: bool
|
|
256
|
+
# @rbs keep_code: bool
|
|
259
257
|
# @rbs return: Array[Section]
|
|
260
|
-
def self.sections: (?bool defer_code) -> Array[Section]
|
|
258
|
+
def self.sections: (?bool defer_code, ?bool keep_code) -> Array[Section]
|
|
261
259
|
|
|
262
260
|
# @rbs return: TypeSection
|
|
263
261
|
def self.type_section: () -> TypeSection
|
|
@@ -286,9 +284,15 @@ module Wardite
|
|
|
286
284
|
# @rbs return: TableSection
|
|
287
285
|
def self.table_section: () -> TableSection
|
|
288
286
|
|
|
287
|
+
# @rbs defer_code: bool
|
|
288
|
+
# @rbs keep_code: bool
|
|
289
|
+
# @rbs return: CodeSection
|
|
290
|
+
def self.code_section: (?bool defer_code, ?bool keep_code) -> CodeSection
|
|
291
|
+
|
|
292
|
+
# @rbs bytes: String
|
|
289
293
|
# @rbs defer_code: bool
|
|
290
294
|
# @rbs return: CodeSection
|
|
291
|
-
def self.
|
|
295
|
+
def self.decode_code_section: (String bytes, ?bool defer_code) -> CodeSection
|
|
292
296
|
|
|
293
297
|
# @rbs sbuf: StringIO
|
|
294
298
|
# @rbs defer_code: bool
|
|
@@ -303,10 +307,6 @@ module Wardite
|
|
|
303
307
|
# @rbs return: DecodedBody
|
|
304
308
|
def self.decode_body: (File | StringIO buf) -> DecodedBody
|
|
305
309
|
|
|
306
|
-
# @rbs code: Symbol
|
|
307
|
-
# @rbs return: bool
|
|
308
|
-
def self.eh_instruction?: (Symbol code) -> bool
|
|
309
|
-
|
|
310
310
|
# Decode s33, distinguishing the one-byte value/void forms from indices.
|
|
311
311
|
# @rbs buf: File|StringIO
|
|
312
312
|
# @rbs return: Block
|