OLD | NEW |
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 | 5 // Flags: --expose-wasm |
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 var builder = new WasmModuleBuilder(); | 10 var builder = new WasmModuleBuilder(); |
11 | 11 |
12 var imported_idx = builder.addImport("func", kSig_v_v); | 12 var imported_idx = builder.addImport("mode", "func", kSig_v_v); |
13 | 13 |
14 var call_imported_idx = builder.addFunction('call_func', kSig_v_v) | 14 var call_imported_idx = builder.addFunction('call_func', kSig_v_v) |
15 .addBody([kExprCallFunction, imported_idx]) | 15 .addBody([kExprCallFunction, imported_idx]) |
16 .index; | 16 .index; |
17 | 17 |
18 // Open a block in order to make the positions more interesting... | 18 // Open a block in order to make the positions more interesting... |
19 builder.addFunction('main', kSig_v_v) | 19 builder.addFunction('main', kSig_v_v) |
20 .addBody( | 20 .addBody( |
21 [kExprBlock, kAstStmt, kExprCallFunction, call_imported_idx, kExprEnd]) | 21 [kExprBlock, kAstStmt, kExprCallFunction, call_imported_idx, kExprEnd]) |
22 .exportAs('main'); | 22 .exportAs('main'); |
23 | 23 |
24 var module_bytes = builder.toArray(); | 24 var module_bytes = builder.toArray(); |
25 | 25 |
26 function testFunction(bytes) { | 26 function testFunction(bytes) { |
27 function call_debugger() { | 27 function call_debugger() { |
28 debugger; | 28 debugger; |
29 } | 29 } |
30 | 30 |
31 var buffer = new ArrayBuffer(bytes.length); | 31 var buffer = new ArrayBuffer(bytes.length); |
32 var view = new Uint8Array(buffer); | 32 var view = new Uint8Array(buffer); |
33 for (var i = 0; i < bytes.length; i++) { | 33 for (var i = 0; i < bytes.length; i++) { |
34 view[i] = bytes[i] | 0; | 34 view[i] = bytes[i] | 0; |
35 } | 35 } |
36 | 36 |
37 var module = new WebAssembly.Module(buffer); | 37 var module = new WebAssembly.Module(buffer); |
38 var instance = new WebAssembly.Instance(module, {func: call_debugger}); | 38 var instance = new WebAssembly.Instance(module, {mode: {func: call_debugger}})
; |
39 | 39 |
40 instance.exports.main(); | 40 instance.exports.main(); |
41 } | 41 } |
42 | 42 |
43 InspectorTest.addScript(testFunction.toString()); | 43 InspectorTest.addScript(testFunction.toString()); |
44 | 44 |
45 Protocol.Debugger.enable(); | 45 Protocol.Debugger.enable(); |
46 Protocol.Debugger.onPaused(handleDebuggerPaused); | 46 Protocol.Debugger.onPaused(handleDebuggerPaused); |
47 InspectorTest.log('Running testFunction with generated WASM bytes...'); | 47 InspectorTest.log('Running testFunction with generated WASM bytes...'); |
48 Protocol.Runtime.evaluate( | 48 Protocol.Runtime.evaluate( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 { | 87 { |
88 InspectorTest.log( | 88 InspectorTest.log( |
89 'Result of evaluate (' + response.result.result.type + '):'); | 89 'Result of evaluate (' + response.result.result.type + '):'); |
90 var result_lines = response.result.result.value.split('\n'); | 90 var result_lines = response.result.result.value.split('\n'); |
91 // Skip the second line, containing the 'evaluate' position. | 91 // Skip the second line, containing the 'evaluate' position. |
92 result_lines[1] = ' -- skipped --'; | 92 result_lines[1] = ' -- skipped --'; |
93 InspectorTest.log(result_lines.join('\n')); | 93 InspectorTest.log(result_lines.join('\n')); |
94 InspectorTest.log('Finished!'); | 94 InspectorTest.log('Finished!'); |
95 InspectorTest.completeTest(); | 95 InspectorTest.completeTest(); |
96 } | 96 } |
OLD | NEW |