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

[heap] No leakage of gc-idle-time-handler.h outside of heap.

This prevents the internal gc-idle-time-handler.h to be usable outisde
of the "heap" directory. The logic inside that component is only useful
within the GC and is now properly encapsulated.

R=ulan@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#30939}
parent e4f7ebb0
...@@ -42,7 +42,7 @@ void GCIdleTimeAction::Print() { ...@@ -42,7 +42,7 @@ void GCIdleTimeAction::Print() {
} }
void GCIdleTimeHandler::HeapState::Print() { void GCIdleTimeHeapState::Print() {
PrintF("contexts_disposed=%d ", contexts_disposed); PrintF("contexts_disposed=%d ", contexts_disposed);
PrintF("contexts_disposal_rate=%f ", contexts_disposal_rate); PrintF("contexts_disposal_rate=%f ", contexts_disposal_rate);
PrintF("size_of_objects=%" V8_PTR_PREFIX "d ", size_of_objects); PrintF("size_of_objects=%" V8_PTR_PREFIX "d ", size_of_objects);
...@@ -240,7 +240,7 @@ GCIdleTimeAction GCIdleTimeHandler::NothingOrDone(double idle_time_in_ms) { ...@@ -240,7 +240,7 @@ GCIdleTimeAction GCIdleTimeHandler::NothingOrDone(double idle_time_in_ms) {
// (5) If incremental marking is in progress, we perform a marking step. Note, // (5) If incremental marking is in progress, we perform a marking step. Note,
// that this currently may trigger a full garbage collection. // that this currently may trigger a full garbage collection.
GCIdleTimeAction GCIdleTimeHandler::Compute(double idle_time_in_ms, GCIdleTimeAction GCIdleTimeHandler::Compute(double idle_time_in_ms,
HeapState heap_state) { GCIdleTimeHeapState heap_state) {
if (static_cast<int>(idle_time_in_ms) <= 0) { if (static_cast<int>(idle_time_in_ms) <= 0) {
if (heap_state.incremental_marking_stopped) { if (heap_state.incremental_marking_stopped) {
if (ShouldDoContextDisposalMarkCompact( if (ShouldDoContextDisposalMarkCompact(
......
...@@ -63,7 +63,26 @@ class GCIdleTimeAction { ...@@ -63,7 +63,26 @@ class GCIdleTimeAction {
}; };
class GCTracer; class GCIdleTimeHeapState {
public:
void Print();
int contexts_disposed;
double contexts_disposal_rate;
size_t size_of_objects;
bool incremental_marking_stopped;
bool sweeping_in_progress;
bool sweeping_completed;
bool has_low_allocation_rate;
size_t mark_compact_speed_in_bytes_per_ms;
size_t incremental_marking_speed_in_bytes_per_ms;
size_t final_incremental_mark_compact_speed_in_bytes_per_ms;
size_t scavenge_speed_in_bytes_per_ms;
size_t used_new_space_size;
size_t new_space_capacity;
size_t new_space_allocation_throughput_in_bytes_per_ms;
};
// The idle time handler makes decisions about which garbage collection // The idle time handler makes decisions about which garbage collection
// operations are executing during IdleNotification. // operations are executing during IdleNotification.
...@@ -133,29 +152,10 @@ class GCIdleTimeHandler { ...@@ -133,29 +152,10 @@ class GCIdleTimeHandler {
// ensure we don't keep scheduling idle tasks and making no progress. // ensure we don't keep scheduling idle tasks and making no progress.
static const int kMaxNoProgressIdleTimes = 10; static const int kMaxNoProgressIdleTimes = 10;
class HeapState {
public:
void Print();
int contexts_disposed;
double contexts_disposal_rate;
size_t size_of_objects;
bool incremental_marking_stopped;
bool sweeping_in_progress;
bool sweeping_completed;
bool has_low_allocation_rate;
size_t mark_compact_speed_in_bytes_per_ms;
size_t incremental_marking_speed_in_bytes_per_ms;
size_t final_incremental_mark_compact_speed_in_bytes_per_ms;
size_t scavenge_speed_in_bytes_per_ms;
size_t used_new_space_size;
size_t new_space_capacity;
size_t new_space_allocation_throughput_in_bytes_per_ms;
};
GCIdleTimeHandler() : idle_times_which_made_no_progress_(0) {} GCIdleTimeHandler() : idle_times_which_made_no_progress_(0) {}
GCIdleTimeAction Compute(double idle_time_in_ms, HeapState heap_state); GCIdleTimeAction Compute(double idle_time_in_ms,
GCIdleTimeHeapState heap_state);
void ResetNoProgressCounter() { idle_times_which_made_no_progress_ = 0; } void ResetNoProgressCounter() { idle_times_which_made_no_progress_ = 0; }
......
...@@ -125,6 +125,7 @@ Heap::Heap() ...@@ -125,6 +125,7 @@ Heap::Heap()
mark_compact_collector_(this), mark_compact_collector_(this),
store_buffer_(this), store_buffer_(this),
incremental_marking_(this), incremental_marking_(this),
gc_idle_time_handler_(nullptr),
memory_reducer_(nullptr), memory_reducer_(nullptr),
object_stats_(nullptr), object_stats_(nullptr),
full_codegen_bytes_generated_(0), full_codegen_bytes_generated_(0),
...@@ -1012,7 +1013,7 @@ void Heap::StartIncrementalMarking(int gc_flags, ...@@ -1012,7 +1013,7 @@ void Heap::StartIncrementalMarking(int gc_flags,
void Heap::StartIdleIncrementalMarking() { void Heap::StartIdleIncrementalMarking() {
gc_idle_time_handler_.ResetNoProgressCounter(); gc_idle_time_handler_->ResetNoProgressCounter();
StartIncrementalMarking(kReduceMemoryFootprintMask, kNoGCCallbackFlags, StartIncrementalMarking(kReduceMemoryFootprintMask, kNoGCCallbackFlags,
"idle"); "idle");
} }
...@@ -4071,14 +4072,14 @@ bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) { ...@@ -4071,14 +4072,14 @@ bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) {
(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))) {
CollectAllGarbage(current_gc_flags_, CollectAllGarbage(current_gc_flags_,
...@@ -4089,8 +4090,8 @@ bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) { ...@@ -4089,8 +4090,8 @@ bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) {
} }
GCIdleTimeHandler::HeapState Heap::ComputeHeapState() { GCIdleTimeHeapState Heap::ComputeHeapState() {
GCIdleTimeHandler::HeapState heap_state; GCIdleTimeHeapState heap_state;
heap_state.contexts_disposed = contexts_disposed_; heap_state.contexts_disposed = contexts_disposed_;
heap_state.contexts_disposal_rate = heap_state.contexts_disposal_rate =
tracer()->ContextDisposalRateInMilliseconds(); tracer()->ContextDisposalRateInMilliseconds();
...@@ -4134,7 +4135,7 @@ double Heap::AdvanceIncrementalMarking( ...@@ -4134,7 +4135,7 @@ double Heap::AdvanceIncrementalMarking(
bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, bool Heap::PerformIdleTimeAction(GCIdleTimeAction action,
GCIdleTimeHandler::HeapState heap_state, GCIdleTimeHeapState heap_state,
double deadline_in_ms) { double deadline_in_ms) {
bool result = false; bool result = false;
switch (action.type) { switch (action.type) {
...@@ -4171,7 +4172,7 @@ bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, ...@@ -4171,7 +4172,7 @@ bool Heap::PerformIdleTimeAction(GCIdleTimeAction action,
void Heap::IdleNotificationEpilogue(GCIdleTimeAction action, void Heap::IdleNotificationEpilogue(GCIdleTimeAction action,
GCIdleTimeHandler::HeapState heap_state, GCIdleTimeHeapState heap_state,
double start_ms, double deadline_in_ms) { double start_ms, double deadline_in_ms) {
double idle_time_in_ms = deadline_in_ms - start_ms; double idle_time_in_ms = deadline_in_ms - start_ms;
double current_time = MonotonicallyIncreasingTimeInMs(); double current_time = MonotonicallyIncreasingTimeInMs();
...@@ -4268,10 +4269,10 @@ bool Heap::IdleNotification(double deadline_in_seconds) { ...@@ -4268,10 +4269,10 @@ bool Heap::IdleNotification(double deadline_in_seconds) {
tracer()->SampleAllocation(start_ms, NewSpaceAllocationCounter(), tracer()->SampleAllocation(start_ms, NewSpaceAllocationCounter(),
OldGenerationAllocationCounter()); OldGenerationAllocationCounter());
GCIdleTimeHandler::HeapState heap_state = ComputeHeapState(); GCIdleTimeHeapState heap_state = ComputeHeapState();
GCIdleTimeAction action = GCIdleTimeAction action =
gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); gc_idle_time_handler_->Compute(idle_time_in_ms, heap_state);
bool result = PerformIdleTimeAction(action, heap_state, deadline_in_ms); bool result = PerformIdleTimeAction(action, heap_state, deadline_in_ms);
...@@ -5073,6 +5074,8 @@ bool Heap::SetUp() { ...@@ -5073,6 +5074,8 @@ bool Heap::SetUp() {
scavenge_collector_ = new Scavenger(this); scavenge_collector_ = new Scavenger(this);
gc_idle_time_handler_ = new GCIdleTimeHandler();
memory_reducer_ = new MemoryReducer(this); memory_reducer_ = new MemoryReducer(this);
object_stats_ = new ObjectStats(this); object_stats_ = new ObjectStats(this);
...@@ -5187,6 +5190,9 @@ void Heap::TearDown() { ...@@ -5187,6 +5190,9 @@ void Heap::TearDown() {
delete scavenge_collector_; delete scavenge_collector_;
scavenge_collector_ = nullptr; scavenge_collector_ = nullptr;
delete gc_idle_time_handler_;
gc_idle_time_handler_ = nullptr;
if (memory_reducer_ != nullptr) { if (memory_reducer_ != nullptr) {
memory_reducer_->TearDown(); memory_reducer_->TearDown();
delete memory_reducer_; delete memory_reducer_;
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#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"
#include "src/heap/gc-idle-time-handler.h"
#include "src/heap/incremental-marking.h" #include "src/heap/incremental-marking.h"
#include "src/heap/mark-compact.h" #include "src/heap/mark-compact.h"
#include "src/heap/spaces.h" #include "src/heap/spaces.h"
...@@ -422,6 +421,10 @@ namespace internal { ...@@ -422,6 +421,10 @@ namespace internal {
// Forward declarations. // Forward declarations.
class ArrayBufferTracker; class ArrayBufferTracker;
class GCIdleTimeAction;
class GCIdleTimeHandler;
class GCIdleTimeHeapState;
class GCTracer;
class HeapObjectsFilter; class HeapObjectsFilter;
class HeapStats; class HeapStats;
class Isolate; class Isolate;
...@@ -1780,15 +1783,15 @@ class Heap { ...@@ -1780,15 +1783,15 @@ class Heap {
double idle_time_in_ms, size_t size_of_objects, double idle_time_in_ms, size_t size_of_objects,
size_t mark_compact_speed_in_bytes_per_ms); size_t mark_compact_speed_in_bytes_per_ms);
GCIdleTimeHandler::HeapState ComputeHeapState(); GCIdleTimeHeapState ComputeHeapState();
bool PerformIdleTimeAction(GCIdleTimeAction action, bool PerformIdleTimeAction(GCIdleTimeAction action,
GCIdleTimeHandler::HeapState heap_state, GCIdleTimeHeapState heap_state,
double deadline_in_ms); double deadline_in_ms);
void IdleNotificationEpilogue(GCIdleTimeAction action, void IdleNotificationEpilogue(GCIdleTimeAction action,
GCIdleTimeHandler::HeapState heap_state, GCIdleTimeHeapState heap_state, double start_ms,
double start_ms, double deadline_in_ms); double deadline_in_ms);
void CheckAndNotifyBackgroundIdleNotification(double idle_time_in_ms, void CheckAndNotifyBackgroundIdleNotification(double idle_time_in_ms,
double now_ms); double now_ms);
...@@ -2258,7 +2261,7 @@ class Heap { ...@@ -2258,7 +2261,7 @@ class Heap {
IncrementalMarking incremental_marking_; IncrementalMarking incremental_marking_;
GCIdleTimeHandler gc_idle_time_handler_; GCIdleTimeHandler* gc_idle_time_handler_;
MemoryReducer* memory_reducer_; MemoryReducer* memory_reducer_;
......
...@@ -19,8 +19,8 @@ class GCIdleTimeHandlerTest : public ::testing::Test { ...@@ -19,8 +19,8 @@ class GCIdleTimeHandlerTest : public ::testing::Test {
GCIdleTimeHandler* handler() { return &handler_; } GCIdleTimeHandler* handler() { return &handler_; }
GCIdleTimeHandler::HeapState DefaultHeapState() { GCIdleTimeHeapState DefaultHeapState() {
GCIdleTimeHandler::HeapState result; GCIdleTimeHeapState result;
result.contexts_disposed = 0; result.contexts_disposed = 0;
result.contexts_disposal_rate = GCIdleTimeHandler::kHighContextDisposalRate; result.contexts_disposal_rate = GCIdleTimeHandler::kHighContextDisposalRate;
result.incremental_marking_stopped = false; result.incremental_marking_stopped = false;
...@@ -108,7 +108,7 @@ TEST(GCIdleTimeHandler, EstimateMarkCompactTimeMax) { ...@@ -108,7 +108,7 @@ TEST(GCIdleTimeHandler, EstimateMarkCompactTimeMax) {
TEST_F(GCIdleTimeHandlerTest, DoScavengeEmptyNewSpace) { TEST_F(GCIdleTimeHandlerTest, DoScavengeEmptyNewSpace) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
int idle_time_ms = 16; int idle_time_ms = 16;
EXPECT_FALSE(GCIdleTimeHandler::ShouldDoScavenge( EXPECT_FALSE(GCIdleTimeHandler::ShouldDoScavenge(
idle_time_ms, heap_state.new_space_capacity, idle_time_ms, heap_state.new_space_capacity,
...@@ -118,7 +118,7 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeEmptyNewSpace) { ...@@ -118,7 +118,7 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeEmptyNewSpace) {
TEST_F(GCIdleTimeHandlerTest, DoScavengeFullNewSpace) { TEST_F(GCIdleTimeHandlerTest, DoScavengeFullNewSpace) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.used_new_space_size = kNewSpaceCapacity; heap_state.used_new_space_size = kNewSpaceCapacity;
int idle_time_ms = 16; int idle_time_ms = 16;
EXPECT_TRUE(GCIdleTimeHandler::ShouldDoScavenge( EXPECT_TRUE(GCIdleTimeHandler::ShouldDoScavenge(
...@@ -129,7 +129,7 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeFullNewSpace) { ...@@ -129,7 +129,7 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeFullNewSpace) {
TEST_F(GCIdleTimeHandlerTest, DoScavengeUnknownScavengeSpeed) { TEST_F(GCIdleTimeHandlerTest, DoScavengeUnknownScavengeSpeed) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.used_new_space_size = kNewSpaceCapacity; heap_state.used_new_space_size = kNewSpaceCapacity;
heap_state.scavenge_speed_in_bytes_per_ms = 0; heap_state.scavenge_speed_in_bytes_per_ms = 0;
int idle_time_ms = 8; int idle_time_ms = 8;
...@@ -141,7 +141,7 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeUnknownScavengeSpeed) { ...@@ -141,7 +141,7 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeUnknownScavengeSpeed) {
TEST_F(GCIdleTimeHandlerTest, DoScavengeLowScavengeSpeed) { TEST_F(GCIdleTimeHandlerTest, DoScavengeLowScavengeSpeed) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.used_new_space_size = kNewSpaceCapacity; heap_state.used_new_space_size = kNewSpaceCapacity;
heap_state.scavenge_speed_in_bytes_per_ms = 1 * KB; heap_state.scavenge_speed_in_bytes_per_ms = 1 * KB;
int idle_time_ms = 16; int idle_time_ms = 16;
...@@ -153,7 +153,7 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeLowScavengeSpeed) { ...@@ -153,7 +153,7 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeLowScavengeSpeed) {
TEST_F(GCIdleTimeHandlerTest, DoScavengeLowAllocationRate) { TEST_F(GCIdleTimeHandlerTest, DoScavengeLowAllocationRate) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.used_new_space_size = kNewSpaceCapacity; heap_state.used_new_space_size = kNewSpaceCapacity;
heap_state.new_space_allocation_throughput_in_bytes_per_ms = heap_state.new_space_allocation_throughput_in_bytes_per_ms =
GCIdleTimeHandler::kLowAllocationThroughput - 1; GCIdleTimeHandler::kLowAllocationThroughput - 1;
...@@ -166,7 +166,7 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeLowAllocationRate) { ...@@ -166,7 +166,7 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeLowAllocationRate) {
TEST_F(GCIdleTimeHandlerTest, DoScavengeHighScavengeSpeed) { TEST_F(GCIdleTimeHandlerTest, DoScavengeHighScavengeSpeed) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.used_new_space_size = kNewSpaceCapacity; heap_state.used_new_space_size = kNewSpaceCapacity;
heap_state.scavenge_speed_in_bytes_per_ms = kNewSpaceCapacity; heap_state.scavenge_speed_in_bytes_per_ms = kNewSpaceCapacity;
int idle_time_ms = 16; int idle_time_ms = 16;
...@@ -178,7 +178,7 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeHighScavengeSpeed) { ...@@ -178,7 +178,7 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeHighScavengeSpeed) {
TEST_F(GCIdleTimeHandlerTest, DoNotScavengeSmallNewSpaceSize) { TEST_F(GCIdleTimeHandlerTest, DoNotScavengeSmallNewSpaceSize) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.used_new_space_size = (MB / 2) - 1; heap_state.used_new_space_size = (MB / 2) - 1;
heap_state.scavenge_speed_in_bytes_per_ms = kNewSpaceCapacity; heap_state.scavenge_speed_in_bytes_per_ms = kNewSpaceCapacity;
int idle_time_ms = 16; int idle_time_ms = 16;
...@@ -217,7 +217,7 @@ TEST_F(GCIdleTimeHandlerTest, DontDoFinalIncrementalMarkCompact) { ...@@ -217,7 +217,7 @@ TEST_F(GCIdleTimeHandlerTest, DontDoFinalIncrementalMarkCompact) {
TEST_F(GCIdleTimeHandlerTest, ContextDisposeLowRate) { TEST_F(GCIdleTimeHandlerTest, ContextDisposeLowRate) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.contexts_disposed = 1; heap_state.contexts_disposed = 1;
heap_state.incremental_marking_stopped = true; heap_state.incremental_marking_stopped = true;
double idle_time_ms = 0; double idle_time_ms = 0;
...@@ -227,7 +227,7 @@ TEST_F(GCIdleTimeHandlerTest, ContextDisposeLowRate) { ...@@ -227,7 +227,7 @@ TEST_F(GCIdleTimeHandlerTest, ContextDisposeLowRate) {
TEST_F(GCIdleTimeHandlerTest, ContextDisposeHighRate) { TEST_F(GCIdleTimeHandlerTest, ContextDisposeHighRate) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.contexts_disposed = 1; heap_state.contexts_disposed = 1;
heap_state.contexts_disposal_rate = heap_state.contexts_disposal_rate =
GCIdleTimeHandler::kHighContextDisposalRate - 1; GCIdleTimeHandler::kHighContextDisposalRate - 1;
...@@ -239,7 +239,7 @@ TEST_F(GCIdleTimeHandlerTest, ContextDisposeHighRate) { ...@@ -239,7 +239,7 @@ TEST_F(GCIdleTimeHandlerTest, ContextDisposeHighRate) {
TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeZeroIdleTime) { TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeZeroIdleTime) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.contexts_disposed = 1; heap_state.contexts_disposed = 1;
heap_state.contexts_disposal_rate = 1.0; heap_state.contexts_disposal_rate = 1.0;
heap_state.incremental_marking_stopped = true; heap_state.incremental_marking_stopped = true;
...@@ -250,7 +250,7 @@ TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeZeroIdleTime) { ...@@ -250,7 +250,7 @@ TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeZeroIdleTime) {
TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime1) { TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime1) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.contexts_disposed = 1; heap_state.contexts_disposed = 1;
heap_state.contexts_disposal_rate = heap_state.contexts_disposal_rate =
GCIdleTimeHandler::kHighContextDisposalRate; GCIdleTimeHandler::kHighContextDisposalRate;
...@@ -262,7 +262,7 @@ TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime1) { ...@@ -262,7 +262,7 @@ TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime1) {
TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime2) { TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime2) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.contexts_disposed = 1; heap_state.contexts_disposed = 1;
heap_state.contexts_disposal_rate = heap_state.contexts_disposal_rate =
GCIdleTimeHandler::kHighContextDisposalRate; GCIdleTimeHandler::kHighContextDisposalRate;
...@@ -274,7 +274,7 @@ TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime2) { ...@@ -274,7 +274,7 @@ TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime2) {
TEST_F(GCIdleTimeHandlerTest, IncrementalMarking1) { TEST_F(GCIdleTimeHandlerTest, IncrementalMarking1) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
double idle_time_ms = 10; double idle_time_ms = 10;
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
EXPECT_EQ(DO_INCREMENTAL_STEP, action.type); EXPECT_EQ(DO_INCREMENTAL_STEP, action.type);
...@@ -282,7 +282,7 @@ TEST_F(GCIdleTimeHandlerTest, IncrementalMarking1) { ...@@ -282,7 +282,7 @@ TEST_F(GCIdleTimeHandlerTest, IncrementalMarking1) {
TEST_F(GCIdleTimeHandlerTest, NotEnoughTime) { TEST_F(GCIdleTimeHandlerTest, NotEnoughTime) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.incremental_marking_stopped = true; heap_state.incremental_marking_stopped = true;
size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms;
double idle_time_ms = static_cast<double>(kSizeOfObjects / speed - 1); double idle_time_ms = static_cast<double>(kSizeOfObjects / speed - 1);
...@@ -292,7 +292,7 @@ TEST_F(GCIdleTimeHandlerTest, NotEnoughTime) { ...@@ -292,7 +292,7 @@ TEST_F(GCIdleTimeHandlerTest, NotEnoughTime) {
TEST_F(GCIdleTimeHandlerTest, Scavenge) { TEST_F(GCIdleTimeHandlerTest, Scavenge) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
int idle_time_ms = 10; int idle_time_ms = 10;
heap_state.used_new_space_size = heap_state.used_new_space_size =
heap_state.new_space_capacity - heap_state.new_space_capacity -
...@@ -305,7 +305,7 @@ TEST_F(GCIdleTimeHandlerTest, Scavenge) { ...@@ -305,7 +305,7 @@ TEST_F(GCIdleTimeHandlerTest, Scavenge) {
TEST_F(GCIdleTimeHandlerTest, ScavengeAndDone) { TEST_F(GCIdleTimeHandlerTest, ScavengeAndDone) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
int idle_time_ms = 10; int idle_time_ms = 10;
heap_state.incremental_marking_stopped = true; heap_state.incremental_marking_stopped = true;
heap_state.used_new_space_size = heap_state.used_new_space_size =
...@@ -321,7 +321,7 @@ TEST_F(GCIdleTimeHandlerTest, ScavengeAndDone) { ...@@ -321,7 +321,7 @@ TEST_F(GCIdleTimeHandlerTest, ScavengeAndDone) {
TEST_F(GCIdleTimeHandlerTest, DoNotStartIncrementalMarking) { TEST_F(GCIdleTimeHandlerTest, DoNotStartIncrementalMarking) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.incremental_marking_stopped = true; heap_state.incremental_marking_stopped = true;
double idle_time_ms = 10.0; double idle_time_ms = 10.0;
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
...@@ -330,7 +330,7 @@ TEST_F(GCIdleTimeHandlerTest, DoNotStartIncrementalMarking) { ...@@ -330,7 +330,7 @@ TEST_F(GCIdleTimeHandlerTest, DoNotStartIncrementalMarking) {
TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop) { TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.incremental_marking_stopped = true; heap_state.incremental_marking_stopped = true;
double idle_time_ms = 10.0; double idle_time_ms = 10.0;
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
...@@ -342,7 +342,7 @@ TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop) { ...@@ -342,7 +342,7 @@ TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop) {
TEST_F(GCIdleTimeHandlerTest, ZeroIdleTimeNothingToDo) { TEST_F(GCIdleTimeHandlerTest, ZeroIdleTimeNothingToDo) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
for (int i = 0; i < kMaxNotifications; i++) { for (int i = 0; i < kMaxNotifications; i++) {
GCIdleTimeAction action = handler()->Compute(0, heap_state); GCIdleTimeAction action = handler()->Compute(0, heap_state);
EXPECT_EQ(DO_NOTHING, action.type); EXPECT_EQ(DO_NOTHING, action.type);
...@@ -351,7 +351,7 @@ TEST_F(GCIdleTimeHandlerTest, ZeroIdleTimeNothingToDo) { ...@@ -351,7 +351,7 @@ TEST_F(GCIdleTimeHandlerTest, ZeroIdleTimeNothingToDo) {
TEST_F(GCIdleTimeHandlerTest, SmallIdleTimeNothingToDo) { TEST_F(GCIdleTimeHandlerTest, SmallIdleTimeNothingToDo) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.incremental_marking_stopped = true; heap_state.incremental_marking_stopped = true;
for (int i = 0; i < kMaxNotifications; i++) { for (int i = 0; i < kMaxNotifications; i++) {
GCIdleTimeAction action = handler()->Compute(10, heap_state); GCIdleTimeAction action = handler()->Compute(10, heap_state);
...@@ -362,7 +362,7 @@ TEST_F(GCIdleTimeHandlerTest, SmallIdleTimeNothingToDo) { ...@@ -362,7 +362,7 @@ TEST_F(GCIdleTimeHandlerTest, SmallIdleTimeNothingToDo) {
TEST_F(GCIdleTimeHandlerTest, DoneIfNotMakingProgressOnIncrementalMarking) { TEST_F(GCIdleTimeHandlerTest, DoneIfNotMakingProgressOnIncrementalMarking) {
// Regression test for crbug.com/489323. // Regression test for crbug.com/489323.
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
// Simulate incremental marking stopped and not eligible to start. // Simulate incremental marking stopped and not eligible to start.
heap_state.incremental_marking_stopped = true; heap_state.incremental_marking_stopped = true;
......
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