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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1329043002: [turbofan] Clarify comment about Parameter indexing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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/js-type-feedback.h" 10 #include "src/compiler/js-type-feedback.h"
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 int param_num = 0; 675 int param_num = 0;
676 if (builder->info()->is_this_defined()) { 676 if (builder->info()->is_this_defined()) {
677 const Operator* op = common()->Parameter(param_num++, "%this"); 677 const Operator* op = common()->Parameter(param_num++, "%this");
678 Node* receiver = builder->graph()->NewNode(op, builder->graph()->start()); 678 Node* receiver = builder->graph()->NewNode(op, builder->graph()->start());
679 values()->push_back(receiver); 679 values()->push_back(receiver);
680 } else { 680 } else {
681 values()->push_back(builder->jsgraph()->UndefinedConstant()); 681 values()->push_back(builder->jsgraph()->UndefinedConstant());
682 } 682 }
683 683
684 // Bind all parameter variables. The parameter indices are shifted by 1 684 // Bind all parameter variables. The parameter indices are shifted by 1
685 // (receiver is parameter index -1 but environment index 0). 685 // (receiver is variable index -1 but {Parameter} node index 0 and located at
686 // index 0 in the environment).
686 for (int i = 0; i < scope->num_parameters(); ++i) { 687 for (int i = 0; i < scope->num_parameters(); ++i) {
687 const char* debug_name = GetDebugParameterName(graph()->zone(), scope, i); 688 const char* debug_name = GetDebugParameterName(graph()->zone(), scope, i);
688 const Operator* op = common()->Parameter(param_num++, debug_name); 689 const Operator* op = common()->Parameter(param_num++, debug_name);
689 Node* parameter = builder->graph()->NewNode(op, builder->graph()->start()); 690 Node* parameter = builder->graph()->NewNode(op, builder->graph()->start());
690 values()->push_back(parameter); 691 values()->push_back(parameter);
691 } 692 }
692 693
693 // Bind all local variables to undefined. 694 // Bind all local variables to undefined.
694 Node* undefined_constant = builder->jsgraph()->UndefinedConstant(); 695 Node* undefined_constant = builder->jsgraph()->UndefinedConstant();
695 values()->insert(values()->end(), locals_count(), undefined_constant); 696 values()->insert(values()->end(), locals_count(), undefined_constant);
(...skipping 18 matching lines...) Expand all
714 values_.insert(values_.begin(), copy->values_.begin(), copy->values_.end()); 715 values_.insert(values_.begin(), copy->values_.begin(), copy->values_.end());
715 contexts_.reserve(copy->contexts_.size()); 716 contexts_.reserve(copy->contexts_.size());
716 contexts_.insert(contexts_.begin(), copy->contexts_.begin(), 717 contexts_.insert(contexts_.begin(), copy->contexts_.begin(),
717 copy->contexts_.end()); 718 copy->contexts_.end());
718 } 719 }
719 720
720 721
721 void AstGraphBuilder::Environment::Bind(Variable* variable, Node* node) { 722 void AstGraphBuilder::Environment::Bind(Variable* variable, Node* node) {
722 DCHECK(variable->IsStackAllocated()); 723 DCHECK(variable->IsStackAllocated());
723 if (variable->IsParameter()) { 724 if (variable->IsParameter()) {
724 // The parameter indices are shifted by 1 (receiver is parameter 725 // The parameter indices are shifted by 1 (receiver is variable
725 // index -1 but environment index 0). 726 // index -1 but located at index 0 in the environment).
726 values()->at(variable->index() + 1) = node; 727 values()->at(variable->index() + 1) = node;
727 } else { 728 } else {
728 DCHECK(variable->IsStackLocal()); 729 DCHECK(variable->IsStackLocal());
729 values()->at(variable->index() + parameters_count_) = node; 730 values()->at(variable->index() + parameters_count_) = node;
730 DCHECK(IsLivenessBlockConsistent()); 731 DCHECK(IsLivenessBlockConsistent());
731 if (liveness_block() != nullptr) { 732 if (liveness_block() != nullptr) {
732 liveness_block()->Bind(variable->index()); 733 liveness_block()->Bind(variable->index());
733 } 734 }
734 } 735 }
735 } 736 }
736 737
737 738
738 Node* AstGraphBuilder::Environment::Lookup(Variable* variable) { 739 Node* AstGraphBuilder::Environment::Lookup(Variable* variable) {
739 DCHECK(variable->IsStackAllocated()); 740 DCHECK(variable->IsStackAllocated());
740 if (variable->IsParameter()) { 741 if (variable->IsParameter()) {
741 // The parameter indices are shifted by 1 (receiver is parameter 742 // The parameter indices are shifted by 1 (receiver is variable
742 // index -1 but environment index 0). 743 // index -1 but located at index 0 in the environment).
743 return values()->at(variable->index() + 1); 744 return values()->at(variable->index() + 1);
744 } else { 745 } else {
745 DCHECK(variable->IsStackLocal()); 746 DCHECK(variable->IsStackLocal());
746 DCHECK(IsLivenessBlockConsistent()); 747 DCHECK(IsLivenessBlockConsistent());
747 if (liveness_block() != nullptr) { 748 if (liveness_block() != nullptr) {
748 liveness_block()->Lookup(variable->index()); 749 liveness_block()->Lookup(variable->index());
749 } 750 }
750 return values()->at(variable->index() + parameters_count_); 751 return values()->at(variable->index() + parameters_count_);
751 } 752 }
752 } 753 }
(...skipping 3513 matching lines...) Expand 10 before | Expand all | Expand 10 after
4266 // Phi does not exist yet, introduce one. 4267 // Phi does not exist yet, introduce one.
4267 value = NewPhi(inputs, value, control); 4268 value = NewPhi(inputs, value, control);
4268 value->ReplaceInput(inputs - 1, other); 4269 value->ReplaceInput(inputs - 1, other);
4269 } 4270 }
4270 return value; 4271 return value;
4271 } 4272 }
4272 4273
4273 } // namespace compiler 4274 } // namespace compiler
4274 } // namespace internal 4275 } // namespace internal
4275 } // namespace v8 4276 } // 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