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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 // Note on Mips implementation: | 7 // Note on Mips implementation: |
8 // | 8 // |
9 // The result_register() for mips is the 'v0' register, which is defined | 9 // The result_register() for mips is the 'v0' register, which is defined |
10 // by the ABI to contain function return values. However, the first | 10 // by the ABI to contain function return values. However, the first |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 | 750 |
751 | 751 |
752 void FullCodeGenerator::VisitVariableDeclaration( | 752 void FullCodeGenerator::VisitVariableDeclaration( |
753 VariableDeclaration* declaration) { | 753 VariableDeclaration* declaration) { |
754 // If it was not possible to allocate the variable at compile time, we | 754 // If it was not possible to allocate the variable at compile time, we |
755 // need to "declare" it at runtime to make sure it actually exists in the | 755 // need to "declare" it at runtime to make sure it actually exists in the |
756 // local context. | 756 // local context. |
757 VariableProxy* proxy = declaration->proxy(); | 757 VariableProxy* proxy = declaration->proxy(); |
758 VariableMode mode = declaration->mode(); | 758 VariableMode mode = declaration->mode(); |
759 Variable* variable = proxy->var(); | 759 Variable* variable = proxy->var(); |
760 bool hole_init = mode == LET || mode == CONST || mode == CONST_LEGACY; | 760 bool hole_init = mode == LET || mode == CONST; |
761 switch (variable->location()) { | 761 switch (variable->location()) { |
762 case VariableLocation::GLOBAL: | 762 case VariableLocation::GLOBAL: |
763 case VariableLocation::UNALLOCATED: | 763 case VariableLocation::UNALLOCATED: |
764 globals_->Add(variable->name(), zone()); | 764 globals_->Add(variable->name(), zone()); |
765 globals_->Add(variable->binding_needs_init() | 765 globals_->Add(variable->binding_needs_init() |
766 ? isolate()->factory()->the_hole_value() | 766 ? isolate()->factory()->the_hole_value() |
767 : isolate()->factory()->undefined_value(), | 767 : isolate()->factory()->undefined_value(), |
768 zone()); | 768 zone()); |
769 break; | 769 break; |
770 | 770 |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 // introducing variables. In those cases, we do not want to | 1272 // introducing variables. In those cases, we do not want to |
1273 // perform a runtime call for all variables in the scope | 1273 // perform a runtime call for all variables in the scope |
1274 // containing the eval. | 1274 // containing the eval. |
1275 Variable* var = proxy->var(); | 1275 Variable* var = proxy->var(); |
1276 if (var->mode() == DYNAMIC_GLOBAL) { | 1276 if (var->mode() == DYNAMIC_GLOBAL) { |
1277 EmitLoadGlobalCheckExtensions(proxy, typeof_mode, slow); | 1277 EmitLoadGlobalCheckExtensions(proxy, typeof_mode, slow); |
1278 __ Branch(done); | 1278 __ Branch(done); |
1279 } else if (var->mode() == DYNAMIC_LOCAL) { | 1279 } else if (var->mode() == DYNAMIC_LOCAL) { |
1280 Variable* local = var->local_if_not_shadowed(); | 1280 Variable* local = var->local_if_not_shadowed(); |
1281 __ ld(v0, ContextSlotOperandCheckExtensions(local, slow)); | 1281 __ ld(v0, ContextSlotOperandCheckExtensions(local, slow)); |
1282 if (local->mode() == LET || local->mode() == CONST || | 1282 if (local->mode() == LET || local->mode() == CONST) { |
1283 local->mode() == CONST_LEGACY) { | |
1284 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | 1283 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
1285 __ dsubu(at, v0, at); // Sub as compare: at == 0 on eq. | 1284 __ dsubu(at, v0, at); // Sub as compare: at == 0 on eq. |
1286 if (local->mode() == CONST_LEGACY) { | 1285 __ Branch(done, ne, at, Operand(zero_reg)); |
1287 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); | 1286 __ li(a0, Operand(var->name())); |
1288 __ Movz(v0, a0, at); // Conditional move: return Undefined if TheHole. | 1287 __ push(a0); |
1289 } else { // LET || CONST | 1288 __ CallRuntime(Runtime::kThrowReferenceError); |
1290 __ Branch(done, ne, at, Operand(zero_reg)); | |
1291 __ li(a0, Operand(var->name())); | |
1292 __ push(a0); | |
1293 __ CallRuntime(Runtime::kThrowReferenceError); | |
1294 } | |
1295 } | 1289 } |
1296 __ Branch(done); | 1290 __ Branch(done); |
1297 } | 1291 } |
1298 } | 1292 } |
1299 | 1293 |
1300 | 1294 |
1301 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, | 1295 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
1302 TypeofMode typeof_mode) { | 1296 TypeofMode typeof_mode) { |
1303 Variable* var = proxy->var(); | 1297 Variable* var = proxy->var(); |
1304 DCHECK(var->IsUnallocatedOrGlobalSlot() || | 1298 DCHECK(var->IsUnallocatedOrGlobalSlot() || |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1342 __ dsubu(at, v0, at); // Sub as compare: at == 0 on eq. | 1336 __ dsubu(at, v0, at); // Sub as compare: at == 0 on eq. |
1343 if (var->mode() == LET || var->mode() == CONST) { | 1337 if (var->mode() == LET || var->mode() == CONST) { |
1344 // Throw a reference error when using an uninitialized let/const | 1338 // Throw a reference error when using an uninitialized let/const |
1345 // binding in harmony mode. | 1339 // binding in harmony mode. |
1346 Label done; | 1340 Label done; |
1347 __ Branch(&done, ne, at, Operand(zero_reg)); | 1341 __ Branch(&done, ne, at, Operand(zero_reg)); |
1348 __ li(a0, Operand(var->name())); | 1342 __ li(a0, Operand(var->name())); |
1349 __ push(a0); | 1343 __ push(a0); |
1350 __ CallRuntime(Runtime::kThrowReferenceError); | 1344 __ CallRuntime(Runtime::kThrowReferenceError); |
1351 __ bind(&done); | 1345 __ bind(&done); |
1352 } else { | |
1353 // Uninitialized legacy const bindings are unholed. | |
1354 DCHECK(var->mode() == CONST_LEGACY); | |
1355 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); | |
1356 __ Movz(v0, a0, at); // Conditional move: Undefined if TheHole. | |
1357 } | 1346 } |
1358 context()->Plug(v0); | 1347 context()->Plug(v0); |
1359 break; | 1348 break; |
1360 } | 1349 } |
1361 context()->Plug(var); | 1350 context()->Plug(var); |
1362 break; | 1351 break; |
1363 } | 1352 } |
1364 | 1353 |
1365 case VariableLocation::LOOKUP: { | 1354 case VariableLocation::LOOKUP: { |
1366 Comment cmnt(masm_, "[ Lookup variable"); | 1355 Comment cmnt(masm_, "[ Lookup variable"); |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2234 MemOperand location = VarOperand(var, a1); | 2223 MemOperand location = VarOperand(var, a1); |
2235 __ ld(a3, location); | 2224 __ ld(a3, location); |
2236 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | 2225 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
2237 __ Branch(&uninitialized_this, eq, a3, Operand(at)); | 2226 __ Branch(&uninitialized_this, eq, a3, Operand(at)); |
2238 __ li(a0, Operand(var->name())); | 2227 __ li(a0, Operand(var->name())); |
2239 __ Push(a0); | 2228 __ Push(a0); |
2240 __ CallRuntime(Runtime::kThrowReferenceError); | 2229 __ CallRuntime(Runtime::kThrowReferenceError); |
2241 __ bind(&uninitialized_this); | 2230 __ bind(&uninitialized_this); |
2242 EmitStoreToStackLocalOrContextSlot(var, location); | 2231 EmitStoreToStackLocalOrContextSlot(var, location); |
2243 | 2232 |
2244 } else if (!var->is_const_mode() || | 2233 } else if (!var->is_const_mode() || op == Token::INIT) { |
2245 (var->mode() == CONST && op == Token::INIT)) { | |
2246 if (var->IsLookupSlot()) { | 2234 if (var->IsLookupSlot()) { |
2247 __ Push(var->name()); | 2235 __ Push(var->name()); |
2248 __ Push(v0); | 2236 __ Push(v0); |
2249 __ CallRuntime(is_strict(language_mode()) | 2237 __ CallRuntime(is_strict(language_mode()) |
2250 ? Runtime::kStoreLookupSlot_Strict | 2238 ? Runtime::kStoreLookupSlot_Strict |
2251 : Runtime::kStoreLookupSlot_Sloppy); | 2239 : Runtime::kStoreLookupSlot_Sloppy); |
2252 } else { | 2240 } else { |
2253 // Assignment to var or initializing assignment to let/const in harmony | 2241 // Assignment to var or initializing assignment to let/const in harmony |
2254 // mode. | 2242 // mode. |
2255 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); | 2243 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); |
2256 MemOperand location = VarOperand(var, a1); | 2244 MemOperand location = VarOperand(var, a1); |
2257 if (FLAG_debug_code && var->mode() == LET && op == Token::INIT) { | 2245 if (FLAG_debug_code && var->mode() == LET && op == Token::INIT) { |
2258 // Check for an uninitialized let binding. | 2246 // Check for an uninitialized let binding. |
2259 __ ld(a2, location); | 2247 __ ld(a2, location); |
2260 __ LoadRoot(a4, Heap::kTheHoleValueRootIndex); | 2248 __ LoadRoot(a4, Heap::kTheHoleValueRootIndex); |
2261 __ Check(eq, kLetBindingReInitialization, a2, Operand(a4)); | 2249 __ Check(eq, kLetBindingReInitialization, a2, Operand(a4)); |
2262 } | 2250 } |
2263 EmitStoreToStackLocalOrContextSlot(var, location); | 2251 EmitStoreToStackLocalOrContextSlot(var, location); |
2264 } | 2252 } |
2265 | 2253 |
2266 } else if (var->mode() == CONST_LEGACY && op == Token::INIT) { | |
2267 // Const initializers need a write barrier. | |
2268 DCHECK(!var->IsParameter()); // No const parameters. | |
2269 if (var->IsLookupSlot()) { | |
2270 __ li(a0, Operand(var->name())); | |
2271 __ Push(v0, cp, a0); // Context and name. | |
2272 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot); | |
2273 } else { | |
2274 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | |
2275 Label skip; | |
2276 MemOperand location = VarOperand(var, a1); | |
2277 __ ld(a2, location); | |
2278 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | |
2279 __ Branch(&skip, ne, a2, Operand(at)); | |
2280 EmitStoreToStackLocalOrContextSlot(var, location); | |
2281 __ bind(&skip); | |
2282 } | |
2283 | |
2284 } else { | 2254 } else { |
2285 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT); | 2255 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT); |
2286 if (is_strict(language_mode())) { | 2256 if (is_strict(language_mode())) { |
2287 __ CallRuntime(Runtime::kThrowConstAssignError); | 2257 __ CallRuntime(Runtime::kThrowConstAssignError); |
2288 } | 2258 } |
2289 // Silently ignore store in sloppy mode. | 2259 // Silently ignore store in sloppy mode. |
2290 } | 2260 } |
2291 } | 2261 } |
2292 | 2262 |
2293 | 2263 |
(...skipping 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4021 reinterpret_cast<uint64_t>( | 3991 reinterpret_cast<uint64_t>( |
4022 isolate->builtins()->OnStackReplacement()->entry())); | 3992 isolate->builtins()->OnStackReplacement()->entry())); |
4023 return ON_STACK_REPLACEMENT; | 3993 return ON_STACK_REPLACEMENT; |
4024 } | 3994 } |
4025 | 3995 |
4026 | 3996 |
4027 } // namespace internal | 3997 } // namespace internal |
4028 } // namespace v8 | 3998 } // namespace v8 |
4029 | 3999 |
4030 #endif // V8_TARGET_ARCH_MIPS64 | 4000 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |