Skip to content

Commit dc49fe0

Browse files
hashseedV8 LUCI CQ
authored andcommitted
[debug] correctly tier down function for side effect check mode
Previously we do not tier down from baseline to interpreter, which breaks per-bytecode side effect checks (to check whether e.g. we are mutating a temporary object, which is not considered a side effect). R=leszeks@chromium.org Bug: chromium:1233401 Change-Id: Ie08b5352aa4c124421b4c9abce18326938bbc822 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3056981 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#75963}
1 parent 4ccf0a4 commit dc49fe0

3 files changed

Lines changed: 129 additions & 1 deletion

File tree

src/runtime/runtime-debug.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,8 @@ RUNTIME_FUNCTION(Runtime_DebugOnFunctionCall) {
685685
CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1);
686686
if (isolate->debug()->needs_check_on_function_call()) {
687687
// Ensure that the callee will perform debug check on function call too.
688-
Deoptimizer::DeoptimizeFunction(*fun);
688+
Handle<SharedFunctionInfo> shared(fun->shared(), isolate);
689+
isolate->debug()->DeoptimizeFunction(shared);
689690
if (isolate->debug()->last_step_action() >= StepInto ||
690691
isolate->debug()->break_on_next_function_call()) {
691692
DCHECK_EQ(isolate->debug_execution_mode(), DebugInfo::kBreakpoints);
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
Execute it separately
2+
{
3+
id : <messageId>
4+
result : {
5+
exceptionDetails : {
6+
columnNumber : -1
7+
exception : {
8+
className : EvalError
9+
description : EvalError: Possible side-effect in debug-evaluate
10+
objectId : <objectId>
11+
subtype : error
12+
type : object
13+
}
14+
exceptionId : <exceptionId>
15+
lineNumber : -1
16+
scriptId : <scriptId>
17+
text : Uncaught
18+
}
19+
result : {
20+
className : EvalError
21+
description : EvalError: Possible side-effect in debug-evaluate
22+
objectId : <objectId>
23+
subtype : error
24+
type : object
25+
}
26+
}
27+
}
28+
{
29+
id : <messageId>
30+
result : {
31+
result : {
32+
description : 1
33+
type : number
34+
value : 1
35+
}
36+
}
37+
}
38+
{
39+
id : <messageId>
40+
result : {
41+
exceptionDetails : {
42+
columnNumber : -1
43+
exception : {
44+
className : EvalError
45+
description : EvalError: Possible side-effect in debug-evaluate
46+
objectId : <objectId>
47+
subtype : error
48+
type : object
49+
}
50+
exceptionId : <exceptionId>
51+
lineNumber : -1
52+
scriptId : <scriptId>
53+
text : Uncaught
54+
}
55+
result : {
56+
className : EvalError
57+
description : EvalError: Possible side-effect in debug-evaluate
58+
objectId : <objectId>
59+
subtype : error
60+
type : object
61+
}
62+
}
63+
}
64+
{
65+
id : <messageId>
66+
result : {
67+
result : {
68+
description : 2
69+
type : number
70+
value : 2
71+
}
72+
}
73+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2021 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --sparkplug
6+
// Flags: --no-baseline-batch-compilation
7+
8+
const baseScript = `
9+
var paths = [
10+
[ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 1],
11+
[ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 1],
12+
[ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0]
13+
];
14+
15+
function sink(arr) {
16+
let i = arr.length - 2;
17+
for (let j = 0; j < arr[i].length; j++) {
18+
const node = arr[i][j];
19+
const right = arr[i + 1][j + 1];
20+
arr[i][j] = Math.max(node + right);
21+
}
22+
arr.pop();
23+
return arr[i][arr[i].length-1];
24+
}
25+
`;
26+
27+
let {session, contextGroup, Protocol} = InspectorTest.start(
28+
'Evaluate with and without side effect checks');
29+
30+
(async function test() {
31+
await Protocol.Runtime.evaluate({
32+
expression: baseScript,
33+
replMode: true,
34+
});
35+
InspectorTest.logMessage(await Protocol.Runtime.evaluate({
36+
expression: 'sink(paths);',
37+
replMode: true,
38+
throwOnSideEffect: true,
39+
}));
40+
InspectorTest.logMessage(await Protocol.Runtime.evaluate({
41+
expression: 'sink(paths)',
42+
replMode: true,
43+
}));
44+
InspectorTest.logMessage(await Protocol.Runtime.evaluate({
45+
expression: 'sink(paths);',
46+
replMode: true,
47+
throwOnSideEffect: true,
48+
}));
49+
InspectorTest.logMessage(await Protocol.Runtime.evaluate({
50+
expression: 'sink(paths);',
51+
replMode: true,
52+
}));
53+
InspectorTest.completeTest();
54+
})();

0 commit comments

Comments
 (0)