Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Unified Diff: src/heap/heap.cc

Issue 1393773004: Reland "[heap] No leakage of mark-compact.h outside of heap." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index b739fc2d51f69d9a8fcd7565c3fe37555f45104d..75b7ec1fa698f824e2e82c57da0cb9947132b08f 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -122,7 +122,7 @@ Heap::Heap()
last_idle_notification_time_(0.0),
last_gc_time_(0.0),
scavenge_collector_(nullptr),
- mark_compact_collector_(this),
+ mark_compact_collector_(nullptr),
store_buffer_(this),
incremental_marking_(nullptr),
gc_idle_time_handler_(nullptr),
@@ -958,7 +958,8 @@ bool Heap::CollectGarbage(GarbageCollector collector, const char* gc_reason,
incremental_marking()->Step(kStepSizeWhenDelayedByScavenge,
IncrementalMarking::NO_GC_VIA_STACK_GUARD);
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) {
PrintF("[IncrementalMarking] Delaying MarkSweep.\n");
}
@@ -1298,8 +1299,8 @@ bool Heap::PerformGarbageCollection(
// We finished a marking cycle. We can uncommit the marking deque until
// we start marking again.
- mark_compact_collector_.marking_deque()->Uninitialize();
- mark_compact_collector_.EnsureMarkingDequeIsCommitted(
+ mark_compact_collector()->marking_deque()->Uninitialize();
+ mark_compact_collector()->EnsureMarkingDequeIsCommitted(
MarkCompactCollector::kMinMarkingDequeSize);
}
@@ -1393,13 +1394,13 @@ void Heap::MarkCompact() {
uint64_t size_of_objects_before_gc = SizeOfObjects();
- mark_compact_collector_.Prepare();
+ mark_compact_collector()->Prepare();
ms_count_++;
MarkCompactPrologue();
- mark_compact_collector_.CollectGarbage();
+ mark_compact_collector()->CollectGarbage();
LOG(isolate_, ResourceEvent("markcompact", "end"));
@@ -4071,10 +4072,10 @@ void Heap::FinalizeIncrementalMarkingIfComplete(const char* comment) {
if (FLAG_overapproximate_weak_closure && incremental_marking()->IsMarking() &&
(incremental_marking()->IsReadyToOverApproximateWeakClosure() ||
(!incremental_marking()->weak_closure_was_overapproximated() &&
- mark_compact_collector_.marking_deque()->IsEmpty()))) {
+ mark_compact_collector()->marking_deque()->IsEmpty()))) {
OverApproximateWeakClosure(comment);
} else if (incremental_marking()->IsComplete() ||
- (mark_compact_collector_.marking_deque()->IsEmpty())) {
+ (mark_compact_collector()->marking_deque()->IsEmpty())) {
CollectAllGarbage(current_gc_flags_, comment);
}
}
@@ -4088,14 +4089,14 @@ bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) {
if (FLAG_overapproximate_weak_closure &&
(incremental_marking()->IsReadyToOverApproximateWeakClosure() ||
(!incremental_marking()->weak_closure_was_overapproximated() &&
- mark_compact_collector_.marking_deque()->IsEmpty() &&
+ mark_compact_collector()->marking_deque()->IsEmpty() &&
gc_idle_time_handler_->ShouldDoOverApproximateWeakClosure(
static_cast<size_t>(idle_time_in_ms))))) {
OverApproximateWeakClosure(
"Idle notification: overapproximate weak closure");
return true;
} else if (incremental_marking()->IsComplete() ||
- (mark_compact_collector_.marking_deque()->IsEmpty() &&
+ (mark_compact_collector()->marking_deque()->IsEmpty() &&
gc_idle_time_handler_->ShouldDoFinalIncrementalMarkCompact(
static_cast<size_t>(idle_time_in_ms), size_of_objects,
final_incremental_mark_compact_speed_in_bytes_per_ms))) {
@@ -4417,9 +4418,9 @@ void Heap::Verify() {
lo_space_->Verify();
- mark_compact_collector_.VerifyWeakEmbeddedObjectsInCode();
+ mark_compact_collector()->VerifyWeakEmbeddedObjectsInCode();
if (FLAG_omit_map_checks_for_leaf_maps) {
- mark_compact_collector_.VerifyOmittedMapChecks();
+ mark_compact_collector()->VerifyOmittedMapChecks();
}
}
#endif
@@ -5069,6 +5070,8 @@ bool Heap::SetUp() {
scavenge_collector_ = new Scavenger(this);
+ mark_compact_collector_ = new MarkCompactCollector(this);
+
gc_idle_time_handler_ = new GCIdleTimeHandler();
memory_reducer_ = new MemoryReducer(this);
@@ -5189,6 +5192,12 @@ void Heap::TearDown() {
delete scavenge_collector_;
scavenge_collector_ = nullptr;
+ if (mark_compact_collector_ != nullptr) {
+ mark_compact_collector_->TearDown();
+ delete mark_compact_collector_;
+ mark_compact_collector_ = nullptr;
+ }
+
delete incremental_marking_;
incremental_marking_ = nullptr;
@@ -5216,8 +5225,6 @@ void Heap::TearDown() {
external_string_table_.TearDown();
- mark_compact_collector()->TearDown();
-
delete tracer_;
tracer_ = nullptr;
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698