Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 1657213002: [turbofan] Constant-fold ToNumber conversions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Preserve identity of ToNumber w/ number nodes. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
index 4eb89ccbec234be3d7725a4b60e6909b1a4b66d6..a4a59ce723bab50b0431219175090f90f80b8692 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -780,8 +780,18 @@ Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) {
}
}
}
- // Check if we have a cached conversion.
+ // Try constant-folding of JSToNumber with constant inputs.
Type* input_type = NodeProperties::GetType(input);
+ if (input_type->IsConstant()) {
+ Handle<Object> input_value = input_type->AsConstant()->Value();
+ if (input_value->IsString()) {
+ return Replace(jsgraph()->Constant(
+ String::ToNumber(Handle<String>::cast(input_value))));
+ } else if (input_value->IsOddball()) {
+ return Replace(jsgraph()->Constant(
+ Oddball::ToNumber(Handle<Oddball>::cast(input_value))));
+ }
+ }
if (input_type->Is(Type::Number())) {
// JSToNumber(x:number) => x
return Changed(input);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698