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,179 @@
|
|
|
1
|
+
# Generated from lib/wardite/efflorescence/vm.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Wardite
|
|
4
|
+
module Efflorescence
|
|
5
|
+
class VM
|
|
6
|
+
attr_reader instance: Wardite::Instance
|
|
7
|
+
|
|
8
|
+
attr_reader ir: Wardite::Efflorescence::IR
|
|
9
|
+
|
|
10
|
+
attr_reader semantic_ir: Wardite::Efflorescence::IR
|
|
11
|
+
|
|
12
|
+
attr_reader optimized_ir: Wardite::Efflorescence::IR
|
|
13
|
+
|
|
14
|
+
attr_reader metrics: Wardite::Efflorescence::Metrics
|
|
15
|
+
|
|
16
|
+
# @rbs instance: Wardite::Instance
|
|
17
|
+
# @rbs disabled_optimizations: Array[Symbol]
|
|
18
|
+
# @rbs profile: bool
|
|
19
|
+
def initialize: (Wardite::Instance instance, ?disabled_optimizations: Array[Symbol], ?profile: bool) -> untyped
|
|
20
|
+
|
|
21
|
+
# @rbs name: String|Symbol
|
|
22
|
+
# @rbs return: bool
|
|
23
|
+
def callable?: (String | Symbol name) -> bool
|
|
24
|
+
|
|
25
|
+
# Compatible with Runtime.call: boxing happens once, at the Ruby boundary.
|
|
26
|
+
# @rbs name: String|Symbol
|
|
27
|
+
# @rbs arguments: Array[Object]
|
|
28
|
+
# @rbs return: Wardite::wasmValue?
|
|
29
|
+
def call: (String | Symbol name, Array[Object] arguments) -> Wardite::wasmValue?
|
|
30
|
+
|
|
31
|
+
# Integers retain their register representation. Floats cross as Ruby Float.
|
|
32
|
+
# @rbs name: String|Symbol
|
|
33
|
+
# @rbs arguments: Array[Object]
|
|
34
|
+
# @rbs return: (Integer | Float)?
|
|
35
|
+
def call_unboxed: (String | Symbol name, Array[Object] arguments) -> (Integer | Float)?
|
|
36
|
+
|
|
37
|
+
# @rbs name: Symbol
|
|
38
|
+
# @rbs *arguments: Object
|
|
39
|
+
# @rbs return: Wardite::wasmValue?
|
|
40
|
+
def method_missing: (Symbol name, *Object arguments) -> Wardite::wasmValue?
|
|
41
|
+
|
|
42
|
+
# @rbs name: String|Symbol
|
|
43
|
+
# @rbs include_private: bool
|
|
44
|
+
# @rbs return: bool
|
|
45
|
+
def respond_to_missing?: (String | Symbol name, ?bool include_private) -> bool
|
|
46
|
+
|
|
47
|
+
# @rbs return: String
|
|
48
|
+
def dump_mir: () -> String
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
# @rbs name: String|Symbol
|
|
53
|
+
# @rbs return: Wardite::Efflorescence::FunctionEntry
|
|
54
|
+
def export_entry: (String | Symbol name) -> Wardite::Efflorescence::FunctionEntry
|
|
55
|
+
|
|
56
|
+
# @rbs entry: Wardite::Efflorescence::FunctionEntry
|
|
57
|
+
# @rbs arguments: Array[Object]
|
|
58
|
+
# @rbs return: Integer?
|
|
59
|
+
def execute_public: (Wardite::Efflorescence::FunctionEntry entry, Array[Object] arguments) -> Integer?
|
|
60
|
+
|
|
61
|
+
# @rbs type: Symbol
|
|
62
|
+
# @rbs value: Object?
|
|
63
|
+
# @rbs return: Integer?
|
|
64
|
+
def float_argument: (Symbol type, Object? value) -> Integer?
|
|
65
|
+
|
|
66
|
+
# @rbs type: Symbol
|
|
67
|
+
# @rbs bits: Integer
|
|
68
|
+
# @rbs return: Integer | Float
|
|
69
|
+
def unbox_result: (Symbol type, Integer bits) -> (Integer | Float)
|
|
70
|
+
|
|
71
|
+
# @rbs type: Symbol
|
|
72
|
+
# @rbs bits: Integer
|
|
73
|
+
# @rbs return: Wardite::wasmValue
|
|
74
|
+
def box_result: (Symbol type, Integer bits) -> Wardite::wasmValue
|
|
75
|
+
|
|
76
|
+
# A concrete return type breaks the inference cycle between the current
|
|
77
|
+
# frame and the array it is restored from after every internal RETURN.
|
|
78
|
+
# @rbs return: Wardite::Efflorescence::Frame
|
|
79
|
+
def current_frame: (untyped frames) -> Wardite::Efflorescence::Frame
|
|
80
|
+
|
|
81
|
+
# @rbs value: Integer
|
|
82
|
+
# @rbs return: Integer
|
|
83
|
+
def signed: (Integer value) -> Integer
|
|
84
|
+
|
|
85
|
+
# Cold/new ALU paths stay outside the established hot-loop operations.
|
|
86
|
+
# @rbs opcode: Integer
|
|
87
|
+
# @rbs left: Integer
|
|
88
|
+
# @rbs right: Integer
|
|
89
|
+
# @rbs return: Integer
|
|
90
|
+
def calculate: (Integer opcode, Integer left, Integer right) -> Integer
|
|
91
|
+
|
|
92
|
+
# The pending value owns its payload before any frame is released. No
|
|
93
|
+
# Ruby raise/rescue is used to unwind the explicit Wasm call stack.
|
|
94
|
+
# @rbs value: Wardite::Efflorescence::ExceptionValue
|
|
95
|
+
# @rbs frames: Array[Wardite::Efflorescence::Frame]
|
|
96
|
+
# @rbs pools: Array[Wardite::Efflorescence::FramePool]
|
|
97
|
+
# @rbs return: Wardite::Efflorescence::Frame
|
|
98
|
+
def propagate: (Wardite::Efflorescence::ExceptionValue value, Array[Wardite::Efflorescence::Frame] frames, Array[Wardite::Efflorescence::FramePool] pools) -> Wardite::Efflorescence::Frame
|
|
99
|
+
|
|
100
|
+
# @rbs frame: Wardite::Efflorescence::Frame
|
|
101
|
+
# @rbs id: Integer
|
|
102
|
+
# @rbs return: Wardite::Efflorescence::ExceptionValue
|
|
103
|
+
def exception_at: (Wardite::Efflorescence::Frame frame, Integer id) -> Wardite::Efflorescence::ExceptionValue
|
|
104
|
+
|
|
105
|
+
# @rbs pools: Array[Wardite::Efflorescence::FramePool]
|
|
106
|
+
# @rbs index: Integer
|
|
107
|
+
# @rbs return: Wardite::Efflorescence::FramePool
|
|
108
|
+
def pool_at: (Array[Wardite::Efflorescence::FramePool] pools, Integer index) -> Wardite::Efflorescence::FramePool
|
|
109
|
+
|
|
110
|
+
# @rbs host_index: Integer
|
|
111
|
+
# @rbs arguments: Array[Integer]
|
|
112
|
+
# @rbs metrics: Wardite::Efflorescence::Metrics
|
|
113
|
+
# @rbs return: Integer?
|
|
114
|
+
# @rbs sources: Array[Integer]?
|
|
115
|
+
def invoke_host: (Integer host_index, Array[Integer] arguments, Wardite::Efflorescence::Metrics metrics, ?Array[Integer]? sources) -> Integer?
|
|
116
|
+
|
|
117
|
+
# @rbs host: Wardite::Efflorescence::HostFunction
|
|
118
|
+
# @rbs arguments: Array[Integer]
|
|
119
|
+
# @rbs sources: Array[Integer]?
|
|
120
|
+
# @rbs return: Integer?
|
|
121
|
+
def invoke_typed_host: (Wardite::Efflorescence::HostFunction host, Array[Integer] arguments, Array[Integer]? sources) -> Integer?
|
|
122
|
+
|
|
123
|
+
# Each public entry owns its frames, pools and counters, including when a
|
|
124
|
+
# host callback re-enters the VM. Store mutations are shared immediately.
|
|
125
|
+
# @rbs entry: Wardite::Efflorescence::FunctionEntry
|
|
126
|
+
# @rbs arguments: Array[Integer]
|
|
127
|
+
# @rbs return: Integer?
|
|
128
|
+
def execute: (Wardite::Efflorescence::FunctionEntry entry, Array[Integer] arguments) -> Integer?
|
|
129
|
+
|
|
130
|
+
# @rbs frame: Wardite::Efflorescence::Frame
|
|
131
|
+
# @rbs site: Wardite::Efflorescence::DynamicCallSite
|
|
132
|
+
# @rbs host_index: Integer
|
|
133
|
+
# @rbs destination: Integer
|
|
134
|
+
# @rbs metrics: Wardite::Efflorescence::Metrics
|
|
135
|
+
# @rbs return: void
|
|
136
|
+
def execute_host_site: (Wardite::Efflorescence::Frame frame, Wardite::Efflorescence::DynamicCallSite site, Integer host_index, Integer destination, Wardite::Efflorescence::Metrics metrics) -> void
|
|
137
|
+
|
|
138
|
+
# @rbs site: Wardite::Efflorescence::DynamicCallSite
|
|
139
|
+
# @rbs selector: Integer
|
|
140
|
+
# @rbs return: Wardite::Efflorescence::FunctionEntry
|
|
141
|
+
def indirect_entry: (Wardite::Efflorescence::DynamicCallSite site, Integer selector) -> Wardite::Efflorescence::FunctionEntry
|
|
142
|
+
|
|
143
|
+
# @rbs frame: Wardite::Efflorescence::Frame
|
|
144
|
+
# @rbs site_id: Integer
|
|
145
|
+
# @rbs destination: Integer
|
|
146
|
+
# @rbs metrics: Wardite::Efflorescence::Metrics
|
|
147
|
+
# @rbs return: void
|
|
148
|
+
def execute_direct_host: (Wardite::Efflorescence::Frame frame, Integer site_id, Integer destination, Wardite::Efflorescence::Metrics metrics) -> void
|
|
149
|
+
|
|
150
|
+
# Keep table resolution and the additional call locals off the hot path.
|
|
151
|
+
# @rbs frame: Wardite::Efflorescence::Frame
|
|
152
|
+
# @rbs pools: Array[Wardite::Efflorescence::FramePool]
|
|
153
|
+
# @rbs frames: Array[Wardite::Efflorescence::Frame]
|
|
154
|
+
# @rbs destination: Integer
|
|
155
|
+
# @rbs site_id: Integer
|
|
156
|
+
# @rbs selector: Integer
|
|
157
|
+
# @rbs metrics: Wardite::Efflorescence::Metrics
|
|
158
|
+
# @rbs return: Wardite::Efflorescence::Frame
|
|
159
|
+
def execute_indirect: (Wardite::Efflorescence::Frame frame, Array[Wardite::Efflorescence::FramePool] pools, Array[Wardite::Efflorescence::Frame] frames, Integer destination, Integer site_id, Integer selector, Wardite::Efflorescence::Metrics metrics) -> Wardite::Efflorescence::Frame
|
|
160
|
+
|
|
161
|
+
# Float instructions use the same flat words and integer registers.
|
|
162
|
+
# Their dispatch stays outside the main integer switch.
|
|
163
|
+
# @rbs opcode: Integer
|
|
164
|
+
# @rbs instructions: Array[Integer]
|
|
165
|
+
# @rbs pc: Integer
|
|
166
|
+
# @rbs a: Integer
|
|
167
|
+
# @rbs registers: Array[Integer]
|
|
168
|
+
# @rbs return: void
|
|
169
|
+
def execute_float: (Integer opcode, Array[Integer] instructions, Integer pc, Integer a, Array[Integer] registers) -> void
|
|
170
|
+
|
|
171
|
+
# @rbs frame: Wardite::Efflorescence::Frame
|
|
172
|
+
# @rbs pools: Array[Wardite::Efflorescence::FramePool]
|
|
173
|
+
# @rbs active_frames: Array[Wardite::Efflorescence::Frame]
|
|
174
|
+
# @rbs return: Integer
|
|
175
|
+
# @rbs metrics: Wardite::Efflorescence::Metrics
|
|
176
|
+
def execute_flat: (Wardite::Efflorescence::Frame frame, Array[Wardite::Efflorescence::FramePool] pools, Array[Wardite::Efflorescence::Frame] active_frames, Wardite::Efflorescence::Metrics metrics) -> Integer
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Generated from lib/wardite/efflorescence/wasi.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Wardite
|
|
4
|
+
module Efflorescence
|
|
5
|
+
class WasiSnapshotPreview1 < Wardite::WasiSnapshotPreview1
|
|
6
|
+
FD_WRITE_ARGUMENTS: untyped
|
|
7
|
+
|
|
8
|
+
PROC_EXIT_ARGUMENTS: untyped
|
|
9
|
+
|
|
10
|
+
# @rbs fnname: Symbol
|
|
11
|
+
# @rbs return: Wardite::_WasmCallable
|
|
12
|
+
def callable: (Symbol fnname) -> Wardite::_WasmCallable
|
|
13
|
+
|
|
14
|
+
# @rbs environment: Wardite::Efflorescence::WasiSnapshotPreview1
|
|
15
|
+
# @rbs function: Wardite::ExternalFunction
|
|
16
|
+
# @rbs return: Wardite::Efflorescence::_WasiCallable?
|
|
17
|
+
def self.unboxed_callable: (Wardite::Efflorescence::WasiSnapshotPreview1 environment, Wardite::ExternalFunction function) -> Wardite::Efflorescence::_WasiCallable?
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
# @rbs store: Wardite::Store
|
|
22
|
+
# @rbs values: Array[Integer]
|
|
23
|
+
# @rbs sources: Array[Integer]?
|
|
24
|
+
# @rbs return: Integer
|
|
25
|
+
def fd_write_from_registers: (Wardite::Store store, Array[Integer] values, Array[Integer]? sources) -> Integer
|
|
26
|
+
|
|
27
|
+
# @rbs _store: Wardite::Store
|
|
28
|
+
# @rbs values: Array[Integer]
|
|
29
|
+
# @rbs sources: Array[Integer]?
|
|
30
|
+
# @rbs return: bot
|
|
31
|
+
def proc_exit_from_registers: (untyped _store, Array[Integer] values, Array[Integer]? sources) -> bot
|
|
32
|
+
|
|
33
|
+
# @rbs store: Wardite::Store
|
|
34
|
+
# @rbs fd: Integer
|
|
35
|
+
# @rbs iovs: Integer
|
|
36
|
+
# @rbs count: Integer
|
|
37
|
+
# @rbs written_at: Integer
|
|
38
|
+
# @rbs return: Integer
|
|
39
|
+
def fd_write_i32: (Wardite::Store store, Integer fd, Integer iovs, Integer count, Integer written_at) -> Integer
|
|
40
|
+
|
|
41
|
+
# @rbs data: String
|
|
42
|
+
# @rbs iov: Integer
|
|
43
|
+
# @rbs return: String?
|
|
44
|
+
def iovec_payload: (String data, Integer iov) -> String?
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -7,6 +7,18 @@ module Wardite
|
|
|
7
7
|
class WebAssemblyError < StandardError
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
+
class UncaughtWasmException < WebAssemblyError
|
|
11
|
+
attr_reader exception_value: Wardite::Efflorescence::ExceptionValue
|
|
12
|
+
|
|
13
|
+
attr_reader tag: Wardite::Efflorescence::Tag
|
|
14
|
+
|
|
15
|
+
# Public payloads follow tag order, with floats decoded at the boundary.
|
|
16
|
+
attr_reader payload: Array[Integer | Float]
|
|
17
|
+
|
|
18
|
+
# @rbs value: Wardite::Efflorescence::ExceptionValue
|
|
19
|
+
def initialize: (Wardite::Efflorescence::ExceptionValue value) -> untyped
|
|
20
|
+
end
|
|
21
|
+
|
|
10
22
|
class IntegerOverflow < WebAssemblyError
|
|
11
23
|
end
|
|
12
24
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Generated from lib/wardite/float_bits.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Wardite
|
|
4
|
+
module FloatBits
|
|
5
|
+
# @rbs type: Symbol
|
|
6
|
+
# @rbs return: bool
|
|
7
|
+
def self.float_type?: (Symbol type) -> bool
|
|
8
|
+
|
|
9
|
+
# f32 carriers are unsigned, f64 carriers are signed.
|
|
10
|
+
# @rbs type: Symbol
|
|
11
|
+
# @rbs bytes: String
|
|
12
|
+
# @rbs return: Integer
|
|
13
|
+
def self.read: (Symbol type, String bytes) -> Integer
|
|
14
|
+
|
|
15
|
+
# @rbs type: Symbol
|
|
16
|
+
# @rbs bits: Integer
|
|
17
|
+
# @rbs return: String
|
|
18
|
+
def self.write: (Symbol type, Integer bits) -> String
|
|
19
|
+
|
|
20
|
+
# @rbs type: Symbol
|
|
21
|
+
# @rbs bits: Integer
|
|
22
|
+
# @rbs return: Float
|
|
23
|
+
def self.to_float: (Symbol type, Integer bits) -> Float
|
|
24
|
+
|
|
25
|
+
# @rbs type: Symbol
|
|
26
|
+
# @rbs value: Float
|
|
27
|
+
# @rbs return: Integer
|
|
28
|
+
def self.from_float: (Symbol type, Float value) -> Integer
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
# Generated from lib/wardite/instruction.rb with RBS::Inline
|
|
2
2
|
|
|
3
3
|
module Wardite
|
|
4
|
-
type operandItem = Integer |
|
|
4
|
+
type operandItem = Integer | Float | Block | OperandVector | FloatImmediate
|
|
5
|
+
|
|
6
|
+
# Give br_table and try_table vectors a concrete type in the mixed operand list.
|
|
7
|
+
class FloatImmediate
|
|
8
|
+
attr_reader bits: Integer
|
|
9
|
+
|
|
10
|
+
attr_reader type: Symbol
|
|
11
|
+
|
|
12
|
+
# @rbs type: Symbol
|
|
13
|
+
# @rbs bits: Integer
|
|
14
|
+
def initialize: (Symbol type, Integer bits) -> untyped
|
|
15
|
+
|
|
16
|
+
# @rbs return: Float
|
|
17
|
+
def value: () -> Float
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class OperandVector
|
|
21
|
+
attr_reader entries: Array[Integer]
|
|
22
|
+
|
|
23
|
+
# @rbs entries: Array[Integer]
|
|
24
|
+
def initialize: (Array[Integer] entries) -> untyped
|
|
25
|
+
end
|
|
5
26
|
|
|
6
27
|
class Op
|
|
7
28
|
# @see https://pengowray.github.io/wasm-ops/
|
|
@@ -9,11 +30,11 @@ module Wardite
|
|
|
9
30
|
|
|
10
31
|
FC_SYMS: Array[Symbol]
|
|
11
32
|
|
|
12
|
-
|
|
13
|
-
|
|
33
|
+
OPERANDS: Array[Array[Symbol]]
|
|
34
|
+
|
|
35
|
+
NAMESPACES: Array[Symbol]
|
|
14
36
|
|
|
15
|
-
|
|
16
|
-
def self.fc_table: () -> Hash[Integer, Symbol]
|
|
37
|
+
FC_OPERANDS: Array[Symbol]
|
|
17
38
|
|
|
18
39
|
attr_accessor namespace: Symbol
|
|
19
40
|
|
|
@@ -24,18 +45,22 @@ module Wardite
|
|
|
24
45
|
|
|
25
46
|
attr_accessor meta: Hash[Symbol, Integer]
|
|
26
47
|
|
|
48
|
+
# $OP_COUNT = 0
|
|
49
|
+
# END {
|
|
50
|
+
# puts "Total opcodes: #{$OP_COUNT}"
|
|
51
|
+
# }
|
|
27
52
|
# @rbs namespace: Symbol
|
|
28
53
|
# @rbs code: Symbol
|
|
29
54
|
# @rbs operand: Array[operandItem]
|
|
30
55
|
def initialize: (Symbol namespace, Symbol code, Array[operandItem] operand) -> untyped
|
|
31
56
|
|
|
32
|
-
# @rbs chr:
|
|
33
|
-
# @rbs return:
|
|
34
|
-
def self.to_sym: (
|
|
57
|
+
# @rbs chr: Integer
|
|
58
|
+
# @rbs return: Symbol
|
|
59
|
+
def self.to_sym: (Integer chr) -> Symbol
|
|
35
60
|
|
|
36
61
|
# @rbs lower: Integer
|
|
37
|
-
# @rbs return:
|
|
38
|
-
def self.resolve_fc_sym: (Integer lower) ->
|
|
62
|
+
# @rbs return: Symbol
|
|
63
|
+
def self.resolve_fc_sym: (Integer lower) -> Symbol
|
|
39
64
|
|
|
40
65
|
# @rbs code: Symbol
|
|
41
66
|
# @rbs return: Array[Symbol]
|
|
@@ -10,6 +10,8 @@ module Wardite
|
|
|
10
10
|
|
|
11
11
|
# @rbs buf: File|StringIO
|
|
12
12
|
# @rbs return: Integer
|
|
13
|
-
|
|
13
|
+
# @rbs max_level: Integer
|
|
14
|
+
# @rbs width: Integer?
|
|
15
|
+
def fetch_sleb128: (File | StringIO buf, ?max_level: Integer, ?width: Integer?) -> Integer
|
|
14
16
|
end
|
|
15
17
|
end
|
|
@@ -18,6 +18,12 @@ module Wardite
|
|
|
18
18
|
def initialize: () -> void
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
class TagSection < Section
|
|
22
|
+
attr_reader type_indices: Array[Integer]
|
|
23
|
+
|
|
24
|
+
def initialize: () -> untyped
|
|
25
|
+
end
|
|
26
|
+
|
|
21
27
|
class FunctionSection < Section
|
|
22
28
|
attr_accessor func_indices: Array[Integer]
|
|
23
29
|
|
|
@@ -71,11 +77,15 @@ module Wardite
|
|
|
71
77
|
end
|
|
72
78
|
|
|
73
79
|
class ElemSection < Section
|
|
80
|
+
type indexVector = Array[Integer]
|
|
81
|
+
|
|
74
82
|
attr_accessor table_indices: Array[Integer]
|
|
75
83
|
|
|
76
84
|
attr_accessor table_offsets: Array[Integer]
|
|
77
85
|
|
|
78
|
-
|
|
86
|
+
# Rows are also shared with Store#elements. Keep the precise RBS type via
|
|
87
|
+
# an alias rather than pinning Spinel's specialized nested-array layout.
|
|
88
|
+
attr_accessor element_indices: Array[indexVector]
|
|
79
89
|
|
|
80
90
|
# @rbs return: void
|
|
81
91
|
def initialize: () -> void
|
|
@@ -87,7 +97,7 @@ module Wardite
|
|
|
87
97
|
|
|
88
98
|
attr_accessor locals_type: Array[Symbol]
|
|
89
99
|
|
|
90
|
-
attr_accessor body: Array[
|
|
100
|
+
attr_accessor body: Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]]
|
|
91
101
|
|
|
92
102
|
# @rbs &blk: (CodeBody) -> void
|
|
93
103
|
# @rbs return: void
|
|
@@ -175,8 +185,11 @@ module Wardite
|
|
|
175
185
|
# @rbs buf: File|StringIO
|
|
176
186
|
# @rbs import_object: Hash[Symbol, wasmModuleSrc]
|
|
177
187
|
# @rbs enable_wasi: boolish
|
|
188
|
+
# @rbs engine: Symbol
|
|
189
|
+
# @rbs disabled_optimizations: Array[Symbol]
|
|
190
|
+
# @rbs mir_profile: bool
|
|
178
191
|
# @rbs return: Instance
|
|
179
|
-
def self.load_from_buffer: (File | StringIO buf, ?import_object: Hash[Symbol, wasmModuleSrc], ?enable_wasi: boolish) -> Instance
|
|
192
|
+
def self.load_from_buffer: (File | StringIO buf, ?import_object: Hash[Symbol, wasmModuleSrc], ?enable_wasi: boolish, ?engine: Symbol, ?disabled_optimizations: Array[Symbol], ?mir_profile: bool) -> Instance
|
|
180
193
|
|
|
181
194
|
# @rbs return: Integer
|
|
182
195
|
def self.preamble: () -> Integer
|
|
@@ -187,6 +200,9 @@ module Wardite
|
|
|
187
200
|
# @rbs return: TypeSection
|
|
188
201
|
def self.type_section: () -> TypeSection
|
|
189
202
|
|
|
203
|
+
# @rbs return: TagSection
|
|
204
|
+
def self.tag_section: () -> TagSection
|
|
205
|
+
|
|
190
206
|
# @rbs return: ImportSection
|
|
191
207
|
def self.import_section: () -> ImportSection
|
|
192
208
|
|
|
@@ -211,14 +227,23 @@ module Wardite
|
|
|
211
227
|
# @rbs return: CodeSection
|
|
212
228
|
def self.code_section: () -> CodeSection
|
|
213
229
|
|
|
230
|
+
# @rbs sbuf: StringIO
|
|
231
|
+
# @rbs return: CodeSection::CodeBody
|
|
232
|
+
def self.read_function_body: (StringIO sbuf) -> CodeSection::CodeBody
|
|
233
|
+
|
|
214
234
|
# @rbs buf: StringIO
|
|
215
|
-
# @rbs return: Array[
|
|
216
|
-
def self.code_body: (StringIO buf) -> Array[
|
|
235
|
+
# @rbs return: Array[[Symbol, Symbol, Array[operandItem], Integer?, Integer?]]
|
|
236
|
+
def self.code_body: (StringIO buf) -> Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]]
|
|
237
|
+
|
|
238
|
+
# Decode s33, distinguishing the one-byte value/void forms from indices.
|
|
239
|
+
# @rbs buf: StringIO
|
|
240
|
+
# @rbs return: Block
|
|
241
|
+
def self.read_blocktype: (StringIO buf) -> Block
|
|
217
242
|
|
|
218
243
|
# @rbs c: String
|
|
219
244
|
# @rbs buf: StringIO
|
|
220
|
-
# @rbs return: [Symbol, Symbol]
|
|
221
|
-
def self.resolve_code: (String c, StringIO buf) -> [ Symbol, Symbol ]
|
|
245
|
+
# @rbs return: [Symbol, Symbol, Array[Symbol]]
|
|
246
|
+
def self.resolve_code: (String c, StringIO buf) -> [ Symbol, Symbol, Array[Symbol] ]
|
|
222
247
|
|
|
223
248
|
# @rbs return: DataSection
|
|
224
249
|
def self.data_section: () -> DataSection
|
|
@@ -230,13 +255,13 @@ module Wardite
|
|
|
230
255
|
# @rbs return: String
|
|
231
256
|
def self.fetch_insn_while_end: (StringIO sbuf) -> String
|
|
232
257
|
|
|
233
|
-
# @rbs ops: Array[
|
|
258
|
+
# @rbs ops: Array[[Symbol, Symbol, Array[operandItem], Integer?, Integer?]]
|
|
234
259
|
# @rbs return: Integer
|
|
235
|
-
def self.decode_expr: (Array[
|
|
260
|
+
def self.decode_expr: (Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]] ops) -> Integer
|
|
236
261
|
|
|
237
|
-
# @rbs ops: Array[
|
|
262
|
+
# @rbs ops: Array[[Symbol, Symbol, Array[operandItem], Integer?, Integer?]]
|
|
238
263
|
# @rbs return: wasmValue
|
|
239
|
-
def self.decode_global_expr: (Array[
|
|
264
|
+
def self.decode_global_expr: (Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]] ops) -> wasmValue
|
|
240
265
|
|
|
241
266
|
# @rbs return: ExportSection
|
|
242
267
|
def self.export_section: () -> ExportSection
|
|
@@ -245,9 +270,9 @@ module Wardite
|
|
|
245
270
|
# @rbs return: nil
|
|
246
271
|
def self.unimplemented_skip_section: (Integer code) -> nil
|
|
247
272
|
|
|
248
|
-
# @rbs sbuf: StringIO
|
|
273
|
+
# @rbs sbuf: File|StringIO
|
|
249
274
|
# @rbs n: Integer
|
|
250
275
|
# @rbs return: String
|
|
251
|
-
def self.assert_read: (StringIO sbuf, Integer n) -> String
|
|
276
|
+
def self.assert_read: (File | StringIO sbuf, Integer n) -> String
|
|
252
277
|
end
|
|
253
278
|
end
|
|
@@ -19,6 +19,14 @@ module Wardite
|
|
|
19
19
|
# @rbs value: Float
|
|
20
20
|
# @rbs return: F64
|
|
21
21
|
def F64: (Float value) -> F64
|
|
22
|
+
|
|
23
|
+
# Check the range before Float#to_i, whose result may exceed a native word.
|
|
24
|
+
# @rbs value: Float
|
|
25
|
+
# @rbs to: Symbol
|
|
26
|
+
# @rbs signed: bool
|
|
27
|
+
# @rbs saturating: bool
|
|
28
|
+
# @rbs return: I32 | I64
|
|
29
|
+
def truncate_float: (Float value, to: Symbol, signed: bool, saturating: bool) -> (I32 | I64)
|
|
22
30
|
end
|
|
23
31
|
|
|
24
32
|
extend ValueHelper
|
|
@@ -54,6 +62,12 @@ module Wardite
|
|
|
54
62
|
# @rbs return: Integer
|
|
55
63
|
def value_s: () -> Integer
|
|
56
64
|
|
|
65
|
+
# Keep intermediate products below 2**49, even for 0xffffffff operands.
|
|
66
|
+
# The omitted high bits do not contribute to the low 32-bit result.
|
|
67
|
+
# @rbs other: I32
|
|
68
|
+
# @rbs return: I32
|
|
69
|
+
def multiply: (I32 other) -> I32
|
|
70
|
+
|
|
57
71
|
# TODO: eliminate use of pack, to support mruby - in this file!
|
|
58
72
|
# @rbs size: Integer|nil
|
|
59
73
|
# @rbs return: String
|
|
@@ -121,12 +135,15 @@ module Wardite
|
|
|
121
135
|
class I64
|
|
122
136
|
include ValueHelper
|
|
123
137
|
|
|
138
|
+
type bits = Integer
|
|
139
|
+
|
|
124
140
|
I64_MAX: Integer
|
|
125
141
|
|
|
126
|
-
|
|
142
|
+
# Leave the representation inferred so Spinel can hold unsigned 64-bit values.
|
|
143
|
+
attr_accessor value: bits
|
|
127
144
|
|
|
128
|
-
# @rbs value:
|
|
129
|
-
def initialize: (?
|
|
145
|
+
# @rbs value: bits
|
|
146
|
+
def initialize: (?bits value) -> untyped
|
|
130
147
|
|
|
131
148
|
# @rbs str: String
|
|
132
149
|
# @rbs size: Integer|nil
|
|
@@ -141,6 +158,20 @@ module Wardite
|
|
|
141
158
|
# @rbs return: Integer
|
|
142
159
|
def value_s: () -> Integer
|
|
143
160
|
|
|
161
|
+
# @rbs other: I64
|
|
162
|
+
# @rbs return: I64
|
|
163
|
+
def add: (I64 other) -> I64
|
|
164
|
+
|
|
165
|
+
# @rbs count: Integer
|
|
166
|
+
# @rbs return: I64
|
|
167
|
+
def shift_left: (Integer count) -> I64
|
|
168
|
+
|
|
169
|
+
# Multiply in base 2**16; only the low four words contribute modulo 2**64.
|
|
170
|
+
# Every intermediate product and carry fits in a signed 64-bit integer.
|
|
171
|
+
# @rbs other: I64
|
|
172
|
+
# @rbs return: I64
|
|
173
|
+
def multiply: (I64 other) -> I64
|
|
174
|
+
|
|
144
175
|
# @rbs size: Integer|nil
|
|
145
176
|
# @rbs return: String
|
|
146
177
|
def packed: (?size: Integer | nil) -> String
|
|
@@ -207,7 +238,24 @@ module Wardite
|
|
|
207
238
|
class F32
|
|
208
239
|
include ValueHelper
|
|
209
240
|
|
|
210
|
-
|
|
241
|
+
# A wrapper holds a Ruby-origin value or raw Wasm bits. Reassignment
|
|
242
|
+
# discards the raw representation so existing value= callers stay current.
|
|
243
|
+
# @rbs bits: Integer?
|
|
244
|
+
def initialize: (?bits: Integer?) -> untyped
|
|
245
|
+
|
|
246
|
+
# @rbs return: Float
|
|
247
|
+
def value: () -> Float
|
|
248
|
+
|
|
249
|
+
# @rbs value: Float
|
|
250
|
+
# @rbs return: Float
|
|
251
|
+
def value=: (Float value) -> Float
|
|
252
|
+
|
|
253
|
+
# @rbs return: Integer
|
|
254
|
+
def raw_bits: () -> Integer
|
|
255
|
+
|
|
256
|
+
# @rbs bits: Integer
|
|
257
|
+
# @rbs return: F32
|
|
258
|
+
def self.from_bits: (Integer bits) -> F32
|
|
211
259
|
|
|
212
260
|
# @rbs str: String
|
|
213
261
|
# @rbs return: F32
|
|
@@ -235,16 +283,11 @@ module Wardite
|
|
|
235
283
|
# @rbs return: wasmValue
|
|
236
284
|
def extend_u: (to: Symbol) -> wasmValue
|
|
237
285
|
|
|
238
|
-
# @todo need more testcase...
|
|
239
|
-
# @see https://webassembly.github.io/spec/core/exec/numerics.html#xref-exec-numerics-op-trunc-s-mathrm-trunc-mathsf-s-m-n-z
|
|
240
|
-
# @see copy this impl to F64 when changed
|
|
241
286
|
# @rbs to: Symbol
|
|
242
287
|
# @rbs saturating: bool
|
|
243
288
|
# @rbs return: wasmValue
|
|
244
289
|
def trunc_s: (to: Symbol, ?saturating: bool) -> wasmValue
|
|
245
290
|
|
|
246
|
-
# @see https://webassembly.github.io/spec/core/exec/numerics.html#xref-exec-numerics-op-trunc-u-mathrm-trunc-mathsf-u-m-n-z
|
|
247
|
-
# @see copy this impl to F64 when changed
|
|
248
291
|
# @rbs to: Symbol
|
|
249
292
|
# @rbs sturating: bool
|
|
250
293
|
# @rbs return: wasmValue
|
|
@@ -291,7 +334,24 @@ module Wardite
|
|
|
291
334
|
class F64
|
|
292
335
|
include ValueHelper
|
|
293
336
|
|
|
294
|
-
|
|
337
|
+
# A wrapper holds a Ruby-origin value or raw Wasm bits. Reassignment
|
|
338
|
+
# discards the raw representation so existing value= callers stay current.
|
|
339
|
+
# @rbs bits: Integer?
|
|
340
|
+
def initialize: (?bits: Integer?) -> untyped
|
|
341
|
+
|
|
342
|
+
# @rbs return: Float
|
|
343
|
+
def value: () -> Float
|
|
344
|
+
|
|
345
|
+
# @rbs value: Float
|
|
346
|
+
# @rbs return: Float
|
|
347
|
+
def value=: (Float value) -> Float
|
|
348
|
+
|
|
349
|
+
# @rbs return: Integer
|
|
350
|
+
def raw_bits: () -> Integer
|
|
351
|
+
|
|
352
|
+
# @rbs bits: Integer
|
|
353
|
+
# @rbs return: F64
|
|
354
|
+
def self.from_bits: (Integer bits) -> F64
|
|
295
355
|
|
|
296
356
|
# @rbs str: String
|
|
297
357
|
# @rbs return: F64
|
|
@@ -325,7 +385,6 @@ module Wardite
|
|
|
325
385
|
# @rbs return: wasmValue
|
|
326
386
|
def trunc_s: (to: Symbol, ?saturating: bool) -> wasmValue
|
|
327
387
|
|
|
328
|
-
# @see the same as F32
|
|
329
388
|
# @rbs to: Symbol
|
|
330
389
|
# @rbs saturating: bool
|
|
331
390
|
# @rbs return: wasmValue
|