| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1785 PagedSpace* space; | 1785 PagedSpace* space; |
| 1786 switch (space_index) { | 1786 switch (space_index) { |
| 1787 case OLD_DATA_SPACE: space = Heap::old_data_space(); break; | 1787 case OLD_DATA_SPACE: space = Heap::old_data_space(); break; |
| 1788 case OLD_POINTER_SPACE: space = Heap::old_pointer_space(); break; | 1788 case OLD_POINTER_SPACE: space = Heap::old_pointer_space(); break; |
| 1789 case MAP_SPACE: space = Heap::map_space(); break; | 1789 case MAP_SPACE: space = Heap::map_space(); break; |
| 1790 case CODE_SPACE: space = Heap::code_space(); break; | 1790 case CODE_SPACE: space = Heap::code_space(); break; |
| 1791 case CELL_SPACE: space = Heap::cell_space(); break; | 1791 case CELL_SPACE: space = Heap::cell_space(); break; |
| 1792 default: UNREACHABLE(); space = NULL; break; | 1792 default: UNREACHABLE(); space = NULL; break; |
| 1793 } | 1793 } |
| 1794 ASSERT(size <= Page::kPageSize - Page::kObjectStartOffset); | 1794 ASSERT(size <= Page::kPageSize - Page::kObjectStartOffset); |
| 1795 int current_page = old_fullness >> Page::kPageSizeBits; | 1795 int current_page = old_fullness >> kPageSizeBits; |
| 1796 int new_fullness = old_fullness + size; | 1796 int new_fullness = old_fullness + size; |
| 1797 int new_page = new_fullness >> Page::kPageSizeBits; | 1797 int new_page = new_fullness >> kPageSizeBits; |
| 1798 // What is our new position within the current page. | 1798 // What is our new position within the current page. |
| 1799 int intra_page_offset = new_fullness - current_page * Page::kPageSize; | 1799 int intra_page_offset = new_fullness - current_page * Page::kPageSize; |
| 1800 if (intra_page_offset > Page::kPageSize - Page::kObjectStartOffset) { | 1800 if (intra_page_offset > Page::kPageSize - Page::kObjectStartOffset) { |
| 1801 // This object will not fit in a page and we have to move to the next. | 1801 // This object will not fit in a page and we have to move to the next. |
| 1802 new_page = current_page + 1; | 1802 new_page = current_page + 1; |
| 1803 old_fullness = new_page << Page::kPageSizeBits; | 1803 old_fullness = new_page << kPageSizeBits; |
| 1804 new_fullness = old_fullness + size; | 1804 new_fullness = old_fullness + size; |
| 1805 record_page = true; | 1805 record_page = true; |
| 1806 } | 1806 } |
| 1807 fullness_[space_index] = new_fullness; | 1807 fullness_[space_index] = new_fullness; |
| 1808 Object* new_allocation = space->AllocateRaw(size); | 1808 Object* new_allocation = space->AllocateRaw(size); |
| 1809 new_object = HeapObject::cast(new_allocation); | 1809 new_object = HeapObject::cast(new_allocation); |
| 1810 ASSERT(!new_object->IsFailure()); | 1810 ASSERT(!new_object->IsFailure()); |
| 1811 ASSERT((reinterpret_cast<intptr_t>(new_object->address()) & | 1811 ASSERT((reinterpret_cast<intptr_t>(new_object->address()) & |
| 1812 Page::kPageAlignmentMask) == | 1812 Page::kPageAlignmentMask) == |
| 1813 (old_fullness & Page::kPageAlignmentMask) + | 1813 (old_fullness & Page::kPageAlignmentMask) + |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1855 pages_[LO_SPACE][fullness_[LO_SPACE] - offset]); | 1855 pages_[LO_SPACE][fullness_[LO_SPACE] - offset]); |
| 1856 } | 1856 } |
| 1857 offset <<= kObjectAlignmentBits; | 1857 offset <<= kObjectAlignmentBits; |
| 1858 if (space == NEW_SPACE) { | 1858 if (space == NEW_SPACE) { |
| 1859 // New space has only one space - numbered 0. | 1859 // New space has only one space - numbered 0. |
| 1860 return HeapObject::FromAddress( | 1860 return HeapObject::FromAddress( |
| 1861 pages_[space][0] + fullness_[space] - offset); | 1861 pages_[space][0] + fullness_[space] - offset); |
| 1862 } | 1862 } |
| 1863 ASSERT(SpaceIsPaged(space)); | 1863 ASSERT(SpaceIsPaged(space)); |
| 1864 int virtual_address = fullness_[space] - offset; | 1864 int virtual_address = fullness_[space] - offset; |
| 1865 int page_of_pointee = (virtual_address) >> Page::kPageSizeBits; | 1865 int page_of_pointee = (virtual_address) >> kPageSizeBits; |
| 1866 Address object_address = pages_[space][page_of_pointee] + | 1866 Address object_address = pages_[space][page_of_pointee] + |
| 1867 (virtual_address & Page::kPageAlignmentMask); | 1867 (virtual_address & Page::kPageAlignmentMask); |
| 1868 return HeapObject::FromAddress(object_address); | 1868 return HeapObject::FromAddress(object_address); |
| 1869 } | 1869 } |
| 1870 | 1870 |
| 1871 | 1871 |
| 1872 void Deserializer2::Deserialize() { | 1872 void Deserializer2::Deserialize() { |
| 1873 // Don't GC while deserializing - just expand the heap. | 1873 // Don't GC while deserializing - just expand the heap. |
| 1874 AlwaysAllocateScope always_allocate; | 1874 AlwaysAllocateScope always_allocate; |
| 1875 // Don't use the free lists while deserializing. | 1875 // Don't use the free lists while deserializing. |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2242 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); | 2242 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); |
| 2243 } | 2243 } |
| 2244 } | 2244 } |
| 2245 int allocation_address = fullness_[space]; | 2245 int allocation_address = fullness_[space]; |
| 2246 fullness_[space] = allocation_address + size; | 2246 fullness_[space] = allocation_address + size; |
| 2247 return allocation_address; | 2247 return allocation_address; |
| 2248 } | 2248 } |
| 2249 | 2249 |
| 2250 | 2250 |
| 2251 } } // namespace v8::internal | 2251 } } // namespace v8::internal |
| OLD | NEW |