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

Unified Diff: test/mjsunit/wasm/module-memory.js

Issue 2345593003: [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test failures and TSAN races. Created 4 years, 3 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 | « test/mjsunit/wasm/instantiate-module-basic.js ('k') | test/mjsunit/wasm/parallel_compilation.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/module-memory.js
diff --git a/test/mjsunit/wasm/module-memory.js b/test/mjsunit/wasm/module-memory.js
index a5e5f42488aad5c3dc0a9ab9673e2ca3229d1301..6707f0816410c0667e3711b78936226b2e0cf2be 100644
--- a/test/mjsunit/wasm/module-memory.js
+++ b/test/mjsunit/wasm/module-memory.js
@@ -15,33 +15,36 @@ function genModule(memory) {
builder.addMemory(1, 1, true);
builder.addFunction("main", kSig_i_i)
.addBody([
- // main body: while(i) { if(mem[i]) return -1; i -= 4; } return 0;
- kExprLoop,
- kExprGetLocal,0,
- kExprIf,
- kExprGetLocal,0,
- kExprI32LoadMem,0,0,
- kExprIf,
- kExprI8Const,255,
- kExprReturn, kArity1,
- kExprEnd,
- kExprGetLocal,0,
- kExprI8Const,4,
- kExprI32Sub,
- kExprSetLocal,0,
- kExprBr, kArity1, 1,
- kExprEnd,
- kExprEnd,
- kExprI8Const,0
+ // main body: while(i) { if(mem[i]) return -1; i -= 4; } return 0;
+ // TODO(titzer): this manual bytecode has a copy of test-run-wasm.cc
+ /**/ kExprLoop, kAstStmt, // --
+ /* */ kExprGetLocal, 0, // --
+ /* */ kExprIf, kAstStmt, // --
+ /* */ kExprGetLocal, 0, // --
+ /* */ kExprI32LoadMem, 0, 0, // --
+ /* */ kExprIf, kAstStmt, // --
+ /* */ kExprI8Const, 255, // --
+ /* */ kExprReturn, // --
+ /* */ kExprEnd, // --
+ /* */ kExprGetLocal, 0, // --
+ /* */ kExprI8Const, 4, // --
+ /* */ kExprI32Sub, // --
+ /* */ kExprSetLocal, 0, // --
+ /* */ kExprBr, 1, // --
+ /* */ kExprEnd, // --
+ /* */ kExprEnd, // --
+ /**/ kExprI8Const, 0 // --
])
.exportFunc();
-
- return builder.instantiate(null, memory);
+ var module = builder.instantiate(null, memory);
+ assertTrue(module.exports.memory instanceof WebAssembly.Memory);
+ if (memory != null) assertEquals(memory, module.exports.memory.buffer);
+ return module;
}
function testPokeMemory() {
var module = genModule(null);
- var buffer = module.exports.memory;
+ var buffer = module.exports.memory.buffer;
var main = module.exports.main;
assertEquals(kMemSize, buffer.byteLength);
@@ -66,9 +69,13 @@ function testPokeMemory() {
testPokeMemory();
+function genAndGetMain(buffer) {
+ return genModule(buffer).exports.main; // to prevent intermediates living
+}
+
function testSurvivalAcrossGc() {
- var checker = genModule(null).exports.main;
- for (var i = 0; i < 5; i++) {
+ var checker = genAndGetMain(null);
+ for (var i = 0; i < 3; i++) {
print("gc run ", i);
assertEquals(0, checker(kMemSize - 4));
gc();
@@ -110,8 +117,8 @@ testPokeOuterMemory();
function testOuterMemorySurvivalAcrossGc() {
var buffer = new ArrayBuffer(kMemSize);
- var checker = genModule(buffer).exports.main;
- for (var i = 0; i < 5; i++) {
+ var checker = genAndGetMain(buffer);
+ for (var i = 0; i < 3; i++) {
print("gc run ", i);
assertEquals(0, checker(kMemSize - 4));
gc();
@@ -133,7 +140,9 @@ function testOOBThrows() {
kExprGetLocal, 0,
kExprGetLocal, 1,
kExprI32LoadMem, 0, 0,
- kExprI32StoreMem, 0, 0
+ kExprI32StoreMem, 0, 0,
+ kExprGetLocal, 1,
+ kExprI32LoadMem, 0, 0,
])
.exportFunc();
« no previous file with comments | « test/mjsunit/wasm/instantiate-module-basic.js ('k') | test/mjsunit/wasm/parallel_compilation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698