summaryrefslogtreecommitdiff
path: root/test/wasm2js/bulk-memory.2asm.js
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2020-11-10 18:06:14 -0800
committerGitHub <noreply@github.com>2020-11-10 18:06:14 -0800
commit32171f1d6ff57fdb31f55d8aa554eac15cb5d8f5 (patch)
tree24cdd04d3e616aa25354372a9cab2f72f95094af /test/wasm2js/bulk-memory.2asm.js
parentbb124f995527f650d98bdac30b00b125b76fab9c (diff)
downloadbinaryen-32171f1d6ff57fdb31f55d8aa554eac15cb5d8f5.tar.gz
binaryen-32171f1d6ff57fdb31f55d8aa554eac15cb5d8f5.tar.bz2
binaryen-32171f1d6ff57fdb31f55d8aa554eac15cb5d8f5.zip
wasm2js: Support for exported memory (#3323)
The asmFunc now sets the outer scope's `bufferView` variable as well as its own internal views.
Diffstat (limited to 'test/wasm2js/bulk-memory.2asm.js')
-rw-r--r--test/wasm2js/bulk-memory.2asm.js56
1 files changed, 26 insertions, 30 deletions
diff --git a/test/wasm2js/bulk-memory.2asm.js b/test/wasm2js/bulk-memory.2asm.js
index 71f7168c5..b87b52d3c 100644
--- a/test/wasm2js/bulk-memory.2asm.js
+++ b/test/wasm2js/bulk-memory.2asm.js
@@ -34,7 +34,8 @@ var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); }
bufferView.fill(value, dest, dest + size);
}
-function asmFunc(env, buffer) {
+function asmFunc(env) {
+ var buffer = new ArrayBuffer(65536);
var HEAP8 = new Int8Array(buffer);
var HEAP16 = new Int16Array(buffer);
var HEAP32 = new Int32Array(buffer);
@@ -43,6 +44,7 @@ function asmFunc(env, buffer) {
var HEAPU32 = new Uint32Array(buffer);
var HEAPF32 = new Float32Array(buffer);
var HEAPF64 = new Float64Array(buffer);
+ bufferView = HEAPU8;
var Math_imul = Math.imul;
var Math_fround = Math.fround;
var Math_abs = Math.abs;
@@ -80,7 +82,6 @@ function asmFunc(env, buffer) {
var newBuffer = new ArrayBuffer(Math_imul(newPages, 65536));
var newHEAP8 = new Int8Array(newBuffer);
newHEAP8.set(HEAP8);
- HEAP8 = newHEAP8;
HEAP8 = new Int8Array(newBuffer);
HEAP16 = new Int16Array(newBuffer);
HEAP32 = new Int32Array(newBuffer);
@@ -90,6 +91,7 @@ function asmFunc(env, buffer) {
HEAPF32 = new Float32Array(newBuffer);
HEAPF64 = new Float64Array(newBuffer);
buffer = newBuffer;
+ bufferView = HEAPU8;
}
return oldPages;
}
@@ -100,12 +102,9 @@ function asmFunc(env, buffer) {
};
}
-var memasmFunc = new ArrayBuffer(65536);
-var bufferView = new Uint8Array(memasmFunc);
+var bufferView;
var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); }
- },
- memasmFunc
-);
+ });
export var fill = retasmFunc.fill;
export var load8_u = retasmFunc.load8_u;
@@ -120,7 +119,8 @@ export var load8_u = retasmFunc.load8_u;
bufferView.copyWithin(dest, source, source + size);
}
-function asmFunc(env, buffer) {
+function asmFunc(env) {
+ var buffer = new ArrayBuffer(65536);
var HEAP8 = new Int8Array(buffer);
var HEAP16 = new Int16Array(buffer);
var HEAP32 = new Int32Array(buffer);
@@ -129,6 +129,7 @@ function asmFunc(env, buffer) {
var HEAPU32 = new Uint32Array(buffer);
var HEAPF32 = new Float32Array(buffer);
var HEAPF64 = new Float64Array(buffer);
+ bufferView = HEAPU8;
var Math_imul = Math.imul;
var Math_fround = Math.fround;
var Math_abs = Math.abs;
@@ -164,8 +165,9 @@ function asmFunc(env, buffer) {
};
}
-var memasmFunc = new ArrayBuffer(65536);
-var bufferView = new Uint8Array(memasmFunc);
+var bufferView;
+var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); }
+ });
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'
@@ -186,10 +188,6 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i
return uint8Array;
}
base64DecodeToExistingUint8Array(bufferView, 0, "qrvM3Q==");
-var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); }
- },
- memasmFunc
-);
export var copy = retasmFunc.copy;
export var load8_u = retasmFunc.load8_u;
@@ -206,7 +204,8 @@ export var load8_u = retasmFunc.load8_u;
var memorySegments = {};
-function asmFunc(env, buffer) {
+function asmFunc(env) {
+ var buffer = new ArrayBuffer(65536);
var HEAP8 = new Int8Array(buffer);
var HEAP16 = new Int16Array(buffer);
var HEAP32 = new Int32Array(buffer);
@@ -215,6 +214,7 @@ function asmFunc(env, buffer) {
var HEAPU32 = new Uint32Array(buffer);
var HEAPF32 = new Float32Array(buffer);
var HEAPF64 = new Float64Array(buffer);
+ bufferView = HEAPU8;
var Math_imul = Math.imul;
var Math_fround = Math.fround;
var Math_abs = Math.abs;
@@ -252,7 +252,6 @@ function asmFunc(env, buffer) {
var newBuffer = new ArrayBuffer(Math_imul(newPages, 65536));
var newHEAP8 = new Int8Array(newBuffer);
newHEAP8.set(HEAP8);
- HEAP8 = newHEAP8;
HEAP8 = new Int8Array(newBuffer);
HEAP16 = new Int16Array(newBuffer);
HEAP32 = new Int32Array(newBuffer);
@@ -262,6 +261,7 @@ function asmFunc(env, buffer) {
HEAPF32 = new Float32Array(newBuffer);
HEAPF64 = new Float64Array(newBuffer);
buffer = newBuffer;
+ bufferView = HEAPU8;
}
return oldPages;
}
@@ -272,8 +272,9 @@ function asmFunc(env, buffer) {
};
}
-var memasmFunc = new ArrayBuffer(65536);
-var bufferView = new Uint8Array(memasmFunc);
+var bufferView;
+var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); }
+ });
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'
@@ -294,10 +295,6 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i
return uint8Array;
}
memorySegments[0] = base64DecodeToExistingUint8Array(new Uint8Array(4), 0, "qrvM3Q==");
-var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); }
- },
- memasmFunc
-);
export var init = retasmFunc.init;
export var load8_u = retasmFunc.load8_u;
@@ -319,7 +316,8 @@ export var load8_u = retasmFunc.load8_u;
var memorySegments = {};
-function asmFunc(env, buffer) {
+function asmFunc(env) {
+ var buffer = new ArrayBuffer(65536);
var HEAP8 = new Int8Array(buffer);
var HEAP16 = new Int16Array(buffer);
var HEAP32 = new Int32Array(buffer);
@@ -328,6 +326,7 @@ function asmFunc(env, buffer) {
var HEAPU32 = new Uint32Array(buffer);
var HEAPF32 = new Float32Array(buffer);
var HEAPF64 = new Float64Array(buffer);
+ bufferView = HEAPU8;
var Math_imul = Math.imul;
var Math_fround = Math.fround;
var Math_abs = Math.abs;
@@ -369,7 +368,6 @@ function asmFunc(env, buffer) {
var newBuffer = new ArrayBuffer(Math_imul(newPages, 65536));
var newHEAP8 = new Int8Array(newBuffer);
newHEAP8.set(HEAP8);
- HEAP8 = newHEAP8;
HEAP8 = new Int8Array(newBuffer);
HEAP16 = new Int16Array(newBuffer);
HEAP32 = new Int32Array(newBuffer);
@@ -379,6 +377,7 @@ function asmFunc(env, buffer) {
HEAPF32 = new Float32Array(newBuffer);
HEAPF64 = new Float64Array(newBuffer);
buffer = newBuffer;
+ bufferView = HEAPU8;
}
return oldPages;
}
@@ -391,8 +390,9 @@ function asmFunc(env, buffer) {
};
}
-var memasmFunc = new ArrayBuffer(65536);
-var bufferView = new Uint8Array(memasmFunc);
+var bufferView;
+var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); }
+ });
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'
@@ -414,10 +414,6 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i
}
memorySegments[0] = base64DecodeToExistingUint8Array(new Uint8Array(0), 0, "");
base64DecodeToExistingUint8Array(bufferView, 0, "");
-var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); }
- },
- memasmFunc
-);
export var drop_passive = retasmFunc.drop_passive;
export var init_passive = retasmFunc.init_passive;
export var drop_active = retasmFunc.drop_active;