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

Side by Side Diff: src/objects-inl.h

Issue 9663002: Use CopyElements for SetFastDoubleElementsCapacityAndLength (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 8 years, 9 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 | « src/objects.cc ('k') | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); 1727 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
1728 } 1728 }
1729 1729
1730 1730
1731 bool FixedDoubleArray::is_the_hole(int index) { 1731 bool FixedDoubleArray::is_the_hole(int index) {
1732 int offset = kHeaderSize + index * kDoubleSize; 1732 int offset = kHeaderSize + index * kDoubleSize;
1733 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); 1733 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset));
1734 } 1734 }
1735 1735
1736 1736
1737 void FixedDoubleArray::Initialize(FixedDoubleArray* from) {
1738 int old_length = from->length();
1739 ASSERT(old_length < length());
1740 if (old_length * kDoubleSize >= OS::kMinComplexMemCopy) {
1741 OS::MemCopy(FIELD_ADDR(this, kHeaderSize),
1742 FIELD_ADDR(from, kHeaderSize),
1743 old_length * kDoubleSize);
1744 } else {
1745 for (int i = 0; i < old_length; ++i) {
1746 if (from->is_the_hole(i)) {
1747 set_the_hole(i);
1748 } else {
1749 set(i, from->get_scalar(i));
1750 }
1751 }
1752 }
1753 int offset = kHeaderSize + old_length * kDoubleSize;
1754 for (int current = from->length(); current < length(); ++current) {
1755 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
1756 offset += kDoubleSize;
1757 }
1758 }
1759
1760
1761 void FixedDoubleArray::Initialize(FixedArray* from) {
1762 int old_length = from->length();
1763 ASSERT(old_length <= length());
1764 for (int i = 0; i < old_length; i++) {
1765 Object* hole_or_object = from->get(i);
1766 if (hole_or_object->IsTheHole()) {
1767 set_the_hole(i);
1768 } else {
1769 set(i, hole_or_object->Number());
1770 }
1771 }
1772 int offset = kHeaderSize + old_length * kDoubleSize;
1773 for (int current = from->length(); current < length(); ++current) {
1774 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
1775 offset += kDoubleSize;
1776 }
1777 }
1778
1779
1780 void FixedDoubleArray::Initialize(SeededNumberDictionary* from) {
1781 int offset = kHeaderSize;
1782 for (int current = 0; current < length(); ++current) {
1783 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
1784 offset += kDoubleSize;
1785 }
1786 for (int i = 0; i < from->Capacity(); i++) {
1787 Object* key = from->KeyAt(i);
1788 if (key->IsNumber()) {
1789 uint32_t entry = static_cast<uint32_t>(key->Number());
1790 set(entry, from->ValueAt(i)->Number());
1791 }
1792 }
1793 }
1794
1795
1796 WriteBarrierMode HeapObject::GetWriteBarrierMode(const AssertNoAllocation&) { 1737 WriteBarrierMode HeapObject::GetWriteBarrierMode(const AssertNoAllocation&) {
1797 Heap* heap = GetHeap(); 1738 Heap* heap = GetHeap();
1798 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; 1739 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER;
1799 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; 1740 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER;
1800 return UPDATE_WRITE_BARRIER; 1741 return UPDATE_WRITE_BARRIER;
1801 } 1742 }
1802 1743
1803 1744
1804 void FixedArray::set(int index, 1745 void FixedArray::set(int index,
1805 Object* value, 1746 Object* value,
(...skipping 3168 matching lines...) Expand 10 before | Expand all | Expand 10 after
4974 #undef WRITE_UINT32_FIELD 4915 #undef WRITE_UINT32_FIELD
4975 #undef READ_SHORT_FIELD 4916 #undef READ_SHORT_FIELD
4976 #undef WRITE_SHORT_FIELD 4917 #undef WRITE_SHORT_FIELD
4977 #undef READ_BYTE_FIELD 4918 #undef READ_BYTE_FIELD
4978 #undef WRITE_BYTE_FIELD 4919 #undef WRITE_BYTE_FIELD
4979 4920
4980 4921
4981 } } // namespace v8::internal 4922 } } // namespace v8::internal
4982 4923
4983 #endif // V8_OBJECTS_INL_H_ 4924 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698