Commit 4a655cbe authored by yangguo's avatar yangguo Committed by Commit bot

[debugger] extend side effect free debug-evaluate to Array builtins.

R=jgruber@chromium.org
BUG=v8:5821

Review-Url: https://codereview.chromium.org/2695933005
Cr-Commit-Position: refs/heads/master@{#43371}
parent 087e95ba
......@@ -3561,6 +3561,9 @@ void Genesis::InitializeGlobal_enable_fast_array_builtins() {
Object::GetProperty(&it3).ToHandleChecked();
Handle<JSFunction>::cast(for_each_function)
->set_code(isolate->builtins()->builtin(Builtins::kArrayForEach));
Handle<JSFunction>::cast(for_each_function)
->shared()
->set_code(isolate->builtins()->builtin(Builtins::kArrayForEach));
}
void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
......
......@@ -271,12 +271,14 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
case Runtime::kInlineToString:
case Runtime::kToLength:
case Runtime::kInlineToLength:
case Runtime::kToNumber:
// Type checks.
case Runtime::kIsJSReceiver:
case Runtime::kInlineIsJSReceiver:
case Runtime::kIsSmi:
case Runtime::kInlineIsSmi:
case Runtime::kIsArray:
case Runtime::kInlineIsArray:
case Runtime::kIsFunction:
case Runtime::kIsDate:
case Runtime::kIsJSProxy:
......@@ -284,6 +286,12 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
case Runtime::kIsTypedArray:
// Loads.
case Runtime::kLoadLookupSlotForCall:
// Arrays.
case Runtime::kArraySpeciesConstructor:
case Runtime::kNormalizeElements:
case Runtime::kGetArrayKeys:
case Runtime::kHasComplexElements:
case Runtime::kEstimateNumberOfElements:
// Errors.
case Runtime::kReThrow:
case Runtime::kThrowReferenceError:
......@@ -371,6 +379,7 @@ bool BytecodeHasNoSideEffect(interpreter::Bytecode bytecode) {
case Bytecode::kCreateUnmappedArguments:
// Conversions.
case Bytecode::kToObject:
case Bytecode::kToNumber:
// Misc.
case Bytecode::kForInPrepare:
case Bytecode::kForInContinue:
......@@ -397,7 +406,13 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) {
switch (id) {
// Whitelist for builtins.
// Array builtins.
case Builtins::kArrayCode:
case Builtins::kArrayIndexOf:
case Builtins::kArrayPrototypeValues:
case Builtins::kArrayIncludes:
case Builtins::kArrayPrototypeEntries:
case Builtins::kArrayPrototypeKeys:
case Builtins::kArrayForEach:
// Math builtins.
case Builtins::kMathAbs:
case Builtins::kMathAcos:
......@@ -470,6 +485,12 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) {
// JSON builtins.
case Builtins::kJsonParse:
case Builtins::kJsonStringify:
// Error builtins.
case Builtins::kMakeError:
case Builtins::kMakeTypeError:
case Builtins::kMakeSyntaxError:
case Builtins::kMakeRangeError:
case Builtins::kMakeURIError:
return true;
default:
if (FLAG_trace_side_effect_free_debug_evaluate) {
......
......@@ -20,11 +20,35 @@ function listener(event, exec_state, event_data, data) {
EvalError);
}
// Test Array functions.
var function_param = [
"forEach", "every", "some", "reduce", "reduceRight", "find", "filter",
"map", "findIndex"
];
var fails = ["toString", "join", "toLocaleString", "pop", "push",
"reverse", "shift", "unshift", "slice", "splice", "sort", "filter",
"map", "copyWithin", "fill", "concat"];
for (f of Object.getOwnPropertyNames(Array.prototype)) {
if (typeof Array.prototype[f] === "function") {
if (fails.includes(f)) {
if (function_param.includes(f)) {
fail(`[1, 2, 3].${f}(()=>{});`);
} else {
fail(`[1, 2, 3].${f}();`);
}
} else if (function_param.includes(f)) {
exec_state.frame(0).evaluate(`[1, 2, 3].${f}(()=>{});`, true);
} else {
exec_state.frame(0).evaluate(`[1, 2, 3].${f}();`, true);
}
}
}
// Test Math functions.
for (f of Object.getOwnPropertyNames(Math)) {
if (typeof Math[f] === "function") {
var result = exec_state.frame(0).evaluate(
`Math.${f}(0.5, -0.5);`).value();
`Math.${f}(0.5, -0.5);`, true).value();
if (f != "random") assertEquals(Math[f](0.5, -0.5), result);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment