| 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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 Deserializer::Deserializer(SnapshotByteSource* source) : source_(source) { | 570 Deserializer::Deserializer(SnapshotByteSource* source) : source_(source) { |
| 571 } | 571 } |
| 572 | 572 |
| 573 | 573 |
| 574 // This routine both allocates a new object, and also keeps | 574 // This routine both allocates a new object, and also keeps |
| 575 // track of where objects have been allocated so that we can | 575 // track of where objects have been allocated so that we can |
| 576 // fix back references when deserializing. | 576 // fix back references when deserializing. |
| 577 Address Deserializer::Allocate(int space_index, Space* space, int size) { | 577 Address Deserializer::Allocate(int space_index, Space* space, int size) { |
| 578 Address address; | 578 Address address; |
| 579 if (!SpaceIsLarge(space_index)) { | 579 if (!SpaceIsLarge(space_index)) { |
| 580 ASSERT(!SpaceIsPaged(space_index) || | 580 ASSERT(!SpaceIsPaged(space_index) || size <= Page::kMaxHeapObjectSize); |
| 581 size <= Page::kPageSize - Page::kObjectStartOffset); | |
| 582 MaybeObject* maybe_new_allocation; | 581 MaybeObject* maybe_new_allocation; |
| 583 if (space_index == NEW_SPACE) { | 582 if (space_index == NEW_SPACE) { |
| 584 maybe_new_allocation = | 583 maybe_new_allocation = |
| 585 reinterpret_cast<NewSpace*>(space)->AllocateRaw(size); | 584 reinterpret_cast<NewSpace*>(space)->AllocateRaw(size); |
| 586 } else { | 585 } else { |
| 587 maybe_new_allocation = | 586 maybe_new_allocation = |
| 588 reinterpret_cast<PagedSpace*>(space)->AllocateRaw(size); | 587 reinterpret_cast<PagedSpace*>(space)->AllocateRaw(size); |
| 589 } | 588 } |
| 590 Object* new_allocation = maybe_new_allocation->ToObjectUnchecked(); | 589 Object* new_allocation = maybe_new_allocation->ToObjectUnchecked(); |
| 591 HeapObject* new_object = HeapObject::cast(new_allocation); | 590 HeapObject* new_object = HeapObject::cast(new_allocation); |
| 592 address = new_object->address(); | 591 address = new_object->address(); |
| 593 high_water_[space_index] = address + size; | 592 high_water_[space_index] = address + size; |
| 594 } else { | 593 } else { |
| 595 ASSERT(SpaceIsLarge(space_index)); | 594 ASSERT(SpaceIsLarge(space_index)); |
| 596 ASSERT(size > Page::kPageSize - Page::kObjectStartOffset); | 595 ASSERT(size > Page::kMaxHeapObjectSize); |
| 597 LargeObjectSpace* lo_space = reinterpret_cast<LargeObjectSpace*>(space); | 596 LargeObjectSpace* lo_space = reinterpret_cast<LargeObjectSpace*>(space); |
| 598 Object* new_allocation; | 597 Object* new_allocation; |
| 599 if (space_index == kLargeData) { | 598 if (space_index == kLargeData) { |
| 600 new_allocation = lo_space->AllocateRaw(size)->ToObjectUnchecked(); | 599 new_allocation = lo_space->AllocateRaw(size)->ToObjectUnchecked(); |
| 601 } else if (space_index == kLargeFixedArray) { | 600 } else if (space_index == kLargeFixedArray) { |
| 602 new_allocation = | 601 new_allocation = |
| 603 lo_space->AllocateRawFixedArray(size)->ToObjectUnchecked(); | 602 lo_space->AllocateRawFixedArray(size)->ToObjectUnchecked(); |
| 604 } else { | 603 } else { |
| 605 ASSERT_EQ(kLargeCode, space_index); | 604 ASSERT_EQ(kLargeCode, space_index); |
| 606 new_allocation = lo_space->AllocateRawCode(size)->ToObjectUnchecked(); | 605 new_allocation = lo_space->AllocateRawCode(size)->ToObjectUnchecked(); |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1518 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); | 1517 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); |
| 1519 } | 1518 } |
| 1520 } | 1519 } |
| 1521 int allocation_address = fullness_[space]; | 1520 int allocation_address = fullness_[space]; |
| 1522 fullness_[space] = allocation_address + size; | 1521 fullness_[space] = allocation_address + size; |
| 1523 return allocation_address; | 1522 return allocation_address; |
| 1524 } | 1523 } |
| 1525 | 1524 |
| 1526 | 1525 |
| 1527 } } // namespace v8::internal | 1526 } } // namespace v8::internal |
| OLD | NEW |