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

Unified Diff: src/heap/heap.h

Issue 1324023007: [heap] introduce ArrayBufferTracker (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: destructor Created 5 years, 3 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/array-buffer-tracker.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index 933c4dc4dc4c9480297a1e4cb5c05a0e599b8ef1..a5d113117430b42b36d4b25f7770368fcd5c3083 100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -420,6 +420,7 @@ namespace internal {
PRIVATE_SYMBOL_LIST(V)
// Forward declarations.
+class ArrayBufferTracker;
class HeapObjectsFilter;
class HeapStats;
class Isolate;
@@ -984,6 +985,10 @@ class Heap {
return amount_of_external_allocated_memory_;
}
+ void update_amount_of_external_allocated_memory(int64_t delta) {
+ amount_of_external_allocated_memory_ += delta;
+ }
+
void DeoptMarkedAllocationSites();
bool DeoptMaybeTenuredAllocationSites() {
@@ -1009,29 +1014,6 @@ class Heap {
bool deserialization_complete() const { return deserialization_complete_; }
- // The following methods are used to track raw C++ pointers to externally
- // allocated memory used as backing store in live array buffers.
-
- // A new ArrayBuffer was created with |data| as backing store.
- void RegisterNewArrayBuffer(bool in_new_space, void* data, size_t length);
-
- // The backing store |data| is no longer owned by V8.
- void UnregisterArrayBuffer(bool in_new_space, void* data);
-
- // A live ArrayBuffer was discovered during marking/scavenge.
- void RegisterLiveArrayBuffer(bool in_new_space, void* data);
-
- // Frees all backing store pointers that weren't discovered in the previous
- // marking or scavenge phase.
- void FreeDeadArrayBuffers(bool from_scavenge);
-
- // Prepare for a new scavenge phase. A new marking phase is implicitly
- // prepared by finishing the previous one.
- void PrepareArrayBufferDiscoveryInNewSpace();
-
- // An ArrayBuffer moved from new space to old space.
- void PromoteArrayBuffer(Object* buffer);
-
bool HasLowAllocationRate();
bool HasHighFragmentation();
bool HasHighFragmentation(intptr_t used, intptr_t committed);
@@ -1522,6 +1504,16 @@ class Heap {
int allocation_size,
AllocationAlignment alignment);
+ // ===========================================================================
+ // ArrayBufferTracker. =======================================================
+ // ===========================================================================
+ void RegisterNewArrayBuffer(JSArrayBuffer* buffer);
+ void UnregisterArrayBuffer(JSArrayBuffer* buffer);
+
+ inline ArrayBufferTracker* array_buffer_tracker() {
+ return array_buffer_tracker_;
+ }
+
// =============================================================================
#ifdef VERIFY_HEAP
@@ -1755,9 +1747,6 @@ class Heap {
// the old space.
void EvaluateOldSpaceLocalPretenuring(uint64_t size_of_objects_before_gc);
- // Called on heap tear-down. Frees all remaining ArrayBuffer backing stores.
- void TearDownArrayBuffers();
-
// Record statistics before and after garbage collection.
void ReportStatisticsBeforeGC();
void ReportStatisticsAfterGC();
@@ -2339,27 +2328,10 @@ class Heap {
bool concurrent_sweeping_enabled_;
- // |live_array_buffers_| maps externally allocated memory used as backing
- // store for ArrayBuffers to the length of the respective memory blocks.
- //
- // At the beginning of mark/compact, |not_yet_discovered_array_buffers_| is
- // a copy of |live_array_buffers_| and we remove pointers as we discover live
- // ArrayBuffer objects during marking. At the end of mark/compact, the
- // remaining memory blocks can be freed.
- std::map<void*, size_t> live_array_buffers_;
- std::map<void*, size_t> not_yet_discovered_array_buffers_;
-
- // To be able to free memory held by ArrayBuffers during scavenge as well, we
- // have a separate list of allocated memory held by ArrayBuffers in new space.
- //
- // Since mark/compact also evacuates the new space, all pointers in the
- // |live_array_buffers_for_scavenge_| list are also in the
- // |live_array_buffers_| list.
- std::map<void*, size_t> live_array_buffers_for_scavenge_;
- std::map<void*, size_t> not_yet_discovered_array_buffers_for_scavenge_;
-
StrongRootsList* strong_roots_list_;
+ ArrayBufferTracker* array_buffer_tracker_;
+
// Classes in "heap" can be friends.
friend class AlwaysAllocateScope;
friend class GCCallbacksScope;
« no previous file with comments | « src/heap/array-buffer-tracker.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698