Index: src/heap/spaces.h |
diff --git a/src/heap/spaces.h b/src/heap/spaces.h |
index 97f9de996f6cc8abd753072b4c003ac36bb4add9..d37c5423fb965461772cc3d9291ad2f7feb476a7 100644 |
--- a/src/heap/spaces.h |
+++ b/src/heap/spaces.h |
@@ -14,6 +14,7 @@ |
#include "src/base/platform/mutex.h" |
#include "src/flags.h" |
#include "src/hashmap.h" |
+#include "src/heap/array-buffer-tracker.h" |
#include "src/list.h" |
#include "src/objects.h" |
#include "src/utils.h" |
@@ -473,6 +474,8 @@ class MemoryChunk { |
kSweepingInProgress, |
}; |
+ enum ArrayBufferTrackerAccessMode { kDontCreate, kCreateIfNotPresent }; |
+ |
// Every n write barrier invocations we go to runtime even though |
// we could have handled it in generated code. This lets us check |
// whether we have hit the limit and should do some more marking. |
@@ -528,7 +531,8 @@ class MemoryChunk { |
+ kPointerSize // AtomicValue next_chunk_ |
+ kPointerSize // AtomicValue prev_chunk_ |
// FreeListCategory categories_[kNumberOfCategories] |
- + FreeListCategory::kSize * kNumberOfCategories; |
+ + FreeListCategory::kSize * kNumberOfCategories + |
+ kPointerSize; // LocalArrayBufferTracker tracker_ |
// We add some more space to the computed header size to amount for missing |
// alignment requirements in our computation. |
@@ -647,6 +651,21 @@ class MemoryChunk { |
void AllocateTypedOldToOldSlots(); |
void ReleaseTypedOldToOldSlots(); |
+ template <ArrayBufferTrackerAccessMode tracker_access> |
+ inline LocalArrayBufferTracker* local_tracker() { |
+ LocalArrayBufferTracker* tracker = local_tracker_.Value(); |
+ if (tracker == nullptr && tracker_access == kCreateIfNotPresent) { |
+ tracker = new LocalArrayBufferTracker(heap_); |
+ if (!local_tracker_.TrySetValue(nullptr, tracker)) { |
+ tracker = local_tracker_.Value(); |
+ } |
+ DCHECK_NOT_NULL(tracker); |
+ } |
+ return tracker; |
+ } |
+ |
+ void ReleaseLocalTracker(); |
+ |
Address area_start() { return area_start_; } |
Address area_end() { return area_end_; } |
int area_size() { return static_cast<int>(area_end() - area_start()); } |
@@ -832,6 +851,8 @@ class MemoryChunk { |
FreeListCategory categories_[kNumberOfCategories]; |
+ base::AtomicValue<LocalArrayBufferTracker*> local_tracker_; |
+ |
private: |
void InitializeReservedMemory() { reservation_.Reset(); } |