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

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 1964993002: [cleanup] Global variable declarations are never hole initialized (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 | « src/full-codegen/x87/full-codegen-x87.cc ('k') | 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/interpreter/bytecode-generator.h" 5 #include "src/interpreter/bytecode-generator.h"
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/interpreter/bytecode-register-allocator.h" 10 #include "src/interpreter/bytecode-register-allocator.h"
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 740
741 741
742 void BytecodeGenerator::VisitVariableDeclaration(VariableDeclaration* decl) { 742 void BytecodeGenerator::VisitVariableDeclaration(VariableDeclaration* decl) {
743 Variable* variable = decl->proxy()->var(); 743 Variable* variable = decl->proxy()->var();
744 VariableMode mode = decl->mode(); 744 VariableMode mode = decl->mode();
745 // Const and let variables are initialized with the hole so that we can 745 // Const and let variables are initialized with the hole so that we can
746 // check that they are only assigned once. 746 // check that they are only assigned once.
747 bool hole_init = mode == CONST || mode == LET; 747 bool hole_init = mode == CONST || mode == LET;
748 switch (variable->location()) { 748 switch (variable->location()) {
749 case VariableLocation::GLOBAL: 749 case VariableLocation::GLOBAL:
750 case VariableLocation::UNALLOCATED: { 750 case VariableLocation::UNALLOCATED:
751 Handle<Oddball> value = variable->binding_needs_init() 751 DCHECK(!variable->binding_needs_init());
752 ? isolate()->factory()->the_hole_value()
753 : isolate()->factory()->undefined_value();
754 globals()->push_back(variable->name()); 752 globals()->push_back(variable->name());
755 globals()->push_back(value); 753 globals()->push_back(isolate()->factory()->undefined_value());
756 break; 754 break;
757 }
758 case VariableLocation::LOCAL: 755 case VariableLocation::LOCAL:
759 if (hole_init) { 756 if (hole_init) {
760 Register destination(variable->index()); 757 Register destination(variable->index());
761 builder()->LoadTheHole().StoreAccumulatorInRegister(destination); 758 builder()->LoadTheHole().StoreAccumulatorInRegister(destination);
762 } 759 }
763 break; 760 break;
764 case VariableLocation::PARAMETER: 761 case VariableLocation::PARAMETER:
765 if (hole_init) { 762 if (hole_init) {
766 // The parameter indices are shifted by 1 (receiver is variable 763 // The parameter indices are shifted by 1 (receiver is variable
767 // index -1 but is parameter index 0 in BytecodeArrayBuilder). 764 // index -1 but is parameter index 0 in BytecodeArrayBuilder).
(...skipping 2502 matching lines...) Expand 10 before | Expand all | Expand 10 after
3270 } 3267 }
3271 3268
3272 3269
3273 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 3270 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
3274 return info()->shared_info()->feedback_vector()->GetIndex(slot); 3271 return info()->shared_info()->feedback_vector()->GetIndex(slot);
3275 } 3272 }
3276 3273
3277 } // namespace interpreter 3274 } // namespace interpreter
3278 } // namespace internal 3275 } // namespace internal
3279 } // namespace v8 3276 } // namespace v8
OLDNEW
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698