| 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 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1551 | 1551 |
| 1552 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1552 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
| 1553 Comment cmnt(masm_, "[ ObjectLiteral"); | 1553 Comment cmnt(masm_, "[ ObjectLiteral"); |
| 1554 Handle<FixedArray> constant_properties = expr->constant_properties(); | 1554 Handle<FixedArray> constant_properties = expr->constant_properties(); |
| 1555 int flags = expr->fast_elements() | 1555 int flags = expr->fast_elements() |
| 1556 ? ObjectLiteral::kFastElements | 1556 ? ObjectLiteral::kFastElements |
| 1557 : ObjectLiteral::kNoFlags; | 1557 : ObjectLiteral::kNoFlags; |
| 1558 flags |= expr->has_function() | 1558 flags |= expr->has_function() |
| 1559 ? ObjectLiteral::kHasFunction | 1559 ? ObjectLiteral::kHasFunction |
| 1560 : ObjectLiteral::kNoFlags; | 1560 : ObjectLiteral::kNoFlags; |
| 1561 |
| 1562 if (FLAG_track_allocation_sites && !IsOneTimeCode()) { |
| 1563 // Don't track global arrays that are never re-created |
| 1564 flags |= ObjectLiteral::kCreateAllocationSiteInfos; |
| 1565 } |
| 1566 |
| 1561 int properties_count = constant_properties->length() / 2; | 1567 int properties_count = constant_properties->length() / 2; |
| 1562 if (expr->depth() > 1) { | 1568 if (expr->depth() > 1) { |
| 1563 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1569 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1564 __ push(FieldOperand(rdi, JSFunction::kLiteralsOffset)); | 1570 __ push(FieldOperand(rdi, JSFunction::kLiteralsOffset)); |
| 1565 __ Push(Smi::FromInt(expr->literal_index())); | 1571 __ Push(Smi::FromInt(expr->literal_index())); |
| 1566 __ Push(constant_properties); | 1572 __ Push(constant_properties); |
| 1567 __ Push(Smi::FromInt(flags)); | 1573 __ Push(Smi::FromInt(flags)); |
| 1568 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); | 1574 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
| 1569 } else if (Serializer::enabled() || flags != ObjectLiteral::kFastElements || | 1575 } else if (Serializer::enabled() || flags != ObjectLiteral::kFastElements || |
| 1570 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { | 1576 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 int length = subexprs->length(); | 1694 int length = subexprs->length(); |
| 1689 Handle<FixedArray> constant_elements = expr->constant_elements(); | 1695 Handle<FixedArray> constant_elements = expr->constant_elements(); |
| 1690 ASSERT_EQ(2, constant_elements->length()); | 1696 ASSERT_EQ(2, constant_elements->length()); |
| 1691 ElementsKind constant_elements_kind = | 1697 ElementsKind constant_elements_kind = |
| 1692 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | 1698 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); |
| 1693 bool has_constant_fast_elements = | 1699 bool has_constant_fast_elements = |
| 1694 IsFastObjectElementsKind(constant_elements_kind); | 1700 IsFastObjectElementsKind(constant_elements_kind); |
| 1695 Handle<FixedArrayBase> constant_elements_values( | 1701 Handle<FixedArrayBase> constant_elements_values( |
| 1696 FixedArrayBase::cast(constant_elements->get(1))); | 1702 FixedArrayBase::cast(constant_elements->get(1))); |
| 1697 | 1703 |
| 1704 AllocationSiteMode allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
| 1705 int flags = ArrayLiteral::kNoFlags; |
| 1706 if (FLAG_track_allocation_sites && !IsOneTimeCode()) { |
| 1707 // Don't track global arrays that are never re-created |
| 1708 flags |= ArrayLiteral::kCreateAllocationSiteInfos; |
| 1709 allocation_site_mode = TRACK_ALLOCATION_SITE; |
| 1710 } |
| 1711 |
| 1712 ASSERT(((flags & ArrayLiteral::kCreateAllocationSiteInfos) && |
| 1713 (allocation_site_mode == TRACK_ALLOCATION_SITE)) || |
| 1714 (((flags & ArrayLiteral::kCreateAllocationSiteInfos) == 0) && |
| 1715 (allocation_site_mode == DONT_TRACK_ALLOCATION_SITE))); |
| 1716 |
| 1698 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1717 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1699 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); | 1718 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); |
| 1700 __ Push(Smi::FromInt(expr->literal_index())); | 1719 __ Push(Smi::FromInt(expr->literal_index())); |
| 1701 __ Push(constant_elements); | 1720 __ Push(constant_elements); |
| 1702 Heap* heap = isolate()->heap(); | 1721 Heap* heap = isolate()->heap(); |
| 1703 if (has_constant_fast_elements && | 1722 if (has_constant_fast_elements && |
| 1704 constant_elements_values->map() == heap->fixed_cow_array_map()) { | 1723 constant_elements_values->map() == heap->fixed_cow_array_map()) { |
| 1705 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | 1724 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot |
| 1706 // change, so it's possible to specialize the stub in advance. | 1725 // change, so it's possible to specialize the stub in advance. |
| 1707 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); | 1726 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); |
| 1708 FastCloneShallowArrayStub stub( | 1727 FastCloneShallowArrayStub stub( |
| 1709 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, | 1728 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, |
| 1710 DONT_TRACK_ALLOCATION_SITE, | 1729 DONT_TRACK_ALLOCATION_SITE, |
| 1711 length); | 1730 length); |
| 1712 __ CallStub(&stub); | 1731 __ CallStub(&stub); |
| 1713 } else if (expr->depth() > 1) { | 1732 } else if (expr->depth() > 1) { |
| 1714 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); | 1733 __ Push(Smi::FromInt(flags)); |
| 1734 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); |
| 1715 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { | 1735 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
| 1716 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); | 1736 __ Push(Smi::FromInt(flags)); |
| 1737 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 4); |
| 1717 } else { | 1738 } else { |
| 1718 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || | 1739 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || |
| 1719 FLAG_smi_only_arrays); | 1740 FLAG_smi_only_arrays); |
| 1720 FastCloneShallowArrayStub::Mode mode = | 1741 FastCloneShallowArrayStub::Mode mode = |
| 1721 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | 1742 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; |
| 1722 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites | |
| 1723 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; | |
| 1724 | 1743 |
| 1725 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | 1744 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot |
| 1726 // change, so it's possible to specialize the stub in advance. | 1745 // change, so it's possible to specialize the stub in advance. |
| 1727 if (has_constant_fast_elements) { | 1746 if (has_constant_fast_elements) { |
| 1728 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; | 1747 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; |
| 1729 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | 1748 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
| 1730 } | 1749 } |
| 1731 | 1750 |
| 1732 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); | 1751 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); |
| 1733 __ CallStub(&stub); | 1752 __ CallStub(&stub); |
| (...skipping 2839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4573 *context_length = 0; | 4592 *context_length = 0; |
| 4574 return previous_; | 4593 return previous_; |
| 4575 } | 4594 } |
| 4576 | 4595 |
| 4577 | 4596 |
| 4578 #undef __ | 4597 #undef __ |
| 4579 | 4598 |
| 4580 } } // namespace v8::internal | 4599 } } // namespace v8::internal |
| 4581 | 4600 |
| 4582 #endif // V8_TARGET_ARCH_X64 | 4601 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |