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-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1593 expr->BuildConstantProperties(isolate()); | 1593 expr->BuildConstantProperties(isolate()); |
1594 Handle<FixedArray> constant_properties = expr->constant_properties(); | 1594 Handle<FixedArray> constant_properties = expr->constant_properties(); |
1595 int flags = expr->fast_elements() | 1595 int flags = expr->fast_elements() |
1596 ? ObjectLiteral::kFastElements | 1596 ? ObjectLiteral::kFastElements |
1597 : ObjectLiteral::kNoFlags; | 1597 : ObjectLiteral::kNoFlags; |
1598 flags |= expr->has_function() | 1598 flags |= expr->has_function() |
1599 ? ObjectLiteral::kHasFunction | 1599 ? ObjectLiteral::kHasFunction |
1600 : ObjectLiteral::kNoFlags; | 1600 : ObjectLiteral::kNoFlags; |
1601 int properties_count = constant_properties->length() / 2; | 1601 int properties_count = constant_properties->length() / 2; |
1602 if (expr->may_store_doubles() || expr->depth() > 1 || | 1602 if (expr->may_store_doubles() || expr->depth() > 1 || |
1603 masm()->serializer_enabled() || | 1603 masm()->serializer_enabled() || flags != ObjectLiteral::kFastElements || |
1604 flags != ObjectLiteral::kFastElements || | |
1605 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { | 1604 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { |
1606 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1605 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1607 __ push(FieldOperand(edi, JSFunction::kLiteralsOffset)); | 1606 __ push(FieldOperand(edi, JSFunction::kLiteralsOffset)); |
1608 __ push(Immediate(Smi::FromInt(expr->literal_index()))); | 1607 __ push(Immediate(Smi::FromInt(expr->literal_index()))); |
1609 __ push(Immediate(constant_properties)); | 1608 __ push(Immediate(constant_properties)); |
1610 __ push(Immediate(Smi::FromInt(flags))); | 1609 __ push(Immediate(Smi::FromInt(flags))); |
1611 __ CallRuntime(Runtime::kHiddenCreateObjectLiteral, 4); | 1610 __ CallRuntime(Runtime::kHiddenCreateObjectLiteral, 4); |
1612 } else { | 1611 } else { |
1613 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1612 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1614 __ mov(eax, FieldOperand(edi, JSFunction::kLiteralsOffset)); | 1613 __ mov(eax, FieldOperand(edi, JSFunction::kLiteralsOffset)); |
1615 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); | 1614 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); |
1616 __ mov(ecx, Immediate(constant_properties)); | 1615 __ mov(ecx, Immediate(constant_properties)); |
1617 __ mov(edx, Immediate(Smi::FromInt(flags))); | 1616 __ mov(edx, Immediate(Smi::FromInt(flags))); |
1618 FastCloneShallowObjectStub stub(isolate(), properties_count); | 1617 FastCloneShallowObjectStub stub(isolate(), properties_count); |
1619 __ CallStub(&stub); | 1618 __ CallStub(&stub); |
1620 } | 1619 } |
1621 | 1620 |
1622 // If result_saved is true the result is on top of the stack. If | 1621 // If result_saved is true the result is on top of the stack. If |
1623 // result_saved is false the result is in eax. | 1622 // result_saved is false the result is in eax. |
1624 bool result_saved = false; | 1623 bool result_saved = false; |
1625 | 1624 |
1626 // Mark all computed expressions that are bound to a key that | 1625 // Mark all computed expressions that are bound to a key that |
1627 // is shadowed by a later occurrence of the same key. For the | 1626 // is shadowed by a later occurrence of the same key. For the |
1628 // marked expressions, no store code is emitted. | 1627 // marked expressions, no store code is emitted. |
1629 expr->CalculateEmitStore(zone()); | 1628 expr->CalculateEmitStore(zone()); |
1630 | 1629 |
1631 AccessorTable accessor_table(zone()); | 1630 AccessorTable accessor_table(zone()); |
| 1631 bool has_seen_computed_name = false; |
1632 for (int i = 0; i < expr->properties()->length(); i++) { | 1632 for (int i = 0; i < expr->properties()->length(); i++) { |
1633 ObjectLiteral::Property* property = expr->properties()->at(i); | 1633 ObjectLiteral::Property* property = expr->properties()->at(i); |
1634 if (property->IsCompileTimeValue()) continue; | |
1635 | 1634 |
1636 Literal* key = property->key(); | 1635 if (!has_seen_computed_name && property->IsCompileTimeValue()) { |
| 1636 continue; |
| 1637 } |
| 1638 if (property->kind() == ObjectLiteral::Property::COMPUTED_NAME) { |
| 1639 has_seen_computed_name = true; |
| 1640 } |
| 1641 |
| 1642 Literal* literal_key = property->key()->AsLiteral(); |
1637 Expression* value = property->value(); | 1643 Expression* value = property->value(); |
1638 if (!result_saved) { | 1644 if (!result_saved) { |
1639 __ push(eax); // Save result on the stack | 1645 __ push(eax); // Save result on the stack |
1640 result_saved = true; | 1646 result_saved = true; |
1641 } | 1647 } |
1642 switch (property->kind()) { | 1648 switch (property->kind()) { |
1643 case ObjectLiteral::Property::CONSTANT: | 1649 case ObjectLiteral::Property::CONSTANT: |
1644 UNREACHABLE(); | 1650 ASSERT(has_seen_computed_name); |
| 1651 // Fall through. |
1645 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1652 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
1646 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); | 1653 ASSERT(has_seen_computed_name || |
| 1654 !CompileTimeValue::IsCompileTimeValue(value)); |
1647 // Fall through. | 1655 // Fall through. |
1648 case ObjectLiteral::Property::COMPUTED: | 1656 case ObjectLiteral::Property::COMPUTED: |
1649 if (key->value()->IsInternalizedString()) { | 1657 if (literal_key->value()->IsInternalizedString()) { |
1650 if (property->emit_store()) { | 1658 if (property->emit_store()) { |
1651 VisitForAccumulatorValue(value); | 1659 VisitForAccumulatorValue(value); |
1652 __ mov(ecx, Immediate(key->value())); | 1660 __ mov(ecx, Immediate(literal_key->value())); |
1653 __ mov(edx, Operand(esp, 0)); | 1661 __ mov(edx, Operand(esp, 0)); |
1654 CallStoreIC(key->LiteralFeedbackId()); | 1662 CallStoreIC(literal_key->LiteralFeedbackId()); |
1655 PrepareForBailoutForId(key->id(), NO_REGISTERS); | 1663 PrepareForBailoutForId(literal_key->id(), NO_REGISTERS); |
1656 } else { | 1664 } else { |
1657 VisitForEffect(value); | 1665 VisitForEffect(value); |
1658 } | 1666 } |
1659 break; | 1667 break; |
1660 } | 1668 } |
| 1669 // Fall through. |
| 1670 case ObjectLiteral::Property::COMPUTED_NAME: |
1661 __ push(Operand(esp, 0)); // Duplicate receiver. | 1671 __ push(Operand(esp, 0)); // Duplicate receiver. |
1662 VisitForStackValue(key); | 1672 VisitForStackValue(property->key()); |
1663 VisitForStackValue(value); | 1673 VisitForStackValue(value); |
1664 if (property->emit_store()) { | 1674 if (property->emit_store()) { |
1665 __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes | 1675 __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes |
1666 __ CallRuntime(Runtime::kSetProperty, 4); | 1676 __ CallRuntime(Runtime::kSetProperty, 4); |
1667 } else { | 1677 } else { |
1668 __ Drop(3); | 1678 __ Drop(3); |
1669 } | 1679 } |
1670 break; | 1680 break; |
1671 case ObjectLiteral::Property::PROTOTYPE: | 1681 case ObjectLiteral::Property::PROTOTYPE: |
1672 __ push(Operand(esp, 0)); // Duplicate receiver. | 1682 __ push(Operand(esp, 0)); // Duplicate receiver. |
1673 VisitForStackValue(value); | 1683 VisitForStackValue(value); |
1674 if (property->emit_store()) { | 1684 if (property->emit_store()) { |
1675 __ CallRuntime(Runtime::kSetPrototype, 2); | 1685 __ CallRuntime(Runtime::kSetPrototype, 2); |
1676 } else { | 1686 } else { |
1677 __ Drop(2); | 1687 __ Drop(2); |
1678 } | 1688 } |
1679 break; | 1689 break; |
1680 case ObjectLiteral::Property::GETTER: | 1690 case ObjectLiteral::Property::GETTER: |
1681 accessor_table.lookup(key)->second->getter = value; | 1691 accessor_table.lookup(literal_key)->second->getter = value; |
1682 break; | 1692 break; |
1683 case ObjectLiteral::Property::SETTER: | 1693 case ObjectLiteral::Property::SETTER: |
1684 accessor_table.lookup(key)->second->setter = value; | 1694 accessor_table.lookup(literal_key)->second->setter = value; |
1685 break; | 1695 break; |
1686 } | 1696 } |
1687 } | 1697 } |
1688 | 1698 |
1689 // Emit code to define accessors, using only a single call to the runtime for | 1699 // Emit code to define accessors, using only a single call to the runtime for |
1690 // each pair of corresponding getters and setters. | 1700 // each pair of corresponding getters and setters. |
1691 for (AccessorTable::Iterator it = accessor_table.begin(); | 1701 for (AccessorTable::Iterator it = accessor_table.begin(); |
1692 it != accessor_table.end(); | 1702 it != accessor_table.end(); |
1693 ++it) { | 1703 ++it) { |
1694 __ push(Operand(esp, 0)); // Duplicate receiver. | 1704 __ push(Operand(esp, 0)); // Duplicate receiver. |
(...skipping 3108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4803 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4813 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4804 Assembler::target_address_at(call_target_address, | 4814 Assembler::target_address_at(call_target_address, |
4805 unoptimized_code)); | 4815 unoptimized_code)); |
4806 return OSR_AFTER_STACK_CHECK; | 4816 return OSR_AFTER_STACK_CHECK; |
4807 } | 4817 } |
4808 | 4818 |
4809 | 4819 |
4810 } } // namespace v8::internal | 4820 } } // namespace v8::internal |
4811 | 4821 |
4812 #endif // V8_TARGET_ARCH_IA32 | 4822 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |