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

Side by Side Diff: test/mjsunit/wasm/frame-inspection.js

Issue 2493823003: [wasm] Allocate a single script per wasm module (Closed)
Patch Set: rebase Created 4 years, 1 month 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/debug-disassembly.js ('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
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 // Flags: --expose-wasm --expose-debug-as debug 5 // Flags: --expose-wasm --expose-debug-as debug
6 6
7 load("test/mjsunit/wasm/wasm-constants.js"); 7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js"); 8 load("test/mjsunit/wasm/wasm-module-builder.js");
9 9
10 Debug = debug.Debug 10 Debug = debug.Debug
11 11
12 var exception = null; 12 var exception = null;
13 var break_count = 0; 13 var break_count = 0;
14 14
15 const expected_num_frames = 5; 15 const expected_frames = [
16 const expected_wasm_frames = [false, true, true, false, false]; 16 // func-name; wasm?; pos; line; col
17 const expected_wasm_positions = [0, 1, 2, 0, 0]; 17 ['call_debugger', false], // --
18 const expected_function_names = ["call_debugger", "wasm_2", "wasm_1", "testFrame Inspection", ""]; 18 ['wasm_2', true, 56, 2, 1], // --
19 ['wasm_1', true, 52, 1, 2], // --
20 ['testFrameInspection', false], // --
21 ['', false]
22 ];
19 23
20 function listener(event, exec_state, event_data, data) { 24 function listener(event, exec_state, event_data, data) {
21 if (event != Debug.DebugEvent.Break) return; 25 if (event != Debug.DebugEvent.Break) return;
22 ++break_count; 26 ++break_count;
23 try { 27 try {
24 var break_id = exec_state.break_id; 28 var break_id = exec_state.break_id;
25 var frame_count = exec_state.frameCount(); 29 var frame_count = exec_state.frameCount();
26 assertEquals(expected_num_frames, frame_count); 30 assertEquals(expected_frames.length, frame_count, 'frame count');
27 31
28 for (var i = 0; i < frame_count; ++i) { 32 for (var i = 0; i < frame_count; ++i) {
29 var frame = exec_state.frame(i); 33 var frame = exec_state.frame(i);
34 assertEquals(expected_frames[i][0], frame.func().name(), 'name at ' + i);
30 // wasm frames have unresolved function, others resolved ones. 35 // wasm frames have unresolved function, others resolved ones.
31 assertEquals(expected_wasm_frames[i], !frame.func().resolved()); 36 assertEquals(
32 assertEquals(expected_function_names[i], frame.func().name()); 37 expected_frames[i][1], !frame.func().resolved(), 'resolved at ' + i);
33 if (expected_wasm_frames[i]) { 38 if (expected_frames[i][1]) { // wasm frame?
34 var script = frame.details().script(); 39 var script = frame.details().script();
35 assertNotNull(script); 40 assertNotNull(script, 'script at ' + i);
36 assertEquals(expected_wasm_positions[i], frame.details().sourcePosition( )); 41 assertEquals(
42 expected_frames[i][2], frame.details().sourcePosition(),
43 'source pos at ' + i);
37 var loc = script.locationFromPosition(frame.details().sourcePosition()); 44 var loc = script.locationFromPosition(frame.details().sourcePosition());
38 assertEquals(expected_wasm_positions[i], loc.column); 45 assertEquals(expected_frames[i][2], loc.position, 'pos at ' + i);
39 assertEquals(expected_wasm_positions[i], loc.position); 46 assertEquals(expected_frames[i][3], loc.line, 'line at ' + i);
47 assertEquals(expected_frames[i][4], loc.column, 'column at ' + i);
40 } 48 }
41 } 49 }
42 } catch (e) { 50 } catch (e) {
43 exception = e; 51 exception = e;
44 } 52 }
45 }; 53 };
46 54
47 var builder = new WasmModuleBuilder(); 55 var builder = new WasmModuleBuilder();
48 56
49 // wasm_1 calls wasm_2 on offset 2. 57 // wasm_1 calls wasm_2 on offset 2.
50 // wasm_2 calls call_debugger on offset 1. 58 // wasm_2 calls call_debugger on offset 1.
51 59
52 builder.addImport("func", kSig_v_v); 60 builder.addImport('func', kSig_v_v);
53 61
54 builder.addFunction("wasm_1", kSig_v_v) 62 builder.addFunction('wasm_1', kSig_v_v)
55 .addBody([kExprNop, kExprCallFunction, 2]) 63 .addBody([kExprNop, kExprCallFunction, 2])
56 .exportAs("main"); 64 .exportAs('main');
57 65
58 builder.addFunction("wasm_2", kSig_v_v) 66 builder.addFunction('wasm_2', kSig_v_v).addBody([kExprCallFunction, 0]);
59 .addBody([kExprCallFunction, 0]);
60 67
61 function call_debugger() { 68 function call_debugger() {
62 debugger; 69 debugger;
63 } 70 }
64 71
65 var module = builder.instantiate({func: call_debugger}); 72 var module = builder.instantiate({func: call_debugger});
66 73
67 (function testFrameInspection() { 74 (function testFrameInspection() {
68 Debug.setListener(listener); 75 Debug.setListener(listener);
69 module.exports.main(); 76 module.exports.main();
70 Debug.setListener(null); 77 Debug.setListener(null);
71 78
72 assertEquals(1, break_count); 79 assertEquals(1, break_count);
73 if (exception) throw exception; 80 if (exception) throw exception;
74 })(); 81 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/debug-disassembly.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698