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

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

Issue 2361053004: Revert of [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 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 27 matching lines...) Expand all
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("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([kExprCallImport, kArity0, 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_v_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_v_v)
63 .addBody([kExprCallFunction, mem_oob_func.index]) 63 .addBody([kExprCallFunction, kArity0, 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({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>[0]+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();
77 assertEquals(expected_string, stripPath(stack)); 77 assertEquals(expected_string, stripPath(stack));
78 })(); 78 })();
79 79
80 // For the remaining tests, collect the Callsite objects instead of just a 80 // For the remaining tests, collect the Callsite objects instead of just a
81 // string: 81 // string:
82 Error.prepareStackTrace = function(error, frames) { 82 Error.prepareStackTrace = function(error, frames) {
83 return frames; 83 return frames;
84 }; 84 };
85 85
86 (function testStackFrames() { 86 (function testStackFrames() {
87 module.exports.main(); 87 module.exports.main();
88 88
89 verifyStack(stack, [ 89 verifyStack(stack, [
90 // isWasm function line pos file 90 // isWasm function line pos file
91 [ false, "STACK", 39, 0, "stack.js"], 91 [ false, "STACK", 39, 0, "stack.js"],
92 [ true, "main", 1, 1, null], 92 [ true, "main", 0, 1, null],
93 [ false, "testStackFrames", 87, 0, "stack.js"], 93 [ false, "testStackFrames", 87, 0, "stack.js"],
94 [ false, null, 96, 0, "stack.js"] 94 [ false, null, 96, 0, "stack.js"]
95 ]); 95 ]);
96 })(); 96 })();
97 97
98 (function testWasmUnreachable() { 98 (function testWasmUnreachable() {
99 try { 99 try {
100 module.exports.exec_unreachable(); 100 module.exports.exec_unreachable();
101 fail("expected wasm exception"); 101 fail("expected wasm exception");
102 } catch (e) { 102 } catch (e) {
103 assertContains("unreachable", e.message); 103 assertContains("unreachable", e.message);
104 verifyStack(e.stack, [ 104 verifyStack(e.stack, [
105 // isWasm function line pos file 105 // isWasm function line pos file
106 [ true, "exec_unreachable", 2, 1, null], 106 [ true, "exec_unreachable", 1, 1, null],
107 [ false, "testWasmUnreachable", 100, 0, "stack.js"], 107 [ false, "testWasmUnreachable", 100, 0, "stack.js"],
108 [ false, null, 111, 0, "stack.js"] 108 [ false, null, 111, 0, "stack.js"]
109 ]); 109 ]);
110 } 110 }
111 })(); 111 })();
112 112
113 (function testWasmMemOutOfBounds() { 113 (function testWasmMemOutOfBounds() {
114 try { 114 try {
115 module.exports.call_mem_out_of_bounds(); 115 module.exports.call_mem_out_of_bounds();
116 fail("expected wasm exception"); 116 fail("expected wasm exception");
117 } catch (e) { 117 } catch (e) {
118 assertContains("out of bounds", e.message); 118 assertContains("out of bounds", e.message);
119 verifyStack(e.stack, [ 119 verifyStack(e.stack, [
120 // isWasm function line pos file 120 // isWasm function line pos file
121 [ true, "", 3, 3, null], 121 [ true, "", 2, 3, null],
122 [ true, "call_mem_out_of_bounds", 4, 1, null], 122 [ true, "call_mem_out_of_bounds", 3, 1, null],
123 [ false, "testWasmMemOutOfBounds", 115, 0, "stack.js"], 123 [ false, "testWasmMemOutOfBounds", 115, 0, "stack.js"],
124 [ false, null, 127, 0, "stack.js"] 124 [ false, null, 127, 0, "stack.js"]
125 ]); 125 ]);
126 } 126 }
127 })(); 127 })();
128 128
129 129
130 (function testStackOverflow() { 130 (function testStackOverflow() {
131 print("testStackOverflow"); 131 print("testStackOverflow");
132 var builder = new WasmModuleBuilder(); 132 var builder = new WasmModuleBuilder();
133 133
134 var sig_index = builder.addType(kSig_v_v); 134 var sig_index = builder.addType(kSig_v_v);
135 builder.addFunction("recursion", sig_index) 135 builder.addFunction("recursion", sig_index)
136 .addBody([ 136 .addBody([
137 kExprI32Const, 0, 137 kExprI32Const, 0,
138 kExprCallIndirect, sig_index 138 kExprCallIndirect, kArity0, sig_index
139 ]) 139 ])
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