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

Side by Side 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, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after
2588 } 2588 }
2589 return value; 2589 return value;
2590 } 2590 }
2591 case Variable::CONTEXT: { 2591 case Variable::CONTEXT: {
2592 // Context variable (potentially up the context chain). 2592 // Context variable (potentially up the context chain).
2593 int depth = current_scope()->ContextChainLength(variable->scope()); 2593 int depth = current_scope()->ContextChainLength(variable->scope());
2594 bool immutable = variable->maybe_assigned() == kNotAssigned; 2594 bool immutable = variable->maybe_assigned() == kNotAssigned;
2595 const Operator* op = 2595 const Operator* op =
2596 javascript()->LoadContext(depth, variable->index(), immutable); 2596 javascript()->LoadContext(depth, variable->index(), immutable);
2597 Node* value = NewNode(op, current_context()); 2597 Node* value = NewNode(op, current_context());
2598 // TODO(titzer): initialization checks are redundant for already 2598
2599 // initialized immutable context loads, but only specialization knows. 2599 if (immutable) {
2600 // Maybe specializer should be a parameter to the graph builder? 2600 // TODO(titzer): initialization checks are redundant for already
2601 // initialized immutable context loads, but only specialization knows.
2602 // Below copied from context specialization reduction - refactor?
2603 // Maybe specializer should be a parameter to the graph builder?
2604 HeapObjectMatcher<Context> m(NodeProperties::GetValueInput(value, 0));
2605 // If the context is not constant, no reduction can occur.
2606 if (m.HasValue()) {
2607 // Find the right parent context.
2608 Context* context = *m.Value().handle();
2609 for (size_t i = depth; i > 0; --i) {
2610 context = context->previous();
2611 }
2612 Handle<Object> value2 = Handle<Object>(
2613 context->get(static_cast<int>(variable->index())),
2614 jsgraph_->isolate());
2615 if (!value2->IsUndefined() && !value2->IsTheHole()) {
2616 return value;
2617 }
2618 }
2619 }
2620
2601 if (mode == CONST_LEGACY) { 2621 if (mode == CONST_LEGACY) {
2602 // Perform check for uninitialized legacy const variables. 2622 // Perform check for uninitialized legacy const variables.
2603 Node* undefined = jsgraph()->UndefinedConstant(); 2623 Node* undefined = jsgraph()->UndefinedConstant();
2604 value = BuildHoleCheckSilent(value, undefined, value); 2624 value = BuildHoleCheckSilent(value, undefined, value);
2605 } else if (mode == LET || mode == CONST) { 2625 } else if (mode == LET || mode == CONST) {
2606 // Perform check for uninitialized let/const variables. 2626 // Perform check for uninitialized let/const variables.
2607 value = BuildHoleCheckThrow(value, variable, value, bailout_id); 2627 value = BuildHoleCheckThrow(value, variable, value, bailout_id);
2608 } 2628 }
2609 return value; 2629 return value;
2610 } 2630 }
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
3233 // Phi does not exist yet, introduce one. 3253 // Phi does not exist yet, introduce one.
3234 value = NewPhi(inputs, value, control); 3254 value = NewPhi(inputs, value, control);
3235 value->ReplaceInput(inputs - 1, other); 3255 value->ReplaceInput(inputs - 1, other);
3236 } 3256 }
3237 return value; 3257 return value;
3238 } 3258 }
3239 3259
3240 } // namespace compiler 3260 } // namespace compiler
3241 } // namespace internal 3261 } // namespace internal
3242 } // namespace v8 3262 } // namespace v8
OLDNEW
« 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