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

Unified Diff: src/heap/heap.cc

Issue 1404523002: [heap] inline allocation steps refactor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use virtual functions instead of callbacks 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
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 75b7ec1fa698f824e2e82c57da0cb9947132b08f..b138ee51b83fa5c4592051fffe42ff708b2ad05a 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -52,6 +52,19 @@ struct Heap::StrongRootsList {
StrongRootsList* next;
};
+class IdleScavengeObserver : public InlineAllocationObserver {
+ public:
+ IdleScavengeObserver(Heap& heap, intptr_t step_size)
+ : InlineAllocationObserver(step_size), heap_(heap) {}
+
+ virtual void Step(int bytes_allocated) {
+ heap_.ScheduleIdleScavengeIfNeeded(bytes_allocated);
+ }
+
+ private:
+ Heap& heap_;
+};
+
Heap::Heap()
: amount_of_external_allocated_memory_(0),
@@ -129,6 +142,7 @@ Heap::Heap()
memory_reducer_(nullptr),
object_stats_(nullptr),
scavenge_job_(nullptr),
+ idle_scavenge_observer_(nullptr),
full_codegen_bytes_generated_(0),
crankshaft_codegen_bytes_generated_(0),
new_space_allocation_counter_(0),
@@ -4971,17 +4985,6 @@ void Heap::DisableInlineAllocation() {
}
-void Heap::LowerInlineAllocationLimit(intptr_t step) {
- new_space()->LowerInlineAllocationLimit(step);
-}
-
-
-void Heap::ResetInlineAllocationLimit() {
- new_space()->LowerInlineAllocationLimit(
- ScavengeJob::kBytesAllocatedBeforeNextIdleTask);
-}
-
-
V8_DECLARE_ONCE(initialize_gc_once);
static void InitializeGCOnce() {
@@ -5090,7 +5093,9 @@ bool Heap::SetUp() {
mark_compact_collector()->SetUp();
- ResetInlineAllocationLimit();
+ idle_scavenge_observer_ = new IdleScavengeObserver(
+ *this, ScavengeJob::kBytesAllocatedBeforeNextIdleTask);
+ new_space()->AddInlineAllocationObserver(idle_scavenge_observer_);
return true;
}
@@ -5189,6 +5194,10 @@ void Heap::TearDown() {
PrintAlloctionsHash();
}
+ new_space()->RemoveInlineAllocationObserver(idle_scavenge_observer_);
+ delete idle_scavenge_observer_;
+ idle_scavenge_observer_ = nullptr;
+
delete scavenge_collector_;
scavenge_collector_ = nullptr;
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.h » ('j') | src/heap/incremental-marking.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698