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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 2411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2422 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 2422 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
2423 CallIC(code, expr->BinaryOperationFeedbackId()); | 2423 CallIC(code, expr->BinaryOperationFeedbackId()); |
2424 patch_site.EmitPatchInfo(); | 2424 patch_site.EmitPatchInfo(); |
2425 context()->Plug(rax); | 2425 context()->Plug(rax); |
2426 } | 2426 } |
2427 | 2427 |
2428 | 2428 |
2429 void FullCodeGenerator::EmitAssignment(Expression* expr) { | 2429 void FullCodeGenerator::EmitAssignment(Expression* expr) { |
2430 DCHECK(expr->IsValidReferenceExpression()); | 2430 DCHECK(expr->IsValidReferenceExpression()); |
2431 | 2431 |
2432 // Left-hand side can only be a property, a global or a (parameter or local) | |
2433 // slot. | |
2434 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; | |
2435 LhsKind assign_type = VARIABLE; | |
2436 Property* prop = expr->AsProperty(); | 2432 Property* prop = expr->AsProperty(); |
2437 if (prop != NULL) { | 2433 LhsKind assign_type = GetAssignType(prop); |
2438 assign_type = (prop->key()->IsPropertyName()) | |
2439 ? NAMED_PROPERTY | |
2440 : KEYED_PROPERTY; | |
2441 } | |
2442 | 2434 |
2443 switch (assign_type) { | 2435 switch (assign_type) { |
2444 case VARIABLE: { | 2436 case VARIABLE: { |
2445 Variable* var = expr->AsVariableProxy()->var(); | 2437 Variable* var = expr->AsVariableProxy()->var(); |
2446 EffectContext context(this); | 2438 EffectContext context(this); |
2447 EmitVariableAssignment(var, Token::ASSIGN); | 2439 EmitVariableAssignment(var, Token::ASSIGN); |
2448 break; | 2440 break; |
2449 } | 2441 } |
2450 case NAMED_PROPERTY: { | 2442 case NAMED_PROPERTY: { |
2451 __ Push(rax); // Preserve value. | 2443 __ Push(rax); // Preserve value. |
2452 VisitForAccumulatorValue(prop->obj()); | 2444 VisitForAccumulatorValue(prop->obj()); |
2453 __ Move(StoreDescriptor::ReceiverRegister(), rax); | 2445 __ Move(StoreDescriptor::ReceiverRegister(), rax); |
2454 __ Pop(StoreDescriptor::ValueRegister()); // Restore value. | 2446 __ Pop(StoreDescriptor::ValueRegister()); // Restore value. |
2455 __ Move(StoreDescriptor::NameRegister(), | 2447 __ Move(StoreDescriptor::NameRegister(), |
2456 prop->key()->AsLiteral()->value()); | 2448 prop->key()->AsLiteral()->value()); |
2457 CallStoreIC(); | 2449 CallStoreIC(); |
2458 break; | 2450 break; |
2459 } | 2451 } |
| 2452 case NAMED_SUPER_PROPERTY: { |
| 2453 __ Push(rax); |
| 2454 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); |
| 2455 EmitLoadHomeObject(prop->obj()->AsSuperReference()); |
| 2456 // stack: value, this; rax: home_object |
| 2457 Register scratch = rcx; |
| 2458 Register scratch2 = rdx; |
| 2459 __ Move(scratch, result_register()); // home_object |
| 2460 __ movp(rax, MemOperand(rsp, kPointerSize)); // value |
| 2461 __ movp(scratch2, MemOperand(rsp, 0)); // this |
| 2462 __ movp(MemOperand(rsp, kPointerSize), scratch2); // this |
| 2463 __ movp(MemOperand(rsp, 0), scratch); // home_object |
| 2464 // stack: this, home_object; rax: value |
| 2465 EmitNamedSuperPropertyStore(prop); |
| 2466 break; |
| 2467 } |
| 2468 case KEYED_SUPER_PROPERTY: { |
| 2469 __ Push(rax); |
| 2470 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); |
| 2471 EmitLoadHomeObject(prop->obj()->AsSuperReference()); |
| 2472 __ Push(result_register()); |
| 2473 VisitForAccumulatorValue(prop->key()); |
| 2474 Register scratch = rcx; |
| 2475 Register scratch2 = rdx; |
| 2476 __ movp(scratch2, MemOperand(rsp, 2 * kPointerSize)); // value |
| 2477 // stack: value, this, home_object; rax: key, rdx: value |
| 2478 __ movp(scratch, MemOperand(rsp, kPointerSize)); // this |
| 2479 __ movp(MemOperand(rsp, 2 * kPointerSize), scratch); |
| 2480 __ movp(scratch, MemOperand(rsp, 0)); // home_object |
| 2481 __ movp(MemOperand(rsp, kPointerSize), scratch); |
| 2482 __ movp(MemOperand(rsp, 0), rax); |
| 2483 __ Move(rax, scratch2); |
| 2484 // stack: this, home_object, key; rax: value. |
| 2485 EmitKeyedSuperPropertyStore(prop); |
| 2486 break; |
| 2487 } |
2460 case KEYED_PROPERTY: { | 2488 case KEYED_PROPERTY: { |
2461 __ Push(rax); // Preserve value. | 2489 __ Push(rax); // Preserve value. |
2462 VisitForStackValue(prop->obj()); | 2490 VisitForStackValue(prop->obj()); |
2463 VisitForAccumulatorValue(prop->key()); | 2491 VisitForAccumulatorValue(prop->key()); |
2464 __ Move(StoreDescriptor::NameRegister(), rax); | 2492 __ Move(StoreDescriptor::NameRegister(), rax); |
2465 __ Pop(StoreDescriptor::ReceiverRegister()); | 2493 __ Pop(StoreDescriptor::ReceiverRegister()); |
2466 __ Pop(StoreDescriptor::ValueRegister()); // Restore value. | 2494 __ Pop(StoreDescriptor::ValueRegister()); // Restore value. |
2467 Handle<Code> ic = | 2495 Handle<Code> ic = |
2468 CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); | 2496 CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); |
2469 CallIC(ic); | 2497 CallIC(ic); |
(...skipping 2627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5097 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5125 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5098 Assembler::target_address_at(call_target_address, | 5126 Assembler::target_address_at(call_target_address, |
5099 unoptimized_code)); | 5127 unoptimized_code)); |
5100 return OSR_AFTER_STACK_CHECK; | 5128 return OSR_AFTER_STACK_CHECK; |
5101 } | 5129 } |
5102 | 5130 |
5103 | 5131 |
5104 } } // namespace v8::internal | 5132 } } // namespace v8::internal |
5105 | 5133 |
5106 #endif // V8_TARGET_ARCH_X64 | 5134 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |