Commit 1507da8d authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Make the current GCCallbackFlags are part of {Heap}.

Moves the GCCallbackflags where they belong, i.e., {Heap}, and gets rid of
IncrementalMarking::Start() callsites.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#30349}
parent e4bcc336
...@@ -133,6 +133,7 @@ Heap::Heap() ...@@ -133,6 +133,7 @@ Heap::Heap()
promotion_queue_(this), promotion_queue_(this),
configured_(false), configured_(false),
current_gc_flags_(Heap::kNoGCFlags), current_gc_flags_(Heap::kNoGCFlags),
current_gc_callback_flags_(GCCallbackFlags::kNoGCCallbackFlags),
external_string_table_(this), external_string_table_(this),
chunks_queued_for_free_(NULL), chunks_queued_for_free_(NULL),
pending_unmap_job_semaphore_(0), pending_unmap_job_semaphore_(0),
...@@ -741,8 +742,8 @@ void Heap::PreprocessStackTraces() { ...@@ -741,8 +742,8 @@ void Heap::PreprocessStackTraces() {
void Heap::HandleGCRequest() { void Heap::HandleGCRequest() {
if (incremental_marking()->request_type() == if (incremental_marking()->request_type() ==
IncrementalMarking::COMPLETE_MARKING) { IncrementalMarking::COMPLETE_MARKING) {
CollectAllGarbage(current_gc_flags(), "GC interrupt", CollectAllGarbage(current_gc_flags_, "GC interrupt",
incremental_marking()->CallbackFlags()); current_gc_callback_flags_);
return; return;
} }
DCHECK(FLAG_overapproximate_weak_closure); DCHECK(FLAG_overapproximate_weak_closure);
...@@ -947,7 +948,7 @@ bool Heap::CollectGarbage(GarbageCollector collector, const char* gc_reason, ...@@ -947,7 +948,7 @@ bool Heap::CollectGarbage(GarbageCollector collector, const char* gc_reason,
// generator needs incremental marking to stay off after it aborted. // generator needs incremental marking to stay off after it aborted.
if (!ShouldAbortIncrementalMarking() && incremental_marking()->IsStopped() && if (!ShouldAbortIncrementalMarking() && incremental_marking()->IsStopped() &&
incremental_marking()->ShouldActivateEvenWithoutIdleNotification()) { incremental_marking()->ShouldActivateEvenWithoutIdleNotification()) {
incremental_marking()->Start(kNoGCFlags, kNoGCCallbackFlags, "GC epilogue"); StartIncrementalMarking(kNoGCFlags, kNoGCCallbackFlags, "GC epilogue");
} }
return next_gc_likely_to_collect_more; return next_gc_likely_to_collect_more;
...@@ -978,7 +979,9 @@ void Heap::StartIncrementalMarking(int gc_flags, ...@@ -978,7 +979,9 @@ void Heap::StartIncrementalMarking(int gc_flags,
const GCCallbackFlags gc_callback_flags, const GCCallbackFlags gc_callback_flags,
const char* reason) { const char* reason) {
DCHECK(incremental_marking()->IsStopped()); DCHECK(incremental_marking()->IsStopped());
incremental_marking()->Start(gc_flags, gc_callback_flags, reason); set_current_gc_flags(gc_flags);
current_gc_callback_flags_ = gc_callback_flags;
incremental_marking()->Start(reason);
} }
...@@ -4636,7 +4639,7 @@ bool Heap::TryFinalizeIdleIncrementalMarking( ...@@ -4636,7 +4639,7 @@ bool Heap::TryFinalizeIdleIncrementalMarking(
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))) {
CollectAllGarbage(current_gc_flags(), CollectAllGarbage(current_gc_flags_,
"idle notification: finalize incremental"); "idle notification: finalize incremental");
return true; return true;
} }
......
...@@ -1362,8 +1362,9 @@ class Heap { ...@@ -1362,8 +1362,9 @@ class Heap {
// Starts incremental marking assuming incremental marking is currently // Starts incremental marking assuming incremental marking is currently
// stopped. // stopped.
void StartIncrementalMarking(int gc_flags, void StartIncrementalMarking(int gc_flags = kNoGCFlags,
const GCCallbackFlags gc_callback_flags, const GCCallbackFlags gc_callback_flags =
GCCallbackFlags::kNoGCCallbackFlags,
const char* reason = nullptr); const char* reason = nullptr);
// Performs incremental marking steps of step_size_in_bytes as long as // Performs incremental marking steps of step_size_in_bytes as long as
...@@ -1670,8 +1671,6 @@ class Heap { ...@@ -1670,8 +1671,6 @@ class Heap {
ROOT_LIST(ROOT_ACCESSOR) ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR #undef ROOT_ACCESSOR
int current_gc_flags() { return current_gc_flags_; }
void set_current_gc_flags(int flags) { void set_current_gc_flags(int flags) {
current_gc_flags_ = flags; current_gc_flags_ = flags;
DCHECK(!ShouldFinalizeIncrementalMarking() || DCHECK(!ShouldFinalizeIncrementalMarking() ||
...@@ -2346,6 +2345,10 @@ class Heap { ...@@ -2346,6 +2345,10 @@ class Heap {
// Currently set GC flags that are respected by all GC components. // Currently set GC flags that are respected by all GC components.
int current_gc_flags_; int current_gc_flags_;
// Currently set GC callback flags that are used to pass information between
// the embedder and V8's GC.
GCCallbackFlags current_gc_callback_flags_;
ExternalStringTable external_string_table_; ExternalStringTable external_string_table_;
VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_;
......
...@@ -42,8 +42,7 @@ IncrementalMarking::IncrementalMarking(Heap* heap) ...@@ -42,8 +42,7 @@ IncrementalMarking::IncrementalMarking(Heap* heap)
was_activated_(false), was_activated_(false),
weak_closure_was_overapproximated_(false), weak_closure_was_overapproximated_(false),
weak_closure_approximation_rounds_(0), weak_closure_approximation_rounds_(0),
request_type_(COMPLETE_MARKING), request_type_(COMPLETE_MARKING) {}
gc_callback_flags_(kNoGCCallbackFlags) {}
void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot, void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot,
...@@ -463,9 +462,7 @@ static void PatchIncrementalMarkingRecordWriteStubs( ...@@ -463,9 +462,7 @@ static void PatchIncrementalMarkingRecordWriteStubs(
} }
void IncrementalMarking::Start(int flags, void IncrementalMarking::Start(const char* reason) {
const GCCallbackFlags gc_callback_flags,
const char* reason) {
if (FLAG_trace_incremental_marking) { if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Start (%s)\n", PrintF("[IncrementalMarking] Start (%s)\n",
(reason == nullptr) ? "unknown reason" : reason); (reason == nullptr) ? "unknown reason" : reason);
...@@ -477,11 +474,9 @@ void IncrementalMarking::Start(int flags, ...@@ -477,11 +474,9 @@ void IncrementalMarking::Start(int flags,
ResetStepCounters(); ResetStepCounters();
gc_callback_flags_ = gc_callback_flags;
was_activated_ = true; was_activated_ = true;
if (!heap_->mark_compact_collector()->sweeping_in_progress()) { if (!heap_->mark_compact_collector()->sweeping_in_progress()) {
heap_->set_current_gc_flags(flags);
StartMarking(); StartMarking();
} else { } else {
if (FLAG_trace_incremental_marking) { if (FLAG_trace_incremental_marking) {
...@@ -819,7 +814,8 @@ void IncrementalMarking::Epilogue() { ...@@ -819,7 +814,8 @@ void IncrementalMarking::Epilogue() {
void IncrementalMarking::OldSpaceStep(intptr_t allocated) { void IncrementalMarking::OldSpaceStep(intptr_t allocated) {
if (IsStopped() && ShouldActivateEvenWithoutIdleNotification()) { if (IsStopped() && ShouldActivateEvenWithoutIdleNotification()) {
Start(Heap::kNoGCFlags, kNoGCCallbackFlags, "old space step"); heap()->StartIncrementalMarking(Heap::kNoGCFlags, kNoGCCallbackFlags,
"old space step");
} else { } else {
Step(allocated * kFastMarking / kInitialMarkingSpeed, GC_VIA_STACK_GUARD); Step(allocated * kFastMarking / kInitialMarkingSpeed, GC_VIA_STACK_GUARD);
} }
......
...@@ -81,9 +81,7 @@ class IncrementalMarking { ...@@ -81,9 +81,7 @@ class IncrementalMarking {
bool WasActivated(); bool WasActivated();
void Start(int flags, void Start(const char* reason = nullptr);
const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags,
const char* reason = nullptr);
void MarkObjectGroups(); void MarkObjectGroups();
...@@ -199,8 +197,6 @@ class IncrementalMarking { ...@@ -199,8 +197,6 @@ class IncrementalMarking {
Heap* heap() const { return heap_; } Heap* heap() const { return heap_; }
GCCallbackFlags CallbackFlags() const { return gc_callback_flags_; }
private: private:
int64_t SpaceLeftInOldSpace(); int64_t SpaceLeftInOldSpace();
...@@ -259,8 +255,6 @@ class IncrementalMarking { ...@@ -259,8 +255,6 @@ class IncrementalMarking {
GCRequestType request_type_; GCRequestType request_type_;
GCCallbackFlags gc_callback_flags_;
DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking);
}; };
} }
......
...@@ -546,7 +546,7 @@ static inline void SimulateIncrementalMarking(i::Heap* heap, ...@@ -546,7 +546,7 @@ static inline void SimulateIncrementalMarking(i::Heap* heap,
} }
CHECK(marking->IsMarking() || marking->IsStopped()); CHECK(marking->IsMarking() || marking->IsStopped());
if (marking->IsStopped()) { if (marking->IsStopped()) {
marking->Start(i::Heap::kNoGCFlags); heap->StartIncrementalMarking();
} }
CHECK(marking->IsMarking()); CHECK(marking->IsMarking());
if (!force_completion) return; if (!force_completion) return;
......
...@@ -2590,7 +2590,7 @@ TEST(InstanceOfStubWriteBarrier) { ...@@ -2590,7 +2590,7 @@ TEST(InstanceOfStubWriteBarrier) {
IncrementalMarking* marking = CcTest::heap()->incremental_marking(); IncrementalMarking* marking = CcTest::heap()->incremental_marking();
marking->Stop(); marking->Stop();
marking->Start(Heap::kNoGCFlags); CcTest::heap()->StartIncrementalMarking();
Handle<JSFunction> f = Handle<JSFunction> f =
v8::Utils::OpenHandle( v8::Utils::OpenHandle(
...@@ -2718,7 +2718,7 @@ TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { ...@@ -2718,7 +2718,7 @@ TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {
IncrementalMarking* marking = CcTest::heap()->incremental_marking(); IncrementalMarking* marking = CcTest::heap()->incremental_marking();
marking->Stop(); marking->Stop();
marking->Start(Heap::kNoGCFlags); CcTest::heap()->StartIncrementalMarking();
// The following calls will increment CcTest::heap()->global_ic_age(). // The following calls will increment CcTest::heap()->global_ic_age().
CcTest::isolate()->ContextDisposedNotification(); CcTest::isolate()->ContextDisposedNotification();
SimulateIncrementalMarking(CcTest::heap()); SimulateIncrementalMarking(CcTest::heap());
...@@ -2775,12 +2775,12 @@ HEAP_TEST(GCFlags) { ...@@ -2775,12 +2775,12 @@ HEAP_TEST(GCFlags) {
Heap* heap = CcTest::heap(); Heap* heap = CcTest::heap();
heap->set_current_gc_flags(Heap::kNoGCFlags); heap->set_current_gc_flags(Heap::kNoGCFlags);
CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags()); CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_);
// Set the flags to check whether we appropriately resets them after the GC. // Set the flags to check whether we appropriately resets them after the GC.
heap->set_current_gc_flags(Heap::kAbortIncrementalMarkingMask); heap->set_current_gc_flags(Heap::kAbortIncrementalMarkingMask);
heap->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); heap->CollectAllGarbage(Heap::kReduceMemoryFootprintMask);
CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags()); CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_);
MarkCompactCollector* collector = heap->mark_compact_collector(); MarkCompactCollector* collector = heap->mark_compact_collector();
if (collector->sweeping_in_progress()) { if (collector->sweeping_in_progress()) {
...@@ -2789,15 +2789,15 @@ HEAP_TEST(GCFlags) { ...@@ -2789,15 +2789,15 @@ HEAP_TEST(GCFlags) {
IncrementalMarking* marking = heap->incremental_marking(); IncrementalMarking* marking = heap->incremental_marking();
marking->Stop(); marking->Stop();
marking->Start(Heap::kReduceMemoryFootprintMask); heap->StartIncrementalMarking(Heap::kReduceMemoryFootprintMask);
CHECK_NE(0, heap->current_gc_flags() & Heap::kReduceMemoryFootprintMask); CHECK_NE(0, heap->current_gc_flags_ & Heap::kReduceMemoryFootprintMask);
heap->CollectGarbage(NEW_SPACE); heap->CollectGarbage(NEW_SPACE);
// NewSpace scavenges should not overwrite the flags. // NewSpace scavenges should not overwrite the flags.
CHECK_NE(0, heap->current_gc_flags() & Heap::kReduceMemoryFootprintMask); CHECK_NE(0, heap->current_gc_flags_ & Heap::kReduceMemoryFootprintMask);
heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags()); CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_);
} }
...@@ -2807,7 +2807,7 @@ TEST(IdleNotificationFinishMarking) { ...@@ -2807,7 +2807,7 @@ TEST(IdleNotificationFinishMarking) {
SimulateFullSpace(CcTest::heap()->old_space()); SimulateFullSpace(CcTest::heap()->old_space());
IncrementalMarking* marking = CcTest::heap()->incremental_marking(); IncrementalMarking* marking = CcTest::heap()->incremental_marking();
marking->Stop(); marking->Stop();
marking->Start(Heap::kNoGCFlags); CcTest::heap()->StartIncrementalMarking();
CHECK_EQ(CcTest::heap()->gc_count(), 0); CHECK_EQ(CcTest::heap()->gc_count(), 0);
...@@ -4760,7 +4760,9 @@ TEST(IncrementalMarkingStepMakesBigProgressWithLargeObjects) { ...@@ -4760,7 +4760,9 @@ TEST(IncrementalMarkingStepMakesBigProgressWithLargeObjects) {
"};" "};"
"f(10 * 1024 * 1024);"); "f(10 * 1024 * 1024);");
IncrementalMarking* marking = CcTest::heap()->incremental_marking(); IncrementalMarking* marking = CcTest::heap()->incremental_marking();
if (marking->IsStopped()) marking->Start(Heap::kNoGCFlags); if (marking->IsStopped()) {
CcTest::heap()->StartIncrementalMarking();
}
// This big step should be sufficient to mark the whole array. // This big step should be sufficient to mark the whole array.
marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
DCHECK(marking->IsComplete() || DCHECK(marking->IsComplete() ||
...@@ -5488,7 +5490,9 @@ TEST(WeakCellsWithIncrementalMarking) { ...@@ -5488,7 +5490,9 @@ TEST(WeakCellsWithIncrementalMarking) {
Handle<WeakCell> weak_cell = factory->NewWeakCell(value); Handle<WeakCell> weak_cell = factory->NewWeakCell(value);
CHECK(weak_cell->value()->IsFixedArray()); CHECK(weak_cell->value()->IsFixedArray());
IncrementalMarking* marking = heap->incremental_marking(); IncrementalMarking* marking = heap->incremental_marking();
if (marking->IsStopped()) marking->Start(Heap::kNoGCFlags); if (marking->IsStopped()) {
heap->StartIncrementalMarking();
}
marking->Step(128, IncrementalMarking::NO_GC_VIA_STACK_GUARD); marking->Step(128, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
heap->CollectGarbage(NEW_SPACE); heap->CollectGarbage(NEW_SPACE);
CHECK(weak_cell->value()->IsFixedArray()); CHECK(weak_cell->value()->IsFixedArray());
...@@ -5781,7 +5785,7 @@ TEST(Regress388880) { ...@@ -5781,7 +5785,7 @@ TEST(Regress388880) {
// that would cause crash. // that would cause crash.
IncrementalMarking* marking = CcTest::heap()->incremental_marking(); IncrementalMarking* marking = CcTest::heap()->incremental_marking();
marking->Stop(); marking->Stop();
marking->Start(Heap::kNoGCFlags); CcTest::heap()->StartIncrementalMarking();
CHECK(marking->IsMarking()); CHECK(marking->IsMarking());
// Now everything is set up for crashing in JSObject::MigrateFastToFast() // Now everything is set up for crashing in JSObject::MigrateFastToFast()
...@@ -5807,7 +5811,7 @@ TEST(Regress3631) { ...@@ -5807,7 +5811,7 @@ TEST(Regress3631) {
"}" "}"
"weak_map"); "weak_map");
if (marking->IsStopped()) { if (marking->IsStopped()) {
marking->Start(Heap::kNoGCFlags); CcTest::heap()->StartIncrementalMarking();
} }
// Incrementally mark the backing store. // Incrementally mark the backing store.
Handle<JSObject> obj = Handle<JSObject> obj =
......
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