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 1946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1957 case VARIABLE: | 1957 case VARIABLE: |
1958 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), | 1958 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), |
1959 expr->op()); | 1959 expr->op()); |
1960 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 1960 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
1961 context()->Plug(rax); | 1961 context()->Plug(rax); |
1962 break; | 1962 break; |
1963 case NAMED_PROPERTY: | 1963 case NAMED_PROPERTY: |
1964 EmitNamedPropertyAssignment(expr); | 1964 EmitNamedPropertyAssignment(expr); |
1965 break; | 1965 break; |
1966 case NAMED_SUPER_PROPERTY: | 1966 case NAMED_SUPER_PROPERTY: |
1967 EmitNamedSuperPropertyAssignment(expr); | 1967 EmitNamedSuperPropertyStore(property); |
| 1968 context()->Plug(rax); |
1968 break; | 1969 break; |
1969 case KEYED_PROPERTY: | 1970 case KEYED_PROPERTY: |
1970 EmitKeyedPropertyAssignment(expr); | 1971 EmitKeyedPropertyAssignment(expr); |
1971 break; | 1972 break; |
1972 } | 1973 } |
1973 } | 1974 } |
1974 | 1975 |
1975 | 1976 |
1976 void FullCodeGenerator::VisitYield(Yield* expr) { | 1977 void FullCodeGenerator::VisitYield(Yield* expr) { |
1977 Comment cmnt(masm_, "[ Yield"); | 1978 Comment cmnt(masm_, "[ Yield"); |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2540 SetSourcePosition(expr->position()); | 2541 SetSourcePosition(expr->position()); |
2541 __ Move(StoreDescriptor::NameRegister(), prop->key()->AsLiteral()->value()); | 2542 __ Move(StoreDescriptor::NameRegister(), prop->key()->AsLiteral()->value()); |
2542 __ Pop(StoreDescriptor::ReceiverRegister()); | 2543 __ Pop(StoreDescriptor::ReceiverRegister()); |
2543 CallStoreIC(expr->AssignmentFeedbackId()); | 2544 CallStoreIC(expr->AssignmentFeedbackId()); |
2544 | 2545 |
2545 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2546 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2546 context()->Plug(rax); | 2547 context()->Plug(rax); |
2547 } | 2548 } |
2548 | 2549 |
2549 | 2550 |
2550 void FullCodeGenerator::EmitNamedSuperPropertyAssignment(Assignment* expr) { | 2551 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { |
2551 // Assignment to named property of super. | 2552 // Assignment to named property of super. |
2552 // rax : value | 2553 // rax : value |
2553 // stack : receiver ('this'), home_object | 2554 // stack : receiver ('this'), home_object |
2554 Property* prop = expr->target()->AsProperty(); | |
2555 DCHECK(prop != NULL); | 2555 DCHECK(prop != NULL); |
2556 Literal* key = prop->key()->AsLiteral(); | 2556 Literal* key = prop->key()->AsLiteral(); |
2557 DCHECK(key != NULL); | 2557 DCHECK(key != NULL); |
2558 | 2558 |
2559 __ Push(rax); | 2559 __ Push(rax); |
2560 __ Push(key->value()); | 2560 __ Push(key->value()); |
2561 __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict | 2561 __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict |
2562 : Runtime::kStoreToSuper_Sloppy), | 2562 : Runtime::kStoreToSuper_Sloppy), |
2563 4); | 2563 4); |
2564 context()->Plug(rax); | |
2565 } | 2564 } |
2566 | 2565 |
2567 | 2566 |
2568 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { | 2567 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
2569 // Assignment to a property, using a keyed store IC. | 2568 // Assignment to a property, using a keyed store IC. |
2570 | 2569 |
2571 __ Pop(StoreDescriptor::NameRegister()); // Key. | 2570 __ Pop(StoreDescriptor::NameRegister()); // Key. |
2572 __ Pop(StoreDescriptor::ReceiverRegister()); | 2571 __ Pop(StoreDescriptor::ReceiverRegister()); |
2573 DCHECK(StoreDescriptor::ValueRegister().is(rax)); | 2572 DCHECK(StoreDescriptor::ValueRegister().is(rax)); |
2574 // Record source code position before IC call. | 2573 // Record source code position before IC call. |
(...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4338 | 4337 |
4339 | 4338 |
4340 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { | 4339 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
4341 DCHECK(expr->expression()->IsValidReferenceExpression()); | 4340 DCHECK(expr->expression()->IsValidReferenceExpression()); |
4342 | 4341 |
4343 Comment cmnt(masm_, "[ CountOperation"); | 4342 Comment cmnt(masm_, "[ CountOperation"); |
4344 SetSourcePosition(expr->position()); | 4343 SetSourcePosition(expr->position()); |
4345 | 4344 |
4346 // Expression can only be a property, a global or a (parameter or local) | 4345 // Expression can only be a property, a global or a (parameter or local) |
4347 // slot. | 4346 // slot. |
4348 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; | 4347 enum LhsKind { |
| 4348 VARIABLE, |
| 4349 NAMED_PROPERTY, |
| 4350 KEYED_PROPERTY, |
| 4351 NAMED_SUPER_PROPERTY |
| 4352 }; |
4349 LhsKind assign_type = VARIABLE; | 4353 LhsKind assign_type = VARIABLE; |
4350 Property* prop = expr->expression()->AsProperty(); | 4354 Property* prop = expr->expression()->AsProperty(); |
4351 // In case of a property we use the uninitialized expression context | 4355 // In case of a property we use the uninitialized expression context |
4352 // of the key to detect a named property. | 4356 // of the key to detect a named property. |
4353 if (prop != NULL) { | 4357 if (prop != NULL) { |
4354 assign_type = | 4358 assign_type = |
4355 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; | 4359 (prop->key()->IsPropertyName()) |
4356 if (prop->IsSuperAccess()) { | 4360 ? (prop->IsSuperAccess() ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) |
4357 // throw exception. | 4361 : KEYED_PROPERTY; |
4358 VisitSuperReference(prop->obj()->AsSuperReference()); | |
4359 return; | |
4360 } | |
4361 } | 4362 } |
4362 | 4363 |
4363 // Evaluate expression and get value. | 4364 // Evaluate expression and get value. |
4364 if (assign_type == VARIABLE) { | 4365 if (assign_type == VARIABLE) { |
4365 DCHECK(expr->expression()->AsVariableProxy()->var() != NULL); | 4366 DCHECK(expr->expression()->AsVariableProxy()->var() != NULL); |
4366 AccumulatorValueContext context(this); | 4367 AccumulatorValueContext context(this); |
4367 EmitVariableLoad(expr->expression()->AsVariableProxy()); | 4368 EmitVariableLoad(expr->expression()->AsVariableProxy()); |
4368 } else { | 4369 } else { |
4369 // Reserve space for result of postfix operation. | 4370 // Reserve space for result of postfix operation. |
4370 if (expr->is_postfix() && !context()->IsEffect()) { | 4371 if (expr->is_postfix() && !context()->IsEffect()) { |
4371 __ Push(Smi::FromInt(0)); | 4372 __ Push(Smi::FromInt(0)); |
4372 } | 4373 } |
4373 if (assign_type == NAMED_PROPERTY) { | 4374 if (assign_type == NAMED_PROPERTY) { |
4374 VisitForStackValue(prop->obj()); | 4375 VisitForStackValue(prop->obj()); |
4375 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 4376 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
4376 EmitNamedPropertyLoad(prop); | 4377 EmitNamedPropertyLoad(prop); |
| 4378 } else if (assign_type == NAMED_SUPER_PROPERTY) { |
| 4379 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); |
| 4380 EmitLoadHomeObject(prop->obj()->AsSuperReference()); |
| 4381 __ Push(result_register()); |
| 4382 __ Push(MemOperand(rsp, kPointerSize)); |
| 4383 __ Push(result_register()); |
| 4384 EmitNamedSuperPropertyLoad(prop); |
4377 } else { | 4385 } else { |
4378 VisitForStackValue(prop->obj()); | 4386 VisitForStackValue(prop->obj()); |
4379 VisitForStackValue(prop->key()); | 4387 VisitForStackValue(prop->key()); |
4380 // Leave receiver on stack | 4388 // Leave receiver on stack |
4381 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, kPointerSize)); | 4389 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, kPointerSize)); |
4382 // Copy of key, needed for later store. | 4390 // Copy of key, needed for later store. |
4383 __ movp(LoadDescriptor::NameRegister(), Operand(rsp, 0)); | 4391 __ movp(LoadDescriptor::NameRegister(), Operand(rsp, 0)); |
4384 EmitKeyedPropertyLoad(prop); | 4392 EmitKeyedPropertyLoad(prop); |
4385 } | 4393 } |
4386 } | 4394 } |
(...skipping 19 matching lines...) Expand all Loading... |
4406 // Save the result on the stack. If we have a named or keyed property | 4414 // Save the result on the stack. If we have a named or keyed property |
4407 // we store the result under the receiver that is currently on top | 4415 // we store the result under the receiver that is currently on top |
4408 // of the stack. | 4416 // of the stack. |
4409 switch (assign_type) { | 4417 switch (assign_type) { |
4410 case VARIABLE: | 4418 case VARIABLE: |
4411 __ Push(rax); | 4419 __ Push(rax); |
4412 break; | 4420 break; |
4413 case NAMED_PROPERTY: | 4421 case NAMED_PROPERTY: |
4414 __ movp(Operand(rsp, kPointerSize), rax); | 4422 __ movp(Operand(rsp, kPointerSize), rax); |
4415 break; | 4423 break; |
| 4424 case NAMED_SUPER_PROPERTY: |
| 4425 __ movp(Operand(rsp, 2 * kPointerSize), rax); |
| 4426 break; |
4416 case KEYED_PROPERTY: | 4427 case KEYED_PROPERTY: |
4417 __ movp(Operand(rsp, 2 * kPointerSize), rax); | 4428 __ movp(Operand(rsp, 2 * kPointerSize), rax); |
4418 break; | 4429 break; |
4419 } | 4430 } |
4420 } | 4431 } |
4421 } | 4432 } |
4422 | 4433 |
4423 SmiOperationExecutionMode mode; | 4434 SmiOperationExecutionMode mode; |
4424 mode.Add(PRESERVE_SOURCE_REGISTER); | 4435 mode.Add(PRESERVE_SOURCE_REGISTER); |
4425 mode.Add(BAILOUT_ON_NO_OVERFLOW); | 4436 mode.Add(BAILOUT_ON_NO_OVERFLOW); |
(...skipping 15 matching lines...) Expand all Loading... |
4441 // Save the result on the stack. If we have a named or keyed property | 4452 // Save the result on the stack. If we have a named or keyed property |
4442 // we store the result under the receiver that is currently on top | 4453 // we store the result under the receiver that is currently on top |
4443 // of the stack. | 4454 // of the stack. |
4444 switch (assign_type) { | 4455 switch (assign_type) { |
4445 case VARIABLE: | 4456 case VARIABLE: |
4446 __ Push(rax); | 4457 __ Push(rax); |
4447 break; | 4458 break; |
4448 case NAMED_PROPERTY: | 4459 case NAMED_PROPERTY: |
4449 __ movp(Operand(rsp, kPointerSize), rax); | 4460 __ movp(Operand(rsp, kPointerSize), rax); |
4450 break; | 4461 break; |
| 4462 case NAMED_SUPER_PROPERTY: |
| 4463 __ movp(Operand(rsp, 2 * kPointerSize), rax); |
| 4464 break; |
4451 case KEYED_PROPERTY: | 4465 case KEYED_PROPERTY: |
4452 __ movp(Operand(rsp, 2 * kPointerSize), rax); | 4466 __ movp(Operand(rsp, 2 * kPointerSize), rax); |
4453 break; | 4467 break; |
4454 } | 4468 } |
4455 } | 4469 } |
4456 } | 4470 } |
4457 | 4471 |
4458 // Record position before stub call. | 4472 // Record position before stub call. |
4459 SetSourcePosition(expr->position()); | 4473 SetSourcePosition(expr->position()); |
4460 | 4474 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4500 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4514 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4501 if (expr->is_postfix()) { | 4515 if (expr->is_postfix()) { |
4502 if (!context()->IsEffect()) { | 4516 if (!context()->IsEffect()) { |
4503 context()->PlugTOS(); | 4517 context()->PlugTOS(); |
4504 } | 4518 } |
4505 } else { | 4519 } else { |
4506 context()->Plug(rax); | 4520 context()->Plug(rax); |
4507 } | 4521 } |
4508 break; | 4522 break; |
4509 } | 4523 } |
| 4524 case NAMED_SUPER_PROPERTY: { |
| 4525 EmitNamedSuperPropertyStore(prop); |
| 4526 if (expr->is_postfix()) { |
| 4527 if (!context()->IsEffect()) { |
| 4528 context()->PlugTOS(); |
| 4529 } |
| 4530 } else { |
| 4531 context()->Plug(rax); |
| 4532 } |
| 4533 break; |
| 4534 } |
4510 case KEYED_PROPERTY: { | 4535 case KEYED_PROPERTY: { |
4511 __ Pop(StoreDescriptor::NameRegister()); | 4536 __ Pop(StoreDescriptor::NameRegister()); |
4512 __ Pop(StoreDescriptor::ReceiverRegister()); | 4537 __ Pop(StoreDescriptor::ReceiverRegister()); |
4513 Handle<Code> ic = | 4538 Handle<Code> ic = |
4514 CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); | 4539 CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); |
4515 CallIC(ic, expr->CountStoreFeedbackId()); | 4540 CallIC(ic, expr->CountStoreFeedbackId()); |
4516 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4541 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4517 if (expr->is_postfix()) { | 4542 if (expr->is_postfix()) { |
4518 if (!context()->IsEffect()) { | 4543 if (!context()->IsEffect()) { |
4519 context()->PlugTOS(); | 4544 context()->PlugTOS(); |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4963 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4988 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4964 Assembler::target_address_at(call_target_address, | 4989 Assembler::target_address_at(call_target_address, |
4965 unoptimized_code)); | 4990 unoptimized_code)); |
4966 return OSR_AFTER_STACK_CHECK; | 4991 return OSR_AFTER_STACK_CHECK; |
4967 } | 4992 } |
4968 | 4993 |
4969 | 4994 |
4970 } } // namespace v8::internal | 4995 } } // namespace v8::internal |
4971 | 4996 |
4972 #endif // V8_TARGET_ARCH_X64 | 4997 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |