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

Side by Side Diff: test/mjsunit/wasm/asm-wasm-exception-in-tonumber.js

Issue 2555243002: [wasm] Fix location for error in asm.js ToNumber conversion (Closed)
Patch Set: No need to store parent in VisitCall Created 4 years 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
« src/wasm/wasm-objects.cc ('K') | « test/cctest/wasm/wasm-run-utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --validate-asm
6
7 var filename = '(?:[^ ]+/)?test/mjsunit/wasm/asm-wasm-exception-in-tonumber.js';
8 filename = filename.replace(/\//g, '[/\\\\]');
9
10 function verifyStack(frames, expected) {
11 assertTrue(frames.length >= expected.length, 'too few frames');
12 print('frames on detailed stack (' + frames.length + '):');
13 frames.forEach((fr, i) => print('[' + i + '] ' + fr));
14 expected.forEach(function(exp, i) {
15 assertEquals(
16 exp[0], frames[i].getFunctionName(), '[' + i + '].getFunctionName()');
17 assertEquals(
18 exp[1], frames[i].getLineNumber(), '[' + i + '].getLineNumber()');
19 assertEquals(
20 exp[2], frames[i].getColumnNumber(), '[' + i + '].getColumnNumber()');
21 assertContains(
22 ':' + exp[1] + ':' + exp[2], frames[i].toString(),
23 '[' + i + '].toString()');
24 });
25 }
26
27 function verifyPreformattedStack(e, expected_lines) {
28 print('preformatted stack: ' + e.stack);
29 var lines = e.stack.split('\n');
30 assertTrue(lines.length >= expected_lines.length, 'too few lines');
31 for (var i = 0; i < expected_lines.length; ++i) {
32 assertMatches(expected_lines[i], lines[i], 'line ' + i);
33 }
34 }
35
36 function sym(return_sym) {
37 if (return_sym) return Symbol();
38 throw Error("user-thrown");
39 }
40
41 function generateAsmJs(stdlib, foreign) {
42 'use asm';
43 var sym = foreign.sym;
44 function callSym(i) {
45 i=i|0;
46 return sym(i|0) | 0;
47 }
48 return callSym;
49 }
50
51 function testHelper(use_asm_js, check_detailed, expected, input) {
52 if (check_detailed) {
53 Error.prepareStackTrace = (error, frames) => frames;
54 } else {
55 delete Error.prepareStackTrace;
56 }
57
58 var fn_code = '(' + generateAsmJs.toString() + ')({}, {sym: sym})';
59 if (!use_asm_js) fn_code = fn_code.replace('use asm', '');
60 //print('executing:\n' + fn_code);
61 var asm_js_fn = eval(fn_code);
62 try {
63 asm_js_fn(input);
64 } catch (e) {
65 if (check_detailed) {
66 verifyStack(e.stack, expected);
67 } else {
68 verifyPreformattedStack(e, expected);
69 }
70 }
71 }
72
73 function testAll(expected_stack, expected_frames, input) {
74 for (use_asm_js = 0; use_asm_js <= 1; ++use_asm_js) {
75 for (test_detailed = 0; test_detailed <= 1; ++test_detailed) {
76 print('\nConfig: asm ' + use_asm_js + '; detailed ' + test_detailed);
77 testHelper(
78 use_asm_js, test_detailed,
79 test_detailed ? expected_frames : expected_stack, input);
80 }
81 }
82 }
83
84 (function testStackForThrowAtCall() {
85 var expected_stack = [
86 '^Error: user-thrown$',
87 '^ *at sym \\(' + filename + ':41:9\\)$',
bradnelson 2016/12/07 19:19:06 Might be worth being less picky about the row to b
Clemens Hammacher 2016/12/08 10:50:23 Yep, removed all line number information.
88 '^ *at callSym \\(.*<anonymous>:6:12\\)$',
89 ];
90 var expected_frames = [
91 // function line pos
92 [ "sym", 41, 9],
93 [ "callSym", 6, 12],
94 ];
95
96 testAll(expected_stack, expected_frames, 0);
97 })();
98
99 (function testStackForThrowAtConversion() {
100 var expected_stack = [
101 '^TypeError: Cannot convert a Symbol value to a number$',
102 '^ *at callSym \\(.*<anonymous>:6:21\\)$',
103 ];
104 var expected_frames = [
105 // function line pos
106 [ "callSym", 6, 21],
107 ];
108
109 testAll(expected_stack, expected_frames, 1);
110 })();
OLDNEW
« src/wasm/wasm-objects.cc ('K') | « test/cctest/wasm/wasm-run-utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698