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-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 switch (property->kind()) { | 1659 switch (property->kind()) { |
1660 case ObjectLiteral::Property::CONSTANT: | 1660 case ObjectLiteral::Property::CONSTANT: |
1661 UNREACHABLE(); | 1661 UNREACHABLE(); |
1662 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1662 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
1663 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); | 1663 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); |
1664 // Fall through. | 1664 // Fall through. |
1665 case ObjectLiteral::Property::COMPUTED: | 1665 case ObjectLiteral::Property::COMPUTED: |
1666 if (key->value()->IsInternalizedString()) { | 1666 if (key->value()->IsInternalizedString()) { |
1667 if (property->emit_store()) { | 1667 if (property->emit_store()) { |
1668 VisitForAccumulatorValue(value); | 1668 VisitForAccumulatorValue(value); |
1669 __ Move(rcx, key->value()); | 1669 ASSERT(StoreIC::ValueRegister().is(rax)); |
1670 __ movp(rdx, Operand(rsp, 0)); | 1670 __ Move(StoreIC::NameRegister(), key->value()); |
| 1671 __ movp(StoreIC::ReceiverRegister(), Operand(rsp, 0)); |
1671 CallStoreIC(key->LiteralFeedbackId()); | 1672 CallStoreIC(key->LiteralFeedbackId()); |
1672 PrepareForBailoutForId(key->id(), NO_REGISTERS); | 1673 PrepareForBailoutForId(key->id(), NO_REGISTERS); |
1673 } else { | 1674 } else { |
1674 VisitForEffect(value); | 1675 VisitForEffect(value); |
1675 } | 1676 } |
1676 break; | 1677 break; |
1677 } | 1678 } |
1678 __ Push(Operand(rsp, 0)); // Duplicate receiver. | 1679 __ Push(Operand(rsp, 0)); // Duplicate receiver. |
1679 VisitForStackValue(key); | 1680 VisitForStackValue(key); |
1680 VisitForStackValue(value); | 1681 VisitForStackValue(value); |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2340 switch (assign_type) { | 2341 switch (assign_type) { |
2341 case VARIABLE: { | 2342 case VARIABLE: { |
2342 Variable* var = expr->AsVariableProxy()->var(); | 2343 Variable* var = expr->AsVariableProxy()->var(); |
2343 EffectContext context(this); | 2344 EffectContext context(this); |
2344 EmitVariableAssignment(var, Token::ASSIGN); | 2345 EmitVariableAssignment(var, Token::ASSIGN); |
2345 break; | 2346 break; |
2346 } | 2347 } |
2347 case NAMED_PROPERTY: { | 2348 case NAMED_PROPERTY: { |
2348 __ Push(rax); // Preserve value. | 2349 __ Push(rax); // Preserve value. |
2349 VisitForAccumulatorValue(prop->obj()); | 2350 VisitForAccumulatorValue(prop->obj()); |
2350 __ movp(rdx, rax); | 2351 __ Move(StoreIC::ReceiverRegister(), rax); |
2351 __ Pop(rax); // Restore value. | 2352 __ Pop(StoreIC::ValueRegister()); // Restore value. |
2352 __ Move(rcx, prop->key()->AsLiteral()->value()); | 2353 __ Move(StoreIC::NameRegister(), prop->key()->AsLiteral()->value()); |
2353 CallStoreIC(); | 2354 CallStoreIC(); |
2354 break; | 2355 break; |
2355 } | 2356 } |
2356 case KEYED_PROPERTY: { | 2357 case KEYED_PROPERTY: { |
2357 __ Push(rax); // Preserve value. | 2358 __ Push(rax); // Preserve value. |
2358 VisitForStackValue(prop->obj()); | 2359 VisitForStackValue(prop->obj()); |
2359 VisitForAccumulatorValue(prop->key()); | 2360 VisitForAccumulatorValue(prop->key()); |
2360 __ movp(rcx, rax); | 2361 __ Move(KeyedStoreIC::NameRegister(), rax); |
2361 __ Pop(rdx); | 2362 __ Pop(KeyedStoreIC::ReceiverRegister()); |
2362 __ Pop(rax); // Restore value. | 2363 __ Pop(KeyedStoreIC::ValueRegister()); // Restore value. |
2363 Handle<Code> ic = strict_mode() == SLOPPY | 2364 Handle<Code> ic = strict_mode() == SLOPPY |
2364 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2365 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
2365 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 2366 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
2366 CallIC(ic); | 2367 CallIC(ic); |
2367 break; | 2368 break; |
2368 } | 2369 } |
2369 } | 2370 } |
2370 context()->Plug(rax); | 2371 context()->Plug(rax); |
2371 } | 2372 } |
2372 | 2373 |
(...skipping 16 matching lines...) Expand all Loading... |
2389 __ Push(name); | 2390 __ Push(name); |
2390 __ Push(Smi::FromInt(strict_mode)); | 2391 __ Push(Smi::FromInt(strict_mode)); |
2391 __ CallRuntime(Runtime::kStoreContextSlot, 4); | 2392 __ CallRuntime(Runtime::kStoreContextSlot, 4); |
2392 } | 2393 } |
2393 | 2394 |
2394 | 2395 |
2395 void FullCodeGenerator::EmitVariableAssignment(Variable* var, | 2396 void FullCodeGenerator::EmitVariableAssignment(Variable* var, |
2396 Token::Value op) { | 2397 Token::Value op) { |
2397 if (var->IsUnallocated()) { | 2398 if (var->IsUnallocated()) { |
2398 // Global var, const, or let. | 2399 // Global var, const, or let. |
2399 __ Move(rcx, var->name()); | 2400 __ Move(StoreIC::NameRegister(), var->name()); |
2400 __ movp(rdx, GlobalObjectOperand()); | 2401 __ movp(StoreIC::ReceiverRegister(), GlobalObjectOperand()); |
2401 CallStoreIC(); | 2402 CallStoreIC(); |
2402 | 2403 |
2403 } else if (op == Token::INIT_CONST_LEGACY) { | 2404 } else if (op == Token::INIT_CONST_LEGACY) { |
2404 // Const initializers need a write barrier. | 2405 // Const initializers need a write barrier. |
2405 ASSERT(!var->IsParameter()); // No const parameters. | 2406 ASSERT(!var->IsParameter()); // No const parameters. |
2406 if (var->IsLookupSlot()) { | 2407 if (var->IsLookupSlot()) { |
2407 __ Push(rax); | 2408 __ Push(rax); |
2408 __ Push(rsi); | 2409 __ Push(rsi); |
2409 __ Push(var->name()); | 2410 __ Push(var->name()); |
2410 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); | 2411 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2458 | 2459 |
2459 | 2460 |
2460 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 2461 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
2461 // Assignment to a property, using a named store IC. | 2462 // Assignment to a property, using a named store IC. |
2462 Property* prop = expr->target()->AsProperty(); | 2463 Property* prop = expr->target()->AsProperty(); |
2463 ASSERT(prop != NULL); | 2464 ASSERT(prop != NULL); |
2464 ASSERT(prop->key()->IsLiteral()); | 2465 ASSERT(prop->key()->IsLiteral()); |
2465 | 2466 |
2466 // Record source code position before IC call. | 2467 // Record source code position before IC call. |
2467 SetSourcePosition(expr->position()); | 2468 SetSourcePosition(expr->position()); |
2468 __ Move(rcx, prop->key()->AsLiteral()->value()); | 2469 __ Move(StoreIC::NameRegister(), prop->key()->AsLiteral()->value()); |
2469 __ Pop(rdx); | 2470 __ Pop(StoreIC::ReceiverRegister()); |
2470 CallStoreIC(expr->AssignmentFeedbackId()); | 2471 CallStoreIC(expr->AssignmentFeedbackId()); |
2471 | 2472 |
2472 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2473 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2473 context()->Plug(rax); | 2474 context()->Plug(rax); |
2474 } | 2475 } |
2475 | 2476 |
2476 | 2477 |
2477 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { | 2478 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
2478 // Assignment to a property, using a keyed store IC. | 2479 // Assignment to a property, using a keyed store IC. |
2479 | 2480 |
2480 __ Pop(rcx); | 2481 __ Pop(KeyedStoreIC::NameRegister()); // Key. |
2481 __ Pop(rdx); | 2482 __ Pop(KeyedStoreIC::ReceiverRegister()); |
| 2483 ASSERT(KeyedStoreIC::ValueRegister().is(rax)); |
2482 // Record source code position before IC call. | 2484 // Record source code position before IC call. |
2483 SetSourcePosition(expr->position()); | 2485 SetSourcePosition(expr->position()); |
2484 Handle<Code> ic = strict_mode() == SLOPPY | 2486 Handle<Code> ic = strict_mode() == SLOPPY |
2485 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2487 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
2486 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 2488 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
2487 CallIC(ic, expr->AssignmentFeedbackId()); | 2489 CallIC(ic, expr->AssignmentFeedbackId()); |
2488 | 2490 |
2489 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2491 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2490 context()->Plug(rax); | 2492 context()->Plug(rax); |
2491 } | 2493 } |
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4333 } | 4335 } |
4334 } else { | 4336 } else { |
4335 // Perform the assignment as if via '='. | 4337 // Perform the assignment as if via '='. |
4336 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 4338 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
4337 Token::ASSIGN); | 4339 Token::ASSIGN); |
4338 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4340 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4339 context()->Plug(rax); | 4341 context()->Plug(rax); |
4340 } | 4342 } |
4341 break; | 4343 break; |
4342 case NAMED_PROPERTY: { | 4344 case NAMED_PROPERTY: { |
4343 __ Move(rcx, prop->key()->AsLiteral()->value()); | 4345 __ Move(StoreIC::NameRegister(), prop->key()->AsLiteral()->value()); |
4344 __ Pop(rdx); | 4346 __ Pop(StoreIC::ReceiverRegister()); |
4345 CallStoreIC(expr->CountStoreFeedbackId()); | 4347 CallStoreIC(expr->CountStoreFeedbackId()); |
4346 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4348 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4347 if (expr->is_postfix()) { | 4349 if (expr->is_postfix()) { |
4348 if (!context()->IsEffect()) { | 4350 if (!context()->IsEffect()) { |
4349 context()->PlugTOS(); | 4351 context()->PlugTOS(); |
4350 } | 4352 } |
4351 } else { | 4353 } else { |
4352 context()->Plug(rax); | 4354 context()->Plug(rax); |
4353 } | 4355 } |
4354 break; | 4356 break; |
4355 } | 4357 } |
4356 case KEYED_PROPERTY: { | 4358 case KEYED_PROPERTY: { |
4357 __ Pop(rcx); | 4359 __ Pop(KeyedStoreIC::NameRegister()); |
4358 __ Pop(rdx); | 4360 __ Pop(KeyedStoreIC::ReceiverRegister()); |
4359 Handle<Code> ic = strict_mode() == SLOPPY | 4361 Handle<Code> ic = strict_mode() == SLOPPY |
4360 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 4362 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
4361 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 4363 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
4362 CallIC(ic, expr->CountStoreFeedbackId()); | 4364 CallIC(ic, expr->CountStoreFeedbackId()); |
4363 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4365 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4364 if (expr->is_postfix()) { | 4366 if (expr->is_postfix()) { |
4365 if (!context()->IsEffect()) { | 4367 if (!context()->IsEffect()) { |
4366 context()->PlugTOS(); | 4368 context()->PlugTOS(); |
4367 } | 4369 } |
4368 } else { | 4370 } else { |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4812 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4814 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4813 Assembler::target_address_at(call_target_address, | 4815 Assembler::target_address_at(call_target_address, |
4814 unoptimized_code)); | 4816 unoptimized_code)); |
4815 return OSR_AFTER_STACK_CHECK; | 4817 return OSR_AFTER_STACK_CHECK; |
4816 } | 4818 } |
4817 | 4819 |
4818 | 4820 |
4819 } } // namespace v8::internal | 4821 } } // namespace v8::internal |
4820 | 4822 |
4821 #endif // V8_TARGET_ARCH_X64 | 4823 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |