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_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/debug/debug.h" | 10 #include "src/debug/debug.h" |
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 __ jmp(done); | 1338 __ jmp(done); |
1339 } | 1339 } |
1340 } | 1340 } |
1341 | 1341 |
1342 | 1342 |
1343 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, | 1343 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
1344 TypeofMode typeof_mode) { | 1344 TypeofMode typeof_mode) { |
1345 Variable* var = proxy->var(); | 1345 Variable* var = proxy->var(); |
1346 DCHECK(var->IsUnallocatedOrGlobalSlot() || | 1346 DCHECK(var->IsUnallocatedOrGlobalSlot() || |
1347 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); | 1347 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); |
1348 if (var->IsGlobalSlot()) { | 1348 __ Move(LoadDescriptor::NameRegister(), var->name()); |
1349 DCHECK(var->index() > 0); | 1349 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1350 DCHECK(var->IsStaticGlobalObjectProperty()); | 1350 __ Move(LoadDescriptor::SlotRegister(), |
1351 int const slot = var->index(); | 1351 SmiFromSlot(proxy->VariableFeedbackSlot())); |
1352 int const depth = scope()->ContextChainLength(var->scope()); | 1352 CallLoadIC(typeof_mode); |
1353 if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { | |
1354 __ Set(LoadGlobalViaContextDescriptor::SlotRegister(), slot); | |
1355 LoadGlobalViaContextStub stub(isolate(), depth); | |
1356 __ CallStub(&stub); | |
1357 } else { | |
1358 __ Push(Smi::FromInt(slot)); | |
1359 __ CallRuntime(Runtime::kLoadGlobalViaContext, 1); | |
1360 } | |
1361 | |
1362 } else { | |
1363 __ Move(LoadDescriptor::NameRegister(), var->name()); | |
1364 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | |
1365 __ Move(LoadDescriptor::SlotRegister(), | |
1366 SmiFromSlot(proxy->VariableFeedbackSlot())); | |
1367 CallLoadIC(typeof_mode); | |
1368 } | |
1369 } | 1353 } |
1370 | 1354 |
1371 | 1355 |
1372 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, | 1356 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, |
1373 TypeofMode typeof_mode) { | 1357 TypeofMode typeof_mode) { |
1374 // Record position before possible IC call. | 1358 // Record position before possible IC call. |
1375 SetExpressionPosition(proxy); | 1359 SetExpressionPosition(proxy); |
1376 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1360 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); |
1377 Variable* var = proxy->var(); | 1361 Variable* var = proxy->var(); |
1378 | 1362 |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2505 | 2489 |
2506 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, | 2490 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
2507 FeedbackVectorSlot slot) { | 2491 FeedbackVectorSlot slot) { |
2508 if (var->IsUnallocated()) { | 2492 if (var->IsUnallocated()) { |
2509 // Global var, const, or let. | 2493 // Global var, const, or let. |
2510 __ Move(StoreDescriptor::NameRegister(), var->name()); | 2494 __ Move(StoreDescriptor::NameRegister(), var->name()); |
2511 __ movp(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 2495 __ movp(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
2512 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 2496 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
2513 CallStoreIC(); | 2497 CallStoreIC(); |
2514 | 2498 |
2515 } else if (var->IsGlobalSlot()) { | |
2516 // Global var, const, or let. | |
2517 DCHECK(var->index() > 0); | |
2518 DCHECK(var->IsStaticGlobalObjectProperty()); | |
2519 int const slot = var->index(); | |
2520 int const depth = scope()->ContextChainLength(var->scope()); | |
2521 if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { | |
2522 __ Set(StoreGlobalViaContextDescriptor::SlotRegister(), slot); | |
2523 DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(rax)); | |
2524 StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); | |
2525 __ CallStub(&stub); | |
2526 } else { | |
2527 __ Push(Smi::FromInt(slot)); | |
2528 __ Push(rax); | |
2529 __ CallRuntime(is_strict(language_mode()) | |
2530 ? Runtime::kStoreGlobalViaContext_Strict | |
2531 : Runtime::kStoreGlobalViaContext_Sloppy, | |
2532 2); | |
2533 } | |
2534 | |
2535 } else if (var->mode() == LET && op != Token::INIT_LET) { | 2499 } else if (var->mode() == LET && op != Token::INIT_LET) { |
2536 // Non-initializing assignment to let variable needs a write barrier. | 2500 // Non-initializing assignment to let variable needs a write barrier. |
2537 DCHECK(!var->IsLookupSlot()); | 2501 DCHECK(!var->IsLookupSlot()); |
2538 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2502 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2539 Label assign; | 2503 Label assign; |
2540 MemOperand location = VarOperand(var, rcx); | 2504 MemOperand location = VarOperand(var, rcx); |
2541 __ movp(rdx, location); | 2505 __ movp(rdx, location); |
2542 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 2506 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); |
2543 __ j(not_equal, &assign, Label::kNear); | 2507 __ j(not_equal, &assign, Label::kNear); |
2544 __ Push(var->name()); | 2508 __ Push(var->name()); |
(...skipping 2567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5112 Assembler::target_address_at(call_target_address, | 5076 Assembler::target_address_at(call_target_address, |
5113 unoptimized_code)); | 5077 unoptimized_code)); |
5114 return OSR_AFTER_STACK_CHECK; | 5078 return OSR_AFTER_STACK_CHECK; |
5115 } | 5079 } |
5116 | 5080 |
5117 | 5081 |
5118 } // namespace internal | 5082 } // namespace internal |
5119 } // namespace v8 | 5083 } // namespace v8 |
5120 | 5084 |
5121 #endif // V8_TARGET_ARCH_X64 | 5085 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |