MCPcopy Create free account
hub / github.com/nodejs/node / loadScript

Function loadScript

deps/v8/test/inspector/debugger/wasm-scripts-disassembly.js:20–54  ·  view source on GitHub ↗
({url, scriptId})

Source from the content-addressed store, hash-verified

18 }).then(params => loadScript(params));
19
20async function loadScript({url, scriptId}) {
21 InspectorTest.log(`Session #${sessionId}: Script parsed. URL: ${url}.`);
22 ({result: {scriptSource, bytecode}} =
23 await Protocol.Debugger.getScriptSource({scriptId}));
24 ({result: {
25 streamId,
26 totalNumberOfLines,
27 functionBodyOffsets,
28 chunk: {lines, bytecodeOffsets}
29 }} = await Protocol.Debugger.disassembleWasmModule({scriptId}));
30
31 InspectorTest.log(`Session #${sessionId}: Source for ${url}:`);
32 bytecode = InspectorTest.decodeBase64(bytecode);
33 const bytes = [];
34 for (let i = 0; i < bytecode.length; i++) {
35 let byte = bytecode[i];
36 bytes.push((byte < 0x10 ? '0x0' : '0x') + byte.toString(16) + " ");
37 if ((i & 7) == 7) bytes.push(` ;; offset ${i-7}..${i}\n`);
38 }
39 InspectorTest.log(`bytecode:\n${bytes.join("")}`);
40
41 InspectorTest.log(`streamid: ${streamId}`);
42 InspectorTest.log(`functionBodyOffsets: ${functionBodyOffsets}`);
43 InspectorTest.log(`totalNumberOfLines: ${totalNumberOfLines}`);
44 InspectorTest.log(`lines: \n${lines.join("\n")}`);
45 InspectorTest.log(`bytecodeOffsets: ${bytecodeOffsets}`);
46
47 if (streamId) {
48 ({result: {chunk: {lines, bytecodeOffsets}}} =
49 await Protocol.Debugger.nextWasmDissassemblyChunk({streamId}));
50 InspectorTest.log(`chunk #2:`);
51 InspectorTest.log(`lines: \n${lines.join("\n")}`);
52 InspectorTest.log(`bytecodeOffsets: ${bytecodeOffsets}`);
53 }
54}
55
56const builder = new WasmModuleBuilder();
57builder.addFunction('f1', kSig_i_r)

Callers 1

Calls 4

logMethod · 0.45
pushMethod · 0.45
toStringMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected