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() { ...@@ -3561,6 +3561,9 @@ void Genesis::InitializeGlobal_enable_fast_array_builtins() {
Object::GetProperty(&it3).ToHandleChecked(); Object::GetProperty(&it3).ToHandleChecked();
Handle<JSFunction>::cast(for_each_function) Handle<JSFunction>::cast(for_each_function)
->set_code(isolate->builtins()->builtin(Builtins::kArrayForEach)); ->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() { void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
......
...@@ -271,12 +271,14 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) { ...@@ -271,12 +271,14 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
case Runtime::kInlineToString: case Runtime::kInlineToString:
case Runtime::kToLength: case Runtime::kToLength:
case Runtime::kInlineToLength: case Runtime::kInlineToLength:
case Runtime::kToNumber:
// Type checks. // Type checks.
case Runtime::kIsJSReceiver: case Runtime::kIsJSReceiver:
case Runtime::kInlineIsJSReceiver: case Runtime::kInlineIsJSReceiver:
case Runtime::kIsSmi: case Runtime::kIsSmi:
case Runtime::kInlineIsSmi: case Runtime::kInlineIsSmi:
case Runtime::kIsArray: case Runtime::kIsArray:
case Runtime::kInlineIsArray:
case Runtime::kIsFunction: case Runtime::kIsFunction:
case Runtime::kIsDate: case Runtime::kIsDate:
case Runtime::kIsJSProxy: case Runtime::kIsJSProxy:
...@@ -284,6 +286,12 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) { ...@@ -284,6 +286,12 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
case Runtime::kIsTypedArray: case Runtime::kIsTypedArray:
// Loads. // Loads.
case Runtime::kLoadLookupSlotForCall: case Runtime::kLoadLookupSlotForCall:
// Arrays.
case Runtime::kArraySpeciesConstructor:
case Runtime::kNormalizeElements:
case Runtime::kGetArrayKeys:
case Runtime::kHasComplexElements:
case Runtime::kEstimateNumberOfElements:
// Errors. // Errors.
case Runtime::kReThrow: case Runtime::kReThrow:
case Runtime::kThrowReferenceError: case Runtime::kThrowReferenceError:
...@@ -371,6 +379,7 @@ bool BytecodeHasNoSideEffect(interpreter::Bytecode bytecode) { ...@@ -371,6 +379,7 @@ bool BytecodeHasNoSideEffect(interpreter::Bytecode bytecode) {
case Bytecode::kCreateUnmappedArguments: case Bytecode::kCreateUnmappedArguments:
// Conversions. // Conversions.
case Bytecode::kToObject: case Bytecode::kToObject:
case Bytecode::kToNumber:
// Misc. // Misc.
case Bytecode::kForInPrepare: case Bytecode::kForInPrepare:
case Bytecode::kForInContinue: case Bytecode::kForInContinue:
...@@ -397,7 +406,13 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) { ...@@ -397,7 +406,13 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) {
switch (id) { switch (id) {
// Whitelist for builtins. // Whitelist for builtins.
// Array builtins. // Array builtins.
case Builtins::kArrayCode:
case Builtins::kArrayIndexOf:
case Builtins::kArrayPrototypeValues: case Builtins::kArrayPrototypeValues:
case Builtins::kArrayIncludes:
case Builtins::kArrayPrototypeEntries:
case Builtins::kArrayPrototypeKeys:
case Builtins::kArrayForEach:
// Math builtins. // Math builtins.
case Builtins::kMathAbs: case Builtins::kMathAbs:
case Builtins::kMathAcos: case Builtins::kMathAcos:
...@@ -470,6 +485,12 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) { ...@@ -470,6 +485,12 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) {
// JSON builtins. // JSON builtins.
case Builtins::kJsonParse: case Builtins::kJsonParse:
case Builtins::kJsonStringify: case Builtins::kJsonStringify:
// Error builtins.
case Builtins::kMakeError:
case Builtins::kMakeTypeError:
case Builtins::kMakeSyntaxError:
case Builtins::kMakeRangeError:
case Builtins::kMakeURIError:
return true; return true;
default: default:
if (FLAG_trace_side_effect_free_debug_evaluate) { if (FLAG_trace_side_effect_free_debug_evaluate) {
......
...@@ -20,11 +20,35 @@ function listener(event, exec_state, event_data, data) { ...@@ -20,11 +20,35 @@ function listener(event, exec_state, event_data, data) {
EvalError); 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. // Test Math functions.
for (f of Object.getOwnPropertyNames(Math)) { for (f of Object.getOwnPropertyNames(Math)) {
if (typeof Math[f] === "function") { if (typeof Math[f] === "function") {
var result = exec_state.frame(0).evaluate( 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); 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