Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(773)

Unified Diff: test/mjsunit/wasm/asm-wasm.js

Issue 1581913005: Allow asm modules to be instatiated with external heaps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-js.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/asm-wasm.js
diff --git a/test/mjsunit/wasm/asm-wasm.js b/test/mjsunit/wasm/asm-wasm.js
index a424a1c52dfcf583e900cb7a4d01180e0d590dab..a1feea3b2bbeeddff6f5b83fd0951af24f2888a8 100644
--- a/test/mjsunit/wasm/asm-wasm.js
+++ b/test/mjsunit/wasm/asm-wasm.js
@@ -391,19 +391,38 @@ function TestInt32HeapAccess(stdlib, foreign, buffer) {
assertEquals(7, _WASMEXP_.asmCompileRun(TestInt32HeapAccess.toString()));
+function TestInt32HeapAccessExternal() {
+ var memory = new ArrayBuffer(1024);
+ var memory_int32 = new Int32Array(memory);
+ var module = _WASMEXP_.instantiateModuleFromAsm(
+ TestInt32HeapAccess.toString(), null, memory);
+ module.__init__();
+ assertEquals(7, module.caller());
+ assertEquals(7, memory_int32[2]);
+}
+
+TestInt32HeapAccessExternal();
+
+
function TestHeapAccessIntTypes() {
var types = [
- ['Int8Array', '>> 0'],
- ['Uint8Array', '>> 0'],
- ['Int16Array', '>> 1'],
- ['Uint16Array', '>> 1'],
- ['Int32Array', '>> 2'],
- ['Uint32Array', '>> 2'],
+ [Int8Array, 'Int8Array', '>> 0'],
+ [Uint8Array, 'Uint8Array', '>> 0'],
+ [Int16Array, 'Int16Array', '>> 1'],
+ [Uint16Array, 'Uint16Array', '>> 1'],
+ [Int32Array, 'Int32Array', '>> 2'],
+ [Uint32Array, 'Uint32Array', '>> 2'],
];
for (var i = 0; i < types.length; i++) {
var code = TestInt32HeapAccess.toString();
- code = code.replace('Int32Array', types[i][0]);
- code = code.replace(/>> 2/g, types[i][1]);
+ code = code.replace('Int32Array', types[i][1]);
+ code = code.replace(/>> 2/g, types[i][2]);
+ var memory = new ArrayBuffer(1024);
+ var memory_view = new types[i][0](memory);
+ var module = _WASMEXP_.instantiateModuleFromAsm(code, null, memory);
+ module.__init__();
+ assertEquals(7, module.caller());
+ assertEquals(7, memory_view[2]);
assertEquals(7, _WASMEXP_.asmCompileRun(code));
}
}
@@ -436,6 +455,19 @@ function TestFloatHeapAccess(stdlib, foreign, buffer) {
assertEquals(1, _WASMEXP_.asmCompileRun(TestFloatHeapAccess.toString()));
+function TestFloatHeapAccessExternal() {
+ var memory = new ArrayBuffer(1024);
+ var memory_float64 = new Float64Array(memory);
+ var module = _WASMEXP_.instantiateModuleFromAsm(
+ TestFloatHeapAccess.toString(), null, memory);
+ module.__init__();
+ assertEquals(1, module.caller());
+ assertEquals(9.0, memory_float64[1]);
+}
+
+TestFloatHeapAccessExternal();
+
+
function TestConvertI32() {
"use asm";
« no previous file with comments | « src/wasm/wasm-js.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698