| 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();
|
|
|