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 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1718 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); | 1718 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); |
1719 } | 1719 } |
1720 | 1720 |
1721 | 1721 |
1722 bool FixedDoubleArray::is_the_hole(int index) { | 1722 bool FixedDoubleArray::is_the_hole(int index) { |
1723 int offset = kHeaderSize + index * kDoubleSize; | 1723 int offset = kHeaderSize + index * kDoubleSize; |
1724 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); | 1724 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); |
1725 } | 1725 } |
1726 | 1726 |
1727 | 1727 |
1728 void FixedDoubleArray::Initialize(FixedDoubleArray* from) { | |
1729 int old_length = from->length(); | |
1730 ASSERT(old_length < length()); | |
1731 if (old_length * kDoubleSize >= OS::kMinComplexMemCopy) { | |
1732 OS::MemCopy(FIELD_ADDR(this, kHeaderSize), | |
1733 FIELD_ADDR(from, kHeaderSize), | |
1734 old_length * kDoubleSize); | |
1735 } else { | |
1736 for (int i = 0; i < old_length; ++i) { | |
1737 if (from->is_the_hole(i)) { | |
1738 set_the_hole(i); | |
1739 } else { | |
1740 set(i, from->get_scalar(i)); | |
1741 } | |
1742 } | |
1743 } | |
1744 int offset = kHeaderSize + old_length * kDoubleSize; | |
1745 for (int current = from->length(); current < length(); ++current) { | |
1746 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); | |
1747 offset += kDoubleSize; | |
1748 } | |
1749 } | |
1750 | |
1751 | |
1752 void FixedDoubleArray::Initialize(FixedArray* from) { | |
1753 int old_length = from->length(); | |
1754 ASSERT(old_length <= length()); | |
1755 for (int i = 0; i < old_length; i++) { | |
1756 Object* hole_or_object = from->get(i); | |
1757 if (hole_or_object->IsTheHole()) { | |
1758 set_the_hole(i); | |
1759 } else { | |
1760 set(i, hole_or_object->Number()); | |
1761 } | |
1762 } | |
1763 int offset = kHeaderSize + old_length * kDoubleSize; | |
1764 for (int current = from->length(); current < length(); ++current) { | |
1765 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); | |
1766 offset += kDoubleSize; | |
1767 } | |
1768 } | |
1769 | |
1770 | |
1771 void FixedDoubleArray::Initialize(SeededNumberDictionary* from) { | |
1772 int offset = kHeaderSize; | |
1773 for (int current = 0; current < length(); ++current) { | |
1774 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); | |
1775 offset += kDoubleSize; | |
1776 } | |
1777 for (int i = 0; i < from->Capacity(); i++) { | |
1778 Object* key = from->KeyAt(i); | |
1779 if (key->IsNumber()) { | |
1780 uint32_t entry = static_cast<uint32_t>(key->Number()); | |
1781 set(entry, from->ValueAt(i)->Number()); | |
1782 } | |
1783 } | |
1784 } | |
1785 | |
1786 | |
1787 WriteBarrierMode HeapObject::GetWriteBarrierMode(const AssertNoAllocation&) { | 1728 WriteBarrierMode HeapObject::GetWriteBarrierMode(const AssertNoAllocation&) { |
1788 Heap* heap = GetHeap(); | 1729 Heap* heap = GetHeap(); |
1789 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; | 1730 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; |
1790 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; | 1731 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; |
1791 return UPDATE_WRITE_BARRIER; | 1732 return UPDATE_WRITE_BARRIER; |
1792 } | 1733 } |
1793 | 1734 |
1794 | 1735 |
1795 void FixedArray::set(int index, | 1736 void FixedArray::set(int index, |
1796 Object* value, | 1737 Object* value, |
(...skipping 3154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4951 #undef WRITE_INT_FIELD | 4892 #undef WRITE_INT_FIELD |
4952 #undef READ_SHORT_FIELD | 4893 #undef READ_SHORT_FIELD |
4953 #undef WRITE_SHORT_FIELD | 4894 #undef WRITE_SHORT_FIELD |
4954 #undef READ_BYTE_FIELD | 4895 #undef READ_BYTE_FIELD |
4955 #undef WRITE_BYTE_FIELD | 4896 #undef WRITE_BYTE_FIELD |
4956 | 4897 |
4957 | 4898 |
4958 } } // namespace v8::internal | 4899 } } // namespace v8::internal |
4959 | 4900 |
4960 #endif // V8_OBJECTS_INL_H_ | 4901 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |