| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_ARM | 5 #if V8_TARGET_ARCH_ARM |
| 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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 | 754 |
| 755 | 755 |
| 756 void FullCodeGenerator::VisitVariableDeclaration( | 756 void FullCodeGenerator::VisitVariableDeclaration( |
| 757 VariableDeclaration* declaration) { | 757 VariableDeclaration* declaration) { |
| 758 // If it was not possible to allocate the variable at compile time, we | 758 // If it was not possible to allocate the variable at compile time, we |
| 759 // need to "declare" it at runtime to make sure it actually exists in the | 759 // need to "declare" it at runtime to make sure it actually exists in the |
| 760 // local context. | 760 // local context. |
| 761 VariableProxy* proxy = declaration->proxy(); | 761 VariableProxy* proxy = declaration->proxy(); |
| 762 VariableMode mode = declaration->mode(); | 762 VariableMode mode = declaration->mode(); |
| 763 Variable* variable = proxy->var(); | 763 Variable* variable = proxy->var(); |
| 764 bool hole_init = mode == LET || mode == CONST || mode == CONST_LEGACY; | 764 bool hole_init = mode == LET || mode == CONST; |
| 765 switch (variable->location()) { | 765 switch (variable->location()) { |
| 766 case VariableLocation::GLOBAL: | 766 case VariableLocation::GLOBAL: |
| 767 case VariableLocation::UNALLOCATED: | 767 case VariableLocation::UNALLOCATED: |
| 768 globals_->Add(variable->name(), zone()); | 768 globals_->Add(variable->name(), zone()); |
| 769 globals_->Add(variable->binding_needs_init() | 769 globals_->Add(variable->binding_needs_init() |
| 770 ? isolate()->factory()->the_hole_value() | 770 ? isolate()->factory()->the_hole_value() |
| 771 : isolate()->factory()->undefined_value(), | 771 : isolate()->factory()->undefined_value(), |
| 772 zone()); | 772 zone()); |
| 773 break; | 773 break; |
| 774 | 774 |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 // introducing variables. In those cases, we do not want to | 1277 // introducing variables. In those cases, we do not want to |
| 1278 // perform a runtime call for all variables in the scope | 1278 // perform a runtime call for all variables in the scope |
| 1279 // containing the eval. | 1279 // containing the eval. |
| 1280 Variable* var = proxy->var(); | 1280 Variable* var = proxy->var(); |
| 1281 if (var->mode() == DYNAMIC_GLOBAL) { | 1281 if (var->mode() == DYNAMIC_GLOBAL) { |
| 1282 EmitLoadGlobalCheckExtensions(proxy, typeof_mode, slow); | 1282 EmitLoadGlobalCheckExtensions(proxy, typeof_mode, slow); |
| 1283 __ jmp(done); | 1283 __ jmp(done); |
| 1284 } else if (var->mode() == DYNAMIC_LOCAL) { | 1284 } else if (var->mode() == DYNAMIC_LOCAL) { |
| 1285 Variable* local = var->local_if_not_shadowed(); | 1285 Variable* local = var->local_if_not_shadowed(); |
| 1286 __ ldr(r0, ContextSlotOperandCheckExtensions(local, slow)); | 1286 __ ldr(r0, ContextSlotOperandCheckExtensions(local, slow)); |
| 1287 if (local->mode() == LET || local->mode() == CONST || | 1287 if (local->mode() == LET || local->mode() == CONST) { |
| 1288 local->mode() == CONST_LEGACY) { | |
| 1289 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); | 1288 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); |
| 1290 if (local->mode() == CONST_LEGACY) { | 1289 __ b(ne, done); |
| 1291 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq); | 1290 __ mov(r0, Operand(var->name())); |
| 1292 } else { // LET || CONST | 1291 __ push(r0); |
| 1293 __ b(ne, done); | 1292 __ CallRuntime(Runtime::kThrowReferenceError); |
| 1294 __ mov(r0, Operand(var->name())); | |
| 1295 __ push(r0); | |
| 1296 __ CallRuntime(Runtime::kThrowReferenceError); | |
| 1297 } | |
| 1298 } | 1293 } |
| 1299 __ jmp(done); | 1294 __ jmp(done); |
| 1300 } | 1295 } |
| 1301 } | 1296 } |
| 1302 | 1297 |
| 1303 | 1298 |
| 1304 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, | 1299 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
| 1305 TypeofMode typeof_mode) { | 1300 TypeofMode typeof_mode) { |
| 1306 Variable* var = proxy->var(); | 1301 Variable* var = proxy->var(); |
| 1307 DCHECK(var->IsUnallocatedOrGlobalSlot() || | 1302 DCHECK(var->IsUnallocatedOrGlobalSlot() || |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1344 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); | 1339 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); |
| 1345 if (var->mode() == LET || var->mode() == CONST) { | 1340 if (var->mode() == LET || var->mode() == CONST) { |
| 1346 // Throw a reference error when using an uninitialized let/const | 1341 // Throw a reference error when using an uninitialized let/const |
| 1347 // binding in harmony mode. | 1342 // binding in harmony mode. |
| 1348 Label done; | 1343 Label done; |
| 1349 __ b(ne, &done); | 1344 __ b(ne, &done); |
| 1350 __ mov(r0, Operand(var->name())); | 1345 __ mov(r0, Operand(var->name())); |
| 1351 __ push(r0); | 1346 __ push(r0); |
| 1352 __ CallRuntime(Runtime::kThrowReferenceError); | 1347 __ CallRuntime(Runtime::kThrowReferenceError); |
| 1353 __ bind(&done); | 1348 __ bind(&done); |
| 1354 } else { | |
| 1355 // Uninitialized legacy const bindings are unholed. | |
| 1356 DCHECK(var->mode() == CONST_LEGACY); | |
| 1357 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq); | |
| 1358 } | 1349 } |
| 1359 context()->Plug(r0); | 1350 context()->Plug(r0); |
| 1360 break; | 1351 break; |
| 1361 } | 1352 } |
| 1362 context()->Plug(var); | 1353 context()->Plug(var); |
| 1363 break; | 1354 break; |
| 1364 } | 1355 } |
| 1365 | 1356 |
| 1366 case VariableLocation::LOOKUP: { | 1357 case VariableLocation::LOOKUP: { |
| 1367 Comment cmnt(masm_, "[ Lookup variable"); | 1358 Comment cmnt(masm_, "[ Lookup variable"); |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2228 MemOperand location = VarOperand(var, r1); | 2219 MemOperand location = VarOperand(var, r1); |
| 2229 __ ldr(r3, location); | 2220 __ ldr(r3, location); |
| 2230 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); | 2221 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
| 2231 __ b(eq, &uninitialized_this); | 2222 __ b(eq, &uninitialized_this); |
| 2232 __ mov(r0, Operand(var->name())); | 2223 __ mov(r0, Operand(var->name())); |
| 2233 __ Push(r0); | 2224 __ Push(r0); |
| 2234 __ CallRuntime(Runtime::kThrowReferenceError); | 2225 __ CallRuntime(Runtime::kThrowReferenceError); |
| 2235 __ bind(&uninitialized_this); | 2226 __ bind(&uninitialized_this); |
| 2236 EmitStoreToStackLocalOrContextSlot(var, location); | 2227 EmitStoreToStackLocalOrContextSlot(var, location); |
| 2237 | 2228 |
| 2238 } else if (!var->is_const_mode() || | 2229 } else if (!var->is_const_mode() || op == Token::INIT) { |
| 2239 (var->mode() == CONST && op == Token::INIT)) { | |
| 2240 if (var->IsLookupSlot()) { | 2230 if (var->IsLookupSlot()) { |
| 2241 // Assignment to var. | 2231 // Assignment to var. |
| 2242 __ Push(var->name()); | 2232 __ Push(var->name()); |
| 2243 __ Push(r0); | 2233 __ Push(r0); |
| 2244 __ CallRuntime(is_strict(language_mode()) | 2234 __ CallRuntime(is_strict(language_mode()) |
| 2245 ? Runtime::kStoreLookupSlot_Strict | 2235 ? Runtime::kStoreLookupSlot_Strict |
| 2246 : Runtime::kStoreLookupSlot_Sloppy); | 2236 : Runtime::kStoreLookupSlot_Sloppy); |
| 2247 } else { | 2237 } else { |
| 2248 // Assignment to var or initializing assignment to let/const in harmony | 2238 // Assignment to var or initializing assignment to let/const in harmony |
| 2249 // mode. | 2239 // mode. |
| 2250 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); | 2240 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); |
| 2251 MemOperand location = VarOperand(var, r1); | 2241 MemOperand location = VarOperand(var, r1); |
| 2252 if (FLAG_debug_code && var->mode() == LET && op == Token::INIT) { | 2242 if (FLAG_debug_code && var->mode() == LET && op == Token::INIT) { |
| 2253 // Check for an uninitialized let binding. | 2243 // Check for an uninitialized let binding. |
| 2254 __ ldr(r2, location); | 2244 __ ldr(r2, location); |
| 2255 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); | 2245 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); |
| 2256 __ Check(eq, kLetBindingReInitialization); | 2246 __ Check(eq, kLetBindingReInitialization); |
| 2257 } | 2247 } |
| 2258 EmitStoreToStackLocalOrContextSlot(var, location); | 2248 EmitStoreToStackLocalOrContextSlot(var, location); |
| 2259 } | 2249 } |
| 2260 | 2250 |
| 2261 } else if (var->mode() == CONST_LEGACY && op == Token::INIT) { | |
| 2262 // Const initializers need a write barrier. | |
| 2263 DCHECK(!var->IsParameter()); // No const parameters. | |
| 2264 if (var->IsLookupSlot()) { | |
| 2265 __ push(r0); | |
| 2266 __ mov(r0, Operand(var->name())); | |
| 2267 __ Push(cp, r0); // Context and name. | |
| 2268 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot); | |
| 2269 } else { | |
| 2270 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | |
| 2271 Label skip; | |
| 2272 MemOperand location = VarOperand(var, r1); | |
| 2273 __ ldr(r2, location); | |
| 2274 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); | |
| 2275 __ b(ne, &skip); | |
| 2276 EmitStoreToStackLocalOrContextSlot(var, location); | |
| 2277 __ bind(&skip); | |
| 2278 } | |
| 2279 | |
| 2280 } else { | 2251 } else { |
| 2281 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT); | 2252 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT); |
| 2282 if (is_strict(language_mode())) { | 2253 if (is_strict(language_mode())) { |
| 2283 __ CallRuntime(Runtime::kThrowConstAssignError); | 2254 __ CallRuntime(Runtime::kThrowConstAssignError); |
| 2284 } | 2255 } |
| 2285 // Silently ignore store in sloppy mode. | 2256 // Silently ignore store in sloppy mode. |
| 2286 } | 2257 } |
| 2287 } | 2258 } |
| 2288 | 2259 |
| 2289 | 2260 |
| (...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4058 DCHECK(interrupt_address == | 4029 DCHECK(interrupt_address == |
| 4059 isolate->builtins()->OnStackReplacement()->entry()); | 4030 isolate->builtins()->OnStackReplacement()->entry()); |
| 4060 return ON_STACK_REPLACEMENT; | 4031 return ON_STACK_REPLACEMENT; |
| 4061 } | 4032 } |
| 4062 | 4033 |
| 4063 | 4034 |
| 4064 } // namespace internal | 4035 } // namespace internal |
| 4065 } // namespace v8 | 4036 } // namespace v8 |
| 4066 | 4037 |
| 4067 #endif // V8_TARGET_ARCH_ARM | 4038 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |