[debugger] extend whitelist for side-effect free debug-evaluate.
R=jgruber@chromium.org BUG=v8:5821 Review-Url: https://codereview.chromium.org/2680163005 Cr-Commit-Position: refs/heads/master@{#43061}
This commit is contained in:
parent
3186653665
commit
93c1e73d06
@ -269,10 +269,25 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
|
||||
case Runtime::kInlineToString:
|
||||
case Runtime::kToLength:
|
||||
case Runtime::kInlineToLength:
|
||||
// Type checks.
|
||||
case Runtime::kIsJSReceiver:
|
||||
case Runtime::kInlineIsJSReceiver:
|
||||
case Runtime::kIsSmi:
|
||||
case Runtime::kInlineIsSmi:
|
||||
case Runtime::kIsArray:
|
||||
case Runtime::kIsFunction:
|
||||
case Runtime::kIsDate:
|
||||
case Runtime::kIsJSProxy:
|
||||
case Runtime::kIsRegExp:
|
||||
case Runtime::kIsTypedArray:
|
||||
// Loads.
|
||||
case Runtime::kLoadLookupSlotForCall:
|
||||
// Errors.
|
||||
case Runtime::kReThrow:
|
||||
case Runtime::kThrowReferenceError:
|
||||
case Runtime::kThrowSymbolIteratorInvalid:
|
||||
case Runtime::kThrowIteratorResultNotAnObject:
|
||||
case Runtime::kNewTypeError:
|
||||
// Strings.
|
||||
case Runtime::kInlineStringCharCodeAt:
|
||||
case Runtime::kStringCharCodeAt:
|
||||
@ -288,6 +303,7 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
|
||||
case Runtime::kCreateObjectLiteral:
|
||||
case Runtime::kCreateRegExpLiteral:
|
||||
// Misc.
|
||||
case Runtime::kForInPrepare:
|
||||
case Runtime::kInlineCall:
|
||||
case Runtime::kCall:
|
||||
case Runtime::kInlineMaxSmi:
|
||||
@ -350,9 +366,18 @@ bool BytecodeHasNoSideEffect(interpreter::Bytecode bytecode) {
|
||||
case Bytecode::kCreateArrayLiteral:
|
||||
case Bytecode::kCreateObjectLiteral:
|
||||
case Bytecode::kCreateRegExpLiteral:
|
||||
// Misc.
|
||||
// Allocations.
|
||||
case Bytecode::kCreateClosure:
|
||||
case Bytecode::kCreateUnmappedArguments:
|
||||
// Conversions.
|
||||
case Bytecode::kToObject:
|
||||
// Misc.
|
||||
case Bytecode::kForInPrepare:
|
||||
case Bytecode::kForInContinue:
|
||||
case Bytecode::kForInNext:
|
||||
case Bytecode::kForInStep:
|
||||
case Bytecode::kThrow:
|
||||
case Bytecode::kReThrow:
|
||||
case Bytecode::kIllegal:
|
||||
case Bytecode::kCallJSRuntime:
|
||||
case Bytecode::kStackCheck:
|
||||
@ -371,6 +396,8 @@ bool BytecodeHasNoSideEffect(interpreter::Bytecode bytecode) {
|
||||
bool BuiltinHasNoSideEffect(Builtins::Name id) {
|
||||
switch (id) {
|
||||
// Whitelist for builtins.
|
||||
// Array builtins.
|
||||
case Builtins::kArrayPrototypeValues:
|
||||
// Math builtins.
|
||||
case Builtins::kMathAbs:
|
||||
case Builtins::kMathAcos:
|
||||
|
108
test/debugger/debug/debug-evaluate-no-side-effect-control.js
Normal file
108
test/debugger/debug/debug-evaluate-no-side-effect-control.js
Normal file
@ -0,0 +1,108 @@
|
||||
// Copyright 2017 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: --ignition --side-effect-free-debug-evaluate
|
||||
|
||||
Debug = debug.Debug
|
||||
|
||||
var exception = null;
|
||||
|
||||
var o = { p : 1 };
|
||||
|
||||
var successes = [
|
||||
[45,
|
||||
`(function() {
|
||||
var sum = 0;
|
||||
for (var i = 0; i < 10; i++) sum += i;
|
||||
return sum;
|
||||
})()`
|
||||
],
|
||||
["0012",
|
||||
`(function() {
|
||||
var sum = 0;
|
||||
for (var i in [1, 2, 3]) sum += i;
|
||||
return sum;
|
||||
})()`
|
||||
],
|
||||
[15,
|
||||
`(function() {
|
||||
var sum = 1;
|
||||
while (sum < 12) sum += sum + 1;
|
||||
return sum;
|
||||
})()`
|
||||
],
|
||||
[15,
|
||||
`(function() {
|
||||
var sum = 1;
|
||||
do { sum += sum + 1; } while (sum < 12);
|
||||
return sum;
|
||||
})()`
|
||||
],
|
||||
["023",
|
||||
`(function() {
|
||||
var sum = "";
|
||||
for (var i = 0; i < 4; i++) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
case 1:
|
||||
if (i == 0) sum += i;
|
||||
break;
|
||||
default:
|
||||
case 3:
|
||||
sum += i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
})()`
|
||||
],
|
||||
["oups",
|
||||
`(function() {
|
||||
try {
|
||||
if (Math.sin(1) < 1) throw new Error("oups");
|
||||
} catch (e) {
|
||||
return e.message;
|
||||
}
|
||||
})()`
|
||||
],
|
||||
];
|
||||
|
||||
var fails = [
|
||||
`(function() { // Iterator.prototype.next performs stores.
|
||||
var sum = 0;
|
||||
for (let i of [1, 2, 3]) sum += i;
|
||||
return sum;
|
||||
})()`,
|
||||
`(function() { // Store to scope object.
|
||||
with (o) {
|
||||
p = 2;
|
||||
}
|
||||
})()`,
|
||||
];
|
||||
|
||||
function listener(event, exec_state, event_data, data) {
|
||||
if (event != Debug.DebugEvent.Break) return;
|
||||
try {
|
||||
successes.forEach(function ([expectation, source]) {
|
||||
assertEquals(expectation, exec_state.frame(0).evaluate(source).value());
|
||||
});
|
||||
fails.forEach(function (test) {
|
||||
assertThrows(() => exec_state.frame(0).evaluate(test), EvalError);
|
||||
});
|
||||
} catch (e) {
|
||||
exception = e;
|
||||
print(e, e.stack);
|
||||
};
|
||||
};
|
||||
|
||||
// Add the debug event listener.
|
||||
Debug.setListener(listener);
|
||||
|
||||
function f() {
|
||||
debugger;
|
||||
};
|
||||
|
||||
f();
|
||||
|
||||
assertNull(exception);
|
Loading…
Reference in New Issue
Block a user