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

Side by Side Diff: test/mjsunit/wasm/stack.js

Issue 2591753002: [wasm] Implement correct 2-level namespace for imports. (Closed)
Patch Set: Fix debug tests Created 3 years, 12 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 unified diff | Download patch
« no previous file with comments | « test/mjsunit/wasm/receiver.js ('k') | test/mjsunit/wasm/stackwalk.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // clang-format off 5 // clang-format off
6 // Flags: --expose-wasm 6 // Flags: --expose-wasm
7 7
8 load("test/mjsunit/wasm/wasm-constants.js"); 8 load("test/mjsunit/wasm/wasm-constants.js");
9 load("test/mjsunit/wasm/wasm-module-builder.js"); 9 load("test/mjsunit/wasm/wasm-module-builder.js");
10 10
(...skipping 24 matching lines...) Expand all
35 35
36 36
37 var stack; 37 var stack;
38 function STACK() { 38 function STACK() {
39 var e = new Error(); 39 var e = new Error();
40 stack = e.stack; 40 stack = e.stack;
41 } 41 }
42 42
43 var builder = new WasmModuleBuilder(); 43 var builder = new WasmModuleBuilder();
44 44
45 builder.addImport("func", kSig_v_v); 45 builder.addImport("mod", "func", kSig_v_v);
46 46
47 builder.addFunction("main", kSig_v_v) 47 builder.addFunction("main", kSig_v_v)
48 .addBody([kExprCallFunction, 0]) 48 .addBody([kExprCallFunction, 0])
49 .exportAs("main"); 49 .exportAs("main");
50 50
51 builder.addFunction("exec_unreachable", kSig_v_v) 51 builder.addFunction("exec_unreachable", kSig_v_v)
52 .addBody([kExprUnreachable]) 52 .addBody([kExprUnreachable])
53 .exportAs("exec_unreachable"); 53 .exportAs("exec_unreachable");
54 54
55 // Make this function unnamed, just to test also this case. 55 // Make this function unnamed, just to test also this case.
56 var mem_oob_func = builder.addFunction(undefined, kSig_i_v) 56 var mem_oob_func = builder.addFunction(undefined, kSig_i_v)
57 // Access the memory at offset -1, to provoke a trap. 57 // Access the memory at offset -1, to provoke a trap.
58 .addBody([kExprI32Const, 0x7f, kExprI32LoadMem8S, 0, 0]) 58 .addBody([kExprI32Const, 0x7f, kExprI32LoadMem8S, 0, 0])
59 .exportAs("mem_out_of_bounds"); 59 .exportAs("mem_out_of_bounds");
60 60
61 // Call the mem_out_of_bounds function, in order to have two WASM stack frames. 61 // Call the mem_out_of_bounds function, in order to have two WASM stack frames.
62 builder.addFunction("call_mem_out_of_bounds", kSig_i_v) 62 builder.addFunction("call_mem_out_of_bounds", kSig_i_v)
63 .addBody([kExprCallFunction, mem_oob_func.index]) 63 .addBody([kExprCallFunction, mem_oob_func.index])
64 .exportAs("call_mem_out_of_bounds"); 64 .exportAs("call_mem_out_of_bounds");
65 65
66 var module = builder.instantiate({func: STACK}); 66 var module = builder.instantiate({mod: {func: STACK}});
67 67
68 (function testSimpleStack() { 68 (function testSimpleStack() {
69 var expected_string = "Error\n" + 69 var expected_string = "Error\n" +
70 // The line numbers below will change as this test gains / loses lines.. 70 // The line numbers below will change as this test gains / loses lines..
71 " at STACK (stack.js:39:11)\n" + // -- 71 " at STACK (stack.js:39:11)\n" + // --
72 " at main (<WASM>[1]+1)\n" + // -- 72 " at main (<WASM>[1]+1)\n" + // --
73 " at testSimpleStack (stack.js:76:18)\n" + // -- 73 " at testSimpleStack (stack.js:76:18)\n" + // --
74 " at stack.js:78:3"; // -- 74 " at stack.js:78:3"; // --
75 75
76 module.exports.main(); 76 module.exports.main();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 .exportFunc() 140 .exportFunc()
141 builder.appendToTable([0]); 141 builder.appendToTable([0]);
142 142
143 try { 143 try {
144 builder.instantiate().exports.recursion(); 144 builder.instantiate().exports.recursion();
145 fail("expected wasm exception"); 145 fail("expected wasm exception");
146 } catch (e) { 146 } catch (e) {
147 assertEquals("Maximum call stack size exceeded", e.message, "trap reason"); 147 assertEquals("Maximum call stack size exceeded", e.message, "trap reason");
148 } 148 }
149 })(); 149 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/receiver.js ('k') | test/mjsunit/wasm/stackwalk.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698