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

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

Issue 967093002: Avoid initialization checks when loading from an immutable context variable. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index b6c6e0fb3f5bc1a0f396d178d09931f978332bda..6661b4025cd495e1d3022a5908b1af04c4a2d45f 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -2595,9 +2595,29 @@ Node* AstGraphBuilder::BuildVariableLoad(Variable* variable,
const Operator* op =
javascript()->LoadContext(depth, variable->index(), immutable);
Node* value = NewNode(op, current_context());
- // TODO(titzer): initialization checks are redundant for already
- // initialized immutable context loads, but only specialization knows.
- // Maybe specializer should be a parameter to the graph builder?
+
+ if (immutable) {
+ // TODO(titzer): initialization checks are redundant for already
+ // initialized immutable context loads, but only specialization knows.
+ // Below copied from context specialization reduction - refactor?
+ // Maybe specializer should be a parameter to the graph builder?
+ HeapObjectMatcher<Context> m(NodeProperties::GetValueInput(value, 0));
+ // If the context is not constant, no reduction can occur.
+ if (m.HasValue()) {
+ // Find the right parent context.
+ Context* context = *m.Value().handle();
+ for (size_t i = depth; i > 0; --i) {
+ context = context->previous();
+ }
+ Handle<Object> value2 = Handle<Object>(
+ context->get(static_cast<int>(variable->index())),
+ jsgraph_->isolate());
+ if (!value2->IsUndefined() && !value2->IsTheHole()) {
+ return value;
+ }
+ }
+ }
+
if (mode == CONST_LEGACY) {
// Perform check for uninitialized legacy const variables.
Node* undefined = jsgraph()->UndefinedConstant();
« 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