2019-02-20 12:04:27 +00:00
|
|
|
// Copyright 2019 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2022-04-28 14:22:23 +00:00
|
|
|
// TODO(v8:10266): Figure out why this fails on tsan with --always-turbofan.
|
|
|
|
// Flags: --no-always-turbofan --no-turbo-inline-js-wasm-calls
|
2020-02-25 10:59:47 +00:00
|
|
|
|
2019-02-20 12:04:27 +00:00
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start(
|
|
|
|
'Test that console profiles contain wasm function names.');
|
|
|
|
|
|
|
|
utils.load('test/mjsunit/wasm/wasm-module-builder.js');
|
|
|
|
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
// Build module bytes, including a sentinel such that the module will not be
|
|
|
|
// reused from the cache.
|
|
|
|
let sentinel = 0;
|
|
|
|
function buildModuleBytes() {
|
|
|
|
++sentinel;
|
|
|
|
InspectorTest.log(`Building wasm module with sentinel ${sentinel}.`);
|
|
|
|
// Add fibonacci function, calling back and forth between JS and Wasm to also
|
|
|
|
// check for the occurrence of the wrappers.
|
|
|
|
var builder = new WasmModuleBuilder();
|
|
|
|
const imp_index = builder.addImport('q', 'f', kSig_i_i);
|
|
|
|
builder.addFunction('fib', kSig_i_i)
|
|
|
|
.addBody([
|
|
|
|
...wasmI32Const(sentinel), kExprDrop,
|
|
|
|
kExprLocalGet, 0,
|
|
|
|
kExprLocalGet, 0,
|
|
|
|
kExprI32Const, 2,
|
|
|
|
kExprI32LeS, // i < 2 ?
|
|
|
|
kExprBrIf, 0, // --> return i
|
|
|
|
kExprI32Const, 1, kExprI32Sub, // i - 1
|
|
|
|
kExprCallFunction, imp_index, // imp(i - 1)
|
|
|
|
kExprLocalGet, 0, kExprI32Const, 2, kExprI32Sub, // i - 2
|
|
|
|
kExprCallFunction, imp_index, // imp(i - 2)
|
|
|
|
kExprI32Add
|
|
|
|
])
|
|
|
|
.exportFunc();
|
|
|
|
return builder.toArray();
|
|
|
|
}
|
2019-02-20 12:04:27 +00:00
|
|
|
|
|
|
|
function compile(bytes) {
|
|
|
|
let buffer = new ArrayBuffer(bytes.length);
|
|
|
|
let view = new Uint8Array(buffer);
|
|
|
|
for (var i = 0; i < bytes.length; i++) {
|
|
|
|
view[i] = bytes[i] | 0;
|
|
|
|
}
|
|
|
|
let module = new WebAssembly.Module(buffer);
|
2020-02-25 10:59:47 +00:00
|
|
|
let fib = undefined;
|
|
|
|
function imp(i) { return fib(i); }
|
|
|
|
let instance = new WebAssembly.Instance(module, {q: {f: imp}});
|
|
|
|
fib = instance.exports.fib;
|
2019-02-20 12:04:27 +00:00
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
2020-02-25 10:59:47 +00:00
|
|
|
function checkError(message) {
|
|
|
|
if (!message.error) return;
|
|
|
|
InspectorTest.log('Error: ');
|
|
|
|
InspectorTest.logMessage(message);
|
|
|
|
InspectorTest.completeTest();
|
2019-02-20 12:04:27 +00:00
|
|
|
}
|
|
|
|
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
let found_good_profile = false;
|
2020-12-03 17:12:32 +00:00
|
|
|
let found_wasm_script_id;
|
2020-12-08 16:11:40 +00:00
|
|
|
let wasm_position;
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
let finished_profiles = 0;
|
|
|
|
Protocol.Profiler.onConsoleProfileFinished(e => {
|
|
|
|
++finished_profiles;
|
2020-12-08 16:11:40 +00:00
|
|
|
let nodes = e.params.profile.nodes;
|
|
|
|
let function_names = nodes.map(n => n.callFrame.functionName);
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
// Enable this line for debugging:
|
|
|
|
// InspectorTest.log(function_names.join(', '));
|
|
|
|
// Check for at least one full cycle of
|
|
|
|
// fib -> wasm-to-js -> imp -> js-to-wasm -> fib.
|
|
|
|
// There are two different kinds of js-to-wasm-wrappers, so there are two
|
|
|
|
// possible positive traces.
|
2020-12-03 17:12:32 +00:00
|
|
|
const expected = [
|
|
|
|
['fib'], ['wasm-to-js:i:i'], ['imp'],
|
|
|
|
['GenericJSToWasmWrapper', 'js-to-wasm:i:i'], ['fib']
|
|
|
|
];
|
|
|
|
for (let i = 0; i <= function_names.length - expected.length; ++i) {
|
|
|
|
if (expected.every((val, idx) => val.includes(function_names[i + idx]))) {
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
found_good_profile = true;
|
2020-12-08 16:11:40 +00:00
|
|
|
let wasm_frame = nodes[i].callFrame;
|
|
|
|
found_wasm_script_id = wasm_frame.scriptId != 0;
|
|
|
|
wasm_position = `${wasm_frame.url}@${wasm_frame.lineNumber}:${
|
|
|
|
wasm_frame.columnNumber}`;
|
2020-02-25 10:59:47 +00:00
|
|
|
}
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
async function runFibUntilProfileFound() {
|
2019-02-20 12:04:27 +00:00
|
|
|
InspectorTest.log(
|
|
|
|
'Running fib with increasing input until it shows up in the profile.');
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
found_good_profile = false;
|
|
|
|
finished_profiles = 0;
|
2020-02-25 10:59:47 +00:00
|
|
|
for (let i = 1; !found_good_profile; ++i) {
|
2019-02-20 12:04:27 +00:00
|
|
|
checkError(await Protocol.Runtime.evaluate(
|
|
|
|
{expression: 'console.profile(\'profile\');'}));
|
|
|
|
checkError(await Protocol.Runtime.evaluate(
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
{expression: 'globalThis.instance.exports.fib(' + i + ');'}));
|
2019-02-20 12:04:27 +00:00
|
|
|
checkError(await Protocol.Runtime.evaluate(
|
|
|
|
{expression: 'console.profileEnd(\'profile\');'}));
|
|
|
|
if (finished_profiles != i) {
|
|
|
|
InspectorTest.log(
|
|
|
|
'Missing consoleProfileFinished message (expected ' + i + ', got ' +
|
|
|
|
finished_profiles + ')');
|
|
|
|
}
|
|
|
|
}
|
2020-02-25 10:59:47 +00:00
|
|
|
InspectorTest.log('Found expected functions in profile.');
|
2020-12-03 17:12:32 +00:00
|
|
|
InspectorTest.log(
|
|
|
|
'Wasm script id is ' + (found_wasm_script_id ? 'set.' : 'NOT SET.'));
|
2020-12-08 16:11:40 +00:00
|
|
|
InspectorTest.log('Wasm position: ' + wasm_position);
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function compileWasm() {
|
|
|
|
InspectorTest.log('Compiling wasm.');
|
|
|
|
checkError(await Protocol.Runtime.evaluate({
|
|
|
|
expression: `globalThis.instance = (${compile})(${
|
|
|
|
JSON.stringify(buildModuleBytes())});`
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
async function testEnableProfilerEarly() {
|
|
|
|
InspectorTest.log(arguments.callee.name);
|
2020-12-04 16:26:10 +00:00
|
|
|
checkError(await Protocol.Profiler.enable());
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
checkError(await Protocol.Profiler.start());
|
|
|
|
await compileWasm();
|
|
|
|
await runFibUntilProfileFound();
|
2020-12-04 16:26:10 +00:00
|
|
|
checkError(await Protocol.Profiler.disable());
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function testEnableProfilerLate() {
|
|
|
|
InspectorTest.log(arguments.callee.name);
|
|
|
|
await compileWasm();
|
2020-12-04 16:26:10 +00:00
|
|
|
checkError(await Protocol.Profiler.enable());
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
checkError(await Protocol.Profiler.start());
|
|
|
|
await runFibUntilProfileFound();
|
2020-12-04 16:26:10 +00:00
|
|
|
checkError(await Protocol.Profiler.disable());
|
|
|
|
}
|
|
|
|
|
|
|
|
async function testEnableProfilerAfterDebugger() {
|
|
|
|
InspectorTest.log(arguments.callee.name);
|
|
|
|
checkError(await Protocol.Debugger.enable());
|
|
|
|
await compileWasm();
|
|
|
|
checkError(await Protocol.Profiler.enable());
|
|
|
|
checkError(await Protocol.Profiler.start());
|
|
|
|
await runFibUntilProfileFound();
|
|
|
|
checkError(await Protocol.Profiler.disable());
|
|
|
|
checkError(await Protocol.Debugger.disable());
|
|
|
|
}
|
|
|
|
|
|
|
|
async function testEnableProfilerBeforeDebugger() {
|
|
|
|
InspectorTest.log(arguments.callee.name);
|
|
|
|
await compileWasm();
|
|
|
|
await Protocol.Profiler.enable();
|
|
|
|
await Protocol.Debugger.enable();
|
|
|
|
checkError(await Protocol.Profiler.start());
|
|
|
|
await runFibUntilProfileFound();
|
|
|
|
await Protocol.Debugger.disable();
|
|
|
|
await Protocol.Profiler.disable();
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
(async function test() {
|
|
|
|
try {
|
|
|
|
await testEnableProfilerEarly();
|
|
|
|
await testEnableProfilerLate();
|
2020-12-04 16:26:10 +00:00
|
|
|
await testEnableProfilerAfterDebugger();
|
|
|
|
await testEnableProfilerBeforeDebugger();
|
[wasm][profiler] Fix late enabling of the profiler
We had a test which first enabled the profiler, and then compiled wasm
code. In this case, all code objects were registered correctly and the
profile looked as expected.
This CL extends the test for also test another order: First compile the
wasm code, then enable the profiler. In that case, we were reporting a
wrong debug name of the exported wasm function. The name of that
function is spec'ed to be the string representation of the function
index. But for debugging, we want to see a more meaningful name,
identical to the name we show when reporting the code during
compilation.
This fix requires handlifying the {SharedFunctionInfo::DebugName}
method, because for exported wasm functions, it needs to allocate a new
name on the JS heap.
In order to avoid this allocation where possible, a second variant is
added which returns a unique_ptr directly. This can be used in all
places where the name is just being printed, which turned out to be the
majority of cases ({DebugName().ToCString()}).
R=petermarshall@chromium.org
Bug: chromium:1141787
Change-Id: I0343c2f06f0b852007535ff07459b712801ead01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543931
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71308}
2020-11-19 15:42:46 +00:00
|
|
|
} catch (e) {
|
|
|
|
InspectorTest.log('caught: ' + e);
|
|
|
|
}
|
|
|
|
})().catch(e => InspectorTest.log('caught: ' + e))
|
|
|
|
.finally(InspectorTest.completeTest);
|