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_X87 | 7 #if V8_TARGET_ARCH_X87 |
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 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 switch (property->kind()) { | 1623 switch (property->kind()) { |
1624 case ObjectLiteral::Property::CONSTANT: | 1624 case ObjectLiteral::Property::CONSTANT: |
1625 UNREACHABLE(); | 1625 UNREACHABLE(); |
1626 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1626 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
1627 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); | 1627 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); |
1628 // Fall through. | 1628 // Fall through. |
1629 case ObjectLiteral::Property::COMPUTED: | 1629 case ObjectLiteral::Property::COMPUTED: |
1630 if (key->value()->IsInternalizedString()) { | 1630 if (key->value()->IsInternalizedString()) { |
1631 if (property->emit_store()) { | 1631 if (property->emit_store()) { |
1632 VisitForAccumulatorValue(value); | 1632 VisitForAccumulatorValue(value); |
1633 __ mov(ecx, Immediate(key->value())); | 1633 ASSERT(StoreIC::ValueRegister().is(eax)); |
1634 __ mov(edx, Operand(esp, 0)); | 1634 __ mov(StoreIC::NameRegister(), Immediate(key->value())); |
| 1635 __ mov(StoreIC::ReceiverRegister(), Operand(esp, 0)); |
1635 CallStoreIC(key->LiteralFeedbackId()); | 1636 CallStoreIC(key->LiteralFeedbackId()); |
1636 PrepareForBailoutForId(key->id(), NO_REGISTERS); | 1637 PrepareForBailoutForId(key->id(), NO_REGISTERS); |
1637 } else { | 1638 } else { |
1638 VisitForEffect(value); | 1639 VisitForEffect(value); |
1639 } | 1640 } |
1640 break; | 1641 break; |
1641 } | 1642 } |
1642 __ push(Operand(esp, 0)); // Duplicate receiver. | 1643 __ push(Operand(esp, 0)); // Duplicate receiver. |
1643 VisitForStackValue(key); | 1644 VisitForStackValue(key); |
1644 VisitForStackValue(value); | 1645 VisitForStackValue(value); |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2336 switch (assign_type) { | 2337 switch (assign_type) { |
2337 case VARIABLE: { | 2338 case VARIABLE: { |
2338 Variable* var = expr->AsVariableProxy()->var(); | 2339 Variable* var = expr->AsVariableProxy()->var(); |
2339 EffectContext context(this); | 2340 EffectContext context(this); |
2340 EmitVariableAssignment(var, Token::ASSIGN); | 2341 EmitVariableAssignment(var, Token::ASSIGN); |
2341 break; | 2342 break; |
2342 } | 2343 } |
2343 case NAMED_PROPERTY: { | 2344 case NAMED_PROPERTY: { |
2344 __ push(eax); // Preserve value. | 2345 __ push(eax); // Preserve value. |
2345 VisitForAccumulatorValue(prop->obj()); | 2346 VisitForAccumulatorValue(prop->obj()); |
2346 __ mov(edx, eax); | 2347 __ Move(StoreIC::ReceiverRegister(), eax); |
2347 __ pop(eax); // Restore value. | 2348 __ pop(StoreIC::ValueRegister()); // Restore value. |
2348 __ mov(ecx, prop->key()->AsLiteral()->value()); | 2349 __ mov(StoreIC::NameRegister(), prop->key()->AsLiteral()->value()); |
2349 CallStoreIC(); | 2350 CallStoreIC(); |
2350 break; | 2351 break; |
2351 } | 2352 } |
2352 case KEYED_PROPERTY: { | 2353 case KEYED_PROPERTY: { |
2353 __ push(eax); // Preserve value. | 2354 __ push(eax); // Preserve value. |
2354 VisitForStackValue(prop->obj()); | 2355 VisitForStackValue(prop->obj()); |
2355 VisitForAccumulatorValue(prop->key()); | 2356 VisitForAccumulatorValue(prop->key()); |
2356 __ mov(ecx, eax); | 2357 __ Move(KeyedStoreIC::NameRegister(), eax); |
2357 __ pop(edx); // Receiver. | 2358 __ pop(KeyedStoreIC::ReceiverRegister()); // Receiver. |
2358 __ pop(eax); // Restore value. | 2359 __ pop(KeyedStoreIC::ValueRegister()); // Restore value. |
2359 Handle<Code> ic = strict_mode() == SLOPPY | 2360 Handle<Code> ic = strict_mode() == SLOPPY |
2360 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2361 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
2361 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 2362 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
2362 CallIC(ic); | 2363 CallIC(ic); |
2363 break; | 2364 break; |
2364 } | 2365 } |
2365 } | 2366 } |
2366 context()->Plug(eax); | 2367 context()->Plug(eax); |
2367 } | 2368 } |
2368 | 2369 |
(...skipping 16 matching lines...) Expand all Loading... |
2385 __ push(Immediate(name)); | 2386 __ push(Immediate(name)); |
2386 __ push(Immediate(Smi::FromInt(strict_mode))); | 2387 __ push(Immediate(Smi::FromInt(strict_mode))); |
2387 __ CallRuntime(Runtime::kStoreContextSlot, 4); | 2388 __ CallRuntime(Runtime::kStoreContextSlot, 4); |
2388 } | 2389 } |
2389 | 2390 |
2390 | 2391 |
2391 void FullCodeGenerator::EmitVariableAssignment(Variable* var, | 2392 void FullCodeGenerator::EmitVariableAssignment(Variable* var, |
2392 Token::Value op) { | 2393 Token::Value op) { |
2393 if (var->IsUnallocated()) { | 2394 if (var->IsUnallocated()) { |
2394 // Global var, const, or let. | 2395 // Global var, const, or let. |
2395 __ mov(ecx, var->name()); | 2396 __ mov(StoreIC::NameRegister(), var->name()); |
2396 __ mov(edx, GlobalObjectOperand()); | 2397 __ mov(StoreIC::ReceiverRegister(), GlobalObjectOperand()); |
2397 CallStoreIC(); | 2398 CallStoreIC(); |
2398 | 2399 |
2399 } else if (op == Token::INIT_CONST_LEGACY) { | 2400 } else if (op == Token::INIT_CONST_LEGACY) { |
2400 // Const initializers need a write barrier. | 2401 // Const initializers need a write barrier. |
2401 ASSERT(!var->IsParameter()); // No const parameters. | 2402 ASSERT(!var->IsParameter()); // No const parameters. |
2402 if (var->IsLookupSlot()) { | 2403 if (var->IsLookupSlot()) { |
2403 __ push(eax); | 2404 __ push(eax); |
2404 __ push(esi); | 2405 __ push(esi); |
2405 __ push(Immediate(var->name())); | 2406 __ push(Immediate(var->name())); |
2406 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); | 2407 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2457 // Assignment to a property, using a named store IC. | 2458 // Assignment to a property, using a named store IC. |
2458 // eax : value | 2459 // eax : value |
2459 // esp[0] : receiver | 2460 // esp[0] : receiver |
2460 | 2461 |
2461 Property* prop = expr->target()->AsProperty(); | 2462 Property* prop = expr->target()->AsProperty(); |
2462 ASSERT(prop != NULL); | 2463 ASSERT(prop != NULL); |
2463 ASSERT(prop->key()->IsLiteral()); | 2464 ASSERT(prop->key()->IsLiteral()); |
2464 | 2465 |
2465 // Record source code position before IC call. | 2466 // Record source code position before IC call. |
2466 SetSourcePosition(expr->position()); | 2467 SetSourcePosition(expr->position()); |
2467 __ mov(ecx, prop->key()->AsLiteral()->value()); | 2468 __ mov(StoreIC::NameRegister(), prop->key()->AsLiteral()->value()); |
2468 __ pop(edx); | 2469 __ pop(StoreIC::ReceiverRegister()); |
2469 CallStoreIC(expr->AssignmentFeedbackId()); | 2470 CallStoreIC(expr->AssignmentFeedbackId()); |
2470 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2471 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2471 context()->Plug(eax); | 2472 context()->Plug(eax); |
2472 } | 2473 } |
2473 | 2474 |
2474 | 2475 |
2475 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { | 2476 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
2476 // Assignment to a property, using a keyed store IC. | 2477 // Assignment to a property, using a keyed store IC. |
2477 // eax : value | 2478 // eax : value |
2478 // esp[0] : key | 2479 // esp[0] : key |
2479 // esp[kPointerSize] : receiver | 2480 // esp[kPointerSize] : receiver |
2480 | 2481 |
2481 __ pop(ecx); // Key. | 2482 __ pop(KeyedStoreIC::NameRegister()); // Key. |
2482 __ pop(edx); | 2483 __ pop(KeyedStoreIC::ReceiverRegister()); |
| 2484 ASSERT(KeyedStoreIC::ValueRegister().is(eax)); |
2483 // Record source code position before IC call. | 2485 // Record source code position before IC call. |
2484 SetSourcePosition(expr->position()); | 2486 SetSourcePosition(expr->position()); |
2485 Handle<Code> ic = strict_mode() == SLOPPY | 2487 Handle<Code> ic = strict_mode() == SLOPPY |
2486 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2488 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
2487 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 2489 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
2488 CallIC(ic, expr->AssignmentFeedbackId()); | 2490 CallIC(ic, expr->AssignmentFeedbackId()); |
2489 | 2491 |
2490 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2492 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2491 context()->Plug(eax); | 2493 context()->Plug(eax); |
2492 } | 2494 } |
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4318 } | 4320 } |
4319 } else { | 4321 } else { |
4320 // Perform the assignment as if via '='. | 4322 // Perform the assignment as if via '='. |
4321 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 4323 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
4322 Token::ASSIGN); | 4324 Token::ASSIGN); |
4323 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4325 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4324 context()->Plug(eax); | 4326 context()->Plug(eax); |
4325 } | 4327 } |
4326 break; | 4328 break; |
4327 case NAMED_PROPERTY: { | 4329 case NAMED_PROPERTY: { |
4328 __ mov(ecx, prop->key()->AsLiteral()->value()); | 4330 __ mov(StoreIC::NameRegister(), prop->key()->AsLiteral()->value()); |
4329 __ pop(edx); | 4331 __ pop(StoreIC::ReceiverRegister()); |
4330 CallStoreIC(expr->CountStoreFeedbackId()); | 4332 CallStoreIC(expr->CountStoreFeedbackId()); |
4331 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4333 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4332 if (expr->is_postfix()) { | 4334 if (expr->is_postfix()) { |
4333 if (!context()->IsEffect()) { | 4335 if (!context()->IsEffect()) { |
4334 context()->PlugTOS(); | 4336 context()->PlugTOS(); |
4335 } | 4337 } |
4336 } else { | 4338 } else { |
4337 context()->Plug(eax); | 4339 context()->Plug(eax); |
4338 } | 4340 } |
4339 break; | 4341 break; |
4340 } | 4342 } |
4341 case KEYED_PROPERTY: { | 4343 case KEYED_PROPERTY: { |
4342 __ pop(ecx); | 4344 __ pop(KeyedStoreIC::NameRegister()); |
4343 __ pop(edx); | 4345 __ pop(KeyedStoreIC::ReceiverRegister()); |
4344 Handle<Code> ic = strict_mode() == SLOPPY | 4346 Handle<Code> ic = strict_mode() == SLOPPY |
4345 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 4347 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
4346 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 4348 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
4347 CallIC(ic, expr->CountStoreFeedbackId()); | 4349 CallIC(ic, expr->CountStoreFeedbackId()); |
4348 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4350 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4349 if (expr->is_postfix()) { | 4351 if (expr->is_postfix()) { |
4350 // Result is on the stack | 4352 // Result is on the stack |
4351 if (!context()->IsEffect()) { | 4353 if (!context()->IsEffect()) { |
4352 context()->PlugTOS(); | 4354 context()->PlugTOS(); |
4353 } | 4355 } |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4795 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4797 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4796 Assembler::target_address_at(call_target_address, | 4798 Assembler::target_address_at(call_target_address, |
4797 unoptimized_code)); | 4799 unoptimized_code)); |
4798 return OSR_AFTER_STACK_CHECK; | 4800 return OSR_AFTER_STACK_CHECK; |
4799 } | 4801 } |
4800 | 4802 |
4801 | 4803 |
4802 } } // namespace v8::internal | 4804 } } // namespace v8::internal |
4803 | 4805 |
4804 #endif // V8_TARGET_ARCH_X87 | 4806 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |