summaryrefslogtreecommitdiff
path: root/deps/v8/test/inspector/wasm-inspector-test.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/inspector/wasm-inspector-test.js')
-rw-r--r--deps/v8/test/inspector/wasm-inspector-test.js95
1 files changed, 64 insertions, 31 deletions
diff --git a/deps/v8/test/inspector/wasm-inspector-test.js b/deps/v8/test/inspector/wasm-inspector-test.js
index 67333dcbb6..47d8419055 100644
--- a/deps/v8/test/inspector/wasm-inspector-test.js
+++ b/deps/v8/test/inspector/wasm-inspector-test.js
@@ -7,25 +7,40 @@ utils.load('test/mjsunit/wasm/wasm-module-builder.js');
WasmInspectorTest = {}
InspectorTest.getWasmOpcodeName = getOpcodeName;
-WasmInspectorTest.evalWithUrl = (code, url) =>
- Protocol.Runtime
- .evaluate({'expression': code + '\n//# sourceURL=v8://test/' + url})
- .then(printIfFailure);
+WasmInspectorTest.evalWithUrl = async function(code, url) {
+ return await Protocol.Runtime
+ .evaluate({'expression': code + '\n//# sourceURL=v8://test/' + url})
+ .then(printIfFailure);
+};
-WasmInspectorTest.instantiateFromBuffer = function(bytes, imports) {
+WasmInspectorTest.compileFromBuffer = (function(bytes) {
var buffer = new ArrayBuffer(bytes.length);
var view = new Uint8Array(buffer);
for (var i = 0; i < bytes.length; ++i) {
view[i] = bytes[i] | 0;
}
- const module = new WebAssembly.Module(buffer);
- return new WebAssembly.Instance(module, imports);
-}
+ return new WebAssembly.Module(buffer);
+}).toString();
+
+WasmInspectorTest.instantiateFromBuffer =
+ (function(bytes, imports) {
+ return new WebAssembly.Instance(compileFromBuffer(bytes), imports);
+ })
+ .toString()
+ .replace('compileFromBuffer', WasmInspectorTest.compileFromBuffer);
-WasmInspectorTest.instantiate = async function(bytes, instance_name = 'instance') {
- const instantiate_code = `var ${instance_name} = (${WasmInspectorTest.instantiateFromBuffer})(${JSON.stringify(bytes)});`;
+WasmInspectorTest.compile = async function(bytes, module_name = 'module') {
+ const compile_code = `var ${module_name} = (${
+ WasmInspectorTest.compileFromBuffer})(${JSON.stringify(bytes)});`;
+ await WasmInspectorTest.evalWithUrl(compile_code, 'compile_module');
+};
+
+WasmInspectorTest.instantiate =
+ async function(bytes, instance_name = 'instance') {
+ const instantiate_code = `var ${instance_name} = (${
+ WasmInspectorTest.instantiateFromBuffer})(${JSON.stringify(bytes)});`;
await WasmInspectorTest.evalWithUrl(instantiate_code, 'instantiate');
-}
+};
WasmInspectorTest.dumpScopeProperties = async function(message) {
printIfFailure(message);
@@ -33,11 +48,17 @@ WasmInspectorTest.dumpScopeProperties = async function(message) {
var value_str = await getScopeValues(value.name, value.value);
InspectorTest.log(' ' + value.name + ': ' + value_str);
}
-}
+};
-WasmInspectorTest.getWasmValue = value => {
- return value.unserializableValue ?? value.value;
-}
+WasmInspectorTest.getWasmValue = async function(value) {
+ let msg = await Protocol.Runtime.getProperties({objectId: value.objectId});
+ printIfFailure(msg);
+ const value_type = msg.result.result.find(({name}) => name === 'type');
+ const value_value = msg.result.result.find(({name}) => name === 'value');
+ return `${
+ value_value.value.unserializableValue ??
+ value_value.value.value} (${value_type.value.value})`;
+};
function printIfFailure(message) {
if (!message.result) {
@@ -47,19 +68,29 @@ function printIfFailure(message) {
}
async function getScopeValues(name, value) {
- if (value.type == 'object') {
- if (value.subtype === 'typedarray' || value.subtype == 'webassemblymemory') return value.description;
+ async function printValue(value) {
+ if (value.type === 'object' && value.subtype === 'wasmvalue') {
+ return await WasmInspectorTest.getWasmValue(value);
+ } else if ('className' in value) {
+ return `(${value.className})`;
+ }
+ return `${value.unserializableValue ?? value.value} (${
+ value.subtype ?? value.type})`;
+ }
+ if (value.type === 'object' && value.subtype !== 'wasmvalue') {
+ if (value.subtype === 'typedarray' || value.subtype == 'webassemblymemory')
+ return value.description;
if (name === 'instance') return dumpInstanceProperties(value);
if (name === 'module') return value.description;
let msg = await Protocol.Runtime.getProperties({objectId: value.objectId});
printIfFailure(msg);
- const printProperty = function({name, value}) {
- return `"${name}": ${WasmInspectorTest.getWasmValue(value)} (${value.subtype ?? value.type})`;
+ async function printProperty({name, value}) {
+ return `"${name}": ${await printValue(value)}`;
}
- return msg.result.result.map(printProperty).join(', ');
+ return (await Promise.all(msg.result.result.map(printProperty))).join(', ');
}
- return `${WasmInspectorTest.getWasmValue(value)} (${value.subtype ?? value.type})`;
+ return await printValue(value);
}
function recursiveGetPropertiesWrapper(value, depth) {
@@ -68,10 +99,12 @@ function recursiveGetPropertiesWrapper(value, depth) {
async function recursiveGetProperties(value, depth) {
if (depth > 0) {
- const properties = await Promise.all(value.result.result.map(
- x => {return Protocol.Runtime.getProperties({objectId: x.value.objectId});}));
- const recursiveProperties = await Promise.all(properties.map(
- x => {return recursiveGetProperties(x, depth - 1);}));
+ const properties = await Promise.all(value.result.result.map(x => {
+ return Protocol.Runtime.getProperties({objectId: x.value.objectId});
+ }));
+ const recursiveProperties = await Promise.all(properties.map(x => {
+ return recursiveGetProperties(x, depth - 1);
+ }));
return recursiveProperties.flat();
}
return value;
@@ -83,17 +116,17 @@ async function dumpInstanceProperties(instanceObj) {
}
const exportsName = 'exports';
- let exportsObj = await Protocol.Runtime.callFunctionOn(
- {objectId: instanceObj.objectId,
- functionDeclaration: invokeGetter.toString(),
- arguments: [{value: JSON.stringify(exportsName)}]
- });
+ let exportsObj = await Protocol.Runtime.callFunctionOn({
+ objectId: instanceObj.objectId,
+ functionDeclaration: invokeGetter.toString(),
+ arguments: [{value: JSON.stringify(exportsName)}]
+ });
printIfFailure(exportsObj);
let exports = await Protocol.Runtime.getProperties(
{objectId: exportsObj.result.result.objectId});
printIfFailure(exports);
- const printExports = function(value) {
+ function printExports(value) {
return `"${value.name}" (${value.value.className})`;
}
const formattedExports = exports.result.result.map(printExports).join(', ');