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

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

Issue 1077343002: [turbofan] Optimize loads of global constants in JSTypedLowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 | « src/compiler/js-typed-lowering.h ('k') | src/compiler/typer.cc » ('j') | 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 50ad918684816663261a91ea8910328de7f5e4c3..906df7933246bd467ea8dea34e6f2a50afe32e59 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -747,6 +747,27 @@ Reduction JSTypedLowering::ReduceJSToString(Node* node) {
}
+static bool IsGlobalObject(Node* node) {
+ return NodeProperties::IsTyped(node) &&
+ NodeProperties::GetBounds(node).upper->Is(Type::GlobalObject());
+}
+
+
+Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) {
+ if (IsGlobalObject(node->InputAt(0))) {
+ // Optimize global constants like "undefined", "Infinity", and "NaN".
+ Handle<Name> name = LoadNamedParametersOf(node->op()).name().handle();
+ Handle<Object> constant_value = factory()->GlobalConstantFor(name);
+ if (!constant_value.is_null()) {
+ Node* constant = jsgraph()->Constant(constant_value);
+ NodeProperties::ReplaceWithValue(node, constant);
+ return Replace(constant);
+ }
+ }
+ return NoChange();
+}
+
+
Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) {
Node* key = NodeProperties::GetValueInput(node, 1);
Node* base = NodeProperties::GetValueInput(node, 0);
@@ -996,6 +1017,8 @@ Reduction JSTypedLowering::Reduce(Node* node) {
return ReduceJSToNumber(node);
case IrOpcode::kJSToString:
return ReduceJSToString(node);
+ case IrOpcode::kJSLoadNamed:
+ return ReduceJSLoadNamed(node);
case IrOpcode::kJSLoadProperty:
return ReduceJSLoadProperty(node);
case IrOpcode::kJSStoreProperty:
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/compiler/typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698