| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1619 __ Push(x10); | 1619 __ Push(x10); |
| 1620 } else { | 1620 } else { |
| 1621 VisitForStackValue(expression); | 1621 VisitForStackValue(expression); |
| 1622 } | 1622 } |
| 1623 } | 1623 } |
| 1624 | 1624 |
| 1625 | 1625 |
| 1626 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1626 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
| 1627 Comment cmnt(masm_, "[ ObjectLiteral"); | 1627 Comment cmnt(masm_, "[ ObjectLiteral"); |
| 1628 | 1628 |
| 1629 int depth = 1; | 1629 expr->BuildConstantProperties(isolate()); |
| 1630 expr->BuildConstantProperties(isolate(), &depth); | |
| 1631 Handle<FixedArray> constant_properties = expr->constant_properties(); | 1630 Handle<FixedArray> constant_properties = expr->constant_properties(); |
| 1632 __ Ldr(x3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1631 __ Ldr(x3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1633 __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); | 1632 __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); |
| 1634 __ Mov(x2, Operand(Smi::FromInt(expr->literal_index()))); | 1633 __ Mov(x2, Operand(Smi::FromInt(expr->literal_index()))); |
| 1635 __ Mov(x1, Operand(constant_properties)); | 1634 __ Mov(x1, Operand(constant_properties)); |
| 1636 int flags = expr->fast_elements() | 1635 int flags = expr->fast_elements() |
| 1637 ? ObjectLiteral::kFastElements | 1636 ? ObjectLiteral::kFastElements |
| 1638 : ObjectLiteral::kNoFlags; | 1637 : ObjectLiteral::kNoFlags; |
| 1639 flags |= expr->has_function() | 1638 flags |= expr->has_function() |
| 1640 ? ObjectLiteral::kHasFunction | 1639 ? ObjectLiteral::kHasFunction |
| 1641 : ObjectLiteral::kNoFlags; | 1640 : ObjectLiteral::kNoFlags; |
| 1642 __ Mov(x0, Operand(Smi::FromInt(flags))); | 1641 __ Mov(x0, Operand(Smi::FromInt(flags))); |
| 1643 int properties_count = constant_properties->length() / 2; | 1642 int properties_count = constant_properties->length() / 2; |
| 1644 const int max_cloned_properties = | 1643 const int max_cloned_properties = |
| 1645 FastCloneShallowObjectStub::kMaximumClonedProperties; | 1644 FastCloneShallowObjectStub::kMaximumClonedProperties; |
| 1646 if ((FLAG_track_double_fields && expr->may_store_doubles()) || | 1645 if ((FLAG_track_double_fields && expr->may_store_doubles()) || |
| 1647 (depth > 1) || Serializer::enabled() || | 1646 (expr->depth() > 1) || Serializer::enabled() || |
| 1648 (flags != ObjectLiteral::kFastElements) || | 1647 (flags != ObjectLiteral::kFastElements) || |
| 1649 (properties_count > max_cloned_properties)) { | 1648 (properties_count > max_cloned_properties)) { |
| 1650 __ Push(x3, x2, x1, x0); | 1649 __ Push(x3, x2, x1, x0); |
| 1651 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); | 1650 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
| 1652 } else { | 1651 } else { |
| 1653 FastCloneShallowObjectStub stub(properties_count); | 1652 FastCloneShallowObjectStub stub(properties_count); |
| 1654 __ CallStub(&stub); | 1653 __ CallStub(&stub); |
| 1655 } | 1654 } |
| 1656 | 1655 |
| 1657 // If result_saved is true the result is on top of the stack. If | 1656 // If result_saved is true the result is on top of the stack. If |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1757 context()->PlugTOS(); | 1756 context()->PlugTOS(); |
| 1758 } else { | 1757 } else { |
| 1759 context()->Plug(x0); | 1758 context()->Plug(x0); |
| 1760 } | 1759 } |
| 1761 } | 1760 } |
| 1762 | 1761 |
| 1763 | 1762 |
| 1764 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { | 1763 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
| 1765 Comment cmnt(masm_, "[ ArrayLiteral"); | 1764 Comment cmnt(masm_, "[ ArrayLiteral"); |
| 1766 | 1765 |
| 1767 int depth = 1; | 1766 expr->BuildConstantElements(isolate()); |
| 1768 expr->BuildConstantElements(isolate(), &depth); | 1767 int flags = (expr->depth() == 1) ? ArrayLiteral::kShallowElements |
| 1768 : ArrayLiteral::kNoFlags; |
| 1769 |
| 1769 ZoneList<Expression*>* subexprs = expr->values(); | 1770 ZoneList<Expression*>* subexprs = expr->values(); |
| 1770 int length = subexprs->length(); | 1771 int length = subexprs->length(); |
| 1771 Handle<FixedArray> constant_elements = expr->constant_elements(); | 1772 Handle<FixedArray> constant_elements = expr->constant_elements(); |
| 1772 ASSERT_EQ(2, constant_elements->length()); | 1773 ASSERT_EQ(2, constant_elements->length()); |
| 1773 ElementsKind constant_elements_kind = | 1774 ElementsKind constant_elements_kind = |
| 1774 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | 1775 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); |
| 1775 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind); | 1776 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind); |
| 1776 Handle<FixedArrayBase> constant_elements_values( | 1777 Handle<FixedArrayBase> constant_elements_values( |
| 1777 FixedArrayBase::cast(constant_elements->get(1))); | 1778 FixedArrayBase::cast(constant_elements->get(1))); |
| 1778 | 1779 |
| 1779 __ Ldr(x3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1780 __ Ldr(x3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1780 __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); | 1781 __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); |
| 1781 // TODO(jbramley): Can these Operand constructors be implicit? | 1782 // TODO(jbramley): Can these Operand constructors be implicit? |
| 1782 __ Mov(x2, Operand(Smi::FromInt(expr->literal_index()))); | 1783 __ Mov(x2, Operand(Smi::FromInt(expr->literal_index()))); |
| 1783 __ Mov(x1, Operand(constant_elements)); | 1784 __ Mov(x1, Operand(constant_elements)); |
| 1784 if (has_fast_elements && constant_elements_values->map() == | 1785 if (has_fast_elements && constant_elements_values->map() == |
| 1785 isolate()->heap()->fixed_cow_array_map()) { | 1786 isolate()->heap()->fixed_cow_array_map()) { |
| 1786 FastCloneShallowArrayStub stub( | 1787 FastCloneShallowArrayStub stub( |
| 1787 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, | 1788 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, |
| 1788 DONT_TRACK_ALLOCATION_SITE, | 1789 DONT_TRACK_ALLOCATION_SITE, |
| 1789 length); | 1790 length); |
| 1790 __ CallStub(&stub); | 1791 __ CallStub(&stub); |
| 1791 __ IncrementCounter( | 1792 __ IncrementCounter( |
| 1792 isolate()->counters()->cow_arrays_created_stub(), 1, x10, x11); | 1793 isolate()->counters()->cow_arrays_created_stub(), 1, x10, x11); |
| 1793 } else if ((depth > 1) || Serializer::enabled() || | 1794 } else if ((expr->depth() > 1) || Serializer::enabled() || |
| 1794 length > FastCloneShallowArrayStub::kMaximumClonedLength) { | 1795 length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
| 1795 __ Push(x3, x2, x1); | 1796 __ Mov(x0, Operand(Smi::FromInt(flags))); |
| 1796 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); | 1797 __ Push(x3, x2, x1, x0); |
| 1798 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); |
| 1797 } else { | 1799 } else { |
| 1798 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || | 1800 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || |
| 1799 FLAG_smi_only_arrays); | 1801 FLAG_smi_only_arrays); |
| 1800 FastCloneShallowArrayStub::Mode mode = | 1802 FastCloneShallowArrayStub::Mode mode = |
| 1801 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | 1803 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; |
| 1802 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites | 1804 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites |
| 1803 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; | 1805 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; |
| 1804 | 1806 |
| 1805 if (has_fast_elements) { | 1807 if (has_fast_elements) { |
| 1806 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; | 1808 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; |
| (...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3104 VisitForStackValue(args->at(2)); | 3106 VisitForStackValue(args->at(2)); |
| 3105 __ CallRuntime(Runtime::kLog, 2); | 3107 __ CallRuntime(Runtime::kLog, 2); |
| 3106 } | 3108 } |
| 3107 | 3109 |
| 3108 // Finally, we're expected to leave a value on the top of the stack. | 3110 // Finally, we're expected to leave a value on the top of the stack. |
| 3109 __ LoadRoot(x0, Heap::kUndefinedValueRootIndex); | 3111 __ LoadRoot(x0, Heap::kUndefinedValueRootIndex); |
| 3110 context()->Plug(x0); | 3112 context()->Plug(x0); |
| 3111 } | 3113 } |
| 3112 | 3114 |
| 3113 | 3115 |
| 3114 void FullCodeGenerator::EmitRandomHeapNumber(CallRuntime* expr) { | |
| 3115 ASSERT(expr->arguments()->length() == 0); | |
| 3116 Label slow_allocate_heapnumber; | |
| 3117 Label heapnumber_allocated; | |
| 3118 Register heap_num = x19; // Callee-saved register. | |
| 3119 | |
| 3120 __ LoadRoot(x5, Heap::kHeapNumberMapRootIndex); | |
| 3121 __ AllocateHeapNumber(heap_num, &slow_allocate_heapnumber, x10, x11, x5); | |
| 3122 __ B(&heapnumber_allocated); | |
| 3123 | |
| 3124 __ Bind(&slow_allocate_heapnumber); | |
| 3125 // Call the runtime to allocate the heap number. | |
| 3126 __ CallRuntime(Runtime::kNumberAlloc, 0); | |
| 3127 __ Mov(heap_num, x0); | |
| 3128 | |
| 3129 __ Bind(&heapnumber_allocated); | |
| 3130 | |
| 3131 // Get 32 random bits. | |
| 3132 __ Ldr(x0, | |
| 3133 ContextMemOperand(context_register(), Context::GLOBAL_OBJECT_INDEX)); | |
| 3134 __ Ldr(x0, FieldMemOperand(x0, GlobalObject::kNativeContextOffset)); | |
| 3135 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); | |
| 3136 | |
| 3137 // Interpret the 32 random bits as a 0.32 fixed point number, and convert to | |
| 3138 // a double in the range 0.0 <= number < 1.0. | |
| 3139 __ Ucvtf(d0, x0, 32); | |
| 3140 __ Str(d0, FieldMemOperand(heap_num, HeapNumber::kValueOffset)); | |
| 3141 __ Mov(x0, heap_num); | |
| 3142 | |
| 3143 context()->Plug(x0); | |
| 3144 } | |
| 3145 | |
| 3146 | |
| 3147 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { | 3116 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { |
| 3148 // Load the arguments on the stack and call the stub. | 3117 // Load the arguments on the stack and call the stub. |
| 3149 SubStringStub stub; | 3118 SubStringStub stub; |
| 3150 ZoneList<Expression*>* args = expr->arguments(); | 3119 ZoneList<Expression*>* args = expr->arguments(); |
| 3151 ASSERT(args->length() == 3); | 3120 ASSERT(args->length() == 3); |
| 3152 VisitForStackValue(args->at(0)); | 3121 VisitForStackValue(args->at(0)); |
| 3153 VisitForStackValue(args->at(1)); | 3122 VisitForStackValue(args->at(1)); |
| 3154 VisitForStackValue(args->at(2)); | 3123 VisitForStackValue(args->at(2)); |
| 3155 __ CallStub(&stub); | 3124 __ CallStub(&stub); |
| 3156 context()->Plug(x0); | 3125 context()->Plug(x0); |
| (...skipping 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5057 return previous_; | 5026 return previous_; |
| 5058 } | 5027 } |
| 5059 | 5028 |
| 5060 | 5029 |
| 5061 #undef __ | 5030 #undef __ |
| 5062 | 5031 |
| 5063 | 5032 |
| 5064 } } // namespace v8::internal | 5033 } } // namespace v8::internal |
| 5065 | 5034 |
| 5066 #endif // V8_TARGET_ARCH_A64 | 5035 #endif // V8_TARGET_ARCH_A64 |
| OLD | NEW |