Cleanup usage of HEAP in mark-compact.

Review URL: http://codereview.chromium.org/6760025

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7475 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1e8079fc
...@@ -223,9 +223,9 @@ void RelocInfo::Visit(Heap* heap) { ...@@ -223,9 +223,9 @@ void RelocInfo::Visit(Heap* heap) {
if (mode == RelocInfo::EMBEDDED_OBJECT) { if (mode == RelocInfo::EMBEDDED_OBJECT) {
StaticVisitor::VisitPointer(heap, target_object_address()); StaticVisitor::VisitPointer(heap, target_object_address());
} else if (RelocInfo::IsCodeTarget(mode)) { } else if (RelocInfo::IsCodeTarget(mode)) {
StaticVisitor::VisitCodeTarget(this); StaticVisitor::VisitCodeTarget(heap, this);
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
StaticVisitor::VisitGlobalPropertyCell(this); StaticVisitor::VisitGlobalPropertyCell(heap, this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) { } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
StaticVisitor::VisitExternalReference(target_reference_address()); StaticVisitor::VisitExternalReference(target_reference_address());
#ifdef ENABLE_DEBUGGER_SUPPORT #ifdef ENABLE_DEBUGGER_SUPPORT
...@@ -234,7 +234,7 @@ void RelocInfo::Visit(Heap* heap) { ...@@ -234,7 +234,7 @@ void RelocInfo::Visit(Heap* heap) {
IsPatchedReturnSequence()) || IsPatchedReturnSequence()) ||
(RelocInfo::IsDebugBreakSlot(mode) && (RelocInfo::IsDebugBreakSlot(mode) &&
IsPatchedDebugBreakSlotSequence()))) { IsPatchedDebugBreakSlotSequence()))) {
StaticVisitor::VisitDebugTarget(this); StaticVisitor::VisitDebugTarget(heap, this);
#endif #endif
} else if (mode == RelocInfo::RUNTIME_ENTRY) { } else if (mode == RelocInfo::RUNTIME_ENTRY) {
StaticVisitor::VisitRuntimeEntry(this); StaticVisitor::VisitRuntimeEntry(this);
......
...@@ -225,9 +225,9 @@ void RelocInfo::Visit(Heap* heap) { ...@@ -225,9 +225,9 @@ void RelocInfo::Visit(Heap* heap) {
StaticVisitor::VisitPointer(heap, target_object_address()); StaticVisitor::VisitPointer(heap, target_object_address());
CPU::FlushICache(pc_, sizeof(Address)); CPU::FlushICache(pc_, sizeof(Address));
} else if (RelocInfo::IsCodeTarget(mode)) { } else if (RelocInfo::IsCodeTarget(mode)) {
StaticVisitor::VisitCodeTarget(this); StaticVisitor::VisitCodeTarget(heap, this);
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
StaticVisitor::VisitGlobalPropertyCell(this); StaticVisitor::VisitGlobalPropertyCell(heap, this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) { } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
StaticVisitor::VisitExternalReference(target_reference_address()); StaticVisitor::VisitExternalReference(target_reference_address());
CPU::FlushICache(pc_, sizeof(Address)); CPU::FlushICache(pc_, sizeof(Address));
...@@ -237,7 +237,7 @@ void RelocInfo::Visit(Heap* heap) { ...@@ -237,7 +237,7 @@ void RelocInfo::Visit(Heap* heap) {
IsPatchedReturnSequence()) || IsPatchedReturnSequence()) ||
(RelocInfo::IsDebugBreakSlot(mode) && (RelocInfo::IsDebugBreakSlot(mode) &&
IsPatchedDebugBreakSlotSequence()))) { IsPatchedDebugBreakSlotSequence()))) {
StaticVisitor::VisitDebugTarget(this); StaticVisitor::VisitDebugTarget(heap, this);
#endif #endif
} else if (mode == RelocInfo::RUNTIME_ENTRY) { } else if (mode == RelocInfo::RUNTIME_ENTRY) {
StaticVisitor::VisitRuntimeEntry(this); StaticVisitor::VisitRuntimeEntry(this);
......
...@@ -86,15 +86,15 @@ void MarkCompactCollector::CollectGarbage() { ...@@ -86,15 +86,15 @@ void MarkCompactCollector::CollectGarbage() {
GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_COMPACT); GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_COMPACT);
EncodeForwardingAddresses(); EncodeForwardingAddresses();
heap_->MarkMapPointersAsEncoded(true); heap()->MarkMapPointersAsEncoded(true);
UpdatePointers(); UpdatePointers();
heap_->MarkMapPointersAsEncoded(false); heap()->MarkMapPointersAsEncoded(false);
heap_->isolate()->pc_to_code_cache()->Flush(); heap()->isolate()->pc_to_code_cache()->Flush();
RelocateObjects(); RelocateObjects();
} else { } else {
SweepSpaces(); SweepSpaces();
heap_->isolate()->pc_to_code_cache()->Flush(); heap()->isolate()->pc_to_code_cache()->Flush();
} }
Finish(); Finish();
...@@ -123,7 +123,7 @@ void MarkCompactCollector::Prepare(GCTracer* tracer) { ...@@ -123,7 +123,7 @@ void MarkCompactCollector::Prepare(GCTracer* tracer) {
compact_on_next_gc_ = false; compact_on_next_gc_ = false;
if (FLAG_never_compact) compacting_collection_ = false; if (FLAG_never_compact) compacting_collection_ = false;
if (!HEAP->map_space()->MapPointersEncodable()) if (!heap()->map_space()->MapPointersEncodable())
compacting_collection_ = false; compacting_collection_ = false;
if (FLAG_collect_maps) CreateBackPointers(); if (FLAG_collect_maps) CreateBackPointers();
#ifdef ENABLE_GDB_JIT_INTERFACE #ifdef ENABLE_GDB_JIT_INTERFACE
...@@ -161,9 +161,9 @@ void MarkCompactCollector::Finish() { ...@@ -161,9 +161,9 @@ void MarkCompactCollector::Finish() {
// force lazy re-initialization of it. This must be done after the // force lazy re-initialization of it. This must be done after the
// GC, because it relies on the new address of certain old space // GC, because it relies on the new address of certain old space
// objects (empty string, illegal builtin). // objects (empty string, illegal builtin).
heap_->isolate()->stub_cache()->Clear(); heap()->isolate()->stub_cache()->Clear();
heap_->external_string_table_.CleanUp(); heap()->external_string_table_.CleanUp();
// If we've just compacted old space there's no reason to check the // If we've just compacted old space there's no reason to check the
// fragmentation limit. Just return. // fragmentation limit. Just return.
...@@ -456,7 +456,7 @@ class StaticMarkingVisitor : public StaticVisitorBase { ...@@ -456,7 +456,7 @@ class StaticMarkingVisitor : public StaticVisitorBase {
for (Object** p = start; p < end; p++) MarkObjectByPointer(heap, p); for (Object** p = start; p < end; p++) MarkObjectByPointer(heap, p);
} }
static inline void VisitCodeTarget(RelocInfo* rinfo) { static inline void VisitCodeTarget(Heap* heap, RelocInfo* rinfo) {
ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
Code* code = Code::GetCodeFromTargetAddress(rinfo->target_address()); Code* code = Code::GetCodeFromTargetAddress(rinfo->target_address());
if (FLAG_cleanup_ics_at_gc && code->is_inline_cache_stub()) { if (FLAG_cleanup_ics_at_gc && code->is_inline_cache_stub()) {
...@@ -464,28 +464,27 @@ class StaticMarkingVisitor : public StaticVisitorBase { ...@@ -464,28 +464,27 @@ class StaticMarkingVisitor : public StaticVisitorBase {
// Please note targets for cleared inline cached do not have to be // Please note targets for cleared inline cached do not have to be
// marked since they are contained in HEAP->non_monomorphic_cache(). // marked since they are contained in HEAP->non_monomorphic_cache().
} else { } else {
code->heap()->mark_compact_collector()->MarkObject(code); heap->mark_compact_collector()->MarkObject(code);
} }
} }
static void VisitGlobalPropertyCell(RelocInfo* rinfo) { static void VisitGlobalPropertyCell(Heap* heap, RelocInfo* rinfo) {
ASSERT(rinfo->rmode() == RelocInfo::GLOBAL_PROPERTY_CELL); ASSERT(rinfo->rmode() == RelocInfo::GLOBAL_PROPERTY_CELL);
Object* cell = rinfo->target_cell(); Object* cell = rinfo->target_cell();
Object* old_cell = cell; Object* old_cell = cell;
VisitPointer(reinterpret_cast<JSGlobalPropertyCell*>(cell)->heap(), &cell); VisitPointer(heap, &cell);
if (cell != old_cell) { if (cell != old_cell) {
rinfo->set_target_cell(reinterpret_cast<JSGlobalPropertyCell*>(cell)); rinfo->set_target_cell(reinterpret_cast<JSGlobalPropertyCell*>(cell));
} }
} }
static inline void VisitDebugTarget(RelocInfo* rinfo) { static inline void VisitDebugTarget(Heap* heap, RelocInfo* rinfo) {
ASSERT((RelocInfo::IsJSReturn(rinfo->rmode()) && ASSERT((RelocInfo::IsJSReturn(rinfo->rmode()) &&
rinfo->IsPatchedReturnSequence()) || rinfo->IsPatchedReturnSequence()) ||
(RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) &&
rinfo->IsPatchedDebugBreakSlotSequence())); rinfo->IsPatchedDebugBreakSlotSequence()));
HeapObject* code = Code::GetCodeFromTargetAddress(rinfo->call_address()); HeapObject* code = Code::GetCodeFromTargetAddress(rinfo->call_address());
reinterpret_cast<Code*>(code)->heap()->mark_compact_collector()-> heap->mark_compact_collector()->MarkObject(code);
MarkObject(code);
} }
// Mark object pointed to by p. // Mark object pointed to by p.
...@@ -565,8 +564,8 @@ class StaticMarkingVisitor : public StaticVisitorBase { ...@@ -565,8 +564,8 @@ class StaticMarkingVisitor : public StaticVisitorBase {
// flushed. // flushed.
static const int kCodeAgeThreshold = 5; static const int kCodeAgeThreshold = 5;
inline static bool HasSourceCode(SharedFunctionInfo* info) { inline static bool HasSourceCode(Heap* heap, SharedFunctionInfo* info) {
Object* undefined = HEAP->raw_unchecked_undefined_value(); Object* undefined = heap->raw_unchecked_undefined_value();
return (info->script() != undefined) && return (info->script() != undefined) &&
(reinterpret_cast<Script*>(info->script())->source() != undefined); (reinterpret_cast<Script*>(info->script())->source() != undefined);
} }
...@@ -582,7 +581,7 @@ class StaticMarkingVisitor : public StaticVisitorBase { ...@@ -582,7 +581,7 @@ class StaticMarkingVisitor : public StaticVisitorBase {
function->GetIsolate()->builtins()->builtin(Builtins::kLazyCompile); function->GetIsolate()->builtins()->builtin(Builtins::kLazyCompile);
} }
inline static bool IsFlushable(JSFunction* function) { inline static bool IsFlushable(Heap* heap, JSFunction* function) {
SharedFunctionInfo* shared_info = function->unchecked_shared(); SharedFunctionInfo* shared_info = function->unchecked_shared();
// Code is either on stack, in compilation cache or referenced // Code is either on stack, in compilation cache or referenced
...@@ -597,10 +596,10 @@ class StaticMarkingVisitor : public StaticVisitorBase { ...@@ -597,10 +596,10 @@ class StaticMarkingVisitor : public StaticVisitorBase {
return false; return false;
} }
return IsFlushable(shared_info); return IsFlushable(heap, shared_info);
} }
inline static bool IsFlushable(SharedFunctionInfo* shared_info) { inline static bool IsFlushable(Heap* heap, SharedFunctionInfo* shared_info) {
// Code is either on stack, in compilation cache or referenced // Code is either on stack, in compilation cache or referenced
// by optimized version of function. // by optimized version of function.
if (shared_info->unchecked_code()->IsMarked()) { if (shared_info->unchecked_code()->IsMarked()) {
...@@ -610,7 +609,7 @@ class StaticMarkingVisitor : public StaticVisitorBase { ...@@ -610,7 +609,7 @@ class StaticMarkingVisitor : public StaticVisitorBase {
// The function must be compiled and have the source code available, // The function must be compiled and have the source code available,
// to be able to recompile it in case we need the function again. // to be able to recompile it in case we need the function again.
if (!(shared_info->is_compiled() && HasSourceCode(shared_info))) { if (!(shared_info->is_compiled() && HasSourceCode(heap, shared_info))) {
return false; return false;
} }
...@@ -642,7 +641,7 @@ class StaticMarkingVisitor : public StaticVisitorBase { ...@@ -642,7 +641,7 @@ class StaticMarkingVisitor : public StaticVisitorBase {
static bool FlushCodeForFunction(Heap* heap, JSFunction* function) { static bool FlushCodeForFunction(Heap* heap, JSFunction* function) {
if (!IsFlushable(function)) return false; if (!IsFlushable(heap, function)) return false;
// This function's code looks flushable. But we have to postpone the // This function's code looks flushable. But we have to postpone the
// decision until we see all functions that point to the same // decision until we see all functions that point to the same
...@@ -719,7 +718,7 @@ class StaticMarkingVisitor : public StaticVisitorBase { ...@@ -719,7 +718,7 @@ class StaticMarkingVisitor : public StaticVisitorBase {
if (shared->IsInobjectSlackTrackingInProgress()) shared->DetachInitialMap(); if (shared->IsInobjectSlackTrackingInProgress()) shared->DetachInitialMap();
if (!known_flush_code_candidate) { if (!known_flush_code_candidate) {
known_flush_code_candidate = IsFlushable(shared); known_flush_code_candidate = IsFlushable(heap, shared);
if (known_flush_code_candidate) { if (known_flush_code_candidate) {
heap->mark_compact_collector()->code_flusher()->AddCandidate(shared); heap->mark_compact_collector()->code_flusher()->AddCandidate(shared);
} }
...@@ -869,16 +868,16 @@ class MarkingVisitor : public ObjectVisitor { ...@@ -869,16 +868,16 @@ class MarkingVisitor : public ObjectVisitor {
StaticMarkingVisitor::VisitPointers(heap_, start, end); StaticMarkingVisitor::VisitPointers(heap_, start, end);
} }
void VisitCodeTarget(RelocInfo* rinfo) { void VisitCodeTarget(Heap* heap, RelocInfo* rinfo) {
StaticMarkingVisitor::VisitCodeTarget(rinfo); StaticMarkingVisitor::VisitCodeTarget(heap, rinfo);
} }
void VisitGlobalPropertyCell(RelocInfo* rinfo) { void VisitGlobalPropertyCell(Heap* heap, RelocInfo* rinfo) {
StaticMarkingVisitor::VisitGlobalPropertyCell(rinfo); StaticMarkingVisitor::VisitGlobalPropertyCell(heap, rinfo);
} }
void VisitDebugTarget(RelocInfo* rinfo) { void VisitDebugTarget(Heap* heap, RelocInfo* rinfo) {
StaticMarkingVisitor::VisitDebugTarget(rinfo); StaticMarkingVisitor::VisitDebugTarget(heap, rinfo);
} }
private: private:
...@@ -926,7 +925,7 @@ class SharedFunctionInfoMarkingVisitor : public ObjectVisitor { ...@@ -926,7 +925,7 @@ class SharedFunctionInfoMarkingVisitor : public ObjectVisitor {
void MarkCompactCollector::PrepareForCodeFlushing() { void MarkCompactCollector::PrepareForCodeFlushing() {
ASSERT(heap_ == Isolate::Current()->heap()); ASSERT(heap() == Isolate::Current()->heap());
if (!FLAG_flush_code) { if (!FLAG_flush_code) {
EnableCodeFlushing(false); EnableCodeFlushing(false);
...@@ -934,8 +933,8 @@ void MarkCompactCollector::PrepareForCodeFlushing() { ...@@ -934,8 +933,8 @@ void MarkCompactCollector::PrepareForCodeFlushing() {
} }
#ifdef ENABLE_DEBUGGER_SUPPORT #ifdef ENABLE_DEBUGGER_SUPPORT
if (heap_->isolate()->debug()->IsLoaded() || if (heap()->isolate()->debug()->IsLoaded() ||
heap_->isolate()->debug()->has_break_points()) { heap()->isolate()->debug()->has_break_points()) {
EnableCodeFlushing(false); EnableCodeFlushing(false);
return; return;
} }
...@@ -944,10 +943,10 @@ void MarkCompactCollector::PrepareForCodeFlushing() { ...@@ -944,10 +943,10 @@ void MarkCompactCollector::PrepareForCodeFlushing() {
// Ensure that empty descriptor array is marked. Method MarkDescriptorArray // Ensure that empty descriptor array is marked. Method MarkDescriptorArray
// relies on it being marked before any other descriptor array. // relies on it being marked before any other descriptor array.
MarkObject(heap_->raw_unchecked_empty_descriptor_array()); MarkObject(heap()->raw_unchecked_empty_descriptor_array());
// Make sure we are not referencing the code from the stack. // Make sure we are not referencing the code from the stack.
ASSERT(this == heap_->mark_compact_collector()); ASSERT(this == heap()->mark_compact_collector());
for (StackFrameIterator it; !it.done(); it.Advance()) { for (StackFrameIterator it; !it.done(); it.Advance()) {
MarkObject(it.frame()->unchecked_code()); MarkObject(it.frame()->unchecked_code());
} }
...@@ -955,12 +954,12 @@ void MarkCompactCollector::PrepareForCodeFlushing() { ...@@ -955,12 +954,12 @@ void MarkCompactCollector::PrepareForCodeFlushing() {
// Iterate the archived stacks in all threads to check if // Iterate the archived stacks in all threads to check if
// the code is referenced. // the code is referenced.
CodeMarkingVisitor code_marking_visitor(this); CodeMarkingVisitor code_marking_visitor(this);
heap_->isolate()->thread_manager()->IterateArchivedThreads( heap()->isolate()->thread_manager()->IterateArchivedThreads(
&code_marking_visitor); &code_marking_visitor);
SharedFunctionInfoMarkingVisitor visitor(this); SharedFunctionInfoMarkingVisitor visitor(this);
heap_->isolate()->compilation_cache()->IterateFunctions(&visitor); heap()->isolate()->compilation_cache()->IterateFunctions(&visitor);
heap_->isolate()->handle_scope_implementer()->Iterate(&visitor); heap()->isolate()->handle_scope_implementer()->Iterate(&visitor);
ProcessMarkingStack(); ProcessMarkingStack();
} }
...@@ -1008,7 +1007,8 @@ class RootMarkingVisitor : public ObjectVisitor { ...@@ -1008,7 +1007,8 @@ class RootMarkingVisitor : public ObjectVisitor {
// Helper class for pruning the symbol table. // Helper class for pruning the symbol table.
class SymbolTableCleaner : public ObjectVisitor { class SymbolTableCleaner : public ObjectVisitor {
public: public:
SymbolTableCleaner() : pointers_removed_(0) { } explicit SymbolTableCleaner(Heap* heap)
: heap_(heap), pointers_removed_(0) { }
virtual void VisitPointers(Object** start, Object** end) { virtual void VisitPointers(Object** start, Object** end) {
// Visit all HeapObject pointers in [start, end). // Visit all HeapObject pointers in [start, end).
...@@ -1020,10 +1020,10 @@ class SymbolTableCleaner : public ObjectVisitor { ...@@ -1020,10 +1020,10 @@ class SymbolTableCleaner : public ObjectVisitor {
// Since no objects have yet been moved we can safely access the map of // Since no objects have yet been moved we can safely access the map of
// the object. // the object.
if ((*p)->IsExternalString()) { if ((*p)->IsExternalString()) {
HEAP->FinalizeExternalString(String::cast(*p)); heap_->FinalizeExternalString(String::cast(*p));
} }
// Set the entry to null_value (as deleted). // Set the entry to null_value (as deleted).
*p = HEAP->raw_unchecked_null_value(); *p = heap_->raw_unchecked_null_value();
pointers_removed_++; pointers_removed_++;
} }
} }
...@@ -1033,6 +1033,7 @@ class SymbolTableCleaner : public ObjectVisitor { ...@@ -1033,6 +1033,7 @@ class SymbolTableCleaner : public ObjectVisitor {
return pointers_removed_; return pointers_removed_;
} }
private: private:
Heap* heap_;
int pointers_removed_; int pointers_removed_;
}; };
...@@ -1058,7 +1059,7 @@ void MarkCompactCollector::MarkUnmarkedObject(HeapObject* object) { ...@@ -1058,7 +1059,7 @@ void MarkCompactCollector::MarkUnmarkedObject(HeapObject* object) {
if (object->IsMap()) { if (object->IsMap()) {
Map* map = Map::cast(object); Map* map = Map::cast(object);
if (FLAG_cleanup_caches_in_maps_at_gc) { if (FLAG_cleanup_caches_in_maps_at_gc) {
map->ClearCodeCache(heap_); map->ClearCodeCache(heap());
} }
SetMark(map); SetMark(map);
if (FLAG_collect_maps && if (FLAG_collect_maps &&
...@@ -1129,7 +1130,7 @@ void MarkCompactCollector::MarkDescriptorArray( ...@@ -1129,7 +1130,7 @@ void MarkCompactCollector::MarkDescriptorArray(
void MarkCompactCollector::CreateBackPointers() { void MarkCompactCollector::CreateBackPointers() {
HeapObjectIterator iterator(HEAP->map_space()); HeapObjectIterator iterator(heap()->map_space());
for (HeapObject* next_object = iterator.next(); for (HeapObject* next_object = iterator.next();
next_object != NULL; next_object = iterator.next()) { next_object != NULL; next_object = iterator.next()) {
if (next_object->IsMap()) { // Could also be ByteArray on free list. if (next_object->IsMap()) { // Could also be ByteArray on free list.
...@@ -1138,7 +1139,7 @@ void MarkCompactCollector::CreateBackPointers() { ...@@ -1138,7 +1139,7 @@ void MarkCompactCollector::CreateBackPointers() {
map->instance_type() <= JS_FUNCTION_TYPE) { map->instance_type() <= JS_FUNCTION_TYPE) {
map->CreateBackPointers(); map->CreateBackPointers();
} else { } else {
ASSERT(map->instance_descriptors() == HEAP->empty_descriptor_array()); ASSERT(map->instance_descriptors() == heap()->empty_descriptor_array());
} }
} }
} }
...@@ -1186,11 +1187,11 @@ bool MarkCompactCollector::IsUnmarkedHeapObject(Object** p) { ...@@ -1186,11 +1187,11 @@ bool MarkCompactCollector::IsUnmarkedHeapObject(Object** p) {
void MarkCompactCollector::MarkSymbolTable() { void MarkCompactCollector::MarkSymbolTable() {
SymbolTable* symbol_table = heap_->raw_unchecked_symbol_table(); SymbolTable* symbol_table = heap()->raw_unchecked_symbol_table();
// Mark the symbol table itself. // Mark the symbol table itself.
SetMark(symbol_table); SetMark(symbol_table);
// Explicitly mark the prefix. // Explicitly mark the prefix.
MarkingVisitor marker(heap_); MarkingVisitor marker(heap());
symbol_table->IteratePrefix(&marker); symbol_table->IteratePrefix(&marker);
ProcessMarkingStack(); ProcessMarkingStack();
} }
...@@ -1199,7 +1200,7 @@ void MarkCompactCollector::MarkSymbolTable() { ...@@ -1199,7 +1200,7 @@ void MarkCompactCollector::MarkSymbolTable() {
void MarkCompactCollector::MarkRoots(RootMarkingVisitor* visitor) { void MarkCompactCollector::MarkRoots(RootMarkingVisitor* visitor) {
// Mark the heap roots including global variables, stack variables, // Mark the heap roots including global variables, stack variables,
// etc., and all objects reachable from them. // etc., and all objects reachable from them.
HEAP->IterateStrongRoots(visitor, VISIT_ONLY_STRONG); heap()->IterateStrongRoots(visitor, VISIT_ONLY_STRONG);
// Handle the symbol table specially. // Handle the symbol table specially.
MarkSymbolTable(); MarkSymbolTable();
...@@ -1214,7 +1215,7 @@ void MarkCompactCollector::MarkRoots(RootMarkingVisitor* visitor) { ...@@ -1214,7 +1215,7 @@ void MarkCompactCollector::MarkRoots(RootMarkingVisitor* visitor) {
void MarkCompactCollector::MarkObjectGroups() { void MarkCompactCollector::MarkObjectGroups() {
List<ObjectGroup*>* object_groups = List<ObjectGroup*>* object_groups =
heap_->isolate()->global_handles()->object_groups(); heap()->isolate()->global_handles()->object_groups();
for (int i = 0; i < object_groups->length(); i++) { for (int i = 0; i < object_groups->length(); i++) {
ObjectGroup* entry = object_groups->at(i); ObjectGroup* entry = object_groups->at(i);
...@@ -1250,7 +1251,7 @@ void MarkCompactCollector::MarkObjectGroups() { ...@@ -1250,7 +1251,7 @@ void MarkCompactCollector::MarkObjectGroups() {
void MarkCompactCollector::MarkImplicitRefGroups() { void MarkCompactCollector::MarkImplicitRefGroups() {
List<ImplicitRefGroup*>* ref_groups = List<ImplicitRefGroup*>* ref_groups =
heap_->isolate()->global_handles()->implicit_ref_groups(); heap()->isolate()->global_handles()->implicit_ref_groups();
for (int i = 0; i < ref_groups->length(); i++) { for (int i = 0; i < ref_groups->length(); i++) {
ImplicitRefGroup* entry = ref_groups->at(i); ImplicitRefGroup* entry = ref_groups->at(i);
...@@ -1283,7 +1284,7 @@ void MarkCompactCollector::EmptyMarkingStack() { ...@@ -1283,7 +1284,7 @@ void MarkCompactCollector::EmptyMarkingStack() {
while (!marking_stack_.is_empty()) { while (!marking_stack_.is_empty()) {
HeapObject* object = marking_stack_.Pop(); HeapObject* object = marking_stack_.Pop();
ASSERT(object->IsHeapObject()); ASSERT(object->IsHeapObject());
ASSERT(heap_->Contains(object)); ASSERT(heap()->Contains(object));
ASSERT(object->IsMarked()); ASSERT(object->IsMarked());
ASSERT(!object->IsOverflowed()); ASSERT(!object->IsOverflowed());
...@@ -1307,32 +1308,32 @@ void MarkCompactCollector::EmptyMarkingStack() { ...@@ -1307,32 +1308,32 @@ void MarkCompactCollector::EmptyMarkingStack() {
void MarkCompactCollector::RefillMarkingStack() { void MarkCompactCollector::RefillMarkingStack() {
ASSERT(marking_stack_.overflowed()); ASSERT(marking_stack_.overflowed());
SemiSpaceIterator new_it(HEAP->new_space(), &OverflowObjectSize); SemiSpaceIterator new_it(heap()->new_space(), &OverflowObjectSize);
OverflowedObjectsScanner::ScanOverflowedObjects(this, &new_it); OverflowedObjectsScanner::ScanOverflowedObjects(this, &new_it);
if (marking_stack_.is_full()) return; if (marking_stack_.is_full()) return;
HeapObjectIterator old_pointer_it(HEAP->old_pointer_space(), HeapObjectIterator old_pointer_it(heap()->old_pointer_space(),
&OverflowObjectSize); &OverflowObjectSize);
OverflowedObjectsScanner::ScanOverflowedObjects(this, &old_pointer_it); OverflowedObjectsScanner::ScanOverflowedObjects(this, &old_pointer_it);
if (marking_stack_.is_full()) return; if (marking_stack_.is_full()) return;
HeapObjectIterator old_data_it(HEAP->old_data_space(), &OverflowObjectSize); HeapObjectIterator old_data_it(heap()->old_data_space(), &OverflowObjectSize);
OverflowedObjectsScanner::ScanOverflowedObjects(this, &old_data_it); OverflowedObjectsScanner::ScanOverflowedObjects(this, &old_data_it);
if (marking_stack_.is_full()) return; if (marking_stack_.is_full()) return;
HeapObjectIterator code_it(HEAP->code_space(), &OverflowObjectSize); HeapObjectIterator code_it(heap()->code_space(), &OverflowObjectSize);
OverflowedObjectsScanner::ScanOverflowedObjects(this, &code_it); OverflowedObjectsScanner::ScanOverflowedObjects(this, &code_it);
if (marking_stack_.is_full()) return; if (marking_stack_.is_full()) return;
HeapObjectIterator map_it(HEAP->map_space(), &OverflowObjectSize); HeapObjectIterator map_it(heap()->map_space(), &OverflowObjectSize);
OverflowedObjectsScanner::ScanOverflowedObjects(this, &map_it); OverflowedObjectsScanner::ScanOverflowedObjects(this, &map_it);
if (marking_stack_.is_full()) return; if (marking_stack_.is_full()) return;
HeapObjectIterator cell_it(HEAP->cell_space(), &OverflowObjectSize); HeapObjectIterator cell_it(heap()->cell_space(), &OverflowObjectSize);
OverflowedObjectsScanner::ScanOverflowedObjects(this, &cell_it); OverflowedObjectsScanner::ScanOverflowedObjects(this, &cell_it);
if (marking_stack_.is_full()) return; if (marking_stack_.is_full()) return;
LargeObjectIterator lo_it(HEAP->lo_space(), &OverflowObjectSize); LargeObjectIterator lo_it(heap()->lo_space(), &OverflowObjectSize);
OverflowedObjectsScanner::ScanOverflowedObjects(this, &lo_it); OverflowedObjectsScanner::ScanOverflowedObjects(this, &lo_it);
if (marking_stack_.is_full()) return; if (marking_stack_.is_full()) return;
...@@ -1370,7 +1371,7 @@ void MarkCompactCollector::MarkLiveObjects() { ...@@ -1370,7 +1371,7 @@ void MarkCompactCollector::MarkLiveObjects() {
// The recursive GC marker detects when it is nearing stack overflow, // The recursive GC marker detects when it is nearing stack overflow,
// and switches to a different marking system. JS interrupts interfere // and switches to a different marking system. JS interrupts interfere
// with the C stack limit check. // with the C stack limit check.
PostponeInterruptsScope postpone(heap_->isolate()); PostponeInterruptsScope postpone(heap()->isolate());
#ifdef DEBUG #ifdef DEBUG
ASSERT(state_ == PREPARE_GC); ASSERT(state_ == PREPARE_GC);
...@@ -1378,14 +1379,14 @@ void MarkCompactCollector::MarkLiveObjects() { ...@@ -1378,14 +1379,14 @@ void MarkCompactCollector::MarkLiveObjects() {
#endif #endif
// The to space contains live objects, the from space is used as a marking // The to space contains live objects, the from space is used as a marking
// stack. // stack.
marking_stack_.Initialize(heap_->new_space()->FromSpaceLow(), marking_stack_.Initialize(heap()->new_space()->FromSpaceLow(),
heap_->new_space()->FromSpaceHigh()); heap()->new_space()->FromSpaceHigh());
ASSERT(!marking_stack_.overflowed()); ASSERT(!marking_stack_.overflowed());
PrepareForCodeFlushing(); PrepareForCodeFlushing();
RootMarkingVisitor root_visitor(heap_); RootMarkingVisitor root_visitor(heap());
MarkRoots(&root_visitor); MarkRoots(&root_visitor);
// The objects reachable from the roots are marked, yet unreachable // The objects reachable from the roots are marked, yet unreachable
...@@ -1399,10 +1400,10 @@ void MarkCompactCollector::MarkLiveObjects() { ...@@ -1399,10 +1400,10 @@ void MarkCompactCollector::MarkLiveObjects() {
// //
// First we identify nonlive weak handles and mark them as pending // First we identify nonlive weak handles and mark them as pending
// destruction. // destruction.
heap_->isolate()->global_handles()->IdentifyWeakHandles( heap()->isolate()->global_handles()->IdentifyWeakHandles(
&IsUnmarkedHeapObject); &IsUnmarkedHeapObject);
// Then we mark the objects and process the transitive closure. // Then we mark the objects and process the transitive closure.
heap_->isolate()->global_handles()->IterateWeakRoots(&root_visitor); heap()->isolate()->global_handles()->IterateWeakRoots(&root_visitor);
while (marking_stack_.overflowed()) { while (marking_stack_.overflowed()) {
RefillMarkingStack(); RefillMarkingStack();
EmptyMarkingStack(); EmptyMarkingStack();
...@@ -1415,20 +1416,20 @@ void MarkCompactCollector::MarkLiveObjects() { ...@@ -1415,20 +1416,20 @@ void MarkCompactCollector::MarkLiveObjects() {
// Prune the symbol table removing all symbols only pointed to by the // Prune the symbol table removing all symbols only pointed to by the
// symbol table. Cannot use symbol_table() here because the symbol // symbol table. Cannot use symbol_table() here because the symbol
// table is marked. // table is marked.
SymbolTable* symbol_table = heap_->raw_unchecked_symbol_table(); SymbolTable* symbol_table = heap()->raw_unchecked_symbol_table();
SymbolTableCleaner v; SymbolTableCleaner v(heap());
symbol_table->IterateElements(&v); symbol_table->IterateElements(&v);
symbol_table->ElementsRemoved(v.PointersRemoved()); symbol_table->ElementsRemoved(v.PointersRemoved());
heap_->external_string_table_.Iterate(&v); heap()->external_string_table_.Iterate(&v);
heap_->external_string_table_.CleanUp(); heap()->external_string_table_.CleanUp();
// Process the weak references. // Process the weak references.
MarkCompactWeakObjectRetainer mark_compact_object_retainer; MarkCompactWeakObjectRetainer mark_compact_object_retainer;
heap_->ProcessWeakReferences(&mark_compact_object_retainer); heap()->ProcessWeakReferences(&mark_compact_object_retainer);
// Remove object groups after marking phase. // Remove object groups after marking phase.
heap_->isolate()->global_handles()->RemoveObjectGroups(); heap()->isolate()->global_handles()->RemoveObjectGroups();
heap_->isolate()->global_handles()->RemoveImplicitRefGroups(); heap()->isolate()->global_handles()->RemoveImplicitRefGroups();
// Flush code from collected candidates. // Flush code from collected candidates.
if (is_code_flushing_enabled()) { if (is_code_flushing_enabled()) {
...@@ -1436,28 +1437,28 @@ void MarkCompactCollector::MarkLiveObjects() { ...@@ -1436,28 +1437,28 @@ void MarkCompactCollector::MarkLiveObjects() {
} }
// Clean up dead objects from the runtime profiler. // Clean up dead objects from the runtime profiler.
heap_->isolate()->runtime_profiler()->RemoveDeadSamples(); heap()->isolate()->runtime_profiler()->RemoveDeadSamples();
} }
#ifdef DEBUG #ifdef DEBUG
void MarkCompactCollector::UpdateLiveObjectCount(HeapObject* obj) { void MarkCompactCollector::UpdateLiveObjectCount(HeapObject* obj) {
live_bytes_ += obj->Size(); live_bytes_ += obj->Size();
if (HEAP->new_space()->Contains(obj)) { if (heap()->new_space()->Contains(obj)) {
live_young_objects_size_ += obj->Size(); live_young_objects_size_ += obj->Size();
} else if (HEAP->map_space()->Contains(obj)) { } else if (heap()->map_space()->Contains(obj)) {
ASSERT(obj->IsMap()); ASSERT(obj->IsMap());
live_map_objects_size_ += obj->Size(); live_map_objects_size_ += obj->Size();
} else if (HEAP->cell_space()->Contains(obj)) { } else if (heap()->cell_space()->Contains(obj)) {
ASSERT(obj->IsJSGlobalPropertyCell()); ASSERT(obj->IsJSGlobalPropertyCell());
live_cell_objects_size_ += obj->Size(); live_cell_objects_size_ += obj->Size();
} else if (HEAP->old_pointer_space()->Contains(obj)) { } else if (heap()->old_pointer_space()->Contains(obj)) {
live_old_pointer_objects_size_ += obj->Size(); live_old_pointer_objects_size_ += obj->Size();
} else if (HEAP->old_data_space()->Contains(obj)) { } else if (heap()->old_data_space()->Contains(obj)) {
live_old_data_objects_size_ += obj->Size(); live_old_data_objects_size_ += obj->Size();
} else if (HEAP->code_space()->Contains(obj)) { } else if (heap()->code_space()->Contains(obj)) {
live_code_objects_size_ += obj->Size(); live_code_objects_size_ += obj->Size();
} else if (HEAP->lo_space()->Contains(obj)) { } else if (heap()->lo_space()->Contains(obj)) {
live_lo_objects_size_ += obj->Size(); live_lo_objects_size_ += obj->Size();
} else { } else {
UNREACHABLE(); UNREACHABLE();
...@@ -1473,7 +1474,7 @@ void MarkCompactCollector::SweepLargeObjectSpace() { ...@@ -1473,7 +1474,7 @@ void MarkCompactCollector::SweepLargeObjectSpace() {
compacting_collection_ ? ENCODE_FORWARDING_ADDRESSES : SWEEP_SPACES; compacting_collection_ ? ENCODE_FORWARDING_ADDRESSES : SWEEP_SPACES;
#endif #endif
// Deallocate unmarked objects and clear marked bits for marked objects. // Deallocate unmarked objects and clear marked bits for marked objects.
HEAP->lo_space()->FreeUnmarkedObjects(); heap()->lo_space()->FreeUnmarkedObjects();
} }
...@@ -1486,7 +1487,7 @@ bool MarkCompactCollector::SafeIsMap(HeapObject* object) { ...@@ -1486,7 +1487,7 @@ bool MarkCompactCollector::SafeIsMap(HeapObject* object) {
void MarkCompactCollector::ClearNonLiveTransitions() { void MarkCompactCollector::ClearNonLiveTransitions() {
HeapObjectIterator map_iterator(HEAP->map_space(), &SizeOfMarkedObject); HeapObjectIterator map_iterator(heap() ->map_space(), &SizeOfMarkedObject);
// Iterate over the map space, setting map transitions that go from // Iterate over the map space, setting map transitions that go from
// a marked map to an unmarked map to null transitions. At the same time, // a marked map to an unmarked map to null transitions. At the same time,
// set all the prototype fields of maps back to their original value, // set all the prototype fields of maps back to their original value,
...@@ -1536,7 +1537,7 @@ void MarkCompactCollector::ClearNonLiveTransitions() { ...@@ -1536,7 +1537,7 @@ void MarkCompactCollector::ClearNonLiveTransitions() {
// This test will always be false on the first iteration. // This test will always be false on the first iteration.
if (on_dead_path && current->IsMarked()) { if (on_dead_path && current->IsMarked()) {
on_dead_path = false; on_dead_path = false;
current->ClearNonLiveTransitions(heap_, real_prototype); current->ClearNonLiveTransitions(heap(), real_prototype);
} }
*HeapObject::RawField(current, Map::kPrototypeOffset) = *HeapObject::RawField(current, Map::kPrototypeOffset) =
real_prototype; real_prototype;
...@@ -1771,8 +1772,8 @@ void MarkCompactCollector::EncodeForwardingAddressesInNewSpace() { ...@@ -1771,8 +1772,8 @@ void MarkCompactCollector::EncodeForwardingAddressesInNewSpace() {
EncodeForwardingAddressInNewSpace, EncodeForwardingAddressInNewSpace,
IgnoreNonLiveObject>( IgnoreNonLiveObject>(
this, this,
heap_->new_space()->bottom(), heap()->new_space()->bottom(),
heap_->new_space()->top(), heap()->new_space()->top(),
&ignored); &ignored);
} }
...@@ -2194,24 +2195,24 @@ void MarkCompactCollector::EncodeForwardingAddresses() { ...@@ -2194,24 +2195,24 @@ void MarkCompactCollector::EncodeForwardingAddresses() {
// Objects in the active semispace of the young generation may be // Objects in the active semispace of the young generation may be
// relocated to the inactive semispace (if not promoted). Set the // relocated to the inactive semispace (if not promoted). Set the
// relocation info to the beginning of the inactive semispace. // relocation info to the beginning of the inactive semispace.
heap_->new_space()->MCResetRelocationInfo(); heap()->new_space()->MCResetRelocationInfo();
// Compute the forwarding pointers in each space. // Compute the forwarding pointers in each space.
EncodeForwardingAddressesInPagedSpace<MCAllocateFromOldPointerSpace, EncodeForwardingAddressesInPagedSpace<MCAllocateFromOldPointerSpace,
ReportDeleteIfNeeded>( ReportDeleteIfNeeded>(
heap_->old_pointer_space()); heap()->old_pointer_space());
EncodeForwardingAddressesInPagedSpace<MCAllocateFromOldDataSpace, EncodeForwardingAddressesInPagedSpace<MCAllocateFromOldDataSpace,
IgnoreNonLiveObject>( IgnoreNonLiveObject>(
heap_->old_data_space()); heap()->old_data_space());
EncodeForwardingAddressesInPagedSpace<MCAllocateFromCodeSpace, EncodeForwardingAddressesInPagedSpace<MCAllocateFromCodeSpace,
ReportDeleteIfNeeded>( ReportDeleteIfNeeded>(
heap_->code_space()); heap()->code_space());
EncodeForwardingAddressesInPagedSpace<MCAllocateFromCellSpace, EncodeForwardingAddressesInPagedSpace<MCAllocateFromCellSpace,
IgnoreNonLiveObject>( IgnoreNonLiveObject>(
heap_->cell_space()); heap()->cell_space());
// Compute new space next to last after the old and code spaces have been // Compute new space next to last after the old and code spaces have been
...@@ -2223,25 +2224,26 @@ void MarkCompactCollector::EncodeForwardingAddresses() { ...@@ -2223,25 +2224,26 @@ void MarkCompactCollector::EncodeForwardingAddresses() {
// non-live map pointers to get the sizes of non-live objects. // non-live map pointers to get the sizes of non-live objects.
EncodeForwardingAddressesInPagedSpace<MCAllocateFromMapSpace, EncodeForwardingAddressesInPagedSpace<MCAllocateFromMapSpace,
IgnoreNonLiveObject>( IgnoreNonLiveObject>(
heap_->map_space()); heap()->map_space());
// Write relocation info to the top page, so we can use it later. This is // Write relocation info to the top page, so we can use it later. This is
// done after promoting objects from the new space so we get the correct // done after promoting objects from the new space so we get the correct
// allocation top. // allocation top.
heap_->old_pointer_space()->MCWriteRelocationInfoToPage(); heap()->old_pointer_space()->MCWriteRelocationInfoToPage();
heap_->old_data_space()->MCWriteRelocationInfoToPage(); heap()->old_data_space()->MCWriteRelocationInfoToPage();
heap_->code_space()->MCWriteRelocationInfoToPage(); heap()->code_space()->MCWriteRelocationInfoToPage();
heap_->map_space()->MCWriteRelocationInfoToPage(); heap()->map_space()->MCWriteRelocationInfoToPage();
heap_->cell_space()->MCWriteRelocationInfoToPage(); heap()->cell_space()->MCWriteRelocationInfoToPage();
} }
class MapIterator : public HeapObjectIterator { class MapIterator : public HeapObjectIterator {
public: public:
MapIterator() : HeapObjectIterator(HEAP->map_space(), &SizeCallback) { } explicit MapIterator(Heap* heap)
: HeapObjectIterator(heap->map_space(), &SizeCallback) { }
explicit MapIterator(Address start) MapIterator(Heap* heap, Address start)
: HeapObjectIterator(HEAP->map_space(), start, &SizeCallback) { } : HeapObjectIterator(heap->map_space(), start, &SizeCallback) { }
private: private:
static int SizeCallback(HeapObject* unused) { static int SizeCallback(HeapObject* unused) {
...@@ -2257,7 +2259,8 @@ class MapCompact { ...@@ -2257,7 +2259,8 @@ class MapCompact {
: heap_(heap), : heap_(heap),
live_maps_(live_maps), live_maps_(live_maps),
to_evacuate_start_(heap->map_space()->TopAfterCompaction(live_maps)), to_evacuate_start_(heap->map_space()->TopAfterCompaction(live_maps)),
map_to_evacuate_it_(to_evacuate_start_), vacant_map_it_(heap),
map_to_evacuate_it_(heap, to_evacuate_start_),
first_map_to_evacuate_( first_map_to_evacuate_(
reinterpret_cast<Map*>(HeapObject::FromAddress(to_evacuate_start_))) { reinterpret_cast<Map*>(HeapObject::FromAddress(to_evacuate_start_))) {
} }
...@@ -2278,36 +2281,41 @@ class MapCompact { ...@@ -2278,36 +2281,41 @@ class MapCompact {
void UpdateMapPointersInRoots() { void UpdateMapPointersInRoots() {
MapUpdatingVisitor map_updating_visitor; MapUpdatingVisitor map_updating_visitor;
heap_->IterateRoots(&map_updating_visitor, VISIT_ONLY_STRONG); heap()->IterateRoots(&map_updating_visitor, VISIT_ONLY_STRONG);
heap_->isolate()->global_handles()->IterateWeakRoots(&map_updating_visitor); heap()->isolate()->global_handles()->IterateWeakRoots(
&map_updating_visitor);
LiveObjectList::IterateElements(&map_updating_visitor); LiveObjectList::IterateElements(&map_updating_visitor);
} }
void UpdateMapPointersInPagedSpace(PagedSpace* space) { void UpdateMapPointersInPagedSpace(PagedSpace* space) {
ASSERT(space != heap_->map_space()); ASSERT(space != heap()->map_space());
PageIterator it(space, PageIterator::PAGES_IN_USE); PageIterator it(space, PageIterator::PAGES_IN_USE);
while (it.has_next()) { while (it.has_next()) {
Page* p = it.next(); Page* p = it.next();
UpdateMapPointersInRange(heap_, p->ObjectAreaStart(), p->AllocationTop()); UpdateMapPointersInRange(heap(),
p->ObjectAreaStart(),
p->AllocationTop());
} }
} }
void UpdateMapPointersInNewSpace() { void UpdateMapPointersInNewSpace() {
NewSpace* space = heap_->new_space(); NewSpace* space = heap()->new_space();
UpdateMapPointersInRange(heap_, space->bottom(), space->top()); UpdateMapPointersInRange(heap(), space->bottom(), space->top());
} }
void UpdateMapPointersInLargeObjectSpace() { void UpdateMapPointersInLargeObjectSpace() {
LargeObjectIterator it(heap_->lo_space()); LargeObjectIterator it(heap()->lo_space());
for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) for (HeapObject* obj = it.next(); obj != NULL; obj = it.next())
UpdateMapPointersInObject(heap_, obj); UpdateMapPointersInObject(heap(), obj);
} }
void Finish() { void Finish() {
heap_->map_space()->FinishCompaction(to_evacuate_start_, live_maps_); heap()->map_space()->FinishCompaction(to_evacuate_start_, live_maps_);
} }
inline Heap* heap() const { return heap_; }
private: private:
Heap* heap_; Heap* heap_;
int live_maps_; int live_maps_;
...@@ -2457,26 +2465,26 @@ void MarkCompactCollector::SweepSpaces() { ...@@ -2457,26 +2465,26 @@ void MarkCompactCollector::SweepSpaces() {
// the map space last because freeing non-live maps overwrites them and // the map space last because freeing non-live maps overwrites them and
// the other spaces rely on possibly non-live maps to get the sizes for // the other spaces rely on possibly non-live maps to get the sizes for
// non-live objects. // non-live objects.
SweepSpace(heap_, heap_->old_pointer_space()); SweepSpace(heap(), heap()->old_pointer_space());
SweepSpace(heap_, heap_->old_data_space()); SweepSpace(heap(), heap()->old_data_space());
SweepSpace(heap_, heap_->code_space()); SweepSpace(heap(), heap()->code_space());
SweepSpace(heap_, heap_->cell_space()); SweepSpace(heap(), heap()->cell_space());
{ GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP_NEWSPACE); { GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP_NEWSPACE);
SweepNewSpace(heap_, heap_->new_space()); SweepNewSpace(heap(), heap()->new_space());
} }
SweepSpace(heap_, heap_->map_space()); SweepSpace(heap(), heap()->map_space());
heap_->IterateDirtyRegions(heap_->map_space(), heap()->IterateDirtyRegions(heap()->map_space(),
&heap_->IteratePointersInDirtyMapsRegion, &heap()->IteratePointersInDirtyMapsRegion,
&UpdatePointerToNewGen, &UpdatePointerToNewGen,
heap_->WATERMARK_SHOULD_BE_VALID); heap()->WATERMARK_SHOULD_BE_VALID);
intptr_t live_maps_size = heap_->map_space()->Size(); intptr_t live_maps_size = heap()->map_space()->Size();
int live_maps = static_cast<int>(live_maps_size / Map::kSize); int live_maps = static_cast<int>(live_maps_size / Map::kSize);
ASSERT(live_map_objects_size_ == live_maps_size); ASSERT(live_map_objects_size_ == live_maps_size);
if (heap_->map_space()->NeedsCompaction(live_maps)) { if (heap()->map_space()->NeedsCompaction(live_maps)) {
MapCompact map_compact(heap_, live_maps); MapCompact map_compact(heap(), live_maps);
map_compact.CompactMaps(); map_compact.CompactMaps();
map_compact.UpdateMapPointersInRoots(); map_compact.UpdateMapPointersInRoots();
...@@ -2484,7 +2492,7 @@ void MarkCompactCollector::SweepSpaces() { ...@@ -2484,7 +2492,7 @@ void MarkCompactCollector::SweepSpaces() {
PagedSpaces spaces; PagedSpaces spaces;
for (PagedSpace* space = spaces.next(); for (PagedSpace* space = spaces.next();
space != NULL; space = spaces.next()) { space != NULL; space = spaces.next()) {
if (space == heap_->map_space()) continue; if (space == heap()->map_space()) continue;
map_compact.UpdateMapPointersInPagedSpace(space); map_compact.UpdateMapPointersInPagedSpace(space);
} }
map_compact.UpdateMapPointersInNewSpace(); map_compact.UpdateMapPointersInNewSpace();
...@@ -2580,6 +2588,8 @@ class UpdatingVisitor: public ObjectVisitor { ...@@ -2580,6 +2588,8 @@ class UpdatingVisitor: public ObjectVisitor {
reinterpret_cast<Code*>(target)->instruction_start()); reinterpret_cast<Code*>(target)->instruction_start());
} }
inline Heap* heap() const { return heap_; }
private: private:
void UpdatePointer(Object** p) { void UpdatePointer(Object** p) {
if (!(*p)->IsHeapObject()) return; if (!(*p)->IsHeapObject()) return;
...@@ -2587,27 +2597,27 @@ class UpdatingVisitor: public ObjectVisitor { ...@@ -2587,27 +2597,27 @@ class UpdatingVisitor: public ObjectVisitor {
HeapObject* obj = HeapObject::cast(*p); HeapObject* obj = HeapObject::cast(*p);
Address old_addr = obj->address(); Address old_addr = obj->address();
Address new_addr; Address new_addr;
ASSERT(!heap_->InFromSpace(obj)); ASSERT(!heap()->InFromSpace(obj));
if (heap_->new_space()->Contains(obj)) { if (heap()->new_space()->Contains(obj)) {
Address forwarding_pointer_addr = Address forwarding_pointer_addr =
heap_->new_space()->FromSpaceLow() + heap()->new_space()->FromSpaceLow() +
heap_->new_space()->ToSpaceOffsetForAddress(old_addr); heap()->new_space()->ToSpaceOffsetForAddress(old_addr);
new_addr = Memory::Address_at(forwarding_pointer_addr); new_addr = Memory::Address_at(forwarding_pointer_addr);
#ifdef DEBUG #ifdef DEBUG
ASSERT(heap_->old_pointer_space()->Contains(new_addr) || ASSERT(heap()->old_pointer_space()->Contains(new_addr) ||
heap_->old_data_space()->Contains(new_addr) || heap()->old_data_space()->Contains(new_addr) ||
heap_->new_space()->FromSpaceContains(new_addr) || heap()->new_space()->FromSpaceContains(new_addr) ||
heap_->lo_space()->Contains(HeapObject::FromAddress(new_addr))); heap()->lo_space()->Contains(HeapObject::FromAddress(new_addr)));
if (heap_->new_space()->FromSpaceContains(new_addr)) { if (heap()->new_space()->FromSpaceContains(new_addr)) {
ASSERT(heap_->new_space()->FromSpaceOffsetForAddress(new_addr) <= ASSERT(heap()->new_space()->FromSpaceOffsetForAddress(new_addr) <=
heap_->new_space()->ToSpaceOffsetForAddress(old_addr)); heap()->new_space()->ToSpaceOffsetForAddress(old_addr));
} }
#endif #endif
} else if (heap_->lo_space()->Contains(obj)) { } else if (heap()->lo_space()->Contains(obj)) {
// Don't move objects in the large object space. // Don't move objects in the large object space.
return; return;
...@@ -2646,34 +2656,34 @@ void MarkCompactCollector::UpdatePointers() { ...@@ -2646,34 +2656,34 @@ void MarkCompactCollector::UpdatePointers() {
ASSERT(state_ == ENCODE_FORWARDING_ADDRESSES); ASSERT(state_ == ENCODE_FORWARDING_ADDRESSES);
state_ = UPDATE_POINTERS; state_ = UPDATE_POINTERS;
#endif #endif
UpdatingVisitor updating_visitor(heap_); UpdatingVisitor updating_visitor(heap());
heap_->isolate()->runtime_profiler()->UpdateSamplesAfterCompact( heap()->isolate()->runtime_profiler()->UpdateSamplesAfterCompact(
&updating_visitor); &updating_visitor);
heap_->IterateRoots(&updating_visitor, VISIT_ONLY_STRONG); heap()->IterateRoots(&updating_visitor, VISIT_ONLY_STRONG);
heap_->isolate()->global_handles()->IterateWeakRoots(&updating_visitor); heap()->isolate()->global_handles()->IterateWeakRoots(&updating_visitor);
// Update the pointer to the head of the weak list of global contexts. // Update the pointer to the head of the weak list of global contexts.
updating_visitor.VisitPointer(&heap_->global_contexts_list_); updating_visitor.VisitPointer(&heap()->global_contexts_list_);
LiveObjectList::IterateElements(&updating_visitor); LiveObjectList::IterateElements(&updating_visitor);
int live_maps_size = IterateLiveObjects( int live_maps_size = IterateLiveObjects(
heap_->map_space(), &MarkCompactCollector::UpdatePointersInOldObject); heap()->map_space(), &MarkCompactCollector::UpdatePointersInOldObject);
int live_pointer_olds_size = IterateLiveObjects( int live_pointer_olds_size = IterateLiveObjects(
heap_->old_pointer_space(), heap()->old_pointer_space(),
&MarkCompactCollector::UpdatePointersInOldObject); &MarkCompactCollector::UpdatePointersInOldObject);
int live_data_olds_size = IterateLiveObjects( int live_data_olds_size = IterateLiveObjects(
heap_->old_data_space(), heap()->old_data_space(),
&MarkCompactCollector::UpdatePointersInOldObject); &MarkCompactCollector::UpdatePointersInOldObject);
int live_codes_size = IterateLiveObjects( int live_codes_size = IterateLiveObjects(
heap_->code_space(), &MarkCompactCollector::UpdatePointersInOldObject); heap()->code_space(), &MarkCompactCollector::UpdatePointersInOldObject);
int live_cells_size = IterateLiveObjects( int live_cells_size = IterateLiveObjects(
heap_->cell_space(), &MarkCompactCollector::UpdatePointersInOldObject); heap()->cell_space(), &MarkCompactCollector::UpdatePointersInOldObject);
int live_news_size = IterateLiveObjects( int live_news_size = IterateLiveObjects(
heap_->new_space(), &MarkCompactCollector::UpdatePointersInNewObject); heap()->new_space(), &MarkCompactCollector::UpdatePointersInNewObject);
// Large objects do not move, the map word can be updated directly. // Large objects do not move, the map word can be updated directly.
LargeObjectIterator it(heap_->lo_space()); LargeObjectIterator it(heap()->lo_space());
for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) { for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) {
UpdatePointersInNewObject(obj); UpdatePointersInNewObject(obj);
} }
...@@ -2700,8 +2710,8 @@ int MarkCompactCollector::UpdatePointersInNewObject(HeapObject* obj) { ...@@ -2700,8 +2710,8 @@ int MarkCompactCollector::UpdatePointersInNewObject(HeapObject* obj) {
Address forwarded = GetForwardingAddressInOldSpace(old_map); Address forwarded = GetForwardingAddressInOldSpace(old_map);
ASSERT(heap_->map_space()->Contains(old_map)); ASSERT(heap()->map_space()->Contains(old_map));
ASSERT(heap_->map_space()->Contains(forwarded)); ASSERT(heap()->map_space()->Contains(forwarded));
#ifdef DEBUG #ifdef DEBUG
if (FLAG_gc_verbose) { if (FLAG_gc_verbose) {
PrintF("update %p : %p -> %p\n", obj->address(), old_map->address(), PrintF("update %p : %p -> %p\n", obj->address(), old_map->address(),
...@@ -2716,7 +2726,7 @@ int MarkCompactCollector::UpdatePointersInNewObject(HeapObject* obj) { ...@@ -2716,7 +2726,7 @@ int MarkCompactCollector::UpdatePointersInNewObject(HeapObject* obj) {
int obj_size = obj->SizeFromMap(old_map); int obj_size = obj->SizeFromMap(old_map);
// Update pointers in the object body. // Update pointers in the object body.
UpdatingVisitor updating_visitor(heap_); UpdatingVisitor updating_visitor(heap());
obj->IterateBody(old_map->instance_type(), obj_size, &updating_visitor); obj->IterateBody(old_map->instance_type(), obj_size, &updating_visitor);
return obj_size; return obj_size;
} }
...@@ -2725,8 +2735,8 @@ int MarkCompactCollector::UpdatePointersInNewObject(HeapObject* obj) { ...@@ -2725,8 +2735,8 @@ int MarkCompactCollector::UpdatePointersInNewObject(HeapObject* obj) {
int MarkCompactCollector::UpdatePointersInOldObject(HeapObject* obj) { int MarkCompactCollector::UpdatePointersInOldObject(HeapObject* obj) {
// Decode the map pointer. // Decode the map pointer.
MapWord encoding = obj->map_word(); MapWord encoding = obj->map_word();
Address map_addr = encoding.DecodeMapAddress(heap_->map_space()); Address map_addr = encoding.DecodeMapAddress(heap()->map_space());
ASSERT(heap_->map_space()->Contains(HeapObject::FromAddress(map_addr))); ASSERT(heap()->map_space()->Contains(HeapObject::FromAddress(map_addr)));
// At this point, the first word of map_addr is also encoded, cannot // At this point, the first word of map_addr is also encoded, cannot
// cast it to Map* using Map::cast. // cast it to Map* using Map::cast.
...@@ -2747,7 +2757,7 @@ int MarkCompactCollector::UpdatePointersInOldObject(HeapObject* obj) { ...@@ -2747,7 +2757,7 @@ int MarkCompactCollector::UpdatePointersInOldObject(HeapObject* obj) {
#endif #endif
// Update pointers in the object body. // Update pointers in the object body.
UpdatingVisitor updating_visitor(heap_); UpdatingVisitor updating_visitor(heap());
obj->IterateBody(type, obj_size, &updating_visitor); obj->IterateBody(type, obj_size, &updating_visitor);
return obj_size; return obj_size;
} }
...@@ -2804,18 +2814,18 @@ void MarkCompactCollector::RelocateObjects() { ...@@ -2804,18 +2814,18 @@ void MarkCompactCollector::RelocateObjects() {
// Relocates objects, always relocate map objects first. Relocating // Relocates objects, always relocate map objects first. Relocating
// objects in other space relies on map objects to get object size. // objects in other space relies on map objects to get object size.
int live_maps_size = IterateLiveObjects( int live_maps_size = IterateLiveObjects(
heap_->map_space(), &MarkCompactCollector::RelocateMapObject); heap()->map_space(), &MarkCompactCollector::RelocateMapObject);
int live_pointer_olds_size = IterateLiveObjects( int live_pointer_olds_size = IterateLiveObjects(
heap_->old_pointer_space(), heap()->old_pointer_space(),
&MarkCompactCollector::RelocateOldPointerObject); &MarkCompactCollector::RelocateOldPointerObject);
int live_data_olds_size = IterateLiveObjects( int live_data_olds_size = IterateLiveObjects(
heap_->old_data_space(), &MarkCompactCollector::RelocateOldDataObject); heap()->old_data_space(), &MarkCompactCollector::RelocateOldDataObject);
int live_codes_size = IterateLiveObjects( int live_codes_size = IterateLiveObjects(
heap_->code_space(), &MarkCompactCollector::RelocateCodeObject); heap()->code_space(), &MarkCompactCollector::RelocateCodeObject);
int live_cells_size = IterateLiveObjects( int live_cells_size = IterateLiveObjects(
heap_->cell_space(), &MarkCompactCollector::RelocateCellObject); heap()->cell_space(), &MarkCompactCollector::RelocateCellObject);
int live_news_size = IterateLiveObjects( int live_news_size = IterateLiveObjects(
heap_->new_space(), &MarkCompactCollector::RelocateNewObject); heap()->new_space(), &MarkCompactCollector::RelocateNewObject);
USE(live_maps_size); USE(live_maps_size);
USE(live_pointer_olds_size); USE(live_pointer_olds_size);
...@@ -2831,28 +2841,28 @@ void MarkCompactCollector::RelocateObjects() { ...@@ -2831,28 +2841,28 @@ void MarkCompactCollector::RelocateObjects() {
ASSERT(live_news_size == live_young_objects_size_); ASSERT(live_news_size == live_young_objects_size_);
// Flip from and to spaces // Flip from and to spaces
heap_->new_space()->Flip(); heap()->new_space()->Flip();
heap_->new_space()->MCCommitRelocationInfo(); heap()->new_space()->MCCommitRelocationInfo();
// Set age_mark to bottom in to space // Set age_mark to bottom in to space
Address mark = heap_->new_space()->bottom(); Address mark = heap()->new_space()->bottom();
heap_->new_space()->set_age_mark(mark); heap()->new_space()->set_age_mark(mark);
PagedSpaces spaces; PagedSpaces spaces;
for (PagedSpace* space = spaces.next(); space != NULL; space = spaces.next()) for (PagedSpace* space = spaces.next(); space != NULL; space = spaces.next())
space->MCCommitRelocationInfo(); space->MCCommitRelocationInfo();
heap_->CheckNewSpaceExpansionCriteria(); heap()->CheckNewSpaceExpansionCriteria();
heap_->IncrementYoungSurvivorsCounter(live_news_size); heap()->IncrementYoungSurvivorsCounter(live_news_size);
} }
int MarkCompactCollector::RelocateMapObject(HeapObject* obj) { int MarkCompactCollector::RelocateMapObject(HeapObject* obj) {
// Recover map pointer. // Recover map pointer.
MapWord encoding = obj->map_word(); MapWord encoding = obj->map_word();
Address map_addr = encoding.DecodeMapAddress(heap_->map_space()); Address map_addr = encoding.DecodeMapAddress(heap()->map_space());
ASSERT(heap_->map_space()->Contains(HeapObject::FromAddress(map_addr))); ASSERT(heap()->map_space()->Contains(HeapObject::FromAddress(map_addr)));
// Get forwarding address before resetting map pointer // Get forwarding address before resetting map pointer
Address new_addr = GetForwardingAddressInOldSpace(obj); Address new_addr = GetForwardingAddressInOldSpace(obj);
...@@ -2865,7 +2875,7 @@ int MarkCompactCollector::RelocateMapObject(HeapObject* obj) { ...@@ -2865,7 +2875,7 @@ int MarkCompactCollector::RelocateMapObject(HeapObject* obj) {
if (new_addr != old_addr) { if (new_addr != old_addr) {
// Move contents. // Move contents.
heap_->MoveBlockToOldSpaceAndUpdateRegionMarks(new_addr, heap()->MoveBlockToOldSpaceAndUpdateRegionMarks(new_addr,
old_addr, old_addr,
Map::kSize); Map::kSize);
} }
...@@ -2911,8 +2921,8 @@ int MarkCompactCollector::RelocateOldNonCodeObject(HeapObject* obj, ...@@ -2911,8 +2921,8 @@ int MarkCompactCollector::RelocateOldNonCodeObject(HeapObject* obj,
PagedSpace* space) { PagedSpace* space) {
// Recover map pointer. // Recover map pointer.
MapWord encoding = obj->map_word(); MapWord encoding = obj->map_word();
Address map_addr = encoding.DecodeMapAddress(heap_->map_space()); Address map_addr = encoding.DecodeMapAddress(heap()->map_space());
ASSERT(heap_->map_space()->Contains(map_addr)); ASSERT(heap()->map_space()->Contains(map_addr));
// Get forwarding address before resetting map pointer. // Get forwarding address before resetting map pointer.
Address new_addr = GetForwardingAddressInOldSpace(obj); Address new_addr = GetForwardingAddressInOldSpace(obj);
...@@ -2924,10 +2934,10 @@ int MarkCompactCollector::RelocateOldNonCodeObject(HeapObject* obj, ...@@ -2924,10 +2934,10 @@ int MarkCompactCollector::RelocateOldNonCodeObject(HeapObject* obj,
if (new_addr != old_addr) { if (new_addr != old_addr) {
// Move contents. // Move contents.
if (space == heap_->old_data_space()) { if (space == heap()->old_data_space()) {
heap_->MoveBlock(new_addr, old_addr, obj_size); heap()->MoveBlock(new_addr, old_addr, obj_size);
} else { } else {
heap_->MoveBlockToOldSpaceAndUpdateRegionMarks(new_addr, heap()->MoveBlockToOldSpaceAndUpdateRegionMarks(new_addr,
old_addr, old_addr,
obj_size); obj_size);
} }
...@@ -2937,47 +2947,47 @@ int MarkCompactCollector::RelocateOldNonCodeObject(HeapObject* obj, ...@@ -2937,47 +2947,47 @@ int MarkCompactCollector::RelocateOldNonCodeObject(HeapObject* obj,
HeapObject* copied_to = HeapObject::FromAddress(new_addr); HeapObject* copied_to = HeapObject::FromAddress(new_addr);
if (copied_to->IsSharedFunctionInfo()) { if (copied_to->IsSharedFunctionInfo()) {
PROFILE(heap_->isolate(), PROFILE(heap()->isolate(),
SharedFunctionInfoMoveEvent(old_addr, new_addr)); SharedFunctionInfoMoveEvent(old_addr, new_addr));
} }
HEAP_PROFILE(heap_, ObjectMoveEvent(old_addr, new_addr)); HEAP_PROFILE(heap(), ObjectMoveEvent(old_addr, new_addr));
return obj_size; return obj_size;
} }
int MarkCompactCollector::RelocateOldPointerObject(HeapObject* obj) { int MarkCompactCollector::RelocateOldPointerObject(HeapObject* obj) {
return RelocateOldNonCodeObject(obj, heap_->old_pointer_space()); return RelocateOldNonCodeObject(obj, heap()->old_pointer_space());
} }
int MarkCompactCollector::RelocateOldDataObject(HeapObject* obj) { int MarkCompactCollector::RelocateOldDataObject(HeapObject* obj) {
return RelocateOldNonCodeObject(obj, heap_->old_data_space()); return RelocateOldNonCodeObject(obj, heap()->old_data_space());
} }
int MarkCompactCollector::RelocateCellObject(HeapObject* obj) { int MarkCompactCollector::RelocateCellObject(HeapObject* obj) {
return RelocateOldNonCodeObject(obj, heap_->cell_space()); return RelocateOldNonCodeObject(obj, heap()->cell_space());
} }
int MarkCompactCollector::RelocateCodeObject(HeapObject* obj) { int MarkCompactCollector::RelocateCodeObject(HeapObject* obj) {
// Recover map pointer. // Recover map pointer.
MapWord encoding = obj->map_word(); MapWord encoding = obj->map_word();
Address map_addr = encoding.DecodeMapAddress(heap_->map_space()); Address map_addr = encoding.DecodeMapAddress(heap()->map_space());
ASSERT(heap_->map_space()->Contains(HeapObject::FromAddress(map_addr))); ASSERT(heap()->map_space()->Contains(HeapObject::FromAddress(map_addr)));
// Get forwarding address before resetting map pointer // Get forwarding address before resetting map pointer
Address new_addr = GetForwardingAddressInOldSpace(obj); Address new_addr = GetForwardingAddressInOldSpace(obj);
// Reset the map pointer. // Reset the map pointer.
int obj_size = RestoreMap(obj, heap_->code_space(), new_addr, map_addr); int obj_size = RestoreMap(obj, heap()->code_space(), new_addr, map_addr);
Address old_addr = obj->address(); Address old_addr = obj->address();
if (new_addr != old_addr) { if (new_addr != old_addr) {
// Move contents. // Move contents.
heap_->MoveBlock(new_addr, old_addr, obj_size); heap()->MoveBlock(new_addr, old_addr, obj_size);
} }
HeapObject* copied_to = HeapObject::FromAddress(new_addr); HeapObject* copied_to = HeapObject::FromAddress(new_addr);
...@@ -2985,9 +2995,9 @@ int MarkCompactCollector::RelocateCodeObject(HeapObject* obj) { ...@@ -2985,9 +2995,9 @@ int MarkCompactCollector::RelocateCodeObject(HeapObject* obj) {
// May also update inline cache target. // May also update inline cache target.
Code::cast(copied_to)->Relocate(new_addr - old_addr); Code::cast(copied_to)->Relocate(new_addr - old_addr);
// Notify the logger that compiled code has moved. // Notify the logger that compiled code has moved.
PROFILE(heap_->isolate(), CodeMoveEvent(old_addr, new_addr)); PROFILE(heap()->isolate(), CodeMoveEvent(old_addr, new_addr));
} }
HEAP_PROFILE(heap_, ObjectMoveEvent(old_addr, new_addr)); HEAP_PROFILE(heap(), ObjectMoveEvent(old_addr, new_addr));
return obj_size; return obj_size;
} }
...@@ -2998,26 +3008,26 @@ int MarkCompactCollector::RelocateNewObject(HeapObject* obj) { ...@@ -2998,26 +3008,26 @@ int MarkCompactCollector::RelocateNewObject(HeapObject* obj) {
// Get forwarding address // Get forwarding address
Address old_addr = obj->address(); Address old_addr = obj->address();
int offset = heap_->new_space()->ToSpaceOffsetForAddress(old_addr); int offset = heap()->new_space()->ToSpaceOffsetForAddress(old_addr);
Address new_addr = Address new_addr =
Memory::Address_at(heap_->new_space()->FromSpaceLow() + offset); Memory::Address_at(heap()->new_space()->FromSpaceLow() + offset);
#ifdef DEBUG #ifdef DEBUG
if (heap_->new_space()->FromSpaceContains(new_addr)) { if (heap()->new_space()->FromSpaceContains(new_addr)) {
ASSERT(heap_->new_space()->FromSpaceOffsetForAddress(new_addr) <= ASSERT(heap()->new_space()->FromSpaceOffsetForAddress(new_addr) <=
heap_->new_space()->ToSpaceOffsetForAddress(old_addr)); heap()->new_space()->ToSpaceOffsetForAddress(old_addr));
} else { } else {
ASSERT(heap_->TargetSpace(obj) == heap_->old_pointer_space() || ASSERT(heap()->TargetSpace(obj) == heap()->old_pointer_space() ||
heap_->TargetSpace(obj) == heap_->old_data_space()); heap()->TargetSpace(obj) == heap()->old_data_space());
} }
#endif #endif
// New and old addresses cannot overlap. // New and old addresses cannot overlap.
if (heap_->InNewSpace(HeapObject::FromAddress(new_addr))) { if (heap()->InNewSpace(HeapObject::FromAddress(new_addr))) {
heap_->CopyBlock(new_addr, old_addr, obj_size); heap()->CopyBlock(new_addr, old_addr, obj_size);
} else { } else {
heap_->CopyBlockToOldSpaceAndUpdateRegionMarks(new_addr, heap()->CopyBlockToOldSpaceAndUpdateRegionMarks(new_addr,
old_addr, old_addr,
obj_size); obj_size);
} }
...@@ -3030,10 +3040,10 @@ int MarkCompactCollector::RelocateNewObject(HeapObject* obj) { ...@@ -3030,10 +3040,10 @@ int MarkCompactCollector::RelocateNewObject(HeapObject* obj) {
HeapObject* copied_to = HeapObject::FromAddress(new_addr); HeapObject* copied_to = HeapObject::FromAddress(new_addr);
if (copied_to->IsSharedFunctionInfo()) { if (copied_to->IsSharedFunctionInfo()) {
PROFILE(heap_->isolate(), PROFILE(heap()->isolate(),
SharedFunctionInfoMoveEvent(old_addr, new_addr)); SharedFunctionInfoMoveEvent(old_addr, new_addr));
} }
HEAP_PROFILE(heap_, ObjectMoveEvent(old_addr, new_addr)); HEAP_PROFILE(heap(), ObjectMoveEvent(old_addr, new_addr));
return obj_size; return obj_size;
} }
...@@ -3042,7 +3052,7 @@ int MarkCompactCollector::RelocateNewObject(HeapObject* obj) { ...@@ -3042,7 +3052,7 @@ int MarkCompactCollector::RelocateNewObject(HeapObject* obj) {
void MarkCompactCollector::EnableCodeFlushing(bool enable) { void MarkCompactCollector::EnableCodeFlushing(bool enable) {
if (enable) { if (enable) {
if (code_flusher_ != NULL) return; if (code_flusher_ != NULL) return;
code_flusher_ = new CodeFlusher(heap_->isolate()); code_flusher_ = new CodeFlusher(heap()->isolate());
} else { } else {
if (code_flusher_ == NULL) return; if (code_flusher_ == NULL) return;
delete code_flusher_; delete code_flusher_;
......
...@@ -98,8 +98,6 @@ class MarkingStack { ...@@ -98,8 +98,6 @@ class MarkingStack {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Mark-Compact collector // Mark-Compact collector
//
// All methods are static.
class OverflowedObjectsScanner; class OverflowedObjectsScanner;
......
...@@ -393,9 +393,9 @@ void RelocInfo::Visit(Heap* heap) { ...@@ -393,9 +393,9 @@ void RelocInfo::Visit(Heap* heap) {
StaticVisitor::VisitPointer(heap, target_object_address()); StaticVisitor::VisitPointer(heap, target_object_address());
CPU::FlushICache(pc_, sizeof(Address)); CPU::FlushICache(pc_, sizeof(Address));
} else if (RelocInfo::IsCodeTarget(mode)) { } else if (RelocInfo::IsCodeTarget(mode)) {
StaticVisitor::VisitCodeTarget(this); StaticVisitor::VisitCodeTarget(heap, this);
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
StaticVisitor::VisitGlobalPropertyCell(this); StaticVisitor::VisitGlobalPropertyCell(heap, this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) { } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
StaticVisitor::VisitExternalReference(target_reference_address()); StaticVisitor::VisitExternalReference(target_reference_address());
CPU::FlushICache(pc_, sizeof(Address)); CPU::FlushICache(pc_, sizeof(Address));
...@@ -405,7 +405,7 @@ void RelocInfo::Visit(Heap* heap) { ...@@ -405,7 +405,7 @@ void RelocInfo::Visit(Heap* heap) {
IsPatchedReturnSequence()) || IsPatchedReturnSequence()) ||
(RelocInfo::IsDebugBreakSlot(mode) && (RelocInfo::IsDebugBreakSlot(mode) &&
IsPatchedDebugBreakSlotSequence()))) { IsPatchedDebugBreakSlotSequence()))) {
StaticVisitor::VisitDebugTarget(this); StaticVisitor::VisitDebugTarget(heap, this);
#endif #endif
} else if (mode == RelocInfo::RUNTIME_ENTRY) { } else if (mode == RelocInfo::RUNTIME_ENTRY) {
StaticVisitor::VisitRuntimeEntry(this); StaticVisitor::VisitRuntimeEntry(this);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment