v8/test/inspector/debugger/breakpoints-and-side-effects.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.7 KiB
JavaScript
Raw Normal View History

Reland "[debug] introduced runtime side effect check" This is a reland of 7a2c3713839f0915bd01738bf4633d8e5693651f Original change's description: > [debug] introduced runtime side effect check > > This CL demonstrates minimum valuable addition to existing debug evaluate > without side effects mechanism. > With this CL user can evaluate expressions like: > [a,b] // create any kind of temporary array literals > [a,b].reduce((x,y) => x + y, 0); // use reduce method > [1,2,3].fill(2); // change temporary arrays > > The core idea: any change of the object created during evaluation without > side effects is side effect free. As soon as we try to store this temporary > object to object existed before evaluation we will terminate execution. > > Implementation: > - track all objects allocated during evaluation and mark them as temporary, > - patch all bytecodes which change objects. > > A little more details (including performance analysis): [1]. > > [1] https://docs.google.com/document/d/10qqAtZADspPnpYa6SEdYRxrddfKIZJIzbLtGpsZQkRo/edit# > > Bug: v8:7588 > Change-Id: I69f7b96e1ebd7ad0022219e8213211c7be72a111 > Reviewed-on: https://chromium-review.googlesource.com/972615 > Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org> > Reviewed-by: Yang Guo <yangguo@chromium.org> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org> > Cr-Commit-Position: refs/heads/master@{#52370} Bug: v8:7588 Change-Id: Ibc92bf19155f2ddaedae39b0c576b994e84afcf8 Reviewed-on: https://chromium-review.googlesource.com/996760 Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org> Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org> Cr-Commit-Position: refs/heads/master@{#52373}
2018-04-05 02:01:34 +00:00
// Copyright 2018 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.
let {session, contextGroup, Protocol} =
InspectorTest.start('Tests how breakpoints and side effects live together.');
(async function main() {
session.setupScriptMap();
Protocol.Debugger.enable();
Protocol.Runtime.evaluate({expression: `
var a = 1;
function foo() {
a = 2;
}
//# sourceURL=test.js`});
Protocol.Debugger.setBreakpointByUrl({url: 'test.js', lineNumber: 3});
InspectorTest.log('Test breakpoint, should pause inside foo:');
{
const evaluatePromise = Protocol.Runtime.evaluate({expression: 'foo()'});
const {params:{callFrames}} = await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames);
Protocol.Debugger.resume();
await evaluatePromise;
}
InspectorTest.log('\nRun foo with no side effects:');
{
const {result:{result}} = await Protocol.Runtime.evaluate({
expression: 'foo()',
throwOnSideEffect: true
});
InspectorTest.logMessage(result);
}
InspectorTest.log('\nTest breakpoint after run with side effect check:');
{
const evaluatePromise = Protocol.Runtime.evaluate({expression: 'foo()'});
const {params:{callFrames}} = await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames);
Protocol.Debugger.resume();
await evaluatePromise;
}
await Protocol.Debugger.disable();
InspectorTest.log('\nRun foo with no side effects after debugger disabled:');
{
const {result:{result}} = await Protocol.Runtime.evaluate({
expression: 'foo()',
throwOnSideEffect: true
});
InspectorTest.logMessage(result);
}
InspectorTest.completeTest();
})();