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_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
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 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 __ CallStub(&stub); | 1605 __ CallStub(&stub); |
1606 } | 1606 } |
1607 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1607 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); |
1608 | 1608 |
1609 // If result_saved is true the result is on top of the stack. If | 1609 // If result_saved is true the result is on top of the stack. If |
1610 // result_saved is false the result is in eax. | 1610 // result_saved is false the result is in eax. |
1611 bool result_saved = false; | 1611 bool result_saved = false; |
1612 | 1612 |
1613 AccessorTable accessor_table(zone()); | 1613 AccessorTable accessor_table(zone()); |
1614 int property_index = 0; | 1614 int property_index = 0; |
1615 // store_slot_index points to the vector ic slot for the next store ic used. | 1615 // store_slot_index points to the vector IC slot for the next store IC used. |
1616 // ObjectLiteral::ComputeFeedbackRequirements controls the allocation of slots | 1616 // ObjectLiteral::ComputeFeedbackRequirements controls the allocation of slots |
1617 // and must be updated if the number of store ics emitted here changes. | 1617 // and must be updated if the number of store ICs emitted here changes. |
1618 int store_slot_index = 0; | 1618 int store_slot_index = 0; |
1619 for (; property_index < expr->properties()->length(); property_index++) { | 1619 for (; property_index < expr->properties()->length(); property_index++) { |
1620 ObjectLiteral::Property* property = expr->properties()->at(property_index); | 1620 ObjectLiteral::Property* property = expr->properties()->at(property_index); |
1621 if (property->is_computed_name()) break; | 1621 if (property->is_computed_name()) break; |
1622 if (property->IsCompileTimeValue()) continue; | 1622 if (property->IsCompileTimeValue()) continue; |
1623 | 1623 |
1624 Literal* key = property->key()->AsLiteral(); | 1624 Literal* key = property->key()->AsLiteral(); |
1625 Expression* value = property->value(); | 1625 Expression* value = property->value(); |
1626 if (!result_saved) { | 1626 if (!result_saved) { |
1627 __ push(eax); // Save result on the stack | 1627 __ push(eax); // Save result on the stack |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2470 // Constructor is in eax. | 2470 // Constructor is in eax. |
2471 DCHECK(lit != NULL); | 2471 DCHECK(lit != NULL); |
2472 __ push(eax); | 2472 __ push(eax); |
2473 | 2473 |
2474 // No access check is needed here since the constructor is created by the | 2474 // No access check is needed here since the constructor is created by the |
2475 // class literal. | 2475 // class literal. |
2476 Register scratch = ebx; | 2476 Register scratch = ebx; |
2477 __ mov(scratch, FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset)); | 2477 __ mov(scratch, FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset)); |
2478 __ Push(scratch); | 2478 __ Push(scratch); |
2479 | 2479 |
| 2480 // store_slot_index points to the vector IC slot for the next store IC used. |
| 2481 // ClassLiteral::ComputeFeedbackRequirements controls the allocation of slots |
| 2482 // and must be updated if the number of store ICs emitted here changes. |
| 2483 int store_slot_index = 0; |
2480 for (int i = 0; i < lit->properties()->length(); i++) { | 2484 for (int i = 0; i < lit->properties()->length(); i++) { |
2481 ObjectLiteral::Property* property = lit->properties()->at(i); | 2485 ObjectLiteral::Property* property = lit->properties()->at(i); |
2482 Expression* value = property->value(); | 2486 Expression* value = property->value(); |
2483 | 2487 |
2484 if (property->is_static()) { | 2488 if (property->is_static()) { |
2485 __ push(Operand(esp, kPointerSize)); // constructor | 2489 __ push(Operand(esp, kPointerSize)); // constructor |
2486 } else { | 2490 } else { |
2487 __ push(Operand(esp, 0)); // prototype | 2491 __ push(Operand(esp, 0)); // prototype |
2488 } | 2492 } |
2489 EmitPropertyKey(property, lit->GetIdForProperty(i)); | 2493 EmitPropertyKey(property, lit->GetIdForProperty(i)); |
2490 | 2494 |
2491 // The static prototype property is read only. We handle the non computed | 2495 // The static prototype property is read only. We handle the non computed |
2492 // property name case in the parser. Since this is the only case where we | 2496 // property name case in the parser. Since this is the only case where we |
2493 // need to check for an own read only property we special case this so we do | 2497 // need to check for an own read only property we special case this so we do |
2494 // not need to do this for every property. | 2498 // not need to do this for every property. |
2495 if (property->is_static() && property->is_computed_name()) { | 2499 if (property->is_static() && property->is_computed_name()) { |
2496 __ CallRuntime(Runtime::kThrowIfStaticPrototype, 1); | 2500 __ CallRuntime(Runtime::kThrowIfStaticPrototype, 1); |
2497 __ push(eax); | 2501 __ push(eax); |
2498 } | 2502 } |
2499 | 2503 |
2500 VisitForStackValue(value); | 2504 VisitForStackValue(value); |
2501 EmitSetHomeObjectIfNeeded(value, 2); | 2505 EmitSetHomeObjectIfNeeded(value, 2, |
| 2506 lit->SlotForHomeObject(value, &store_slot_index)); |
2502 | 2507 |
2503 switch (property->kind()) { | 2508 switch (property->kind()) { |
2504 case ObjectLiteral::Property::CONSTANT: | 2509 case ObjectLiteral::Property::CONSTANT: |
2505 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 2510 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
2506 case ObjectLiteral::Property::PROTOTYPE: | 2511 case ObjectLiteral::Property::PROTOTYPE: |
2507 UNREACHABLE(); | 2512 UNREACHABLE(); |
2508 case ObjectLiteral::Property::COMPUTED: | 2513 case ObjectLiteral::Property::COMPUTED: |
2509 __ CallRuntime(Runtime::kDefineClassMethod, 3); | 2514 __ CallRuntime(Runtime::kDefineClassMethod, 3); |
2510 break; | 2515 break; |
2511 | 2516 |
2512 case ObjectLiteral::Property::GETTER: | 2517 case ObjectLiteral::Property::GETTER: |
2513 __ push(Immediate(Smi::FromInt(DONT_ENUM))); | 2518 __ push(Immediate(Smi::FromInt(DONT_ENUM))); |
2514 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 4); | 2519 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 4); |
2515 break; | 2520 break; |
2516 | 2521 |
2517 case ObjectLiteral::Property::SETTER: | 2522 case ObjectLiteral::Property::SETTER: |
2518 __ push(Immediate(Smi::FromInt(DONT_ENUM))); | 2523 __ push(Immediate(Smi::FromInt(DONT_ENUM))); |
2519 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 4); | 2524 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 4); |
2520 break; | 2525 break; |
2521 } | 2526 } |
2522 } | 2527 } |
2523 | 2528 |
2524 // prototype | 2529 // prototype |
2525 __ CallRuntime(Runtime::kToFastProperties, 1); | 2530 __ CallRuntime(Runtime::kToFastProperties, 1); |
2526 | 2531 |
2527 // constructor | 2532 // constructor |
2528 __ CallRuntime(Runtime::kToFastProperties, 1); | 2533 __ CallRuntime(Runtime::kToFastProperties, 1); |
| 2534 |
| 2535 // Verify that compilation exactly consumed the number of store ic slots that |
| 2536 // the ClassLiteral node had to offer. |
| 2537 DCHECK(!FLAG_vector_stores || store_slot_index == lit->slot_count()); |
2529 } | 2538 } |
2530 | 2539 |
2531 | 2540 |
2532 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { | 2541 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { |
2533 __ pop(edx); | 2542 __ pop(edx); |
2534 Handle<Code> code = CodeFactory::BinaryOpIC( | 2543 Handle<Code> code = CodeFactory::BinaryOpIC( |
2535 isolate(), op, language_mode()).code(); | 2544 isolate(), op, language_mode()).code(); |
2536 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 2545 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
2537 CallIC(code, expr->BinaryOperationFeedbackId()); | 2546 CallIC(code, expr->BinaryOperationFeedbackId()); |
2538 patch_site.EmitPatchInfo(); | 2547 patch_site.EmitPatchInfo(); |
(...skipping 2921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5460 Assembler::target_address_at(call_target_address, | 5469 Assembler::target_address_at(call_target_address, |
5461 unoptimized_code)); | 5470 unoptimized_code)); |
5462 return OSR_AFTER_STACK_CHECK; | 5471 return OSR_AFTER_STACK_CHECK; |
5463 } | 5472 } |
5464 | 5473 |
5465 | 5474 |
5466 } // namespace internal | 5475 } // namespace internal |
5467 } // namespace v8 | 5476 } // namespace v8 |
5468 | 5477 |
5469 #endif // V8_TARGET_ARCH_IA32 | 5478 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |