OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 __ LoadRoot(a1, Heap::kNullValueRootIndex); | 1637 __ LoadRoot(a1, Heap::kNullValueRootIndex); |
1638 __ push(a1); | 1638 __ push(a1); |
1639 } else { | 1639 } else { |
1640 VisitForStackValue(expression); | 1640 VisitForStackValue(expression); |
1641 } | 1641 } |
1642 } | 1642 } |
1643 | 1643 |
1644 | 1644 |
1645 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1645 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
1646 Comment cmnt(masm_, "[ ObjectLiteral"); | 1646 Comment cmnt(masm_, "[ ObjectLiteral"); |
| 1647 |
| 1648 int depth = 1; |
| 1649 expr->BuildConstantProperties(isolate(), &depth); |
1647 Handle<FixedArray> constant_properties = expr->constant_properties(); | 1650 Handle<FixedArray> constant_properties = expr->constant_properties(); |
1648 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1651 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1649 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); | 1652 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); |
1650 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); | 1653 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); |
1651 __ li(a1, Operand(constant_properties)); | 1654 __ li(a1, Operand(constant_properties)); |
1652 int flags = expr->fast_elements() | 1655 int flags = expr->fast_elements() |
1653 ? ObjectLiteral::kFastElements | 1656 ? ObjectLiteral::kFastElements |
1654 : ObjectLiteral::kNoFlags; | 1657 : ObjectLiteral::kNoFlags; |
1655 flags |= expr->has_function() | 1658 flags |= expr->has_function() |
1656 ? ObjectLiteral::kHasFunction | 1659 ? ObjectLiteral::kHasFunction |
1657 : ObjectLiteral::kNoFlags; | 1660 : ObjectLiteral::kNoFlags; |
1658 __ li(a0, Operand(Smi::FromInt(flags))); | 1661 __ li(a0, Operand(Smi::FromInt(flags))); |
1659 int properties_count = constant_properties->length() / 2; | 1662 int properties_count = constant_properties->length() / 2; |
1660 if ((FLAG_track_double_fields && expr->may_store_doubles()) || | 1663 if ((FLAG_track_double_fields && expr->may_store_doubles()) || |
1661 expr->depth() > 1 || Serializer::enabled() || | 1664 depth > 1 || Serializer::enabled() || |
1662 flags != ObjectLiteral::kFastElements || | 1665 flags != ObjectLiteral::kFastElements || |
1663 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { | 1666 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { |
1664 __ Push(a3, a2, a1, a0); | 1667 __ Push(a3, a2, a1, a0); |
1665 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); | 1668 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
1666 } else { | 1669 } else { |
1667 FastCloneShallowObjectStub stub(properties_count); | 1670 FastCloneShallowObjectStub stub(properties_count); |
1668 __ CallStub(&stub); | 1671 __ CallStub(&stub); |
1669 } | 1672 } |
1670 | 1673 |
1671 // If result_saved is true the result is on top of the stack. If | 1674 // If result_saved is true the result is on top of the stack. If |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 context()->PlugTOS(); | 1773 context()->PlugTOS(); |
1771 } else { | 1774 } else { |
1772 context()->Plug(v0); | 1775 context()->Plug(v0); |
1773 } | 1776 } |
1774 } | 1777 } |
1775 | 1778 |
1776 | 1779 |
1777 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { | 1780 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
1778 Comment cmnt(masm_, "[ ArrayLiteral"); | 1781 Comment cmnt(masm_, "[ ArrayLiteral"); |
1779 | 1782 |
| 1783 int depth = 1; |
| 1784 expr->BuildConstantElements(isolate(), &depth); |
1780 ZoneList<Expression*>* subexprs = expr->values(); | 1785 ZoneList<Expression*>* subexprs = expr->values(); |
1781 int length = subexprs->length(); | 1786 int length = subexprs->length(); |
1782 | 1787 |
1783 Handle<FixedArray> constant_elements = expr->constant_elements(); | 1788 Handle<FixedArray> constant_elements = expr->constant_elements(); |
1784 ASSERT_EQ(2, constant_elements->length()); | 1789 ASSERT_EQ(2, constant_elements->length()); |
1785 ElementsKind constant_elements_kind = | 1790 ElementsKind constant_elements_kind = |
1786 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | 1791 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); |
1787 bool has_fast_elements = | 1792 bool has_fast_elements = |
1788 IsFastObjectElementsKind(constant_elements_kind); | 1793 IsFastObjectElementsKind(constant_elements_kind); |
1789 Handle<FixedArrayBase> constant_elements_values( | 1794 Handle<FixedArrayBase> constant_elements_values( |
1790 FixedArrayBase::cast(constant_elements->get(1))); | 1795 FixedArrayBase::cast(constant_elements->get(1))); |
1791 | 1796 |
1792 __ mov(a0, result_register()); | 1797 __ mov(a0, result_register()); |
1793 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1798 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1794 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); | 1799 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); |
1795 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); | 1800 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); |
1796 __ li(a1, Operand(constant_elements)); | 1801 __ li(a1, Operand(constant_elements)); |
1797 if (has_fast_elements && constant_elements_values->map() == | 1802 if (has_fast_elements && constant_elements_values->map() == |
1798 isolate()->heap()->fixed_cow_array_map()) { | 1803 isolate()->heap()->fixed_cow_array_map()) { |
1799 FastCloneShallowArrayStub stub( | 1804 FastCloneShallowArrayStub stub( |
1800 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, | 1805 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, |
1801 DONT_TRACK_ALLOCATION_SITE, | 1806 DONT_TRACK_ALLOCATION_SITE, |
1802 length); | 1807 length); |
1803 __ CallStub(&stub); | 1808 __ CallStub(&stub); |
1804 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), | 1809 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), |
1805 1, a1, a2); | 1810 1, a1, a2); |
1806 } else if (expr->depth() > 1 || | 1811 } else if (depth > 1 || Serializer::enabled() || |
1807 Serializer::enabled() || | |
1808 length > FastCloneShallowArrayStub::kMaximumClonedLength) { | 1812 length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
1809 __ Push(a3, a2, a1); | 1813 __ Push(a3, a2, a1); |
1810 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); | 1814 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); |
1811 } else { | 1815 } else { |
1812 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || | 1816 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || |
1813 FLAG_smi_only_arrays); | 1817 FLAG_smi_only_arrays); |
1814 FastCloneShallowArrayStub::Mode mode = | 1818 FastCloneShallowArrayStub::Mode mode = |
1815 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | 1819 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; |
1816 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites | 1820 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites |
1817 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; | 1821 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; |
(...skipping 3176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4994 Assembler::target_address_at(pc_immediate_load_address)) == | 4998 Assembler::target_address_at(pc_immediate_load_address)) == |
4995 reinterpret_cast<uint32_t>( | 4999 reinterpret_cast<uint32_t>( |
4996 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5000 isolate->builtins()->OsrAfterStackCheck()->entry())); |
4997 return OSR_AFTER_STACK_CHECK; | 5001 return OSR_AFTER_STACK_CHECK; |
4998 } | 5002 } |
4999 | 5003 |
5000 | 5004 |
5001 } } // namespace v8::internal | 5005 } } // namespace v8::internal |
5002 | 5006 |
5003 #endif // V8_TARGET_ARCH_MIPS | 5007 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |