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

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 1384953002: [turbofan] Move global constant optimization to AstGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 | src/compiler/js-type-feedback.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 2da3cfe1b2f24ad42d67b4baf1459d37a175e421..9f6d17c3a872f077f9e1f4fb68b1fc797e1b588b 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -3289,6 +3289,13 @@ Node* AstGraphBuilder::BuildVariableLoad(Variable* variable,
case VariableLocation::GLOBAL:
case VariableLocation::UNALLOCATED: {
// Global var, const, or let variable.
+ Handle<Name> name = variable->name();
+ Handle<Object> constant_value =
+ jsgraph()->isolate()->factory()->GlobalConstantFor(name);
+ if (!constant_value.is_null()) {
+ // Optimize global constants like "undefined", "Infinity", and "NaN".
+ return jsgraph()->Constant(constant_value);
+ }
Node* script_context = current_context();
int slot_index = -1;
if (variable->index() > 0) {
@@ -3302,7 +3309,6 @@ Node* AstGraphBuilder::BuildVariableLoad(Variable* variable,
}
}
Node* global = BuildLoadGlobalObject();
- Handle<Name> name = variable->name();
Node* value = BuildGlobalLoad(script_context, global, name, feedback,
typeof_mode, slot_index);
states.AddToNode(value, bailout_id, combine);
« no previous file with comments | « no previous file | src/compiler/js-type-feedback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698