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