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 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1672 AllocationSiteMode mode, | 1672 AllocationSiteMode mode, |
1673 ElementsKind kind, | 1673 ElementsKind kind, |
1674 int length) { | 1674 int length) { |
1675 NoObservableSideEffectsScope no_effects(this); | 1675 NoObservableSideEffectsScope no_effects(this); |
1676 | 1676 |
1677 // All sizes here are multiples of kPointerSize. | 1677 // All sizes here are multiples of kPointerSize. |
1678 int size = JSArray::kSize; | 1678 int size = JSArray::kSize; |
1679 if (mode == TRACK_ALLOCATION_SITE) { | 1679 if (mode == TRACK_ALLOCATION_SITE) { |
1680 size += AllocationMemento::kSize; | 1680 size += AllocationMemento::kSize; |
1681 } | 1681 } |
1682 int elems_offset = size; | |
1683 InstanceType instance_type = IsFastDoubleElementsKind(kind) ? | |
1684 FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE; | |
1685 if (length > 0) { | |
1686 size += IsFastDoubleElementsKind(kind) | |
1687 ? FixedDoubleArray::SizeFor(length) | |
1688 : FixedArray::SizeFor(length); | |
1689 } | |
1690 | 1682 |
1691 // Allocate both the JS array and the elements array in one big | 1683 // Allocate both the JS array and the elements array in one big |
Michael Starzinger
2013/08/16 20:02:11
nit: Comment is outdated.
Hannes Payer (out of office)
2013/08/28 13:10:59
Done.
| |
1692 // allocation. This avoids multiple limit checks. | 1684 // allocation. This avoids multiple limit checks. |
1693 HValue* size_in_bytes = Add<HConstant>(size); | 1685 HValue* size_in_bytes = Add<HConstant>(size); |
1694 HInstruction* object = Add<HAllocate>(size_in_bytes, | 1686 HInstruction* object = Add<HAllocate>(size_in_bytes, |
1695 HType::JSObject(), | 1687 HType::JSObject(), |
1696 NOT_TENURED, | 1688 NOT_TENURED, |
1697 instance_type); | 1689 JS_OBJECT_TYPE); |
Michael Starzinger
2013/08/16 20:02:11
Nice, that would have been a disaster once we woul
| |
1698 | 1690 |
1699 // Copy the JS array part. | 1691 // Copy the JS array part. |
1700 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { | 1692 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { |
1701 if ((i != JSArray::kElementsOffset) || (length == 0)) { | 1693 if ((i != JSArray::kElementsOffset) || (length == 0)) { |
1702 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); | 1694 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); |
1703 Add<HStoreNamedField>(object, access, | 1695 Add<HStoreNamedField>(object, access, |
1704 Add<HLoadNamedField>(boilerplate, access)); | 1696 Add<HLoadNamedField>(boilerplate, access)); |
1705 } | 1697 } |
1706 } | 1698 } |
1707 | 1699 |
1708 // Create an allocation site info if requested. | 1700 // Create an allocation site info if requested. |
1709 if (mode == TRACK_ALLOCATION_SITE) { | 1701 if (mode == TRACK_ALLOCATION_SITE) { |
1710 BuildCreateAllocationMemento(object, JSArray::kSize, allocation_site); | 1702 BuildCreateAllocationMemento(object, JSArray::kSize, allocation_site); |
1711 } | 1703 } |
1712 | 1704 |
1713 if (length > 0) { | 1705 if (length > 0) { |
1714 // Get hold of the elements array of the boilerplate and setup the | 1706 // Get hold of the elements array of the boilerplate and setup the |
Michael Starzinger
2013/08/16 20:02:11
nit: Comment is outdated.
Hannes Payer (out of office)
2013/08/28 13:10:59
Done.
| |
1715 // elements pointer in the resulting object. | 1707 // elements pointer in the resulting object. |
1716 HValue* boilerplate_elements = AddLoadElements(boilerplate, NULL); | 1708 HValue* boilerplate_elements = AddLoadElements(boilerplate, NULL); |
1717 HValue* object_elements = Add<HInnerAllocatedObject>(object, elems_offset); | 1709 HValue* object_elements; |
1710 if (IsFastDoubleElementsKind(kind)) { | |
1711 HValue* elems_size = Add<HConstant>(FixedDoubleArray::SizeFor(length)); | |
1712 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), | |
1713 NOT_TENURED, FIXED_DOUBLE_ARRAY_TYPE); | |
1714 } else { | |
1715 HValue* elems_size = Add<HConstant>(FixedArray::SizeFor(length)); | |
1716 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), | |
1717 NOT_TENURED, FIXED_ARRAY_TYPE); | |
1718 } | |
1718 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 1719 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
1719 object_elements); | 1720 object_elements); |
1720 | 1721 |
1721 // Copy the elements array header. | 1722 // Copy the elements array header. |
1722 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { | 1723 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { |
1723 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i); | 1724 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i); |
1724 Add<HStoreNamedField>(object_elements, access, | 1725 Add<HStoreNamedField>(object_elements, access, |
1725 Add<HLoadNamedField>(boilerplate_elements, access)); | 1726 Add<HLoadNamedField>(boilerplate_elements, access)); |
1726 } | 1727 } |
1727 | 1728 |
(...skipping 8115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9843 if (ShouldProduceTraceOutput()) { | 9844 if (ShouldProduceTraceOutput()) { |
9844 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 9845 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
9845 } | 9846 } |
9846 | 9847 |
9847 #ifdef DEBUG | 9848 #ifdef DEBUG |
9848 graph_->Verify(false); // No full verify. | 9849 graph_->Verify(false); // No full verify. |
9849 #endif | 9850 #endif |
9850 } | 9851 } |
9851 | 9852 |
9852 } } // namespace v8::internal | 9853 } } // namespace v8::internal |
OLD | NEW |