@assemblyscript/loader
Advanced tools
Comparing version 0.17.14 to 0.18.0
@@ -18,2 +18,3 @@ /// <reference lib="esnext.bigint" /> | ||
trace?(msg: number, numArgs?: number, ...args: number[]): void; | ||
mark?(): void; | ||
}; | ||
@@ -85,4 +86,4 @@ }; | ||
/** Allocates an instance of the class represented by the specified id. */ | ||
__new(size: number, id: number): number; | ||
/** Tests whether a managed object is an instance of the class represented by the specified base id. */ | ||
__instanceof(ptr: number, baseId: number): boolean; | ||
/** Allocates a new string in the module's memory and returns a reference (pointer) to it. */ | ||
@@ -92,12 +93,11 @@ __newString(str: string): number; | ||
__newArray(id: number, values: ArrayLike<number>): number; | ||
/** Retains a reference to a managed object externally, making sure that it doesn't become collected prematurely. Returns the pointer. */ | ||
__retain(ptr: number): number; | ||
/** Releases a previously retained reference to a managed object, allowing the runtime to collect it once its reference count reaches zero. */ | ||
__release(ptr: number): void; | ||
/** Forcefully resets the heap to its initial offset, effectively clearing dynamic memory. Stub runtime only. */ | ||
__reset?(): void; | ||
/** Tests whether a managed object is an instance of the class represented by the specified base id. */ | ||
__instanceof(ptr: number, baseId: number): boolean; | ||
/** Forces a cycle collection. Only relevant if objects potentially forming reference cycles are used. */ | ||
__collect(): void; | ||
/** Allocates an instance of the class represented by the specified id. */ | ||
__new(size: number, id: number): number; | ||
/** Pins a managed object externally, preventing it from becoming garbage collected. */ | ||
__pin(ptr: number): number; | ||
/** Unpins a managed object externally, allowing it to become garbage collected. */ | ||
__unpin(ptr: number): void; | ||
/** Performs a full garbage collection cycle. */ | ||
__collect(incremental?: boolean): void; | ||
} | ||
@@ -104,0 +104,0 @@ |
27
index.js
@@ -79,2 +79,5 @@ // Runtime header offsets | ||
const E_NOEXPORTRUNTIME = "Operation requires compiling with --exportRuntime"; | ||
const F_NOEXPORTRUNTIME = function() { throw Error(E_NOEXPORTRUNTIME); }; | ||
/** Prepares the final module once instantiation is complete. */ | ||
@@ -85,6 +88,13 @@ function postInstantiate(extendedExports, instance) { | ||
const table = exports.table; | ||
const __new = exports["__new"]; | ||
const __retain = exports["__retain"]; | ||
const __rtti_base = exports["__rtti_base"] || ~0; // oob if not present | ||
const __new = exports.__new || F_NOEXPORTRUNTIME; | ||
const __pin = exports.__pin || F_NOEXPORTRUNTIME; | ||
const __unpin = exports.__unpin || F_NOEXPORTRUNTIME; | ||
const __collect = exports.__collect || F_NOEXPORTRUNTIME; | ||
const __rtti_base = exports.__rtti_base || ~0; // oob if not present | ||
extendedExports.__new = __new; | ||
extendedExports.__pin = __pin; | ||
extendedExports.__unpin = __unpin; | ||
extendedExports.__collect = __collect; | ||
/** Gets the runtime type info for the given id. */ | ||
@@ -123,3 +133,3 @@ function getInfo(id) { | ||
/** Allocates a new string in the module's memory and returns its retained pointer. */ | ||
/** Allocates a new string in the module's memory and returns its pointer. */ | ||
function __newString(str) { | ||
@@ -166,3 +176,3 @@ if (str == null) return 0; | ||
/** Allocates a new array in the module's memory and returns its retained pointer. */ | ||
/** Allocates a new array in the module's memory and returns its pointer. */ | ||
function __newArray(id, values) { | ||
@@ -179,3 +189,3 @@ const info = getArrayInfo(id); | ||
const U32 = new Uint32Array(memory.buffer); | ||
U32[arr + ARRAYBUFFERVIEW_BUFFER_OFFSET >>> 2] = __retain(buf); | ||
U32[arr + ARRAYBUFFERVIEW_BUFFER_OFFSET >>> 2] = buf; | ||
U32[arr + ARRAYBUFFERVIEW_DATASTART_OFFSET >>> 2] = buf; | ||
@@ -188,3 +198,6 @@ U32[arr + ARRAYBUFFERVIEW_DATALENGTH_OFFSET >>> 2] = length << align; | ||
if (info & VAL_MANAGED) { | ||
for (let i = 0; i < length; ++i) view[(buf >>> align) + i] = __retain(values[i]); | ||
for (let i = 0; i < length; ++i) { | ||
const value = values[i]; | ||
view[(buf >>> align) + i] = value; | ||
} | ||
} else { | ||
@@ -191,0 +204,0 @@ view.set(values, buf >>> align); |
@@ -12,3 +12,3 @@ { | ||
], | ||
"version": "0.17.14", | ||
"version": "0.18.0", | ||
"author": "Daniel Wirtz <dcode+assemblyscript@dcode.io>", | ||
@@ -34,4 +34,4 @@ "license": "Apache-2.0", | ||
"asbuild": "npm run asbuild:default && npm run asbuild:legacy", | ||
"asbuild:default": "node ../../bin/asc tests/assembly/index.ts -b tests/build/default.wasm", | ||
"asbuild:legacy": "node ../../bin/asc tests/assembly/index.ts --disable mutable-globals -b tests/build/legacy.wasm", | ||
"asbuild:default": "node ../../bin/asc tests/assembly/index.ts --binaryFile tests/build/default.wasm --exportRuntime", | ||
"asbuild:legacy": "node ../../bin/asc tests/assembly/index.ts --disable mutable-globals --binaryFile tests/build/legacy.wasm --exportRuntime", | ||
"build": "npx esm2umd loader index.js > umd/index.js", | ||
@@ -38,0 +38,0 @@ "test": "node tests && node tests/umd" |
@@ -91,2 +91,8 @@ // GENERATED FILE. DO NOT EDIT. | ||
} | ||
const E_NOEXPORTRUNTIME = "Operation requires compiling with --exportRuntime"; | ||
const F_NOEXPORTRUNTIME = function () { | ||
throw Error(E_NOEXPORTRUNTIME); | ||
}; | ||
/** Prepares the final module once instantiation is complete. */ | ||
@@ -99,10 +105,20 @@ | ||
const table = exports.table; | ||
const __new = exports["__new"]; | ||
const __retain = exports["__retain"]; | ||
const __rtti_base = exports["__rtti_base"] || ~0; // oob if not present | ||
const __new = exports.__new || F_NOEXPORTRUNTIME; | ||
const __pin = exports.__pin || F_NOEXPORTRUNTIME; | ||
const __unpin = exports.__unpin || F_NOEXPORTRUNTIME; | ||
const __collect = exports.__collect || F_NOEXPORTRUNTIME; | ||
const __rtti_base = exports.__rtti_base || ~0; // oob if not present | ||
extendedExports.__new = __new; | ||
extendedExports.__pin = __pin; | ||
extendedExports.__unpin = __unpin; | ||
extendedExports.__collect = __collect; | ||
/** Gets the runtime type info for the given id. */ | ||
function getInfo(id) { | ||
@@ -142,3 +158,3 @@ const U32 = new Uint32Array(memory.buffer); | ||
/** Allocates a new string in the module's memory and returns its retained pointer. */ | ||
/** Allocates a new string in the module's memory and returns its pointer. */ | ||
@@ -202,3 +218,3 @@ | ||
} | ||
/** Allocates a new array in the module's memory and returns its retained pointer. */ | ||
/** Allocates a new array in the module's memory and returns its pointer. */ | ||
@@ -221,3 +237,3 @@ | ||
const U32 = new Uint32Array(memory.buffer); | ||
U32[arr + ARRAYBUFFERVIEW_BUFFER_OFFSET >>> 2] = __retain(buf); | ||
U32[arr + ARRAYBUFFERVIEW_BUFFER_OFFSET >>> 2] = buf; | ||
U32[arr + ARRAYBUFFERVIEW_DATASTART_OFFSET >>> 2] = buf; | ||
@@ -232,3 +248,6 @@ U32[arr + ARRAYBUFFERVIEW_DATALENGTH_OFFSET >>> 2] = length << align; | ||
if (info & VAL_MANAGED) { | ||
for (let i = 0; i < length; ++i) view[(buf >>> align) + i] = __retain(values[i]); | ||
for (let i = 0; i < length; ++i) { | ||
const value = values[i]; | ||
view[(buf >>> align) + i] = value; | ||
} | ||
} else { | ||
@@ -235,0 +254,0 @@ view.set(values, buf >>> align); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40565
904