7f20cf56e6
This adds a new --experimental-value-unavailable flag, which is disabled for now. When enabled the debugger reports values that are optimized out by TurboFan and values of certain variables in Temporal Dead Zones (TDZ) as unavailable. Internally we use a special `value_unavailable` accessor info to represent these values, and on the debugger boundary we report these properties with `value`, `get`, or `set`. Doc: https://goo.gle/devtools-value-unavailable Bug: chromium:1328681 Demo: devtools-dbg-stories.netlify.app/crbug-1328681-value-unavailable Change-Id: Idb09a4a148335a950deae60f7c07caecc48826ba Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3627510 Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/main@{#81509}
82 lines
2.1 KiB
JavaScript
82 lines
2.1 KiB
JavaScript
// Copyright 2022 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.
|
|
|
|
// Flags: --allow-natives-syntax --experimental-value-unavailable
|
|
|
|
let {session, contextGroup, Protocol} =
|
|
InspectorTest.start('Test scopes with unavailable values');
|
|
|
|
contextGroup.addScript(`
|
|
function tdz() {
|
|
debugger;
|
|
const x = 2 ?? y + x;
|
|
let y = x + 1;
|
|
return y;
|
|
}
|
|
|
|
function opt() {
|
|
function optimizedOut(x, stop) {
|
|
let y = x + 1;
|
|
let z = y + 1;
|
|
if (stop) {
|
|
debugger;
|
|
}
|
|
return z;
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(optimizedOut);
|
|
optimizedOut(1, false);
|
|
optimizedOut(2, false);
|
|
%OptimizeFunctionOnNextCall(optimizedOut);
|
|
optimizedOut(3, false);
|
|
|
|
return optimizedOut(1, true);
|
|
}
|
|
`);
|
|
|
|
Protocol.Debugger.onPaused(async ({params: {callFrames: [{scopeChain}]}}) => {
|
|
for (const scope of scopeChain) {
|
|
if (scope.type !== 'local') continue;
|
|
const {result: {result: variables}} =
|
|
await Protocol.Runtime.getProperties({objectId: scope.object.objectId});
|
|
for (const variable of variables) {
|
|
if (variable.name !== 'y') continue;
|
|
if ('value' in variable || 'get' in variable || 'set' in variable) {
|
|
InspectorTest.log(
|
|
'FAIL: variable y was expected to be reported as <value_unavailable>');
|
|
} else {
|
|
InspectorTest.log(
|
|
'variable y correctly reported as <value_unavailable>');
|
|
}
|
|
}
|
|
}
|
|
await Protocol.Debugger.resume();
|
|
});
|
|
|
|
InspectorTest.runAsyncTestSuite([
|
|
async function testTemporalDeadZone() {
|
|
await Promise.all([
|
|
Protocol.Runtime.enable(),
|
|
Protocol.Debugger.enable(),
|
|
]);
|
|
await Protocol.Runtime.evaluate({expression: 'tdz()'});
|
|
await Promise.all([
|
|
Protocol.Runtime.disable(),
|
|
Protocol.Debugger.disable(),
|
|
]);
|
|
},
|
|
|
|
async function testOptimizedOut() {
|
|
await Promise.all([
|
|
Protocol.Runtime.enable(),
|
|
Protocol.Debugger.enable(),
|
|
]);
|
|
await Protocol.Runtime.evaluate({expression: 'opt()'});
|
|
await Promise.all([
|
|
Protocol.Runtime.disable(),
|
|
Protocol.Debugger.disable(),
|
|
]);
|
|
},
|
|
]);
|