| OLD | NEW |
| 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 #if V8_TARGET_ARCH_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 __ CompareRoot(r4, Heap::kWithContextMapRootIndex); | 716 __ CompareRoot(r4, Heap::kWithContextMapRootIndex); |
| 717 __ Check(ne, kDeclarationInWithContext); | 717 __ Check(ne, kDeclarationInWithContext); |
| 718 __ CompareRoot(r4, Heap::kCatchContextMapRootIndex); | 718 __ CompareRoot(r4, Heap::kCatchContextMapRootIndex); |
| 719 __ Check(ne, kDeclarationInCatchContext); | 719 __ Check(ne, kDeclarationInCatchContext); |
| 720 } | 720 } |
| 721 } | 721 } |
| 722 | 722 |
| 723 | 723 |
| 724 void FullCodeGenerator::VisitVariableDeclaration( | 724 void FullCodeGenerator::VisitVariableDeclaration( |
| 725 VariableDeclaration* declaration) { | 725 VariableDeclaration* declaration) { |
| 726 // If it was not possible to allocate the variable at compile time, we | |
| 727 // need to "declare" it at runtime to make sure it actually exists in the | |
| 728 // local context. | |
| 729 VariableProxy* proxy = declaration->proxy(); | 726 VariableProxy* proxy = declaration->proxy(); |
| 730 VariableMode mode = declaration->mode(); | |
| 731 Variable* variable = proxy->var(); | 727 Variable* variable = proxy->var(); |
| 732 bool hole_init = mode == LET || mode == CONST; | |
| 733 switch (variable->location()) { | 728 switch (variable->location()) { |
| 734 case VariableLocation::GLOBAL: | 729 case VariableLocation::GLOBAL: |
| 735 case VariableLocation::UNALLOCATED: { | 730 case VariableLocation::UNALLOCATED: { |
| 736 DCHECK(!variable->binding_needs_init()); | 731 DCHECK(!variable->binding_needs_init()); |
| 737 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); | 732 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); |
| 738 DCHECK(!slot.IsInvalid()); | 733 DCHECK(!slot.IsInvalid()); |
| 739 globals_->Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); | 734 globals_->Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); |
| 740 globals_->Add(isolate()->factory()->undefined_value(), zone()); | 735 globals_->Add(isolate()->factory()->undefined_value(), zone()); |
| 741 break; | 736 break; |
| 742 } | 737 } |
| 743 case VariableLocation::PARAMETER: | 738 case VariableLocation::PARAMETER: |
| 744 case VariableLocation::LOCAL: | 739 case VariableLocation::LOCAL: |
| 745 if (hole_init) { | 740 if (variable->binding_needs_init()) { |
| 746 Comment cmnt(masm_, "[ VariableDeclaration"); | 741 Comment cmnt(masm_, "[ VariableDeclaration"); |
| 747 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 742 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
| 748 __ StoreP(ip, StackOperand(variable)); | 743 __ StoreP(ip, StackOperand(variable)); |
| 749 } | 744 } |
| 750 break; | 745 break; |
| 751 | 746 |
| 752 case VariableLocation::CONTEXT: | 747 case VariableLocation::CONTEXT: |
| 753 if (hole_init) { | 748 if (variable->binding_needs_init()) { |
| 754 Comment cmnt(masm_, "[ VariableDeclaration"); | 749 Comment cmnt(masm_, "[ VariableDeclaration"); |
| 755 EmitDebugCheckDeclarationContext(variable); | 750 EmitDebugCheckDeclarationContext(variable); |
| 756 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 751 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
| 757 __ StoreP(ip, ContextMemOperand(cp, variable->index()), r0); | 752 __ StoreP(ip, ContextMemOperand(cp, variable->index()), r0); |
| 758 // No write barrier since the_hole_value is in old space. | 753 // No write barrier since the_hole_value is in old space. |
| 759 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); | 754 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); |
| 760 } | 755 } |
| 761 break; | 756 break; |
| 762 | 757 |
| 763 case VariableLocation::LOOKUP: { | 758 case VariableLocation::LOOKUP: { |
| 764 Comment cmnt(masm_, "[ VariableDeclaration"); | 759 Comment cmnt(masm_, "[ VariableDeclaration"); |
| 765 DCHECK_EQ(VAR, mode); | 760 DCHECK_EQ(VAR, variable->mode()); |
| 766 DCHECK(!hole_init); | 761 DCHECK(!variable->binding_needs_init()); |
| 767 __ mov(r5, Operand(variable->name())); | 762 __ mov(r5, Operand(variable->name())); |
| 768 __ Push(r5); | 763 __ Push(r5); |
| 769 __ CallRuntime(Runtime::kDeclareEvalVar); | 764 __ CallRuntime(Runtime::kDeclareEvalVar); |
| 770 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); | 765 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); |
| 771 break; | 766 break; |
| 772 } | 767 } |
| 773 | 768 |
| 774 case VariableLocation::MODULE: | 769 case VariableLocation::MODULE: |
| 775 UNREACHABLE(); | 770 UNREACHABLE(); |
| 776 } | 771 } |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 // introducing variables. In those cases, we do not want to | 1231 // introducing variables. In those cases, we do not want to |
| 1237 // perform a runtime call for all variables in the scope | 1232 // perform a runtime call for all variables in the scope |
| 1238 // containing the eval. | 1233 // containing the eval. |
| 1239 Variable* var = proxy->var(); | 1234 Variable* var = proxy->var(); |
| 1240 if (var->mode() == DYNAMIC_GLOBAL) { | 1235 if (var->mode() == DYNAMIC_GLOBAL) { |
| 1241 EmitLoadGlobalCheckExtensions(proxy, typeof_mode, slow); | 1236 EmitLoadGlobalCheckExtensions(proxy, typeof_mode, slow); |
| 1242 __ b(done); | 1237 __ b(done); |
| 1243 } else if (var->mode() == DYNAMIC_LOCAL) { | 1238 } else if (var->mode() == DYNAMIC_LOCAL) { |
| 1244 Variable* local = var->local_if_not_shadowed(); | 1239 Variable* local = var->local_if_not_shadowed(); |
| 1245 __ LoadP(r3, ContextSlotOperandCheckExtensions(local, slow)); | 1240 __ LoadP(r3, ContextSlotOperandCheckExtensions(local, slow)); |
| 1246 if (local->mode() == LET || local->mode() == CONST) { | 1241 if (local->binding_needs_init()) { |
| 1247 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); | 1242 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
| 1248 __ bne(done); | 1243 __ bne(done); |
| 1249 __ mov(r3, Operand(var->name())); | 1244 __ mov(r3, Operand(var->name())); |
| 1250 __ push(r3); | 1245 __ push(r3); |
| 1251 __ CallRuntime(Runtime::kThrowReferenceError); | 1246 __ CallRuntime(Runtime::kThrowReferenceError); |
| 1247 } else { |
| 1248 __ b(done); |
| 1252 } | 1249 } |
| 1253 __ b(done); | |
| 1254 } | 1250 } |
| 1255 } | 1251 } |
| 1256 | 1252 |
| 1257 | 1253 |
| 1258 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, | 1254 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
| 1259 TypeofMode typeof_mode) { | 1255 TypeofMode typeof_mode) { |
| 1260 #ifdef DEBUG | 1256 #ifdef DEBUG |
| 1261 Variable* var = proxy->var(); | 1257 Variable* var = proxy->var(); |
| 1262 DCHECK(var->IsUnallocatedOrGlobalSlot() || | 1258 DCHECK(var->IsUnallocatedOrGlobalSlot() || |
| 1263 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); | 1259 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1286 break; | 1282 break; |
| 1287 } | 1283 } |
| 1288 | 1284 |
| 1289 case VariableLocation::PARAMETER: | 1285 case VariableLocation::PARAMETER: |
| 1290 case VariableLocation::LOCAL: | 1286 case VariableLocation::LOCAL: |
| 1291 case VariableLocation::CONTEXT: { | 1287 case VariableLocation::CONTEXT: { |
| 1292 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); | 1288 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); |
| 1293 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" | 1289 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
| 1294 : "[ Stack variable"); | 1290 : "[ Stack variable"); |
| 1295 if (NeedsHoleCheckForLoad(proxy)) { | 1291 if (NeedsHoleCheckForLoad(proxy)) { |
| 1292 // Throw a reference error when using an uninitialized let/const |
| 1293 // binding in harmony mode. |
| 1296 Label done; | 1294 Label done; |
| 1297 // Let and const need a read barrier. | |
| 1298 GetVar(r3, var); | 1295 GetVar(r3, var); |
| 1299 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); | 1296 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
| 1300 __ bne(&done); | 1297 __ bne(&done); |
| 1301 if (var->mode() == LET || var->mode() == CONST) { | 1298 __ mov(r3, Operand(var->name())); |
| 1302 // Throw a reference error when using an uninitialized let/const | 1299 __ push(r3); |
| 1303 // binding in harmony mode. | 1300 __ CallRuntime(Runtime::kThrowReferenceError); |
| 1304 __ mov(r3, Operand(var->name())); | |
| 1305 __ push(r3); | |
| 1306 __ CallRuntime(Runtime::kThrowReferenceError); | |
| 1307 } | |
| 1308 __ bind(&done); | 1301 __ bind(&done); |
| 1309 context()->Plug(r3); | 1302 context()->Plug(r3); |
| 1310 break; | 1303 break; |
| 1311 } | 1304 } |
| 1312 context()->Plug(var); | 1305 context()->Plug(var); |
| 1313 break; | 1306 break; |
| 1314 } | 1307 } |
| 1315 | 1308 |
| 1316 case VariableLocation::LOOKUP: { | 1309 case VariableLocation::LOOKUP: { |
| 1317 Comment cmnt(masm_, "[ Lookup variable"); | 1310 Comment cmnt(masm_, "[ Lookup variable"); |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2180 | 2173 |
| 2181 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, | 2174 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
| 2182 FeedbackVectorSlot slot) { | 2175 FeedbackVectorSlot slot) { |
| 2183 if (var->IsUnallocated()) { | 2176 if (var->IsUnallocated()) { |
| 2184 // Global var, const, or let. | 2177 // Global var, const, or let. |
| 2185 __ mov(StoreDescriptor::NameRegister(), Operand(var->name())); | 2178 __ mov(StoreDescriptor::NameRegister(), Operand(var->name())); |
| 2186 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); | 2179 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); |
| 2187 EmitLoadStoreICSlot(slot); | 2180 EmitLoadStoreICSlot(slot); |
| 2188 CallStoreIC(); | 2181 CallStoreIC(); |
| 2189 | 2182 |
| 2190 } else if (var->mode() == LET && op != Token::INIT) { | 2183 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { |
| 2191 // Non-initializing assignment to let variable needs a write barrier. | |
| 2192 DCHECK(!var->IsLookupSlot()); | 2184 DCHECK(!var->IsLookupSlot()); |
| 2193 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2185 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
| 2194 Label assign; | |
| 2195 MemOperand location = VarOperand(var, r4); | 2186 MemOperand location = VarOperand(var, r4); |
| 2196 __ LoadP(r6, location); | 2187 // Perform an initialization check for lexically declared variables. |
| 2197 __ CompareRoot(r6, Heap::kTheHoleValueRootIndex); | 2188 if (var->binding_needs_init()) { |
| 2198 __ bne(&assign); | 2189 Label assign; |
| 2199 __ mov(r6, Operand(var->name())); | 2190 __ LoadP(r6, location); |
| 2200 __ push(r6); | 2191 __ CompareRoot(r6, Heap::kTheHoleValueRootIndex); |
| 2201 __ CallRuntime(Runtime::kThrowReferenceError); | 2192 __ bne(&assign); |
| 2202 // Perform the assignment. | 2193 __ mov(r6, Operand(var->name())); |
| 2203 __ bind(&assign); | 2194 __ push(r6); |
| 2204 EmitStoreToStackLocalOrContextSlot(var, location); | 2195 __ CallRuntime(Runtime::kThrowReferenceError); |
| 2205 | 2196 __ bind(&assign); |
| 2206 } else if (var->mode() == CONST && op != Token::INIT) { | 2197 } |
| 2207 // Assignment to const variable needs a write barrier. | 2198 if (var->mode() == CONST) { |
| 2208 DCHECK(!var->IsLookupSlot()); | 2199 __ CallRuntime(Runtime::kThrowConstAssignError); |
| 2209 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2200 } else { |
| 2210 Label const_error; | 2201 EmitStoreToStackLocalOrContextSlot(var, location); |
| 2211 MemOperand location = VarOperand(var, r4); | 2202 } |
| 2212 __ LoadP(r6, location); | |
| 2213 __ CompareRoot(r6, Heap::kTheHoleValueRootIndex); | |
| 2214 __ bne(&const_error); | |
| 2215 __ mov(r6, Operand(var->name())); | |
| 2216 __ push(r6); | |
| 2217 __ CallRuntime(Runtime::kThrowReferenceError); | |
| 2218 __ bind(&const_error); | |
| 2219 __ CallRuntime(Runtime::kThrowConstAssignError); | |
| 2220 | |
| 2221 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) { | 2203 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) { |
| 2222 // Initializing assignment to const {this} needs a write barrier. | 2204 // Initializing assignment to const {this} needs a write barrier. |
| 2223 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2205 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
| 2224 Label uninitialized_this; | 2206 Label uninitialized_this; |
| 2225 MemOperand location = VarOperand(var, r4); | 2207 MemOperand location = VarOperand(var, r4); |
| 2226 __ LoadP(r6, location); | 2208 __ LoadP(r6, location); |
| 2227 __ CompareRoot(r6, Heap::kTheHoleValueRootIndex); | 2209 __ CompareRoot(r6, Heap::kTheHoleValueRootIndex); |
| 2228 __ beq(&uninitialized_this); | 2210 __ beq(&uninitialized_this); |
| 2229 __ mov(r4, Operand(var->name())); | 2211 __ mov(r4, Operand(var->name())); |
| 2230 __ push(r4); | 2212 __ push(r4); |
| (...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3778 | 3760 |
| 3779 DCHECK(Assembler::IsCrSet(Assembler::instr_at(cmp_address))); | 3761 DCHECK(Assembler::IsCrSet(Assembler::instr_at(cmp_address))); |
| 3780 | 3762 |
| 3781 DCHECK(interrupt_address == | 3763 DCHECK(interrupt_address == |
| 3782 isolate->builtins()->OnStackReplacement()->entry()); | 3764 isolate->builtins()->OnStackReplacement()->entry()); |
| 3783 return ON_STACK_REPLACEMENT; | 3765 return ON_STACK_REPLACEMENT; |
| 3784 } | 3766 } |
| 3785 } // namespace internal | 3767 } // namespace internal |
| 3786 } // namespace v8 | 3768 } // namespace v8 |
| 3787 #endif // V8_TARGET_ARCH_PPC | 3769 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |