Index: src/heap.cc |
=================================================================== |
--- src/heap.cc (revision 5368) |
+++ src/heap.cc (working copy) |
@@ -104,6 +104,7 @@ |
GCCallback Heap::global_gc_prologue_callback_ = NULL; |
GCCallback Heap::global_gc_epilogue_callback_ = NULL; |
+HeapObjectCallback Heap::gc_safe_size_of_old_object_ = NULL; |
// Variables set based on semispace_size_ and old_generation_size_ in |
// ConfigureHeap. |
@@ -193,6 +194,33 @@ |
} |
+int Heap::GcSafeSizeOfOldObject(HeapObject* object) { |
+ ASSERT(!Heap::InNewSpace(object)); // Code only works for old objects. |
+ ASSERT(!MarkCompactCollector::are_map_pointers_encoded()); |
+ MapWord map_word = object->map_word(); |
+ map_word.ClearMark(); |
+ map_word.ClearOverflow(); |
+ return object->SizeFromMap(map_word.ToMap()); |
+} |
+ |
+ |
+int Heap::GcSafeSizeOfOldObjectWithEncodedMap(HeapObject* object) { |
+ ASSERT(!Heap::InNewSpace(object)); // Code only works for old objects. |
+ ASSERT(MarkCompactCollector::are_map_pointers_encoded()); |
+ uint32_t marker = Memory::uint32_at(object->address()); |
+ if (marker == MarkCompactCollector::kSingleFreeEncoding) { |
+ return kIntSize; |
+ } else if (marker == MarkCompactCollector::kMultiFreeEncoding) { |
+ return Memory::int_at(object->address() + kIntSize); |
+ } else { |
+ MapWord map_word = object->map_word(); |
+ Address map_address = map_word.DecodeMapAddress(Heap::map_space()); |
+ Map* map = reinterpret_cast<Map*>(HeapObject::FromAddress(map_address)); |
+ return object->SizeFromMap(map); |
+ } |
+} |
+ |
+ |
GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space) { |
// Is global GC requested? |
if (space != NEW_SPACE || FLAG_gc_global) { |
@@ -742,8 +770,6 @@ |
MarkCompactCollector::CollectGarbage(); |
- MarkCompactEpilogue(is_compacting); |
- |
LOG(ResourceEvent("markcompact", "end")); |
gc_state_ = NOT_IN_GC; |
@@ -765,9 +791,6 @@ |
CompilationCache::MarkCompactPrologue(); |
- Top::MarkCompactPrologue(is_compacting); |
- ThreadManager::MarkCompactPrologue(is_compacting); |
- |
CompletelyClearInstanceofCache(); |
if (is_compacting) FlushNumberStringCache(); |
@@ -776,12 +799,6 @@ |
} |
-void Heap::MarkCompactEpilogue(bool is_compacting) { |
- Top::MarkCompactEpilogue(is_compacting); |
- ThreadManager::MarkCompactEpilogue(is_compacting); |
-} |
- |
- |
Object* Heap::FindCodeObject(Address a) { |
Object* obj = code_space_->FindObject(a); |
if (obj->IsFailure()) { |
@@ -4049,6 +4066,8 @@ |
NewSpaceScavenger::Initialize(); |
MarkCompactCollector::Initialize(); |
+ MarkMapPointersAsEncoded(false); |
+ |
// Setup memory allocator and reserve a chunk of memory for new |
// space. The chunk is double the size of the requested reserved |
// new space size to ensure that we can find a pair of semispaces that |