Commit e494bcca authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Reland "[heap] No leakage of mark-compact.h outside of heap."

The revert of the original change in question did not recover
regressions, which allows us to reland this cleanup after all.

This reverts commit 871529b4.

R=hpayer@chromium.org

Review URL: https://codereview.chromium.org/1393773004

Cr-Commit-Position: refs/heads/master@{#31214}
parent f7a35b9a
...@@ -122,7 +122,7 @@ Heap::Heap() ...@@ -122,7 +122,7 @@ Heap::Heap()
last_idle_notification_time_(0.0), last_idle_notification_time_(0.0),
last_gc_time_(0.0), last_gc_time_(0.0),
scavenge_collector_(nullptr), scavenge_collector_(nullptr),
mark_compact_collector_(this), mark_compact_collector_(nullptr),
store_buffer_(this), store_buffer_(this),
incremental_marking_(nullptr), incremental_marking_(nullptr),
gc_idle_time_handler_(nullptr), gc_idle_time_handler_(nullptr),
...@@ -958,7 +958,8 @@ bool Heap::CollectGarbage(GarbageCollector collector, const char* gc_reason, ...@@ -958,7 +958,8 @@ bool Heap::CollectGarbage(GarbageCollector collector, const char* gc_reason,
incremental_marking()->Step(kStepSizeWhenDelayedByScavenge, incremental_marking()->Step(kStepSizeWhenDelayedByScavenge,
IncrementalMarking::NO_GC_VIA_STACK_GUARD); IncrementalMarking::NO_GC_VIA_STACK_GUARD);
if (!incremental_marking()->IsComplete() && if (!incremental_marking()->IsComplete() &&
!mark_compact_collector_.marking_deque_.IsEmpty() && !FLAG_gc_global) { !mark_compact_collector()->marking_deque_.IsEmpty() &&
!FLAG_gc_global) {
if (FLAG_trace_incremental_marking) { if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Delaying MarkSweep.\n"); PrintF("[IncrementalMarking] Delaying MarkSweep.\n");
} }
...@@ -1298,8 +1299,8 @@ bool Heap::PerformGarbageCollection( ...@@ -1298,8 +1299,8 @@ bool Heap::PerformGarbageCollection(
// We finished a marking cycle. We can uncommit the marking deque until // We finished a marking cycle. We can uncommit the marking deque until
// we start marking again. // we start marking again.
mark_compact_collector_.marking_deque()->Uninitialize(); mark_compact_collector()->marking_deque()->Uninitialize();
mark_compact_collector_.EnsureMarkingDequeIsCommitted( mark_compact_collector()->EnsureMarkingDequeIsCommitted(
MarkCompactCollector::kMinMarkingDequeSize); MarkCompactCollector::kMinMarkingDequeSize);
} }
...@@ -1393,13 +1394,13 @@ void Heap::MarkCompact() { ...@@ -1393,13 +1394,13 @@ void Heap::MarkCompact() {
uint64_t size_of_objects_before_gc = SizeOfObjects(); uint64_t size_of_objects_before_gc = SizeOfObjects();
mark_compact_collector_.Prepare(); mark_compact_collector()->Prepare();
ms_count_++; ms_count_++;
MarkCompactPrologue(); MarkCompactPrologue();
mark_compact_collector_.CollectGarbage(); mark_compact_collector()->CollectGarbage();
LOG(isolate_, ResourceEvent("markcompact", "end")); LOG(isolate_, ResourceEvent("markcompact", "end"));
...@@ -4071,10 +4072,10 @@ void Heap::FinalizeIncrementalMarkingIfComplete(const char* comment) { ...@@ -4071,10 +4072,10 @@ void Heap::FinalizeIncrementalMarkingIfComplete(const char* comment) {
if (FLAG_overapproximate_weak_closure && incremental_marking()->IsMarking() && if (FLAG_overapproximate_weak_closure && incremental_marking()->IsMarking() &&
(incremental_marking()->IsReadyToOverApproximateWeakClosure() || (incremental_marking()->IsReadyToOverApproximateWeakClosure() ||
(!incremental_marking()->weak_closure_was_overapproximated() && (!incremental_marking()->weak_closure_was_overapproximated() &&
mark_compact_collector_.marking_deque()->IsEmpty()))) { mark_compact_collector()->marking_deque()->IsEmpty()))) {
OverApproximateWeakClosure(comment); OverApproximateWeakClosure(comment);
} else if (incremental_marking()->IsComplete() || } else if (incremental_marking()->IsComplete() ||
(mark_compact_collector_.marking_deque()->IsEmpty())) { (mark_compact_collector()->marking_deque()->IsEmpty())) {
CollectAllGarbage(current_gc_flags_, comment); CollectAllGarbage(current_gc_flags_, comment);
} }
} }
...@@ -4088,14 +4089,14 @@ bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) { ...@@ -4088,14 +4089,14 @@ bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) {
if (FLAG_overapproximate_weak_closure && if (FLAG_overapproximate_weak_closure &&
(incremental_marking()->IsReadyToOverApproximateWeakClosure() || (incremental_marking()->IsReadyToOverApproximateWeakClosure() ||
(!incremental_marking()->weak_closure_was_overapproximated() && (!incremental_marking()->weak_closure_was_overapproximated() &&
mark_compact_collector_.marking_deque()->IsEmpty() && mark_compact_collector()->marking_deque()->IsEmpty() &&
gc_idle_time_handler_->ShouldDoOverApproximateWeakClosure( gc_idle_time_handler_->ShouldDoOverApproximateWeakClosure(
static_cast<size_t>(idle_time_in_ms))))) { static_cast<size_t>(idle_time_in_ms))))) {
OverApproximateWeakClosure( OverApproximateWeakClosure(
"Idle notification: overapproximate weak closure"); "Idle notification: overapproximate weak closure");
return true; return true;
} else if (incremental_marking()->IsComplete() || } else if (incremental_marking()->IsComplete() ||
(mark_compact_collector_.marking_deque()->IsEmpty() && (mark_compact_collector()->marking_deque()->IsEmpty() &&
gc_idle_time_handler_->ShouldDoFinalIncrementalMarkCompact( gc_idle_time_handler_->ShouldDoFinalIncrementalMarkCompact(
static_cast<size_t>(idle_time_in_ms), size_of_objects, static_cast<size_t>(idle_time_in_ms), size_of_objects,
final_incremental_mark_compact_speed_in_bytes_per_ms))) { final_incremental_mark_compact_speed_in_bytes_per_ms))) {
...@@ -4417,9 +4418,9 @@ void Heap::Verify() { ...@@ -4417,9 +4418,9 @@ void Heap::Verify() {
lo_space_->Verify(); lo_space_->Verify();
mark_compact_collector_.VerifyWeakEmbeddedObjectsInCode(); mark_compact_collector()->VerifyWeakEmbeddedObjectsInCode();
if (FLAG_omit_map_checks_for_leaf_maps) { if (FLAG_omit_map_checks_for_leaf_maps) {
mark_compact_collector_.VerifyOmittedMapChecks(); mark_compact_collector()->VerifyOmittedMapChecks();
} }
} }
#endif #endif
...@@ -5069,6 +5070,8 @@ bool Heap::SetUp() { ...@@ -5069,6 +5070,8 @@ bool Heap::SetUp() {
scavenge_collector_ = new Scavenger(this); scavenge_collector_ = new Scavenger(this);
mark_compact_collector_ = new MarkCompactCollector(this);
gc_idle_time_handler_ = new GCIdleTimeHandler(); gc_idle_time_handler_ = new GCIdleTimeHandler();
memory_reducer_ = new MemoryReducer(this); memory_reducer_ = new MemoryReducer(this);
...@@ -5189,6 +5192,12 @@ void Heap::TearDown() { ...@@ -5189,6 +5192,12 @@ void Heap::TearDown() {
delete scavenge_collector_; delete scavenge_collector_;
scavenge_collector_ = nullptr; scavenge_collector_ = nullptr;
if (mark_compact_collector_ != nullptr) {
mark_compact_collector_->TearDown();
delete mark_compact_collector_;
mark_compact_collector_ = nullptr;
}
delete incremental_marking_; delete incremental_marking_;
incremental_marking_ = nullptr; incremental_marking_ = nullptr;
...@@ -5216,8 +5225,6 @@ void Heap::TearDown() { ...@@ -5216,8 +5225,6 @@ void Heap::TearDown() {
external_string_table_.TearDown(); external_string_table_.TearDown();
mark_compact_collector()->TearDown();
delete tracer_; delete tracer_;
tracer_ = nullptr; tracer_ = nullptr;
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
#include "src/assert-scope.h" #include "src/assert-scope.h"
#include "src/atomic-utils.h" #include "src/atomic-utils.h"
#include "src/globals.h" #include "src/globals.h"
// TODO(mstarzinger): Three more includes to kill! // TODO(mstarzinger): Two more includes to kill!
#include "src/heap/mark-compact.h"
#include "src/heap/spaces.h" #include "src/heap/spaces.h"
#include "src/heap/store-buffer.h" #include "src/heap/store-buffer.h"
#include "src/list.h" #include "src/list.h"
...@@ -1108,7 +1107,7 @@ class Heap { ...@@ -1108,7 +1107,7 @@ class Heap {
inline Isolate* isolate(); inline Isolate* isolate();
MarkCompactCollector* mark_compact_collector() { MarkCompactCollector* mark_compact_collector() {
return &mark_compact_collector_; return mark_compact_collector_;
} }
// =========================================================================== // ===========================================================================
...@@ -2279,7 +2278,7 @@ class Heap { ...@@ -2279,7 +2278,7 @@ class Heap {
Scavenger* scavenge_collector_; Scavenger* scavenge_collector_;
MarkCompactCollector mark_compact_collector_; MarkCompactCollector* mark_compact_collector_;
StoreBuffer store_buffer_; StoreBuffer store_buffer_;
......
...@@ -388,7 +388,7 @@ void IncrementalMarking::SetOldSpacePageFlags(MemoryChunk* chunk, ...@@ -388,7 +388,7 @@ void IncrementalMarking::SetOldSpacePageFlags(MemoryChunk* chunk,
} }
void IncrementalMarking::SetNewSpacePageFlags(NewSpacePage* chunk, void IncrementalMarking::SetNewSpacePageFlags(MemoryChunk* chunk,
bool is_marking) { bool is_marking) {
chunk->SetFlag(MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING); chunk->SetFlag(MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING);
if (is_marking) { if (is_marking) {
......
...@@ -8,12 +8,15 @@ ...@@ -8,12 +8,15 @@
#include "src/cancelable-task.h" #include "src/cancelable-task.h"
#include "src/execution.h" #include "src/execution.h"
#include "src/heap/incremental-marking-job.h" #include "src/heap/incremental-marking-job.h"
#include "src/heap/mark-compact.h"
#include "src/objects.h" #include "src/objects.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
// Forward declarations.
class MarkBit;
class PagedSpace;
class IncrementalMarking { class IncrementalMarking {
public: public:
enum State { STOPPED, SWEEPING, MARKING, COMPLETE }; enum State { STOPPED, SWEEPING, MARKING, COMPLETE };
...@@ -181,7 +184,7 @@ class IncrementalMarking { ...@@ -181,7 +184,7 @@ class IncrementalMarking {
SetOldSpacePageFlags(chunk, IsMarking(), IsCompacting()); SetOldSpacePageFlags(chunk, IsMarking(), IsCompacting());
} }
inline void SetNewSpacePageFlags(NewSpacePage* chunk) { inline void SetNewSpacePageFlags(MemoryChunk* chunk) {
SetNewSpacePageFlags(chunk, IsMarking()); SetNewSpacePageFlags(chunk, IsMarking());
} }
...@@ -231,7 +234,7 @@ class IncrementalMarking { ...@@ -231,7 +234,7 @@ class IncrementalMarking {
static void SetOldSpacePageFlags(MemoryChunk* chunk, bool is_marking, static void SetOldSpacePageFlags(MemoryChunk* chunk, bool is_marking,
bool is_compacting); bool is_compacting);
static void SetNewSpacePageFlags(NewSpacePage* chunk, bool is_marking); static void SetNewSpacePageFlags(MemoryChunk* chunk, bool is_marking);
INLINE(void ProcessMarkingDeque()); INLINE(void ProcessMarkingDeque());
......
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