Reviewers: Michael Lippautz,
Description:
[heap] Hide MemoryReducer inside the heap component.
This prevents leakage of the memory-reducer.h declarations inside of the
heap and prevents it from being exposed to the world. Protects private
state from being inadvertently mocked with.
[email protected]
Please review this at https://codereview.chromium.org/1288913003/
Base URL:
https://chromium.googlesource.com/v8/v8.git@local_cleanup-heap-gc-tracer
Affected files (+14, -8 lines):
M src/heap/heap.h
M src/heap/heap.cc
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
92324c1bbda02c0f90bb4b0b5a1a7bc4e7e041c8..03b6c14c3e728a10fa181142eece058c3213e621
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -120,7 +120,7 @@ Heap::Heap()
mark_compact_collector_(this),
store_buffer_(this),
incremental_marking_(this),
- memory_reducer_(this),
+ memory_reducer_(nullptr),
full_codegen_bytes_generated_(0),
crankshaft_codegen_bytes_generated_(0),
new_space_allocation_counter_(0),
@@ -939,7 +939,7 @@ bool Heap::CollectGarbage(GarbageCollector collector,
const char* gc_reason,
HasHighFragmentation(used_memory_after, committed_memory_after) |
|
(detached_contexts()->length() > 0);
if (deserialization_complete_) {
- memory_reducer_.NotifyMarkCompact(event);
+ memory_reducer_->NotifyMarkCompact(event);
}
}
@@ -978,7 +978,7 @@ int Heap::NotifyContextDisposed(bool dependant_context)
{
MemoryReducer::Event event;
event.type = MemoryReducer::kContextDisposed;
event.time_ms = MonotonicallyIncreasingTimeInMs();
- memory_reducer_.NotifyContextDisposed(event);
+ memory_reducer_->NotifyContextDisposed(event);
return ++contexts_disposed_;
}
@@ -4968,7 +4968,7 @@ void
Heap::CheckAndNotifyBackgroundIdleNotification(double idle_time_in_ms,
event.time_ms = now_ms;
event.can_start_incremental_gc = incremental_marking()->IsStopped() &&
incremental_marking()->CanBeActivated();
- memory_reducer_.NotifyBackgroundIdleNotification(event);
+ memory_reducer_->NotifyBackgroundIdleNotification(event);
optimize_for_memory_usage_ = true;
} else {
optimize_for_memory_usage_ = false;
@@ -5661,7 +5661,7 @@ void Heap::SetOldGenerationAllocationLimit(intptr_t
old_gen_size,
factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained);
}
- if (memory_reducer_.ShouldGrowHeapSlowly() ||
optimize_for_memory_usage_) {
+ if (memory_reducer_->ShouldGrowHeapSlowly() ||
optimize_for_memory_usage_) {
factor = Min(factor, kConservativeHeapGrowingFactor);
}
@@ -5809,6 +5809,8 @@ bool Heap::SetUp() {
tracer_ = new GCTracer(this);
+ memory_reducer_ = new MemoryReducer(this);
+
LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity()));
LOG(isolate_, IntPtrTEvent("heap-available", Available()));
@@ -5907,7 +5909,11 @@ void Heap::TearDown() {
PrintAlloctionsHash();
}
- memory_reducer_.TearDown();
+ if (memory_reducer_ != nullptr) {
+ memory_reducer_->TearDown();
+ delete memory_reducer_;
+ memory_reducer_ = nullptr;
+ }
TearDownArrayBuffers();
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index
da52d3ce8df7ef4ec29cc58239c3a709e8b1db87..6c82764f09b55578aac80311c43b3817f53d42f9
100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -14,7 +14,6 @@
#include "src/heap/gc-idle-time-handler.h"
#include "src/heap/incremental-marking.h"
#include "src/heap/mark-compact.h"
-#include "src/heap/memory-reducer.h"
#include "src/heap/objects-visiting.h"
#include "src/heap/spaces.h"
#include "src/heap/store-buffer.h"
@@ -400,6 +399,7 @@ namespace internal {
// Forward declarations.
class HeapStats;
class Isolate;
+class MemoryReducer;
class WeakObjectRetainer;
@@ -2215,7 +2215,7 @@ class Heap {
GCIdleTimeHandler gc_idle_time_handler_;
- MemoryReducer memory_reducer_;
+ MemoryReducer* memory_reducer_;
// These two counters are monotomically increasing and never reset.
size_t full_codegen_bytes_generated_;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.