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..07072d5b40a83e06f827257807080efa0f0abb1a 100644 |
--- a/test/mjsunit/wasm/module-memory.js |
+++ b/test/mjsunit/wasm/module-memory.js |
@@ -15,24 +15,25 @@ 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(); |
@@ -66,9 +67,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 +115,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 +138,9 @@ function testOOBThrows() { |
kExprGetLocal, 0, |
kExprGetLocal, 1, |
kExprI32LoadMem, 0, 0, |
- kExprI32StoreMem, 0, 0 |
+ kExprI32StoreMem, 0, 0, |
+ kExprGetLocal, 1, |
+ kExprI32LoadMem, 0, 0, |
]) |
.exportFunc(); |