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

Unified Diff: src/heap/heap.cc

Issue 2210263002: [heap] Improve size profiling for ArrayBuffer tracking (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 4 years, 4 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
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 0d753e2227654db5244900aeb958802cf242201e..50e1efc15039e284039c6e85e8390a57348aa256 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -162,7 +162,8 @@ Heap::Heap()
deserialization_complete_(false),
strong_roots_list_(NULL),
heap_iterator_depth_(0),
- force_oom_(false) {
+ force_oom_(false),
+ array_buffer_tracker_(nullptr) {
// Allow build-time customization of the max semispace size. Building
// V8 with snapshots and a non-default max semispace size is much
// easier if you can define it as part of the build environment.
@@ -312,6 +313,21 @@ GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space,
return SCAVENGER;
}
+size_t Heap::external_memory_retained_from_new_space() {
+ // This is just an approximation.
+ return array_buffer_tracker()->retained_from_new_space();
+}
+
+bool Heap::ShouldDoScavengeForReducingExternalMemory() {
+ size_t retained_new_space = external_memory_retained_from_new_space();
+ size_t retained_old_space = external_memory() - retained_new_space;
+ float new_space_ratio =
+ static_cast<float>(new_space_.SizeOfObjects()) / retained_new_space;
+ float old_space_ratio =
+ static_cast<float>(old_space_->SizeOfObjects()) / retained_old_space;
+ // TODO(mlippautz): Add some lower bound.
+ return new_space_ratio > old_space_ratio;
+}
// TODO(1238405): Combine the infrastructure for --heap-stats and
// --log-gc to avoid the complicated preprocessor and flag testing.
@@ -1716,7 +1732,7 @@ void Heap::Scavenge() {
// Set age mark.
new_space_.set_age_mark(new_space_.top());
- ArrayBufferTracker::FreeDeadInNewSpace(this);
+ array_buffer_tracker()->FreeDeadInNewSpace();
// Update how much has survived scavenge.
IncrementYoungSurvivorsCounter(static_cast<int>(
@@ -2002,12 +2018,12 @@ HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) {
void Heap::RegisterNewArrayBuffer(JSArrayBuffer* buffer) {
- ArrayBufferTracker::RegisterNew(this, buffer);
+ array_buffer_tracker()->RegisterNew(buffer);
}
void Heap::UnregisterArrayBuffer(JSArrayBuffer* buffer) {
- ArrayBufferTracker::Unregister(this, buffer);
+ array_buffer_tracker()->Unregister(buffer);
}
@@ -5358,6 +5374,8 @@ bool Heap::SetUp() {
*this, ScavengeJob::kBytesAllocatedBeforeNextIdleTask);
new_space()->AddAllocationObserver(idle_scavenge_observer_);
+ array_buffer_tracker_ = new ArrayBufferTracker(this);
+
return true;
}
@@ -5558,6 +5576,9 @@ void Heap::TearDown() {
delete store_buffer_;
store_buffer_ = nullptr;
+ delete array_buffer_tracker_;
+ array_buffer_tracker_ = nullptr;
+
delete memory_allocator_;
memory_allocator_ = nullptr;
}
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698