Index: src/heap/heap.cc |
diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
index bc55f9e1c5f8fb88a9a3db623d2dba0efd3bc2d9..147d5ddff02578e3fa82428f3672fac83a900712 100644 |
--- a/src/heap/heap.cc |
+++ b/src/heap/heap.cc |
@@ -495,11 +495,11 @@ void Heap::ClearAllICsByKind(Code::Kind kind) { |
} |
-void Heap::RepairFreeListsAfterBoot() { |
+void Heap::RepairFreeListsAfterDeserialization() { |
PagedSpaces spaces(this); |
for (PagedSpace* space = spaces.next(); space != NULL; |
space = spaces.next()) { |
- space->RepairFreeListsAfterBoot(); |
+ space->RepairFreeListsAfterDeserialization(); |
} |
} |
@@ -952,14 +952,15 @@ bool Heap::ReserveSpace(Reservation* reservations) { |
} else { |
allocation = paged_space(space)->AllocateRaw(size); |
} |
- FreeListNode* node; |
- if (allocation.To(&node)) { |
+ HeapObject* free_space; |
+ if (allocation.To(&free_space)) { |
// Mark with a free list node, in case we have a GC before |
// deserializing. |
- node->set_size(this, size); |
+ Address free_space_address = free_space->address(); |
+ CreateFillerObjectAt(free_space_address, size); |
DCHECK(space < Serializer::kNumberOfPreallocatedSpaces); |
- chunk.start = node->address(); |
- chunk.end = node->address() + size; |
+ chunk.start = free_space_address; |
+ chunk.end = free_space_address + size; |
} else { |
perform_gc = true; |
break; |
@@ -3392,13 +3393,18 @@ AllocationResult Heap::AllocateByteArray(int length, PretenureFlag pretenure) { |
void Heap::CreateFillerObjectAt(Address addr, int size) { |
if (size == 0) return; |
HeapObject* filler = HeapObject::FromAddress(addr); |
+ // At this point, we may be deserializing the heap from a snapshot, and |
+ // none of the maps have been created yet and are NULL. |
if (size == kPointerSize) { |
- filler->set_map_no_write_barrier(one_pointer_filler_map()); |
+ filler->set_map_no_write_barrier(raw_unchecked_one_pointer_filler_map()); |
+ DCHECK(filler->map() == NULL || filler->map() == one_pointer_filler_map()); |
} else if (size == 2 * kPointerSize) { |
- filler->set_map_no_write_barrier(two_pointer_filler_map()); |
+ filler->set_map_no_write_barrier(raw_unchecked_two_pointer_filler_map()); |
+ DCHECK(filler->map() == NULL || filler->map() == two_pointer_filler_map()); |
} else { |
- filler->set_map_no_write_barrier(free_space_map()); |
- FreeSpace::cast(filler)->set_size(size); |
+ filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); |
+ DCHECK(filler->map() == NULL || filler->map() == free_space_map()); |
+ FreeSpace::cast(filler)->nobarrier_set_size(size); |
} |
} |