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 builder.addFunction("main", kSig_v_i) |
| 15 .addBody([ |
| 16 // @1 |
| 17 kExprNop, |
| 18 // @2 |
| 19 kExprGetLocal, 0, |
| 20 // @4 |
| 21 kExprIf, kAstStmt, |
| 22 // @6 |
| 23 kExprBlock, kAstStmt, |
| 24 // @8 |
| 25 kExprCallFunction, imported_idx, |
| 26 // @10 |
| 27 kExprEnd, |
| 28 // @11 |
| 29 kExprEnd |
| 30 ]).exportAs("main"); |
| 31 |
| 32 var module_bytes = builder.toArray(); |
| 33 |
| 34 function testFunction(bytes) { |
| 35 function call_debugger() { |
| 36 // Call to the debugger to trigger wasm translations for all functions on |
| 37 // the stack. |
| 38 debugger; |
| 39 } |
| 40 var buffer = new ArrayBuffer(bytes.length); |
| 41 var view = new Uint8Array(buffer); |
| 42 for (var i = 0; i < bytes.length; i++) { |
| 43 view[i] = bytes[i] | 0; |
| 44 } |
| 45 |
| 46 var module = new WebAssembly.Module(buffer); |
| 47 var instance = new WebAssembly.Instance(module, {'func': call_debugger}); |
| 48 |
| 49 instance.exports.main(1); |
| 50 } |
| 51 |
| 52 InspectorTest.addScript(testFunction.toString()); |
| 53 InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes)); |
| 54 |
| 55 Protocol.Debugger.enable(); |
| 56 Protocol.Debugger.onScriptParsed(handleScriptParsed); |
| 57 InspectorTest.log('Running testFunction...'); |
| 58 Protocol.Runtime.evaluate({'expression': 'testFunction(module_bytes)'}); |
| 59 |
| 60 var numScripts = 0; |
| 61 function handleScriptParsed(messageObject) |
| 62 { |
| 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 |