Commit 8d866b42 authored by peterwmwong's avatar peterwmwong Committed by Commit Bot

Reland "[debug] Mark toLocaleString and TA#join builtins as side-effect free."

This is a reland of 660d8287

Original change's description:
> [debug] Mark toLocaleString and TA#join builtins as side-effect free.
>
> Bug: chromium:940373
> Change-Id: If5f90ff5f873f0687c6a6a4063e0d09d6bbbd556
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1533157
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Peter Wong <peter.wm.wong@gmail.com>
> Cr-Commit-Position: refs/heads/master@{#60440}

Bug: chromium:940373
Change-Id: I03fe4c06cad9848db211739170462d52ce3f7acf
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1538791Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Peter Wong <peter.wm.wong@gmail.com>
Cr-Commit-Position: refs/heads/master@{#60575}
parent d341a1a7
...@@ -215,7 +215,6 @@ DebugEvaluate::ContextBuilder::ContextBuilder(Isolate* isolate, ...@@ -215,7 +215,6 @@ DebugEvaluate::ContextBuilder::ContextBuilder(Isolate* isolate,
} }
} }
void DebugEvaluate::ContextBuilder::UpdateValues() { void DebugEvaluate::ContextBuilder::UpdateValues() {
scope_iterator_.Restart(); scope_iterator_.Restart();
for (ContextChainElement& element : context_chain_) { for (ContextChainElement& element : context_chain_) {
...@@ -504,6 +503,7 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtins::Name id) { ...@@ -504,6 +503,7 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtins::Name id) {
case Builtins::kObjectPrototypeIsPrototypeOf: case Builtins::kObjectPrototypeIsPrototypeOf:
case Builtins::kObjectPrototypePropertyIsEnumerable: case Builtins::kObjectPrototypePropertyIsEnumerable:
case Builtins::kObjectPrototypeToString: case Builtins::kObjectPrototypeToString:
case Builtins::kObjectPrototypeToLocaleString:
// Array builtins. // Array builtins.
case Builtins::kArrayIsArray: case Builtins::kArrayIsArray:
case Builtins::kArrayConstructor: case Builtins::kArrayConstructor:
...@@ -546,12 +546,14 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtins::Name id) { ...@@ -546,12 +546,14 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtins::Name id) {
case Builtins::kTypedArrayPrototypeFind: case Builtins::kTypedArrayPrototypeFind:
case Builtins::kTypedArrayPrototypeFindIndex: case Builtins::kTypedArrayPrototypeFindIndex:
case Builtins::kTypedArrayPrototypeIncludes: case Builtins::kTypedArrayPrototypeIncludes:
case Builtins::kTypedArrayPrototypeJoin:
case Builtins::kTypedArrayPrototypeIndexOf: case Builtins::kTypedArrayPrototypeIndexOf:
case Builtins::kTypedArrayPrototypeLastIndexOf: case Builtins::kTypedArrayPrototypeLastIndexOf:
case Builtins::kTypedArrayPrototypeSlice: case Builtins::kTypedArrayPrototypeSlice:
case Builtins::kTypedArrayPrototypeSubArray: case Builtins::kTypedArrayPrototypeSubArray:
case Builtins::kTypedArrayPrototypeEvery: case Builtins::kTypedArrayPrototypeEvery:
case Builtins::kTypedArrayPrototypeSome: case Builtins::kTypedArrayPrototypeSome:
case Builtins::kTypedArrayPrototypeToLocaleString:
case Builtins::kTypedArrayPrototypeFilter: case Builtins::kTypedArrayPrototypeFilter:
case Builtins::kTypedArrayPrototypeMap: case Builtins::kTypedArrayPrototypeMap:
case Builtins::kTypedArrayPrototypeReduce: case Builtins::kTypedArrayPrototypeReduce:
...@@ -609,6 +611,11 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtins::Name id) { ...@@ -609,6 +611,11 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtins::Name id) {
case Builtins::kDatePrototypeToISOString: case Builtins::kDatePrototypeToISOString:
case Builtins::kDatePrototypeToUTCString: case Builtins::kDatePrototypeToUTCString:
case Builtins::kDatePrototypeToString: case Builtins::kDatePrototypeToString:
#ifdef V8_INTL_SUPPORT
case Builtins::kDatePrototypeToLocaleString:
case Builtins::kDatePrototypeToLocaleDateString:
case Builtins::kDatePrototypeToLocaleTimeString:
#endif
case Builtins::kDatePrototypeToTimeString: case Builtins::kDatePrototypeToTimeString:
case Builtins::kDatePrototypeToJson: case Builtins::kDatePrototypeToJson:
case Builtins::kDatePrototypeToPrimitive: case Builtins::kDatePrototypeToPrimitive:
...@@ -674,6 +681,7 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtins::Name id) { ...@@ -674,6 +681,7 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtins::Name id) {
case Builtins::kNumberPrototypeToFixed: case Builtins::kNumberPrototypeToFixed:
case Builtins::kNumberPrototypeToPrecision: case Builtins::kNumberPrototypeToPrecision:
case Builtins::kNumberPrototypeToString: case Builtins::kNumberPrototypeToString:
case Builtins::kNumberPrototypeToLocaleString:
case Builtins::kNumberPrototypeValueOf: case Builtins::kNumberPrototypeValueOf:
// BigInt builtins. // BigInt builtins.
case Builtins::kBigIntConstructor: case Builtins::kBigIntConstructor:
...@@ -977,6 +985,8 @@ static bool TransitivelyCalledBuiltinHasNoSideEffect(Builtins::Name caller, ...@@ -977,6 +985,8 @@ static bool TransitivelyCalledBuiltinHasNoSideEffect(Builtins::Name caller,
switch (caller) { switch (caller) {
case Builtins::kArrayPrototypeJoin: case Builtins::kArrayPrototypeJoin:
case Builtins::kArrayPrototypeToLocaleString: case Builtins::kArrayPrototypeToLocaleString:
case Builtins::kTypedArrayPrototypeJoin:
case Builtins::kTypedArrayPrototypeToLocaleString:
return true; return true;
default: default:
return false; return false;
......
...@@ -45,11 +45,10 @@ function listener(event, exec_state, event_data, data) { ...@@ -45,11 +45,10 @@ function listener(event, exec_state, event_data, data) {
if (typeof Date.prototype[f] === "function") { if (typeof Date.prototype[f] === "function") {
if (f.startsWith("set")) { if (f.startsWith("set")) {
fail(`date.${f}(5);`, true); fail(`date.${f}(5);`, true);
} else if (f.startsWith("toLocale")) { } else if (f.startsWith("toLocale") && typeof Intl === "undefined") {
if (typeof Intl === "undefined") continue; continue;
fail(`date.${f}();`, true);
} else { } else {
success(undefined, `date.${f}();`, true); success(undefined, `date.${f}();`);
} }
} }
} }
......
...@@ -59,6 +59,7 @@ function listener(event, exec_state, event_data, data) { ...@@ -59,6 +59,7 @@ function listener(event, exec_state, event_data, data) {
success(true, `Object.prototype.isPrototypeOf({})`); success(true, `Object.prototype.isPrototypeOf({})`);
success(true, `({a:1}).propertyIsEnumerable("a")`); success(true, `({a:1}).propertyIsEnumerable("a")`);
success("[object Object]", `({a:1}).toString()`); success("[object Object]", `({a:1}).toString()`);
success("[object Object]", `({a:1}).toLocaleString()`);
success("string", `(object_with_callbacks).toString()`); success("string", `(object_with_callbacks).toString()`);
success(3, `(object_with_callbacks).valueOf()`); success(3, `(object_with_callbacks).valueOf()`);
...@@ -73,8 +74,8 @@ function listener(event, exec_state, event_data, data) { ...@@ -73,8 +74,8 @@ function listener(event, exec_state, event_data, data) {
"flatMap", "forEach", "every", "some", "reduce", "reduceRight", "find", "flatMap", "forEach", "every", "some", "reduce", "reduceRight", "find",
"filter", "map", "findIndex" "filter", "map", "findIndex"
]; ];
var fails = ["toLocaleString", "pop", "push", "reverse", "shift", "unshift", var fails = ["pop", "push", "reverse", "shift", "unshift", "splice",
"splice", "sort", "copyWithin", "fill"]; "sort", "copyWithin", "fill"];
for (f of Object.getOwnPropertyNames(Array.prototype)) { for (f of Object.getOwnPropertyNames(Array.prototype)) {
if (typeof Array.prototype[f] === "function") { if (typeof Array.prototype[f] === "function") {
if (fails.includes(f)) { if (fails.includes(f)) {
...@@ -123,8 +124,7 @@ function listener(event, exec_state, event_data, data) { ...@@ -123,8 +124,7 @@ function listener(event, exec_state, event_data, data) {
"forEach", "every", "some", "reduce", "reduceRight", "find", "filter", "forEach", "every", "some", "reduce", "reduceRight", "find", "filter",
"map", "findIndex" "map", "findIndex"
]; ];
fails = ["toString", "join", "toLocaleString", "reverse", "sort", fails = ["reverse", "sort", "copyWithin", "fill", "set"];
"copyWithin", "fill", "set"];
var typed_proto_proto = Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array())); var typed_proto_proto = Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array()));
for (f of Object.getOwnPropertyNames(typed_proto_proto)) { for (f of Object.getOwnPropertyNames(typed_proto_proto)) {
if (typeof typed_array[f] === "function" && f !== "constructor") { if (typeof typed_array[f] === "function" && f !== "constructor") {
...@@ -160,7 +160,7 @@ function listener(event, exec_state, event_data, data) { ...@@ -160,7 +160,7 @@ function listener(event, exec_state, event_data, data) {
} }
for (f of Object.getOwnPropertyNames(Number.prototype)) { for (f of Object.getOwnPropertyNames(Number.prototype)) {
if (typeof Number.prototype[f] === "function") { if (typeof Number.prototype[f] === "function") {
if (f == "toLocaleString") continue; if (f == "toLocaleString" && typeof Intl === "undefined") continue;
success(Number(0.5)[f](5), `Number(0.5).${f}(5);`); success(Number(0.5)[f](5), `Number(0.5).${f}(5);`);
} }
} }
......
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