Commit dde730ff authored by jochen's avatar jochen Committed by Commit bot

Hook up over approximating the weak closure to the idle time handler

The feature itself is still behind a flag.

BUG=v8:3862
R=hpayer@chromium.org
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#27225}
parent dc3f240e
......@@ -16,6 +16,7 @@ const size_t GCIdleTimeHandler::kMinTimeForFinalizeSweeping = 100;
const int GCIdleTimeHandler::kMaxMarkCompactsInIdleRound = 7;
const int GCIdleTimeHandler::kIdleScavengeThreshold = 5;
const double GCIdleTimeHandler::kHighContextDisposalRate = 100;
const size_t GCIdleTimeHandler::kMinTimeForOverApproximatingWeakClosureInMs = 1;
void GCIdleTimeAction::Print() {
......@@ -176,6 +177,13 @@ bool GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact(
}
bool GCIdleTimeHandler::ShouldDoOverApproximateWeakClosure(
size_t idle_time_in_ms) {
// TODO(jochen): Estimate the time it will take to build the object groups.
return idle_time_in_ms >= kMinTimeForOverApproximatingWeakClosureInMs;
}
// The following logic is implemented by the controller:
// (1) If we don't have any idle time, do nothing, unless a context was
// disposed, incremental marking is stopped, and the heap is small. Then do
......
......@@ -135,6 +135,8 @@ class GCIdleTimeHandler {
// Incremental marking step time.
static const size_t kIncrementalMarkingStepTimeInMs = 1;
static const size_t kMinTimeForOverApproximatingWeakClosureInMs;
class HeapState {
public:
void Print();
......@@ -192,6 +194,8 @@ class GCIdleTimeHandler {
size_t idle_time_in_ms, size_t size_of_objects,
size_t final_incremental_mark_compact_speed_in_bytes_per_ms);
static bool ShouldDoOverApproximateWeakClosure(size_t idle_time_in_ms);
static bool ShouldDoScavenge(
size_t idle_time_in_ms, size_t new_space_size, size_t used_new_space_size,
size_t scavenger_speed_in_bytes_per_ms,
......
......@@ -4584,11 +4584,19 @@ void Heap::IdleMarkCompact(const char* message) {
bool Heap::TryFinalizeIdleIncrementalMarking(
double idle_time_in_ms, size_t size_of_objects,
size_t final_incremental_mark_compact_speed_in_bytes_per_ms) {
if (incremental_marking()->IsComplete() ||
(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))) {
if (incremental_marking()->IsReadyToOverApproximateWeakClosure() ||
(FLAG_overapproximate_weak_closure &&
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() &&
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(kNoGCFlags, "idle notification: finalize incremental");
return true;
}
......
......@@ -797,14 +797,16 @@ void IncrementalMarking::Finalize() {
}
void IncrementalMarking::OverApproximateWeakClosure() {
void IncrementalMarking::OverApproximateWeakClosure(CompletionAction action) {
DCHECK(FLAG_overapproximate_weak_closure);
DCHECK(!weak_closure_was_overapproximated_);
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] requesting weak closure overapproximation.\n");
}
request_type_ = OVERAPPROXIMATION;
heap_->isolate()->stack_guard()->RequestGC();
if (action == GC_VIA_STACK_GUARD) {
heap_->isolate()->stack_guard()->RequestGC();
}
}
......@@ -819,8 +821,8 @@ void IncrementalMarking::MarkingComplete(CompletionAction action) {
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Complete (normal).\n");
}
request_type_ = COMPLETE_MARKING;
if (action == GC_VIA_STACK_GUARD) {
request_type_ = COMPLETE_MARKING;
heap_->isolate()->stack_guard()->RequestGC();
}
}
......@@ -974,9 +976,8 @@ intptr_t IncrementalMarking::Step(intptr_t allocated_bytes,
if (completion == FORCE_COMPLETION ||
IsIdleMarkingDelayCounterLimitReached()) {
if (FLAG_overapproximate_weak_closure &&
!weak_closure_was_overapproximated_ &&
action == GC_VIA_STACK_GUARD) {
OverApproximateWeakClosure();
!weak_closure_was_overapproximated_) {
OverApproximateWeakClosure(action);
} else {
MarkingComplete(action);
}
......
......@@ -50,6 +50,10 @@ class IncrementalMarking {
inline bool IsComplete() { return state() == COMPLETE; }
inline bool IsReadyToOverApproximateWeakClosure() const {
return request_type_ == OVERAPPROXIMATION;
}
GCRequestType request_type() const { return request_type_; }
bool WorthActivating();
......@@ -76,7 +80,7 @@ class IncrementalMarking {
void Abort();
void OverApproximateWeakClosure();
void OverApproximateWeakClosure(CompletionAction action);
void MarkingComplete(CompletionAction action);
......
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