Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: src/hydrogen.cc

Issue 23038003: Eliminated manual allocation folding in BuildCloneShallowArray. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 AllocationSiteMode mode, 1701 AllocationSiteMode mode,
1702 ElementsKind kind, 1702 ElementsKind kind,
1703 int length) { 1703 int length) {
1704 NoObservableSideEffectsScope no_effects(this); 1704 NoObservableSideEffectsScope no_effects(this);
1705 1705
1706 // All sizes here are multiples of kPointerSize. 1706 // All sizes here are multiples of kPointerSize.
1707 int size = JSArray::kSize; 1707 int size = JSArray::kSize;
1708 if (mode == TRACK_ALLOCATION_SITE) { 1708 if (mode == TRACK_ALLOCATION_SITE) {
1709 size += AllocationMemento::kSize; 1709 size += AllocationMemento::kSize;
1710 } 1710 }
1711 int elems_offset = size;
1712 InstanceType instance_type = IsFastDoubleElementsKind(kind) ?
1713 FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE;
1714 if (length > 0) {
1715 size += IsFastDoubleElementsKind(kind)
1716 ? FixedDoubleArray::SizeFor(length)
1717 : FixedArray::SizeFor(length);
1718 }
1719 1711
1720 // Allocate both the JS array and the elements array in one big
1721 // allocation. This avoids multiple limit checks.
1722 HValue* size_in_bytes = Add<HConstant>(size); 1712 HValue* size_in_bytes = Add<HConstant>(size);
1723 HInstruction* object = Add<HAllocate>(size_in_bytes, 1713 HInstruction* object = Add<HAllocate>(size_in_bytes,
1724 HType::JSObject(), 1714 HType::JSObject(),
1725 NOT_TENURED, 1715 NOT_TENURED,
1726 instance_type); 1716 JS_OBJECT_TYPE);
1727 1717
1728 // Copy the JS array part. 1718 // Copy the JS array part.
1729 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { 1719 for (int i = 0; i < JSArray::kSize; i += kPointerSize) {
1730 if ((i != JSArray::kElementsOffset) || (length == 0)) { 1720 if ((i != JSArray::kElementsOffset) || (length == 0)) {
1731 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); 1721 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i);
1732 Add<HStoreNamedField>(object, access, 1722 Add<HStoreNamedField>(object, access,
1733 Add<HLoadNamedField>(boilerplate, access)); 1723 Add<HLoadNamedField>(boilerplate, access));
1734 } 1724 }
1735 } 1725 }
1736 1726
1737 // Create an allocation site info if requested. 1727 // Create an allocation site info if requested.
1738 if (mode == TRACK_ALLOCATION_SITE) { 1728 if (mode == TRACK_ALLOCATION_SITE) {
1739 BuildCreateAllocationMemento(object, JSArray::kSize, allocation_site); 1729 BuildCreateAllocationMemento(object, JSArray::kSize, allocation_site);
1740 } 1730 }
1741 1731
1742 if (length > 0) { 1732 if (length > 0) {
1743 // Get hold of the elements array of the boilerplate and setup the
1744 // elements pointer in the resulting object.
1745 HValue* boilerplate_elements = AddLoadElements(boilerplate); 1733 HValue* boilerplate_elements = AddLoadElements(boilerplate);
1746 HValue* object_elements = Add<HInnerAllocatedObject>(object, elems_offset); 1734 HValue* object_elements;
1735 if (IsFastDoubleElementsKind(kind)) {
1736 HValue* elems_size = Add<HConstant>(FixedDoubleArray::SizeFor(length));
1737 object_elements = Add<HAllocate>(elems_size, HType::JSArray(),
1738 NOT_TENURED, FIXED_DOUBLE_ARRAY_TYPE);
1739 } else {
1740 HValue* elems_size = Add<HConstant>(FixedArray::SizeFor(length));
1741 object_elements = Add<HAllocate>(elems_size, HType::JSArray(),
1742 NOT_TENURED, FIXED_ARRAY_TYPE);
1743 }
1747 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), 1744 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
1748 object_elements); 1745 object_elements);
1749 1746
1750 // Copy the elements array header. 1747 // Copy the elements array header.
1751 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { 1748 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) {
1752 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i); 1749 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i);
1753 Add<HStoreNamedField>(object_elements, access, 1750 Add<HStoreNamedField>(object_elements, access,
1754 Add<HLoadNamedField>(boilerplate_elements, access)); 1751 Add<HLoadNamedField>(boilerplate_elements, access));
1755 } 1752 }
1756 1753
(...skipping 8131 matching lines...) Expand 10 before | Expand all | Expand 10 after
9888 if (ShouldProduceTraceOutput()) { 9885 if (ShouldProduceTraceOutput()) {
9889 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9886 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9890 } 9887 }
9891 9888
9892 #ifdef DEBUG 9889 #ifdef DEBUG
9893 graph_->Verify(false); // No full verify. 9890 graph_->Verify(false); // No full verify.
9894 #endif 9891 #endif
9895 } 9892 }
9896 9893
9897 } } // namespace v8::internal 9894 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698