OLD | NEW |
---|---|
(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: --expose-wasm | |
6 | |
7 load('test/mjsunit/wasm/wasm-constants.js'); | |
8 load('test/mjsunit/wasm/wasm-module-builder.js'); | |
9 | |
10 var builder = new WasmModuleBuilder(); | |
11 | |
12 var imported_idx = builder.addImport('func', kSig_v_v); | |
13 | |
14 var func_idx = builder.addFunction('helper', kSig_v_v) | |
15 .addLocals({i32_count: 1}) | |
16 .addBody([ | |
17 kExprNop, | |
18 kExprI32Const, 12, | |
19 kExprSetLocal, 0, | |
20 kExprCallFunction, imported_idx, | |
21 ]).index; | |
22 | |
23 builder.addFunction('main', kSig_v_i) | |
24 .addBody([ | |
25 kExprGetLocal, 0, | |
26 kExprIf, kAstStmt, | |
27 kExprBlock, kAstStmt, | |
28 kExprCallFunction, func_idx, | |
29 kExprEnd, | |
30 kExprEnd | |
31 ]).exportAs('main'); | |
32 | |
33 var module_bytes = builder.toArray(); | |
34 | |
35 function testFunction(bytes) { | |
36 function call_debugger() { | |
37 // Call to the debugger to trigger wasm translations for all functions on | |
38 // the stack. | |
39 debugger; | |
40 } | |
41 var buffer = new ArrayBuffer(bytes.length); | |
42 var view = new Uint8Array(buffer); | |
43 for (var i = 0; i < bytes.length; i++) { | |
44 view[i] = bytes[i] | 0; | |
45 } | |
46 | |
47 var module = new WebAssembly.Module(buffer); | |
48 var instance = new WebAssembly.Instance(module, {'func': call_debugger}); | |
49 | |
50 instance.exports.main(1); | |
51 } | |
52 | |
53 InspectorTest.addScript(testFunction.toString()); | |
54 InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes)); | |
55 | |
56 Protocol.Debugger.enable(); | |
57 Protocol.Debugger.onScriptParsed(handleScriptParsed); | |
58 InspectorTest.log('Running testFunction...'); | |
59 Protocol.Runtime.evaluate({'expression': 'testFunction(module_bytes)'}); | |
60 | |
61 var numScripts = 0; | |
62 function handleScriptParsed(messageObject) { | |
kozy
2016/11/30 18:34:37
Can we just dump this message object and do nothin
Clemens Hammacher
2016/12/02 17:44:13
Done.
| |
63 var scriptId = messageObject.params.scriptId; | |
64 var url = messageObject.params.url; | |
65 InspectorTest.log('Script nr ' + numScripts + ' parsed. URL: ' + url); | |
66 ++numScripts; | |
67 | |
68 if (url.startsWith('wasm://')) { | |
69 InspectorTest.log('This is a wasm script. Requesting breakable locations.'); | |
70 Protocol.Debugger | |
71 .getPossibleBreakpoints( | |
72 {start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}}) | |
73 .then(InspectorTest.logMessage) | |
74 .then(InspectorTest.completeTest); | |
75 } | |
76 } | |
OLD | NEW |