@fluffylabs/anan-as 1.2.0-41e43f6 → 1.2.0-5196d29
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/dist/bin/index.js +3 -2
- package/dist/bin/src/fuzz.js +1 -1
- package/dist/bin/src/test-json.js +2 -6
- package/dist/bin/src/trace-replay.js +8 -4
- package/dist/build/compiler-inline.js +1 -1
- package/dist/build/compiler.d.ts +2 -13
- package/dist/build/compiler.js +1 -25
- 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 +27 -25
- package/dist/build/debug-raw.js +58 -57
- package/dist/build/debug-raw.wasm +0 -0
- package/dist/build/debug.d.ts +27 -25
- package/dist/build/debug.js +59 -58
- package/dist/build/debug.wasm +0 -0
- package/dist/build/js/assembly/api-debugger.d.ts +3 -3
- package/dist/build/js/assembly/api-debugger.js +6 -6
- package/dist/build/js/assembly/api-internal.d.ts +1 -1
- package/dist/build/js/assembly/api-internal.js +2 -3
- package/dist/build/js/assembly/api-types.d.ts +0 -1
- package/dist/build/js/assembly/api-types.js +0 -1
- package/dist/build/js/assembly/api-utils.d.ts +12 -5
- package/dist/build/js/assembly/api-utils.js +28 -13
- package/dist/build/js/assembly/arguments.d.ts +4 -4
- package/dist/build/js/assembly/arguments.js +10 -10
- package/dist/build/js/assembly/gas.d.ts +1 -1
- package/dist/build/js/assembly/gas.js +3 -2
- package/dist/build/js/assembly/instructions/bit.js +22 -22
- package/dist/build/js/assembly/instructions/branch.js +56 -56
- package/dist/build/js/assembly/instructions/jump.js +10 -10
- package/dist/build/js/assembly/instructions/load.js +41 -41
- package/dist/build/js/assembly/instructions/logic.js +20 -20
- package/dist/build/js/assembly/instructions/math.js +105 -105
- package/dist/build/js/assembly/instructions/misc.js +10 -10
- package/dist/build/js/assembly/instructions/mov.js +16 -16
- package/dist/build/js/assembly/instructions/outcome.d.ts +7 -7
- package/dist/build/js/assembly/instructions/outcome.js +63 -36
- package/dist/build/js/assembly/instructions/rot.js +18 -18
- package/dist/build/js/assembly/instructions/set.js +18 -18
- package/dist/build/js/assembly/instructions/shift.js +59 -59
- package/dist/build/js/assembly/instructions/store.js +29 -29
- package/dist/build/js/assembly/instructions/utils.d.ts +6 -4
- package/dist/build/js/assembly/instructions/utils.js +32 -16
- package/dist/build/js/assembly/instructions.d.ts +2 -3
- package/dist/build/js/assembly/instructions.js +4 -4
- package/dist/build/js/assembly/interpreter.d.ts +0 -1
- package/dist/build/js/assembly/interpreter.js +15 -22
- package/dist/build/js/assembly/math.d.ts +6 -8
- package/dist/build/js/assembly/math.js +21 -13
- package/dist/build/js/assembly/memory.js +9 -7
- package/dist/build/js/assembly/portable.js +1 -0
- package/dist/build/js/assembly/program-build.js +4 -4
- package/dist/build/js/assembly/program.d.ts +15 -8
- package/dist/build/js/assembly/program.js +90 -40
- package/dist/build/js/assembly/spi.d.ts +1 -1
- package/dist/build/js/assembly/spi.js +2 -2
- package/dist/build/js/portable-bundle.js +666 -579
- package/dist/build/release-inline.js +1 -1
- package/dist/build/release-mini-inline.js +1 -1
- package/dist/build/release-mini.d.ts +27 -25
- package/dist/build/release-mini.js +59 -58
- package/dist/build/release-mini.wasm +0 -0
- package/dist/build/release-stub-inline.js +1 -1
- package/dist/build/release-stub.d.ts +27 -25
- package/dist/build/release-stub.js +59 -58
- package/dist/build/release-stub.wasm +0 -0
- package/dist/build/release.d.ts +27 -25
- package/dist/build/release.js +59 -58
- 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-gas-cost.js +2 -3
- package/dist/test/test-w3f-common.js +1 -2
- package/package.json +7 -7
- package/dist/build/js/assembly/gas-costs.d.ts +0 -6
- package/dist/build/js/assembly/gas-costs.js +0 -39
package/dist/build/test.wasm
CHANGED
|
Binary file
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "json-bigint-patch";
|
|
3
3
|
import * as assert from "node:assert";
|
|
4
4
|
import { ERR, OK, read, run } from "../bin/src/test-json.js";
|
|
5
|
-
import { disassemble,
|
|
5
|
+
import { disassemble, getBlockGasCosts, HasMetadata, InputKind } from "../build/release.js";
|
|
6
6
|
// Run the CLI application
|
|
7
7
|
main();
|
|
8
8
|
// Main function
|
|
@@ -10,7 +10,6 @@ function main() {
|
|
|
10
10
|
const options = {
|
|
11
11
|
isDebug: false,
|
|
12
12
|
isSilent: false,
|
|
13
|
-
useSbrkGas: false,
|
|
14
13
|
};
|
|
15
14
|
run(processGasCost, options);
|
|
16
15
|
}
|
|
@@ -29,7 +28,7 @@ function processGasCost(data, options, filePath) {
|
|
|
29
28
|
console.info(assembly);
|
|
30
29
|
console.info("\n^^^^^^^^^^^\n");
|
|
31
30
|
}
|
|
32
|
-
const result = asMap(
|
|
31
|
+
const result = asMap(getBlockGasCosts(input.program, InputKind.Generic, HasMetadata.No));
|
|
33
32
|
// silent mode - just put our vals into expected (comparison done externally)
|
|
34
33
|
if (options.isSilent) {
|
|
35
34
|
data.block_gas_costs = result;
|
|
@@ -20,7 +20,6 @@ export function runW3fTests(pvm) {
|
|
|
20
20
|
const options = {
|
|
21
21
|
isDebug: false,
|
|
22
22
|
isSilent: false,
|
|
23
|
-
useSbrkGas: false,
|
|
24
23
|
};
|
|
25
24
|
run((data, opts, filePath) => processW3f(pvm, data, opts, filePath), options);
|
|
26
25
|
}
|
|
@@ -50,7 +49,7 @@ function processW3f(pvm, data, options, _filePath) {
|
|
|
50
49
|
console.info("\n^^^^^^^^^^^\n");
|
|
51
50
|
}
|
|
52
51
|
const exe = pvm.prepareProgram(pvm.InputKind.Generic, pvm.HasMetadata.No, input.program, input.registers, input.pageMap, input.memory, [], 16);
|
|
53
|
-
const result = pvm.runProgram(exe, input.gas, input.pc, options.isDebug,
|
|
52
|
+
const result = pvm.runProgram(exe, input.gas, input.pc, options.isDebug, true);
|
|
54
53
|
const status = statusAsString(result.status);
|
|
55
54
|
// Normalize registers to plain unsigned BigInt array for comparison.
|
|
56
55
|
// The portable build may store signed BigInts or plain numbers in registers.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluffylabs/anan-as",
|
|
3
3
|
"description": "AssemblyScript PVM interpreter.",
|
|
4
|
-
"version": "1.2.0-
|
|
4
|
+
"version": "1.2.0-5196d29",
|
|
5
5
|
"main": "./dist/bin/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"anan-as": "./dist/bin/index.js"
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
"node": ">=18.3.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@biomejs/biome": "^2.4.
|
|
57
|
-
"@typeberry/lib": "^0.5.
|
|
58
|
-
"@types/node": "^25.
|
|
59
|
-
"assemblyscript": "^0.28.
|
|
60
|
-
"esbuild": "^0.27.
|
|
56
|
+
"@biomejs/biome": "^2.4.5",
|
|
57
|
+
"@typeberry/lib": "^0.5.8",
|
|
58
|
+
"@types/node": "^25.3.3",
|
|
59
|
+
"assemblyscript": "^0.28.9",
|
|
60
|
+
"esbuild": "^0.27.3",
|
|
61
61
|
"json-bigint-patch": "^0.0.8",
|
|
62
|
-
"tsx": "^4.
|
|
62
|
+
"tsx": "^4.21.0",
|
|
63
63
|
"typescript": "^5.9.3"
|
|
64
64
|
},
|
|
65
65
|
"files": [
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { INSTRUCTIONS, MISSING_INSTRUCTION } from "./instructions";
|
|
2
|
-
import { portable } from "./portable";
|
|
3
|
-
export class BlockGasCost {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.pc = 0;
|
|
6
|
-
this.gas = u64(0);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export function computeGasCosts(p) {
|
|
10
|
-
const len = p.code.length;
|
|
11
|
-
const blocks = new Map();
|
|
12
|
-
let currentBlock = null;
|
|
13
|
-
for (let i = 0; i < len; i++) {
|
|
14
|
-
if (!p.mask.isInstruction(i)) {
|
|
15
|
-
throw new Error("We should iterate only over instructions!");
|
|
16
|
-
}
|
|
17
|
-
const instruction = p.code[i];
|
|
18
|
-
const iData = instruction >= INSTRUCTIONS.length ? MISSING_INSTRUCTION : INSTRUCTIONS[instruction];
|
|
19
|
-
if (p.basicBlocks.isStart(i)) {
|
|
20
|
-
if (currentBlock !== null) {
|
|
21
|
-
blocks.set(currentBlock.pc, currentBlock);
|
|
22
|
-
}
|
|
23
|
-
currentBlock = new BlockGasCost();
|
|
24
|
-
currentBlock.pc = i;
|
|
25
|
-
}
|
|
26
|
-
if (currentBlock !== null) {
|
|
27
|
-
// add gas for current instruction
|
|
28
|
-
currentBlock.gas = portable.u64_add(currentBlock.gas, iData.gas);
|
|
29
|
-
}
|
|
30
|
-
// move forward
|
|
31
|
-
const skipBytes = p.mask.skipBytesToNextInstruction(i);
|
|
32
|
-
i += skipBytes;
|
|
33
|
-
}
|
|
34
|
-
// add the final block
|
|
35
|
-
if (currentBlock !== null) {
|
|
36
|
-
blocks.set(currentBlock.pc, currentBlock);
|
|
37
|
-
}
|
|
38
|
-
return blocks;
|
|
39
|
-
}
|