diff options
Diffstat (limited to 'src/mono/wasm/runtime/memory.ts')
-rw-r--r-- | src/mono/wasm/runtime/memory.ts | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mono/wasm/runtime/memory.ts b/src/mono/wasm/runtime/memory.ts index ecc4275493d..1653b94af2b 100644 --- a/src/mono/wasm/runtime/memory.ts +++ b/src/mono/wasm/runtime/memory.ts @@ -256,6 +256,15 @@ export function withStackAlloc<T1, T2, T3, TResult>(bytesWanted: number, f: (ptr } } +// @bytes must be a typed array. space is allocated for it in the native heap +// and it is copied to that location. returns the address of the allocation. +export function mono_wasm_load_bytes_into_heap(bytes: Uint8Array): VoidPtr { + const memoryOffset = Module._malloc(bytes.length); + const heapBytes = new Uint8Array(Module.HEAPU8.buffer, <any>memoryOffset, bytes.length); + heapBytes.set(bytes); + return memoryOffset; +} + const BuiltinAtomics = globalThis.Atomics; export const Atomics = monoWasmThreads ? { @@ -269,4 +278,4 @@ export const Atomics = monoWasmThreads ? { } : { storeI32: setI32, notifyI32: () => { /*empty*/ } -}; +};
\ No newline at end of file |