From 721f15831ca547de98992f9ce6158d822b94d167 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 22 Jun 2020 07:00:13 -0700 Subject: wasm2js: Bulk memory support (#2923) Adds a special helper functions for data.drop etc., as unlike most wasm instructions these are too big to emit inline. Track passive segments at runtime in var memorySegments whose indexes are the segment indexes. Emit var bufferView even if the memory exists even without memory segments, as we do still need the view in order to operate on it. Also adds a few constants for atomics that will be useful in future PRs (as this PR updates the constant lists anyhow). --- test/wasm2js/dynamicLibrary.2asm.js.opt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test/wasm2js/dynamicLibrary.2asm.js.opt') diff --git a/test/wasm2js/dynamicLibrary.2asm.js.opt b/test/wasm2js/dynamicLibrary.2asm.js.opt index d2e28b645..71fa441ed 100644 --- a/test/wasm2js/dynamicLibrary.2asm.js.opt +++ b/test/wasm2js/dynamicLibrary.2asm.js.opt @@ -42,6 +42,7 @@ function asmFunc(global, env, buffer) { } var memasmFunc = new ArrayBuffer(16777216); +var bufferView = new Uint8Array(memasmFunc); for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i) { base64ReverseLookup[48+i] = 52+i; // '0-9' base64ReverseLookup[65+i] = i; // 'A-Z' @@ -59,8 +60,8 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } + return uint8Array; } -var bufferView = new Uint8Array(memasmFunc); -base64DecodeToExistingUint8Array(bufferView, memoryBase, "ZHluYW1pYyBkYXRh"); + base64DecodeToExistingUint8Array(bufferView, memoryBase, "ZHluYW1pYyBkYXRh"); var retasmFunc = asmFunc({Math,Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,NaN,Infinity}, {abort:function() { throw new Error('abort'); }},memasmFunc); export var baz = retasmFunc.baz; -- cgit v1.2.3