wardite 1.0.0 → 1.1.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 +33 -7
- data/Steepfile +1 -0
- data/assets/wardite.svg +12 -0
- data/benchmark/measure_mir_cache_verify.rb +58 -0
- data/benchmark/measure_ruby_wasm_cache_hit.rb +59 -0
- data/benchmark/measure_ruby_wasm_startup.rb +43 -0
- data/benchmark/results/efflorescence-mir2-cache-integrity.json +390 -0
- data/benchmark/results/efflorescence-unboxed-globals.json +3451 -0
- data/docs/adr/0007-efflorescence-ruby-wasm-phase1.md +75 -0
- data/docs/adr/0008-efflorescence-ruby-wasm-phase2.md +75 -0
- data/docs/adr/0009-efflorescence-mir2-cache-integrity-modes.md +77 -0
- data/docs/adr/0010-efflorescence-mir2-cache-function-restore.md +80 -0
- data/docs/adr/0011-efflorescence-unboxed-globals.md +89 -0
- data/docs/adr/0012-efflorescence-startup-snapshot.md +173 -0
- data/docs/adr/0013-efflorescence-frame-acquisition.md +114 -0
- data/docs/efflorescence-generated-c-guards.md +5 -0
- data/docs/efflorescence-mir2-cache.md +123 -0
- data/docs/efflorescence-ruby-wasm-phase1.md +90 -0
- data/docs/efflorescence-spinel-linear-memory.md +72 -0
- data/docs/efflorescence-startup-snapshot.md +60 -0
- data/docs/efflorescence-unboxed-globals.md +61 -0
- data/lib/wardite/alu_f32.generated.rb +10 -2
- data/lib/wardite/alu_f64.generated.rb +10 -2
- data/lib/wardite/alu_i32.generated.rb +40 -8
- data/lib/wardite/alu_i64.generated.rb +55 -11
- data/lib/wardite/cli/cli.rb +56 -6
- data/lib/wardite/efflorescence/ir.rb +14 -1
- data/lib/wardite/efflorescence/mir_cache.rb +657 -0
- data/lib/wardite/efflorescence/register_validation.rb +128 -56
- data/lib/wardite/efflorescence/snapshot.rb +229 -0
- data/lib/wardite/efflorescence/store_access.rb +103 -8
- data/lib/wardite/efflorescence/translator.rb +10 -3
- data/lib/wardite/efflorescence/vm.rb +202 -38
- data/lib/wardite/efflorescence/wasi.rb +0 -56
- data/lib/wardite/efflorescence.rb +6 -0
- data/lib/wardite/load.rb +108 -24
- data/lib/wardite/version.rb +1 -1
- data/lib/wardite/wasi/spinel.rb +41 -0
- data/lib/wardite/wasi.rb +483 -268
- data/lib/wardite.rb +218 -70
- data/scripts/gen_alu.rb +55 -11
- data/scripts/verify_ruby_wasm.rb +70 -0
- data/sig/generated/wardite/cli/cli.rbs +15 -0
- data/sig/generated/wardite/efflorescence/ir.rbs +7 -0
- data/sig/generated/wardite/efflorescence/mir_cache.rbs +236 -0
- data/sig/generated/wardite/efflorescence/register_validation.rbs +31 -3
- data/sig/generated/wardite/efflorescence/snapshot.rbs +83 -0
- data/sig/generated/wardite/efflorescence/store_access.rbs +13 -2
- data/sig/generated/wardite/efflorescence/translator.rbs +5 -1
- data/sig/generated/wardite/efflorescence/vm.rbs +68 -7
- data/sig/generated/wardite/efflorescence/wasi.rbs +0 -13
- data/sig/generated/wardite/load.rbs +32 -5
- data/sig/generated/wardite/wasi/spinel.rbs +15 -0
- data/sig/generated/wardite/wasi.rbs +111 -4
- data/sig/generated/wardite.rbs +67 -3
- data/sig/mir_cache_stdlib.rbs +5 -0
- data/spinel/patches/0001-io-buffer-string-view.patch +699 -0
- data/spinel/patches/0002-io-buffer-allocation-error.patch +47 -0
- metadata +29 -1
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# Generated from lib/wardite/efflorescence/mir_cache.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Wardite
|
|
4
|
+
module Efflorescence
|
|
5
|
+
# Local, opt-in cache of the verified output of Lowerer. Bump CODE_VERSION
|
|
6
|
+
# when the generated code or its interpretation changes, including opcodes,
|
|
7
|
+
# optimizer/validator fixes, and changes to the metadata used by the VM.
|
|
8
|
+
class MIRCache
|
|
9
|
+
MAGIC: untyped
|
|
10
|
+
|
|
11
|
+
FORMAT_VERSION: ::Integer
|
|
12
|
+
|
|
13
|
+
CODE_VERSION: ::Integer
|
|
14
|
+
|
|
15
|
+
DIGEST_SIZE: ::Integer
|
|
16
|
+
|
|
17
|
+
LENGTH_SIZE: ::Integer
|
|
18
|
+
|
|
19
|
+
INTEGRITY_SIZE: untyped
|
|
20
|
+
|
|
21
|
+
SAMPLE_EDGE: untyped
|
|
22
|
+
|
|
23
|
+
SAMPLE_STEP: untyped
|
|
24
|
+
|
|
25
|
+
SAMPLE_BLOCK: untyped
|
|
26
|
+
|
|
27
|
+
MAX_BYTES: untyped
|
|
28
|
+
|
|
29
|
+
TYPES: untyped
|
|
30
|
+
|
|
31
|
+
TYPE_IDS: untyped
|
|
32
|
+
|
|
33
|
+
USES_I64: ::Integer
|
|
34
|
+
|
|
35
|
+
USES_FLOAT: ::Integer
|
|
36
|
+
|
|
37
|
+
USES_EH: ::Integer
|
|
38
|
+
|
|
39
|
+
USES_STORE: ::Integer
|
|
40
|
+
|
|
41
|
+
USES_DYNAMIC_CALLS: ::Integer
|
|
42
|
+
|
|
43
|
+
FUNCTION_FLAGS: untyped
|
|
44
|
+
|
|
45
|
+
class Invalid < StandardError
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Identifies the module, the generated code, and the host build.
|
|
49
|
+
attr_reader key: String
|
|
50
|
+
|
|
51
|
+
# All records are little-endian. Vectors carry a nonnegative 32-bit element count.
|
|
52
|
+
# A record count is bounded by the bytes still available to decode it.
|
|
53
|
+
class Reader
|
|
54
|
+
# @rbs bytes: String
|
|
55
|
+
def initialize: (String bytes) -> untyped
|
|
56
|
+
|
|
57
|
+
# @rbs length: Integer
|
|
58
|
+
# @rbs return: String
|
|
59
|
+
def bytes: (Integer length) -> String
|
|
60
|
+
|
|
61
|
+
# @rbs return: Integer
|
|
62
|
+
def integer: () -> Integer
|
|
63
|
+
|
|
64
|
+
# @rbs width: Integer
|
|
65
|
+
# @rbs return: Integer
|
|
66
|
+
def count: (Integer width) -> Integer
|
|
67
|
+
|
|
68
|
+
# @rbs format: String
|
|
69
|
+
# @rbs width: Integer
|
|
70
|
+
# @rbs return: Array[Integer]
|
|
71
|
+
def vector: (String format, Integer width) -> Array[Integer]
|
|
72
|
+
|
|
73
|
+
# @rbs return: Array[Symbol]
|
|
74
|
+
def types: () -> Array[Symbol]
|
|
75
|
+
|
|
76
|
+
# @rbs return: void
|
|
77
|
+
def finish: () -> void
|
|
78
|
+
|
|
79
|
+
private
|
|
80
|
+
|
|
81
|
+
# @rbs length: Integer
|
|
82
|
+
# @rbs return: void
|
|
83
|
+
def ensure_bytes: (Integer length) -> void
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
class Writer
|
|
87
|
+
attr_reader bytes: String
|
|
88
|
+
|
|
89
|
+
def initialize: () -> untyped
|
|
90
|
+
|
|
91
|
+
# @rbs *values: Integer
|
|
92
|
+
# @rbs return: void
|
|
93
|
+
def integers: (*Integer values) -> void
|
|
94
|
+
|
|
95
|
+
# @rbs values: Array[Integer]
|
|
96
|
+
# @rbs format: String
|
|
97
|
+
# @rbs return: void
|
|
98
|
+
def vector: (Array[Integer] values, ?String format) -> void
|
|
99
|
+
|
|
100
|
+
# @rbs types: Array[Symbol]
|
|
101
|
+
# @rbs return: void
|
|
102
|
+
def types: (Array[Symbol] types) -> void
|
|
103
|
+
|
|
104
|
+
# @rbs function: Function
|
|
105
|
+
# @rbs return: void
|
|
106
|
+
def function: (Function function) -> void
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
class Decoder
|
|
110
|
+
include Opcode
|
|
111
|
+
|
|
112
|
+
# Reuse the semantic register roles for fixed operands. Lowering
|
|
113
|
+
# moves direct call arguments into a side table and leaves optional
|
|
114
|
+
# destinations and return operands to be checked against signatures.
|
|
115
|
+
REGISTER_MASKS: Array[Integer]
|
|
116
|
+
|
|
117
|
+
EXTRA_OPERANDS: Array[Symbol?]
|
|
118
|
+
|
|
119
|
+
# @rbs reader: Reader
|
|
120
|
+
# @rbs instance: Wardite::Instance
|
|
121
|
+
# @rbs entries: Array[FunctionEntry]
|
|
122
|
+
def initialize: (Reader reader, Wardite::Instance instance, Array[FunctionEntry] entries) -> untyped
|
|
123
|
+
|
|
124
|
+
# @rbs return: Array[Function]
|
|
125
|
+
def decode: () -> Array[Function]
|
|
126
|
+
|
|
127
|
+
private
|
|
128
|
+
|
|
129
|
+
# @rbs body: Wardite::CodeSection::CodeBody
|
|
130
|
+
# @rbs entry: FunctionEntry
|
|
131
|
+
# @rbs index: Integer
|
|
132
|
+
# @rbs return: Function
|
|
133
|
+
def read_function: (Wardite::CodeSection::CodeBody body, FunctionEntry entry, Integer index) -> Function
|
|
134
|
+
|
|
135
|
+
# @rbs function: Function
|
|
136
|
+
# @rbs return: Array[[Integer, Array[Integer]]]
|
|
137
|
+
def read_sites: (Function function) -> Array[[ Integer, Array[Integer] ]]
|
|
138
|
+
|
|
139
|
+
# @rbs function: Function
|
|
140
|
+
# @rbs return: DynamicCallSite
|
|
141
|
+
def read_dynamic_site: (Function function) -> DynamicCallSite
|
|
142
|
+
|
|
143
|
+
# @rbs function: Function
|
|
144
|
+
# @rbs return: MemorySite
|
|
145
|
+
def read_memory_site: (Function function) -> MemorySite
|
|
146
|
+
|
|
147
|
+
# @rbs function: Function
|
|
148
|
+
# @rbs handler_count: Integer
|
|
149
|
+
# @rbs return: CatchTarget
|
|
150
|
+
def read_catch: (Function function, Integer handler_count) -> CatchTarget
|
|
151
|
+
|
|
152
|
+
# @rbs function: Function
|
|
153
|
+
# @rbs return: void
|
|
154
|
+
def check_code: (Function function) -> void
|
|
155
|
+
|
|
156
|
+
# @rbs tag: Integer
|
|
157
|
+
# @rbs return: Array[Symbol]
|
|
158
|
+
def tag_types: (Integer tag) -> Array[Symbol]
|
|
159
|
+
|
|
160
|
+
# @rbs function: Function
|
|
161
|
+
# @rbs registers: Array[Integer]
|
|
162
|
+
# @rbs types: Array[Symbol]
|
|
163
|
+
# @rbs return: void
|
|
164
|
+
def check_arguments: (Function function, Array[Integer] registers, Array[Symbol] types) -> void
|
|
165
|
+
|
|
166
|
+
# @rbs function: Function
|
|
167
|
+
# @rbs slot: Integer
|
|
168
|
+
# @rbs types: Array[Symbol]
|
|
169
|
+
# @rbs return: void
|
|
170
|
+
def check_result: (Function function, Integer slot, Array[Symbol] types) -> void
|
|
171
|
+
|
|
172
|
+
# @rbs target: Integer
|
|
173
|
+
# @rbs limit: Integer
|
|
174
|
+
# @rbs return: void
|
|
175
|
+
def check_target: (Integer target, Integer limit) -> void
|
|
176
|
+
|
|
177
|
+
# @rbs [T] (Array[T] values, Integer index) -> T
|
|
178
|
+
def at: [T] (Array[T] values, Integer index) -> T
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# @rbs directory: String
|
|
182
|
+
# @rbs wasm: String
|
|
183
|
+
# @rbs configuration: Configuration
|
|
184
|
+
# @rbs verify: Symbol
|
|
185
|
+
def initialize: (String directory, String wasm, Configuration configuration, ?verify: Symbol) -> untyped
|
|
186
|
+
|
|
187
|
+
# Restore against module declarations so a miss can decode and check the
|
|
188
|
+
# Wasm bodies before Store initialization or any host lookup.
|
|
189
|
+
# @rbs instance: Wardite::Instance
|
|
190
|
+
# @rbs return: Array[Function]?
|
|
191
|
+
def read: (Wardite::Instance instance) -> Array[Function]?
|
|
192
|
+
|
|
193
|
+
# @rbs instance: Wardite::Instance
|
|
194
|
+
# @rbs ir: IR
|
|
195
|
+
# @rbs return: void
|
|
196
|
+
def write: (Wardite::Instance instance, IR ir) -> void
|
|
197
|
+
|
|
198
|
+
private
|
|
199
|
+
|
|
200
|
+
# @rbs instance: Wardite::Instance
|
|
201
|
+
# @rbs return: Array[FunctionEntry]
|
|
202
|
+
def module_entries: (Wardite::Instance instance) -> Array[FunctionEntry]
|
|
203
|
+
|
|
204
|
+
# @rbs return: String
|
|
205
|
+
def read_verified_payload: () -> String
|
|
206
|
+
|
|
207
|
+
# @rbs payload: String
|
|
208
|
+
# @rbs length: String
|
|
209
|
+
# @rbs return: String
|
|
210
|
+
def self.sample_checksum: (String payload, String length) -> String
|
|
211
|
+
|
|
212
|
+
# Opening without blocking keeps a FIFO from stalling the start of a run.
|
|
213
|
+
# @rbs path: String
|
|
214
|
+
# @rbs header: String
|
|
215
|
+
# @rbs prefix_size: Integer
|
|
216
|
+
# @rbs return: String
|
|
217
|
+
def self.read_contents: (String path, String header, Integer prefix_size) -> String
|
|
218
|
+
|
|
219
|
+
# Exclusive creation protects a concurrent writer's temporary file.
|
|
220
|
+
# Close the file before publishing it under the cache key.
|
|
221
|
+
# @rbs directory: String
|
|
222
|
+
# @rbs destination: String
|
|
223
|
+
# @rbs prefix: String
|
|
224
|
+
# @rbs payload: String
|
|
225
|
+
# @rbs return: void
|
|
226
|
+
def self.publish: (String directory, String destination, String prefix, String payload) -> void
|
|
227
|
+
|
|
228
|
+
# Include the module's import identities, and every function's signature
|
|
229
|
+
# and index mapping. The live entries and hosts are always linked afresh.
|
|
230
|
+
# @rbs instance: Wardite::Instance
|
|
231
|
+
# @rbs entries: Array[FunctionEntry]
|
|
232
|
+
# @rbs return: String
|
|
233
|
+
def encode_layout: (Wardite::Instance instance, Array[FunctionEntry] entries) -> String
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
end
|
|
@@ -6,6 +6,13 @@ module Wardite
|
|
|
6
6
|
# This makes stale temporary slots harmless when a frame is reused. Keep
|
|
7
7
|
# states per basic block, rather than per instruction, to bound their size.
|
|
8
8
|
class RegisterValidation
|
|
9
|
+
# Keep each word within Spinel's fixed-width Integer.
|
|
10
|
+
WORD_SHIFT: ::Integer
|
|
11
|
+
|
|
12
|
+
WORD_BITS: untyped
|
|
13
|
+
|
|
14
|
+
WORD_MASK: untyped
|
|
15
|
+
|
|
9
16
|
class Block
|
|
10
17
|
attr_reader first: Integer
|
|
11
18
|
|
|
@@ -13,13 +20,16 @@ module Wardite
|
|
|
13
20
|
|
|
14
21
|
attr_reader defined: Array[Integer]
|
|
15
22
|
|
|
23
|
+
attr_reader successors: Array[Integer]
|
|
24
|
+
|
|
25
|
+
attr_accessor pending: bool
|
|
26
|
+
|
|
16
27
|
# @rbs first: Integer
|
|
17
28
|
# @rbs limit: Integer
|
|
18
|
-
|
|
19
|
-
def initialize: (Integer first, Integer limit, Integer register_count) -> untyped
|
|
29
|
+
def initialize: (Integer first, Integer limit) -> untyped
|
|
20
30
|
|
|
21
31
|
# Incoming facts only lose definitions after the first reachable edge.
|
|
22
|
-
#
|
|
32
|
+
# Return true when a changed block needs to enter the worklist.
|
|
23
33
|
# @rbs incoming: Array[Integer]
|
|
24
34
|
# @rbs return: bool
|
|
25
35
|
def merge: (Array[Integer] incoming) -> bool
|
|
@@ -33,6 +43,24 @@ module Wardite
|
|
|
33
43
|
|
|
34
44
|
private
|
|
35
45
|
|
|
46
|
+
# Visit predecessors before joins where possible, then revisit changed
|
|
47
|
+
# states across backedges until the worklist is empty.
|
|
48
|
+
# @rbs blocks: Array[Wardite::Efflorescence::RegisterValidation::Block]
|
|
49
|
+
# @rbs block_for_pc: Array[Integer]
|
|
50
|
+
# @rbs flow: Wardite::Efflorescence::FlowGraph
|
|
51
|
+
# @rbs return: Array[Integer]
|
|
52
|
+
def reverse_postorder: (Array[Wardite::Efflorescence::RegisterValidation::Block] blocks, Array[Integer] block_for_pc, Wardite::Efflorescence::FlowGraph flow) -> Array[Integer]
|
|
53
|
+
|
|
54
|
+
# @rbs words: Array[Integer]
|
|
55
|
+
# @rbs register: Integer
|
|
56
|
+
# @rbs return: void
|
|
57
|
+
def mark: (Array[Integer] words, Integer register) -> void
|
|
58
|
+
|
|
59
|
+
# @rbs words: Array[Integer]
|
|
60
|
+
# @rbs register: Integer
|
|
61
|
+
# @rbs return: bool
|
|
62
|
+
def marked?: (Array[Integer] words, Integer register) -> bool
|
|
63
|
+
|
|
36
64
|
# Validate all registers, including unreachable instructions and table-only
|
|
37
65
|
# operands. Numeric registers are checked before flat execution.
|
|
38
66
|
# @rbs function: Wardite::Efflorescence::Function
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Generated from lib/wardite/efflorescence/snapshot.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Wardite
|
|
4
|
+
module Efflorescence
|
|
5
|
+
class SavedFrame
|
|
6
|
+
attr_reader pool_index: Integer
|
|
7
|
+
|
|
8
|
+
attr_reader pc: Integer
|
|
9
|
+
|
|
10
|
+
attr_reader return_register: Integer
|
|
11
|
+
|
|
12
|
+
attr_reader registers: Array[Integer]
|
|
13
|
+
|
|
14
|
+
attr_reader handlers: Array[Integer]
|
|
15
|
+
|
|
16
|
+
# @rbs pool_index: Integer
|
|
17
|
+
# @rbs pc: Integer
|
|
18
|
+
# @rbs return_register: Integer
|
|
19
|
+
# @rbs registers: Array[Integer]
|
|
20
|
+
# @rbs handlers: Array[Integer]
|
|
21
|
+
def initialize: (Integer pool_index, Integer pc, Integer return_register, Array[Integer] registers, Array[Integer] handlers) -> untyped
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Startup snapshot of a WASI command (ADR 0012). The state is saved just
|
|
25
|
+
# before the first WASI call whose result is not fixed by the key, and a
|
|
26
|
+
# later run with the same key resumes from there.
|
|
27
|
+
class Snapshot
|
|
28
|
+
MAGIC: untyped
|
|
29
|
+
|
|
30
|
+
FORMAT_VERSION: ::Integer
|
|
31
|
+
|
|
32
|
+
PAGE_SIZE: ::Integer
|
|
33
|
+
|
|
34
|
+
ZERO_PAGE: untyped
|
|
35
|
+
|
|
36
|
+
# Their results depend only on values in the key, or are frozen into the
|
|
37
|
+
# snapshot (clocks and random bytes). fd_filestat_get is allowed for
|
|
38
|
+
# stdio only: CRuby probes fds 0-2 before anything else.
|
|
39
|
+
ALLOWED: untyped
|
|
40
|
+
|
|
41
|
+
attr_reader path: String
|
|
42
|
+
|
|
43
|
+
# @rbs directory: String
|
|
44
|
+
# @rbs instance: Wardite::Instance
|
|
45
|
+
# @rbs mir_cache: Wardite::Efflorescence::MIRCache
|
|
46
|
+
def initialize: (String directory, Wardite::Instance instance, Wardite::Efflorescence::MIRCache mir_cache) -> untyped
|
|
47
|
+
|
|
48
|
+
# Does this host call end the deterministic prefix of the run?
|
|
49
|
+
# @rbs host: Wardite::Efflorescence::HostFunction
|
|
50
|
+
# @rbs registers: Array[Integer]
|
|
51
|
+
# @rbs sources: Array[Integer]
|
|
52
|
+
# @rbs return: bool
|
|
53
|
+
def checkpoint?: (Wardite::Efflorescence::HostFunction host, Array[Integer] registers, Array[Integer] sources) -> bool
|
|
54
|
+
|
|
55
|
+
# Saving is best effort: any refusal or I/O error leaves the run as is.
|
|
56
|
+
# @rbs instance: Wardite::Instance
|
|
57
|
+
# @rbs frames: Array[Wardite::Efflorescence::Frame]
|
|
58
|
+
# @rbs return: void
|
|
59
|
+
def save: (Wardite::Instance instance, Array[Wardite::Efflorescence::Frame] frames) -> void
|
|
60
|
+
|
|
61
|
+
# Validate everything before touching the Store, so a rejected file
|
|
62
|
+
# leaves a fresh instance for the normal start.
|
|
63
|
+
# @rbs vm: Wardite::Efflorescence::VM
|
|
64
|
+
# @rbs return: Array[Wardite::Efflorescence::SavedFrame]?
|
|
65
|
+
def restore: (Wardite::Efflorescence::VM vm) -> Array[Wardite::Efflorescence::SavedFrame]?
|
|
66
|
+
|
|
67
|
+
private
|
|
68
|
+
|
|
69
|
+
# The top frame resumes at its host call. Callers resume after the call
|
|
70
|
+
# that created the frame above them, which writes its return register.
|
|
71
|
+
# @rbs functions: Array[Wardite::Efflorescence::Function]
|
|
72
|
+
# @rbs frames: Array[Wardite::Efflorescence::SavedFrame]
|
|
73
|
+
# @rbs index: Integer
|
|
74
|
+
# @rbs return: void
|
|
75
|
+
def check_frame: (Array[Wardite::Efflorescence::Function] functions, Array[Wardite::Efflorescence::SavedFrame] frames, Integer index) -> void
|
|
76
|
+
|
|
77
|
+
# @rbs message: String
|
|
78
|
+
# @rbs started: Float
|
|
79
|
+
# @rbs return: void
|
|
80
|
+
def trace: (String message, ?Float started) -> void
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
module Wardite
|
|
4
4
|
module Efflorescence
|
|
5
|
-
# Checked byte operations live off the integer
|
|
6
|
-
#
|
|
5
|
+
# Checked byte operations and global synchronization live off the integer
|
|
6
|
+
# dispatch path. Never retain a Memory#data buffer across a call.
|
|
7
7
|
class StoreAccess
|
|
8
8
|
PAGE_SIZE: ::Integer
|
|
9
9
|
|
|
@@ -53,6 +53,17 @@ module Wardite
|
|
|
53
53
|
# @rbs return: void
|
|
54
54
|
def global_set_i64: (Integer index, Integer value) -> void
|
|
55
55
|
|
|
56
|
+
# @rbs index: Integer
|
|
57
|
+
# @rbs type: Symbol
|
|
58
|
+
# @rbs return: Integer
|
|
59
|
+
def global_bits_at: (Integer index, Symbol type) -> Integer
|
|
60
|
+
|
|
61
|
+
# @rbs index: Integer
|
|
62
|
+
# @rbs type: Symbol
|
|
63
|
+
# @rbs value: Integer
|
|
64
|
+
# @rbs return: void
|
|
65
|
+
def write_global_bits: (Integer index, Symbol type, Integer value) -> void
|
|
66
|
+
|
|
56
67
|
# @rbs address: Integer
|
|
57
68
|
# @rbs offset: Integer
|
|
58
69
|
# @rbs width: Integer
|
|
@@ -87,7 +87,11 @@ module Wardite
|
|
|
87
87
|
def initialize: (Wardite::Instance instance) -> untyped
|
|
88
88
|
|
|
89
89
|
# @rbs return: Wardite::Efflorescence::IR
|
|
90
|
-
def
|
|
90
|
+
def link: () -> Wardite::Efflorescence::IR
|
|
91
|
+
|
|
92
|
+
# @rbs linked: Wardite::Efflorescence::IR
|
|
93
|
+
# @rbs return: Wardite::Efflorescence::IR
|
|
94
|
+
def translate: (?Wardite::Efflorescence::IR linked) -> Wardite::Efflorescence::IR
|
|
91
95
|
|
|
92
96
|
# @rbs wasm: Wardite::WasmFunction
|
|
93
97
|
# @rbs index: Integer
|
|
@@ -7,16 +7,36 @@ module Wardite
|
|
|
7
7
|
|
|
8
8
|
attr_reader ir: Wardite::Efflorescence::IR
|
|
9
9
|
|
|
10
|
-
attr_reader
|
|
10
|
+
attr_reader metrics: Wardite::Efflorescence::Metrics
|
|
11
11
|
|
|
12
|
-
attr_reader
|
|
12
|
+
attr_reader mir_cache_hit: bool
|
|
13
13
|
|
|
14
|
-
attr_reader
|
|
14
|
+
attr_reader mir_cache: Wardite::Efflorescence::MIRCache?
|
|
15
|
+
|
|
16
|
+
# Records a startup snapshot before the first WASI call outside its allowlist.
|
|
17
|
+
attr_accessor snapshot: Wardite::Efflorescence::Snapshot?
|
|
18
|
+
|
|
19
|
+
@global_bits: Array[Integer]
|
|
20
|
+
|
|
21
|
+
@optimized_ir: Wardite::Efflorescence::IR?
|
|
22
|
+
|
|
23
|
+
@semantic_ir: Wardite::Efflorescence::IR?
|
|
15
24
|
|
|
16
25
|
# @rbs instance: Wardite::Instance
|
|
17
26
|
# @rbs disabled_optimizations: Array[Symbol]
|
|
18
27
|
# @rbs profile: bool
|
|
19
|
-
|
|
28
|
+
# @rbs mir_cache: Wardite::Efflorescence::MIRCache?
|
|
29
|
+
# @rbs cached_functions: Array[Function]?
|
|
30
|
+
# @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
|
|
32
|
+
|
|
33
|
+
# A caller explicitly inspecting a cache hit can still request the
|
|
34
|
+
# intermediate forms. Execution continues to use the restored MIR2.
|
|
35
|
+
# @rbs return: Wardite::Efflorescence::IR
|
|
36
|
+
def semantic_ir: () -> Wardite::Efflorescence::IR
|
|
37
|
+
|
|
38
|
+
# @rbs return: Wardite::Efflorescence::IR
|
|
39
|
+
def optimized_ir: () -> Wardite::Efflorescence::IR
|
|
20
40
|
|
|
21
41
|
# @rbs name: String|Symbol
|
|
22
42
|
# @rbs return: bool
|
|
@@ -47,8 +67,23 @@ module Wardite
|
|
|
47
67
|
# @rbs return: String
|
|
48
68
|
def dump_mir: () -> String
|
|
49
69
|
|
|
70
|
+
# Continue a public call restored from a startup snapshot. Each frame
|
|
71
|
+
# resumes at its saved pc: the host call for the top, a return for others.
|
|
72
|
+
# @rbs saved: Array[Wardite::Efflorescence::SavedFrame]
|
|
73
|
+
# @rbs return: void
|
|
74
|
+
def resume: (Array[Wardite::Efflorescence::SavedFrame] saved) -> void
|
|
75
|
+
|
|
50
76
|
private
|
|
51
77
|
|
|
78
|
+
# @rbs translator: Wardite::Efflorescence::Translator
|
|
79
|
+
# @rbs linked: Wardite::Efflorescence::IR
|
|
80
|
+
# @rbs profile: bool
|
|
81
|
+
# @rbs return: Wardite::Efflorescence::IR
|
|
82
|
+
def build_mir: (Wardite::Efflorescence::Translator translator, Wardite::Efflorescence::IR linked, bool profile) -> Wardite::Efflorescence::IR
|
|
83
|
+
|
|
84
|
+
# @rbs return: void
|
|
85
|
+
def restore_inspection_ir: () -> void
|
|
86
|
+
|
|
52
87
|
# @rbs name: String|Symbol
|
|
53
88
|
# @rbs return: Wardite::Efflorescence::FunctionEntry
|
|
54
89
|
def export_entry: (String | Symbol name) -> Wardite::Efflorescence::FunctionEntry
|
|
@@ -107,12 +142,27 @@ module Wardite
|
|
|
107
142
|
# @rbs return: Wardite::Efflorescence::FramePool
|
|
108
143
|
def pool_at: (Array[Wardite::Efflorescence::FramePool] pools, Integer index) -> Wardite::Efflorescence::FramePool
|
|
109
144
|
|
|
145
|
+
# Update in place so a suspended execute_flat retains the same array
|
|
146
|
+
# across a host call, including a reentrant call on this VM.
|
|
147
|
+
# @rbs return: void
|
|
148
|
+
def read_globals: () -> void
|
|
149
|
+
|
|
150
|
+
# @rbs return: void
|
|
151
|
+
def write_globals: () -> void
|
|
152
|
+
|
|
110
153
|
# @rbs host_index: Integer
|
|
111
154
|
# @rbs arguments: Array[Integer]
|
|
112
155
|
# @rbs metrics: Wardite::Efflorescence::Metrics
|
|
156
|
+
# @rbs sources: Array[Integer]?
|
|
113
157
|
# @rbs return: Integer?
|
|
158
|
+
def invoke_host_with_globals: (Integer host_index, Array[Integer] arguments, Wardite::Efflorescence::Metrics metrics, Array[Integer]? sources) -> Integer?
|
|
159
|
+
|
|
160
|
+
# @rbs host_index: Integer
|
|
161
|
+
# @rbs arguments: Array[Integer]
|
|
162
|
+
# @rbs metrics: Wardite::Efflorescence::Metrics
|
|
114
163
|
# @rbs sources: Array[Integer]?
|
|
115
|
-
|
|
164
|
+
# @rbs return: Integer?
|
|
165
|
+
def invoke_host: (Integer host_index, Array[Integer] arguments, Wardite::Efflorescence::Metrics metrics, Array[Integer]? sources) -> Integer?
|
|
116
166
|
|
|
117
167
|
# @rbs host: Wardite::Efflorescence::HostFunction
|
|
118
168
|
# @rbs arguments: Array[Integer]
|
|
@@ -120,13 +170,24 @@ module Wardite
|
|
|
120
170
|
# @rbs return: Integer?
|
|
121
171
|
def invoke_typed_host: (Wardite::Efflorescence::HostFunction host, Array[Integer] arguments, Array[Integer]? sources) -> Integer?
|
|
122
172
|
|
|
123
|
-
# Each public entry owns its frames, pools and counters
|
|
124
|
-
#
|
|
173
|
+
# Each public or start entry owns its frames, pools and counters. Host
|
|
174
|
+
# calls synchronize globals before a callback can re-enter the VM.
|
|
125
175
|
# @rbs entry: Wardite::Efflorescence::FunctionEntry
|
|
126
176
|
# @rbs arguments: Array[Integer]
|
|
127
177
|
# @rbs return: Integer?
|
|
128
178
|
def execute: (Wardite::Efflorescence::FunctionEntry entry, Array[Integer] arguments) -> Integer?
|
|
129
179
|
|
|
180
|
+
# @rbs return: Array[Wardite::Efflorescence::FramePool]
|
|
181
|
+
def new_pools: () -> Array[Wardite::Efflorescence::FramePool]
|
|
182
|
+
|
|
183
|
+
# Globals live in @global_bits while frames run. A restored snapshot
|
|
184
|
+
# writes the Store first, so both public calls and resume read it here.
|
|
185
|
+
# @rbs pools: Array[Wardite::Efflorescence::FramePool]
|
|
186
|
+
# @rbs active_frames: Array[Wardite::Efflorescence::Frame]
|
|
187
|
+
# @rbs root_entries: Integer
|
|
188
|
+
# @rbs return: Integer
|
|
189
|
+
def run_frames: (Array[Wardite::Efflorescence::FramePool] pools, Array[Wardite::Efflorescence::Frame] active_frames, Integer root_entries) -> Integer
|
|
190
|
+
|
|
130
191
|
# @rbs frame: Wardite::Efflorescence::Frame
|
|
131
192
|
# @rbs site: Wardite::Efflorescence::DynamicCallSite
|
|
132
193
|
# @rbs host_index: Integer
|
|
@@ -29,19 +29,6 @@ module Wardite
|
|
|
29
29
|
# @rbs sources: Array[Integer]?
|
|
30
30
|
# @rbs return: bot
|
|
31
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
32
|
end
|
|
46
33
|
end
|
|
47
34
|
end
|
|
@@ -97,11 +97,33 @@ module Wardite
|
|
|
97
97
|
|
|
98
98
|
attr_accessor locals_type: Array[Symbol]
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
attr_writer instruction_bytes: String?
|
|
101
|
+
|
|
102
|
+
attr_writer type_section: TypeSection?
|
|
101
103
|
|
|
102
104
|
# @rbs &blk: (CodeBody) -> void
|
|
103
105
|
# @rbs return: void
|
|
104
106
|
def initialize: () { (CodeBody) -> void } -> void
|
|
107
|
+
|
|
108
|
+
# @rbs return: Array[[Symbol, Symbol, Array[operandItem], Integer?, Integer?]]
|
|
109
|
+
def body: () -> Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]]
|
|
110
|
+
|
|
111
|
+
# @rbs instructions: Array[[Symbol, Symbol, Array[operandItem], Integer?, Integer?]]
|
|
112
|
+
# @rbs return: void
|
|
113
|
+
def body=: (Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]] instructions) -> void
|
|
114
|
+
|
|
115
|
+
# @rbs types: TypeSection?
|
|
116
|
+
# @rbs stack: bool
|
|
117
|
+
# @rbs return: void
|
|
118
|
+
def check_features: (TypeSection? types, bool stack) -> void
|
|
119
|
+
|
|
120
|
+
private
|
|
121
|
+
|
|
122
|
+
# @rbs instructions: Array[[Symbol, Symbol, Array[operandItem], Integer?, Integer?]]
|
|
123
|
+
# @rbs types: TypeSection?
|
|
124
|
+
# @rbs stack: bool
|
|
125
|
+
# @rbs return: void
|
|
126
|
+
def check_instructions: (Array[[ Symbol, Symbol, Array[operandItem], Integer?, Integer? ]] instructions, TypeSection? types, bool stack) -> void
|
|
105
127
|
end
|
|
106
128
|
|
|
107
129
|
attr_accessor func_codes: Array[CodeBody]
|
|
@@ -188,14 +210,17 @@ module Wardite
|
|
|
188
210
|
# @rbs engine: Symbol
|
|
189
211
|
# @rbs disabled_optimizations: Array[Symbol]
|
|
190
212
|
# @rbs mir_profile: bool
|
|
213
|
+
# @rbs mir_cache: String?
|
|
214
|
+
# @rbs mir_cache_verify: Symbol
|
|
191
215
|
# @rbs return: 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
|
|
216
|
+
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, ?mir_cache: String?, ?mir_cache_verify: Symbol) -> Instance
|
|
193
217
|
|
|
194
218
|
# @rbs return: Integer
|
|
195
219
|
def self.preamble: () -> Integer
|
|
196
220
|
|
|
221
|
+
# @rbs defer_code: bool
|
|
197
222
|
# @rbs return: Array[Section]
|
|
198
|
-
def self.sections: () -> Array[Section]
|
|
223
|
+
def self.sections: (?bool defer_code) -> Array[Section]
|
|
199
224
|
|
|
200
225
|
# @rbs return: TypeSection
|
|
201
226
|
def self.type_section: () -> TypeSection
|
|
@@ -224,12 +249,14 @@ module Wardite
|
|
|
224
249
|
# @rbs return: TableSection
|
|
225
250
|
def self.table_section: () -> TableSection
|
|
226
251
|
|
|
252
|
+
# @rbs defer_code: bool
|
|
227
253
|
# @rbs return: CodeSection
|
|
228
|
-
def self.code_section: () -> CodeSection
|
|
254
|
+
def self.code_section: (?bool defer_code) -> CodeSection
|
|
229
255
|
|
|
230
256
|
# @rbs sbuf: StringIO
|
|
257
|
+
# @rbs defer_code: bool
|
|
231
258
|
# @rbs return: CodeSection::CodeBody
|
|
232
|
-
def self.read_function_body: (StringIO sbuf) -> CodeSection::CodeBody
|
|
259
|
+
def self.read_function_body: (StringIO sbuf, ?bool defer_code) -> CodeSection::CodeBody
|
|
233
260
|
|
|
234
261
|
# @rbs buf: StringIO
|
|
235
262
|
# @rbs return: Array[[Symbol, Symbol, Array[operandItem], Integer?, Integer?]]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Generated from lib/wardite/wasi/spinel.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Wardite
|
|
4
|
+
module Wasi
|
|
5
|
+
module Native
|
|
6
|
+
def self.ffi_source: (String) -> void
|
|
7
|
+
|
|
8
|
+
def self.ffi_func: (Symbol, Array[Symbol], Symbol) -> void
|
|
9
|
+
|
|
10
|
+
def self.wardite_wasi_getfl: (Integer) -> Integer
|
|
11
|
+
|
|
12
|
+
def self.wardite_wasi_errno: (Integer) -> Integer
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|