@fluffylabs/anan-as 1.1.3-dde58f0 → 1.1.3-dffbae7
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.
- package/README.md +47 -10
- package/dist/bin/index.js +97 -42
- package/dist/bin/{fuzz.js → src/fuzz.js} +4 -21
- package/dist/bin/src/log-host-call.js +41 -0
- package/dist/bin/src/trace-parse.js +315 -0
- package/dist/bin/src/trace-replay.js +130 -0
- package/dist/bin/src/tracer.js +64 -0
- package/dist/bin/src/utils.js +25 -0
- package/dist/bin/test.js +1 -3
- package/dist/build/compiler-inline.js +1 -1
- package/dist/build/compiler.wasm +0 -0
- package/dist/build/debug-inline.js +1 -1
- package/dist/build/debug-raw-inline.js +1 -1
- package/dist/build/debug-raw.d.ts +121 -42
- package/dist/build/debug-raw.js +109 -48
- package/dist/build/debug-raw.wasm +0 -0
- package/dist/build/debug.d.ts +121 -42
- package/dist/build/debug.js +119 -50
- package/dist/build/debug.wasm +0 -0
- package/dist/build/release-inline.js +1 -1
- package/dist/build/release-mini-inline.js +1 -1
- package/dist/build/release-mini.d.ts +121 -42
- package/dist/build/release-mini.js +119 -50
- package/dist/build/release-mini.wasm +0 -0
- package/dist/build/release-stub-inline.js +1 -1
- package/dist/build/release-stub.d.ts +121 -42
- package/dist/build/release-stub.js +119 -50
- package/dist/build/release-stub.wasm +0 -0
- package/dist/build/release.d.ts +121 -42
- package/dist/build/release.js +119 -50
- package/dist/build/release.wasm +0 -0
- package/dist/build/test-inline.js +1 -1
- package/dist/build/test.wasm +0 -0
- package/dist/test/test-as.js +3 -0
- package/dist/{bin → test}/test-gas-cost.js +1 -1
- package/dist/test/test-trace-replay.js +19 -0
- package/dist/{bin → test}/test-w3f.js +2 -2
- package/package.json +5 -5
- /package/dist/bin/{test-json.js → src/test-json.js} +0 -0
package/dist/build/release.js
CHANGED
|
@@ -113,24 +113,11 @@ async function instantiate(module, imports = {}) {
|
|
|
113
113
|
p = __lowerInternref(p) || __notnull();
|
|
114
114
|
return __liftString(exports.getAssembly(p) >>> 0);
|
|
115
115
|
},
|
|
116
|
-
runVm(input, logs, useSbrkGas) {
|
|
117
|
-
// assembly/api-internal/runVm(assembly/api-types/VmInput, bool?, bool?) => assembly/api-types/VmOutput
|
|
118
|
-
input = __lowerInternref(input) || __notnull();
|
|
119
|
-
logs = logs ? 1 : 0;
|
|
120
|
-
useSbrkGas = useSbrkGas ? 1 : 0;
|
|
121
|
-
exports.__setArgumentsLength(arguments.length);
|
|
122
|
-
return __liftRecord49(exports.runVm(input, logs, useSbrkGas) >>> 0);
|
|
123
|
-
},
|
|
124
|
-
getOutputChunks(memory) {
|
|
125
|
-
// assembly/api-internal/getOutputChunks(assembly/memory/Memory) => ~lib/array/Array<assembly/api-types/InitialChunk>
|
|
126
|
-
memory = __lowerInternref(memory) || __notnull();
|
|
127
|
-
return __liftArray(pointer => __liftRecord45(__getU32(pointer)), 2, exports.getOutputChunks(memory) >>> 0);
|
|
128
|
-
},
|
|
129
116
|
buildMemory(builder, pages, chunks) {
|
|
130
117
|
// assembly/api-internal/buildMemory(assembly/memory/MemoryBuilder, ~lib/array/Array<assembly/api-types/InitialPage>, ~lib/array/Array<assembly/api-types/InitialChunk>) => assembly/memory/Memory
|
|
131
118
|
builder = __retain(__lowerInternref(builder) || __notnull());
|
|
132
|
-
pages = __retain(__lowerArray((pointer, value) => { __setU32(pointer,
|
|
133
|
-
chunks = __lowerArray((pointer, value) => { __setU32(pointer,
|
|
119
|
+
pages = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord44(value) || __notnull()); }, 45, 2, pages) || __notnull());
|
|
120
|
+
chunks = __lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord46(value) || __notnull()); }, 47, 2, chunks) || __notnull();
|
|
134
121
|
try {
|
|
135
122
|
return __liftInternref(exports.buildMemory(builder, pages, chunks) >>> 0);
|
|
136
123
|
} finally {
|
|
@@ -138,6 +125,35 @@ async function instantiate(module, imports = {}) {
|
|
|
138
125
|
__release(pages);
|
|
139
126
|
}
|
|
140
127
|
},
|
|
128
|
+
vmInit(input, useSbrkGas) {
|
|
129
|
+
// assembly/api-internal/vmInit(assembly/api-types/VmInput, bool?) => assembly/interpreter/Interpreter
|
|
130
|
+
input = __lowerInternref(input) || __notnull();
|
|
131
|
+
useSbrkGas = useSbrkGas ? 1 : 0;
|
|
132
|
+
exports.__setArgumentsLength(arguments.length);
|
|
133
|
+
return __liftInternref(exports.vmInit(input, useSbrkGas) >>> 0);
|
|
134
|
+
},
|
|
135
|
+
vmRunOnce(input, logs, useSbrkGas) {
|
|
136
|
+
// assembly/api-internal/vmRunOnce(assembly/api-types/VmInput, bool?, bool?) => assembly/api-types/VmOutput
|
|
137
|
+
input = __lowerInternref(input) || __notnull();
|
|
138
|
+
logs = logs ? 1 : 0;
|
|
139
|
+
useSbrkGas = useSbrkGas ? 1 : 0;
|
|
140
|
+
exports.__setArgumentsLength(arguments.length);
|
|
141
|
+
return __liftRecord50(exports.vmRunOnce(input, logs, useSbrkGas) >>> 0);
|
|
142
|
+
},
|
|
143
|
+
vmExecute(int, logs) {
|
|
144
|
+
// assembly/api-internal/vmExecute(assembly/interpreter/Interpreter, bool?) => void
|
|
145
|
+
int = __lowerInternref(int) || __notnull();
|
|
146
|
+
logs = logs ? 1 : 0;
|
|
147
|
+
exports.__setArgumentsLength(arguments.length);
|
|
148
|
+
exports.vmExecute(int, logs);
|
|
149
|
+
},
|
|
150
|
+
vmDestroy(int, dumpMemory) {
|
|
151
|
+
// assembly/api-internal/vmDestroy(assembly/interpreter/Interpreter, bool?) => assembly/api-types/VmOutput
|
|
152
|
+
int = __lowerInternref(int) || __notnull();
|
|
153
|
+
dumpMemory = dumpMemory ? 1 : 0;
|
|
154
|
+
exports.__setArgumentsLength(arguments.length);
|
|
155
|
+
return __liftRecord50(exports.vmDestroy(int, dumpMemory) >>> 0);
|
|
156
|
+
},
|
|
141
157
|
InputKind: (values => (
|
|
142
158
|
// assembly/api-utils/InputKind
|
|
143
159
|
values[values.Generic = exports["InputKind.Generic"].valueOf()] = "Generic",
|
|
@@ -153,22 +169,22 @@ async function instantiate(module, imports = {}) {
|
|
|
153
169
|
getGasCosts(input, kind, withMetadata) {
|
|
154
170
|
// assembly/api-utils/getGasCosts(~lib/array/Array<u8>, i32, i32) => ~lib/array/Array<assembly/gas-costs/BlockGasCost>
|
|
155
171
|
input = __lowerArray(__setU8, 6, 0, input) || __notnull();
|
|
156
|
-
return __liftArray(pointer =>
|
|
172
|
+
return __liftArray(pointer => __liftRecord55(__getU32(pointer)), 2, exports.getGasCosts(input, kind, withMetadata) >>> 0);
|
|
157
173
|
},
|
|
158
174
|
disassemble(input, kind, withMetadata) {
|
|
159
175
|
// assembly/api-utils/disassemble(~lib/array/Array<u8>, i32, i32) => ~lib/string/String
|
|
160
176
|
input = __lowerArray(__setU8, 6, 0, input) || __notnull();
|
|
161
177
|
return __liftString(exports.disassemble(input, kind, withMetadata) >>> 0);
|
|
162
178
|
},
|
|
163
|
-
prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args) {
|
|
164
|
-
// assembly/api-utils/prepareProgram(i32, i32, ~lib/array/Array<u8>, ~lib/array/Array<u64>, ~lib/array/Array<assembly/api-types/InitialPage>, ~lib/array/Array<assembly/api-types/InitialChunk>, ~lib/array/Array<u8
|
|
179
|
+
prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args, preallocateMemoryPages) {
|
|
180
|
+
// assembly/api-utils/prepareProgram(i32, i32, ~lib/array/Array<u8>, ~lib/array/Array<u64>, ~lib/array/Array<assembly/api-types/InitialPage>, ~lib/array/Array<assembly/api-types/InitialChunk>, ~lib/array/Array<u8>, u32) => assembly/spi/StandardProgram
|
|
165
181
|
program = __retain(__lowerArray(__setU8, 6, 0, program) || __notnull());
|
|
166
|
-
initialRegisters = __retain(__lowerArray(__setU64,
|
|
167
|
-
initialPageMap = __retain(__lowerArray((pointer, value) => { __setU32(pointer,
|
|
168
|
-
initialMemory = __retain(__lowerArray((pointer, value) => { __setU32(pointer,
|
|
182
|
+
initialRegisters = __retain(__lowerArray(__setU64, 51, 3, initialRegisters) || __notnull());
|
|
183
|
+
initialPageMap = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord44(value) || __notnull()); }, 45, 2, initialPageMap) || __notnull());
|
|
184
|
+
initialMemory = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord46(value) || __notnull()); }, 47, 2, initialMemory) || __notnull());
|
|
169
185
|
args = __lowerArray(__setU8, 6, 0, args) || __notnull();
|
|
170
186
|
try {
|
|
171
|
-
return __liftInternref(exports.prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args) >>> 0);
|
|
187
|
+
return __liftInternref(exports.prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args, preallocateMemoryPages) >>> 0);
|
|
172
188
|
} finally {
|
|
173
189
|
__release(program);
|
|
174
190
|
__release(initialRegisters);
|
|
@@ -183,7 +199,39 @@ async function instantiate(module, imports = {}) {
|
|
|
183
199
|
logs = logs ? 1 : 0;
|
|
184
200
|
useSbrkGas = useSbrkGas ? 1 : 0;
|
|
185
201
|
exports.__setArgumentsLength(arguments.length);
|
|
186
|
-
return
|
|
202
|
+
return __liftRecord50(exports.runProgram(program, initialGas, programCounter, logs, useSbrkGas) >>> 0);
|
|
203
|
+
},
|
|
204
|
+
pvmStart(program, useSbrkGas) {
|
|
205
|
+
// assembly/api-utils/pvmStart(assembly/spi/StandardProgram, bool?) => u32
|
|
206
|
+
program = __lowerInternref(program) || __notnull();
|
|
207
|
+
useSbrkGas = useSbrkGas ? 1 : 0;
|
|
208
|
+
exports.__setArgumentsLength(arguments.length);
|
|
209
|
+
return exports.pvmStart(program, useSbrkGas) >>> 0;
|
|
210
|
+
},
|
|
211
|
+
pvmDestroy(pvmId) {
|
|
212
|
+
// assembly/api-utils/pvmDestroy(u32) => assembly/api-types/VmOutput | null
|
|
213
|
+
return __liftRecord50(exports.pvmDestroy(pvmId) >>> 0);
|
|
214
|
+
},
|
|
215
|
+
pvmSetRegisters(pvmId, registers) {
|
|
216
|
+
// assembly/api-utils/pvmSetRegisters(u32, ~lib/array/Array<u64>) => void
|
|
217
|
+
registers = __lowerArray(__setU64, 51, 3, registers) || __notnull();
|
|
218
|
+
exports.pvmSetRegisters(pvmId, registers);
|
|
219
|
+
},
|
|
220
|
+
pvmReadMemory(pvmId, address, length) {
|
|
221
|
+
// assembly/api-utils/pvmReadMemory(u32, u32, u32) => ~lib/typedarray/Uint8Array | null
|
|
222
|
+
return __liftTypedArray(Uint8Array, exports.pvmReadMemory(pvmId, address, length) >>> 0);
|
|
223
|
+
},
|
|
224
|
+
pvmWriteMemory(pvmId, address, data) {
|
|
225
|
+
// assembly/api-utils/pvmWriteMemory(u32, u32, ~lib/typedarray/Uint8Array) => bool
|
|
226
|
+
data = __lowerTypedArray(Uint8Array, 10, 0, data) || __notnull();
|
|
227
|
+
return exports.pvmWriteMemory(pvmId, address, data) != 0;
|
|
228
|
+
},
|
|
229
|
+
pvmResume(pvmId, gas, pc, logs) {
|
|
230
|
+
// assembly/api-utils/pvmResume(u32, i64, u32, bool?) => assembly/api-types/VmPause | null
|
|
231
|
+
gas = gas || 0n;
|
|
232
|
+
logs = logs ? 1 : 0;
|
|
233
|
+
exports.__setArgumentsLength(arguments.length);
|
|
234
|
+
return __liftRecord59(exports.pvmResume(pvmId, gas, pc, logs) >>> 0);
|
|
187
235
|
},
|
|
188
236
|
wrapAsProgram(bytecode) {
|
|
189
237
|
// assembly/program-build/wrapAsProgram(~lib/typedarray/Uint8Array) => ~lib/typedarray/Uint8Array
|
|
@@ -191,7 +239,28 @@ async function instantiate(module, imports = {}) {
|
|
|
191
239
|
return __liftTypedArray(Uint8Array, exports.wrapAsProgram(bytecode) >>> 0);
|
|
192
240
|
},
|
|
193
241
|
}, exports);
|
|
194
|
-
function
|
|
242
|
+
function __lowerRecord44(value) {
|
|
243
|
+
// assembly/api-types/InitialPage
|
|
244
|
+
// Hint: Opt-out from lowering as a record by providing an empty constructor
|
|
245
|
+
if (value == null) return 0;
|
|
246
|
+
const pointer = exports.__pin(exports.__new(12, 44));
|
|
247
|
+
__setU32(pointer + 0, value.address);
|
|
248
|
+
__setU32(pointer + 4, value.length);
|
|
249
|
+
__setU32(pointer + 8, value.access);
|
|
250
|
+
exports.__unpin(pointer);
|
|
251
|
+
return pointer;
|
|
252
|
+
}
|
|
253
|
+
function __lowerRecord46(value) {
|
|
254
|
+
// assembly/api-types/InitialChunk
|
|
255
|
+
// Hint: Opt-out from lowering as a record by providing an empty constructor
|
|
256
|
+
if (value == null) return 0;
|
|
257
|
+
const pointer = exports.__pin(exports.__new(8, 46));
|
|
258
|
+
__setU32(pointer + 0, value.address);
|
|
259
|
+
__setU32(pointer + 4, __lowerArray(__setU8, 6, 0, value.data) || __notnull());
|
|
260
|
+
exports.__unpin(pointer);
|
|
261
|
+
return pointer;
|
|
262
|
+
}
|
|
263
|
+
function __liftRecord46(pointer) {
|
|
195
264
|
// assembly/api-types/InitialChunk
|
|
196
265
|
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
197
266
|
if (!pointer) return null;
|
|
@@ -200,7 +269,7 @@ async function instantiate(module, imports = {}) {
|
|
|
200
269
|
data: __liftArray(__getU8, 0, __getU32(pointer + 4)),
|
|
201
270
|
};
|
|
202
271
|
}
|
|
203
|
-
function
|
|
272
|
+
function __liftRecord50(pointer) {
|
|
204
273
|
// assembly/api-types/VmOutput
|
|
205
274
|
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
206
275
|
if (!pointer) return null;
|
|
@@ -211,31 +280,10 @@ async function instantiate(module, imports = {}) {
|
|
|
211
280
|
gas: __getI64(pointer + 16),
|
|
212
281
|
result: __liftArray(__getU8, 0, __getU32(pointer + 24)),
|
|
213
282
|
registers: __liftArray(pointer => BigInt.asUintN(64, __getU64(pointer)), 3, __getU32(pointer + 28)),
|
|
214
|
-
memory: __liftArray(pointer =>
|
|
283
|
+
memory: __liftArray(pointer => __liftRecord46(__getU32(pointer)), 2, __getU32(pointer + 32)),
|
|
215
284
|
};
|
|
216
285
|
}
|
|
217
|
-
function
|
|
218
|
-
// assembly/api-types/InitialPage
|
|
219
|
-
// Hint: Opt-out from lowering as a record by providing an empty constructor
|
|
220
|
-
if (value == null) return 0;
|
|
221
|
-
const pointer = exports.__pin(exports.__new(12, 43));
|
|
222
|
-
__setU32(pointer + 0, value.address);
|
|
223
|
-
__setU32(pointer + 4, value.length);
|
|
224
|
-
__setU32(pointer + 8, value.access);
|
|
225
|
-
exports.__unpin(pointer);
|
|
226
|
-
return pointer;
|
|
227
|
-
}
|
|
228
|
-
function __lowerRecord45(value) {
|
|
229
|
-
// assembly/api-types/InitialChunk
|
|
230
|
-
// Hint: Opt-out from lowering as a record by providing an empty constructor
|
|
231
|
-
if (value == null) return 0;
|
|
232
|
-
const pointer = exports.__pin(exports.__new(8, 45));
|
|
233
|
-
__setU32(pointer + 0, value.address);
|
|
234
|
-
__setU32(pointer + 4, __lowerArray(__setU8, 6, 0, value.data) || __notnull());
|
|
235
|
-
exports.__unpin(pointer);
|
|
236
|
-
return pointer;
|
|
237
|
-
}
|
|
238
|
-
function __liftRecord54(pointer) {
|
|
286
|
+
function __liftRecord55(pointer) {
|
|
239
287
|
// assembly/gas-costs/BlockGasCost
|
|
240
288
|
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
241
289
|
if (!pointer) return null;
|
|
@@ -244,6 +292,19 @@ async function instantiate(module, imports = {}) {
|
|
|
244
292
|
gas: __getU64(pointer + 8),
|
|
245
293
|
};
|
|
246
294
|
}
|
|
295
|
+
function __liftRecord59(pointer) {
|
|
296
|
+
// assembly/api-types/VmPause
|
|
297
|
+
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
298
|
+
if (!pointer) return null;
|
|
299
|
+
return {
|
|
300
|
+
status: __getI32(pointer + 0),
|
|
301
|
+
exitCode: __getU32(pointer + 4),
|
|
302
|
+
pc: __getU32(pointer + 8),
|
|
303
|
+
nextPc: __getU32(pointer + 12),
|
|
304
|
+
gas: __getI64(pointer + 16),
|
|
305
|
+
registers: __liftArray(pointer => BigInt.asUintN(64, __getU64(pointer)), 3, __getU32(pointer + 24)),
|
|
306
|
+
};
|
|
307
|
+
}
|
|
247
308
|
function __liftString(pointer) {
|
|
248
309
|
if (!pointer) return null;
|
|
249
310
|
const
|
|
@@ -419,15 +480,23 @@ export const {
|
|
|
419
480
|
getMemory,
|
|
420
481
|
setMemory,
|
|
421
482
|
getAssembly,
|
|
422
|
-
runVm,
|
|
423
|
-
getOutputChunks,
|
|
424
483
|
buildMemory,
|
|
484
|
+
vmInit,
|
|
485
|
+
vmRunOnce,
|
|
486
|
+
vmExecute,
|
|
487
|
+
vmDestroy,
|
|
425
488
|
InputKind,
|
|
426
489
|
HasMetadata,
|
|
427
490
|
getGasCosts,
|
|
428
491
|
disassemble,
|
|
429
492
|
prepareProgram,
|
|
430
493
|
runProgram,
|
|
494
|
+
pvmStart,
|
|
495
|
+
pvmDestroy,
|
|
496
|
+
pvmSetRegisters,
|
|
497
|
+
pvmReadMemory,
|
|
498
|
+
pvmWriteMemory,
|
|
499
|
+
pvmResume,
|
|
431
500
|
wrapAsProgram,
|
|
432
501
|
} = await (async url => instantiate(
|
|
433
502
|
await (async () => {
|
package/dist/build/release.wasm
CHANGED
|
Binary file
|