@fluffylabs/anan-as 1.3.0 → 1.4.0-0f6fa2d

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.
@@ -21,8 +21,9 @@ declare namespace __AdaptedExports {
21
21
  * @param args `~lib/array/Array<u8>`
22
22
  * @param hasMetadata `bool`
23
23
  * @param useBlockGas `bool`
24
+ * @param preallocateMemoryPages `u32`
24
25
  */
25
- export function resetJAM(program: Array<number>, pc: number, initialGas: bigint, args: Array<number>, hasMetadata?: boolean, useBlockGas?: boolean): void;
26
+ export function resetJAM(program: Array<number>, pc: number, initialGas: bigint, args: Array<number>, hasMetadata?: boolean, useBlockGas?: boolean, preallocateMemoryPages?: number): void;
26
27
  /**
27
28
  * assembly/api-debugger/resetGeneric
28
29
  * @param program `~lib/array/Array<u8>`
@@ -41,8 +42,9 @@ declare namespace __AdaptedExports {
41
42
  * @param initialGas `u64`
42
43
  * @param hasMetadata `bool`
43
44
  * @param useBlockGas `bool`
45
+ * @param preallocateMemoryPages `u32`
44
46
  */
45
- export function resetGenericWithMemory(program: Array<number>, flatRegisters: Array<number>, pageMap: Uint8Array, chunks: Uint8Array, initialGas: bigint, hasMetadata?: boolean, useBlockGas?: boolean): void;
47
+ export function resetGenericWithMemory(program: Array<number>, flatRegisters: Array<number>, pageMap: Uint8Array, chunks: Uint8Array, initialGas: bigint, hasMetadata?: boolean, useBlockGas?: boolean, preallocateMemoryPages?: number): void;
46
48
  /**
47
49
  * assembly/api-debugger/nextStep
48
50
  * @returns `bool`
@@ -32,8 +32,8 @@ export async function instantiate(module, imports = {}) {
32
32
  bytecode = __lowerTypedArray(Uint8Array, 15, 0, bytecode) || __notnull();
33
33
  return __liftTypedArray(Uint8Array, exports.wrapAsProgram(bytecode) >>> 0);
34
34
  },
35
- resetJAM(program, pc, initialGas, args, hasMetadata, useBlockGas) {
36
- // assembly/api-debugger/resetJAM(~lib/array/Array<u8>, u32, u64, ~lib/array/Array<u8>, bool?, bool?) => void
35
+ resetJAM(program, pc, initialGas, args, hasMetadata, useBlockGas, preallocateMemoryPages) {
36
+ // assembly/api-debugger/resetJAM(~lib/array/Array<u8>, u32, u64, ~lib/array/Array<u8>, bool?, bool?, u32?) => void
37
37
  program = __retain(__lowerArray(__setU8, 32, 0, program) || __notnull());
38
38
  initialGas = initialGas || 0n;
39
39
  args = __lowerArray(__setU8, 32, 0, args) || __notnull();
@@ -41,7 +41,7 @@ export async function instantiate(module, imports = {}) {
41
41
  useBlockGas = useBlockGas ? 1 : 0;
42
42
  try {
43
43
  exports.__setArgumentsLength(arguments.length);
44
- exports.resetJAM(program, pc, initialGas, args, hasMetadata, useBlockGas);
44
+ exports.resetJAM(program, pc, initialGas, args, hasMetadata, useBlockGas, preallocateMemoryPages);
45
45
  } finally {
46
46
  __release(program);
47
47
  }
@@ -60,8 +60,8 @@ export async function instantiate(module, imports = {}) {
60
60
  __release(program);
61
61
  }
62
62
  },
63
- resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata, useBlockGas) {
64
- // assembly/api-debugger/resetGenericWithMemory(~lib/array/Array<u8>, ~lib/array/Array<u8>, ~lib/typedarray/Uint8Array, ~lib/typedarray/Uint8Array, u64, bool?, bool?) => void
63
+ resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata, useBlockGas, preallocateMemoryPages) {
64
+ // assembly/api-debugger/resetGenericWithMemory(~lib/array/Array<u8>, ~lib/array/Array<u8>, ~lib/typedarray/Uint8Array, ~lib/typedarray/Uint8Array, u64, bool?, bool?, u32?) => void
65
65
  program = __retain(__lowerArray(__setU8, 32, 0, program) || __notnull());
66
66
  flatRegisters = __retain(__lowerArray(__setU8, 32, 0, flatRegisters) || __notnull());
67
67
  pageMap = __retain(__lowerTypedArray(Uint8Array, 15, 0, pageMap) || __notnull());
@@ -71,7 +71,7 @@ export async function instantiate(module, imports = {}) {
71
71
  useBlockGas = useBlockGas ? 1 : 0;
72
72
  try {
73
73
  exports.__setArgumentsLength(arguments.length);
74
- exports.resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata, useBlockGas);
74
+ exports.resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata, useBlockGas, preallocateMemoryPages);
75
75
  } finally {
76
76
  __release(program);
77
77
  __release(flatRegisters);
Binary file
@@ -20,8 +20,9 @@ export declare function wrapAsProgram(bytecode: Uint8Array): Uint8Array;
20
20
  * @param args `~lib/array/Array<u8>`
21
21
  * @param hasMetadata `bool`
22
22
  * @param useBlockGas `bool`
23
+ * @param preallocateMemoryPages `u32`
23
24
  */
24
- export declare function resetJAM(program: Array<number>, pc: number, initialGas: bigint, args: Array<number>, hasMetadata?: boolean, useBlockGas?: boolean): void;
25
+ export declare function resetJAM(program: Array<number>, pc: number, initialGas: bigint, args: Array<number>, hasMetadata?: boolean, useBlockGas?: boolean, preallocateMemoryPages?: number): void;
25
26
  /**
26
27
  * assembly/api-debugger/resetGeneric
27
28
  * @param program `~lib/array/Array<u8>`
@@ -40,8 +41,9 @@ export declare function resetGeneric(program: Array<number>, flatRegisters: Arra
40
41
  * @param initialGas `u64`
41
42
  * @param hasMetadata `bool`
42
43
  * @param useBlockGas `bool`
44
+ * @param preallocateMemoryPages `u32`
43
45
  */
44
- export declare function resetGenericWithMemory(program: Array<number>, flatRegisters: Array<number>, pageMap: Uint8Array, chunks: Uint8Array, initialGas: bigint, hasMetadata?: boolean, useBlockGas?: boolean): void;
46
+ export declare function resetGenericWithMemory(program: Array<number>, flatRegisters: Array<number>, pageMap: Uint8Array, chunks: Uint8Array, initialGas: bigint, hasMetadata?: boolean, useBlockGas?: boolean, preallocateMemoryPages?: number): void;
45
47
  /**
46
48
  * assembly/api-debugger/nextStep
47
49
  * @returns `bool`
@@ -32,8 +32,8 @@ async function instantiate(module, imports = {}) {
32
32
  bytecode = __lowerTypedArray(Uint8Array, 15, 0, bytecode) || __notnull();
33
33
  return __liftTypedArray(Uint8Array, exports.wrapAsProgram(bytecode) >>> 0);
34
34
  },
35
- resetJAM(program, pc, initialGas, args, hasMetadata, useBlockGas) {
36
- // assembly/api-debugger/resetJAM(~lib/array/Array<u8>, u32, u64, ~lib/array/Array<u8>, bool?, bool?) => void
35
+ resetJAM(program, pc, initialGas, args, hasMetadata, useBlockGas, preallocateMemoryPages) {
36
+ // assembly/api-debugger/resetJAM(~lib/array/Array<u8>, u32, u64, ~lib/array/Array<u8>, bool?, bool?, u32?) => void
37
37
  program = __retain(__lowerArray(__setU8, 32, 0, program) || __notnull());
38
38
  initialGas = initialGas || 0n;
39
39
  args = __lowerArray(__setU8, 32, 0, args) || __notnull();
@@ -41,7 +41,7 @@ async function instantiate(module, imports = {}) {
41
41
  useBlockGas = useBlockGas ? 1 : 0;
42
42
  try {
43
43
  exports.__setArgumentsLength(arguments.length);
44
- exports.resetJAM(program, pc, initialGas, args, hasMetadata, useBlockGas);
44
+ exports.resetJAM(program, pc, initialGas, args, hasMetadata, useBlockGas, preallocateMemoryPages);
45
45
  } finally {
46
46
  __release(program);
47
47
  }
@@ -60,8 +60,8 @@ async function instantiate(module, imports = {}) {
60
60
  __release(program);
61
61
  }
62
62
  },
63
- resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata, useBlockGas) {
64
- // assembly/api-debugger/resetGenericWithMemory(~lib/array/Array<u8>, ~lib/array/Array<u8>, ~lib/typedarray/Uint8Array, ~lib/typedarray/Uint8Array, u64, bool?, bool?) => void
63
+ resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata, useBlockGas, preallocateMemoryPages) {
64
+ // assembly/api-debugger/resetGenericWithMemory(~lib/array/Array<u8>, ~lib/array/Array<u8>, ~lib/typedarray/Uint8Array, ~lib/typedarray/Uint8Array, u64, bool?, bool?, u32?) => void
65
65
  program = __retain(__lowerArray(__setU8, 32, 0, program) || __notnull());
66
66
  flatRegisters = __retain(__lowerArray(__setU8, 32, 0, flatRegisters) || __notnull());
67
67
  pageMap = __retain(__lowerTypedArray(Uint8Array, 15, 0, pageMap) || __notnull());
@@ -71,7 +71,7 @@ async function instantiate(module, imports = {}) {
71
71
  useBlockGas = useBlockGas ? 1 : 0;
72
72
  try {
73
73
  exports.__setArgumentsLength(arguments.length);
74
- exports.resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata, useBlockGas);
74
+ exports.resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata, useBlockGas, preallocateMemoryPages);
75
75
  } finally {
76
76
  __release(program);
77
77
  __release(flatRegisters);
Binary file
@@ -1,7 +1,7 @@
1
1
  import { Gas } from "./gas";
2
- export declare function resetJAM(program: u8[], pc: u32, initialGas: Gas, args: u8[], hasMetadata?: boolean, useBlockGas?: boolean): void;
2
+ export declare function resetJAM(program: u8[], pc: u32, initialGas: Gas, args: u8[], hasMetadata?: boolean, useBlockGas?: boolean, preallocateMemoryPages?: u32): void;
3
3
  export declare function resetGeneric(program: u8[], flatRegisters: u8[], initialGas: Gas, hasMetadata?: boolean, useBlockGas?: boolean): void;
4
- export declare function resetGenericWithMemory(program: u8[], flatRegisters: u8[], pageMap: Uint8Array, chunks: Uint8Array, initialGas: Gas, hasMetadata?: boolean, useBlockGas?: boolean): void;
4
+ export declare function resetGenericWithMemory(program: u8[], flatRegisters: u8[], pageMap: Uint8Array, chunks: Uint8Array, initialGas: Gas, hasMetadata?: boolean, useBlockGas?: boolean, preallocateMemoryPages?: u32): void;
5
5
  export declare function nextStep(): boolean;
6
6
  export declare function nSteps(steps: u32): boolean;
7
7
  export declare function getProgramCounter(): u32;
@@ -8,9 +8,9 @@ import { deblob, extractCodeAndMetadata, liftBytes } from "./program";
8
8
  import { NO_OF_REGISTERS, newRegisters, REG_SIZE_BYTES } from "./registers";
9
9
  import { decodeSpi } from "./spi";
10
10
  let interpreter = null;
11
- export function resetJAM(program, pc, initialGas, args, hasMetadata = false, useBlockGas = false) {
11
+ export function resetJAM(program, pc, initialGas, args, hasMetadata = false, useBlockGas = false, preallocateMemoryPages = 128) {
12
12
  const code = hasMetadata ? extractCodeAndMetadata(liftBytes(program)).code : liftBytes(program);
13
- const p = decodeSpi(code, liftBytes(args), 128, useBlockGas);
13
+ const p = decodeSpi(code, liftBytes(args), preallocateMemoryPages, useBlockGas);
14
14
  const int = new Interpreter(p.program, p.registers, p.memory);
15
15
  int.nextPc = pc;
16
16
  int.gas.set(initialGas);
@@ -31,12 +31,12 @@ export function resetGeneric(program, flatRegisters, initialGas, hasMetadata = f
31
31
  }
32
32
  interpreter = int;
33
33
  }
34
- export function resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata = false, useBlockGas = false) {
34
+ export function resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata = false, useBlockGas = false, preallocateMemoryPages = 0) {
35
35
  const code = hasMetadata ? extractCodeAndMetadata(liftBytes(program)).code : liftBytes(program);
36
36
  const p = deblob(code, useBlockGas);
37
37
  const registers = newRegisters();
38
38
  fillRegisters(registers, flatRegisters);
39
- const builder = new MemoryBuilder();
39
+ const builder = new MemoryBuilder(preallocateMemoryPages);
40
40
  const memory = buildMemory(builder, readPages(pageMap), readChunks(chunks));
41
41
  const int = new Interpreter(p, registers, memory);
42
42
  int.gas.set(initialGas);
@@ -4003,9 +4003,9 @@ var StandardProgram = class {
4003
4003
 
4004
4004
  // dist/build/js/assembly/api-debugger.js
4005
4005
  var interpreter = null;
4006
- function resetJAM(program, pc, initialGas, args, hasMetadata = false, useBlockGas = false) {
4006
+ function resetJAM(program, pc, initialGas, args, hasMetadata = false, useBlockGas = false, preallocateMemoryPages = 128) {
4007
4007
  const code = hasMetadata ? extractCodeAndMetadata(liftBytes(program)).code : liftBytes(program);
4008
- const p = decodeSpi(code, liftBytes(args), 128, useBlockGas);
4008
+ const p = decodeSpi(code, liftBytes(args), preallocateMemoryPages, useBlockGas);
4009
4009
  const int = new Interpreter(p.program, p.registers, p.memory);
4010
4010
  int.nextPc = pc;
4011
4011
  int.gas.set(initialGas);
@@ -4026,12 +4026,12 @@ function resetGeneric(program, flatRegisters, initialGas, hasMetadata = false, u
4026
4026
  }
4027
4027
  interpreter = int;
4028
4028
  }
4029
- function resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata = false, useBlockGas = false) {
4029
+ function resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata = false, useBlockGas = false, preallocateMemoryPages = 0) {
4030
4030
  const code = hasMetadata ? extractCodeAndMetadata(liftBytes(program)).code : liftBytes(program);
4031
4031
  const p = deblob(code, useBlockGas);
4032
4032
  const registers = newRegisters();
4033
4033
  fillRegisters(registers, flatRegisters);
4034
- const builder = new MemoryBuilder();
4034
+ const builder = new MemoryBuilder(preallocateMemoryPages);
4035
4035
  const memory = buildMemory(builder, readPages(pageMap), readChunks(chunks));
4036
4036
  const int = new Interpreter(p, registers, memory);
4037
4037
  int.gas.set(initialGas);