Index: src/heap/spaces.cc |
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc |
index 4a565ac90747bea2c3f4bc4e15af1386ec13d778..d0244a8551539e03aad76ff0ad90e5e4696454ae 100644 |
--- a/src/heap/spaces.cc |
+++ b/src/heap/spaces.cc |
@@ -8,6 +8,7 @@ |
#include "src/base/platform/platform.h" |
#include "src/base/platform/semaphore.h" |
#include "src/full-codegen/full-codegen.h" |
+#include "src/heap/array-buffer-tracker.h" |
#include "src/heap/slot-set.h" |
#include "src/macro-assembler.h" |
#include "src/msan.h" |
@@ -511,13 +512,14 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size, |
chunk->progress_bar_ = 0; |
chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); |
chunk->concurrent_sweeping_state().SetValue(kSweepingDone); |
- chunk->mutex_ = nullptr; |
+ chunk->mutex_ = new base::Mutex(); |
chunk->available_in_free_list_ = 0; |
chunk->wasted_memory_ = 0; |
chunk->ResetLiveBytes(); |
Bitmap::Clear(chunk); |
chunk->set_next_chunk(nullptr); |
chunk->set_prev_chunk(nullptr); |
+ chunk->local_tracker_ = nullptr; |
DCHECK(OFFSET_OF(MemoryChunk, flags_) == kFlagsOffset); |
DCHECK(OFFSET_OF(MemoryChunk, live_byte_count_) == kLiveBytesOffset); |
@@ -1010,6 +1012,7 @@ void MemoryChunk::ReleaseAllocatedMemory() { |
if (old_to_old_slots_ != nullptr) ReleaseOldToOldSlots(); |
if (typed_old_to_new_slots_ != nullptr) ReleaseTypedOldToNewSlots(); |
if (typed_old_to_old_slots_ != nullptr) ReleaseTypedOldToOldSlots(); |
+ if (local_tracker_ != nullptr) ReleaseLocalTracker(); |
} |
static SlotSet* AllocateSlotSet(size_t size, Address page_start) { |
@@ -1061,6 +1064,18 @@ void MemoryChunk::ReleaseTypedOldToOldSlots() { |
delete typed_old_to_old_slots_; |
typed_old_to_old_slots_ = nullptr; |
} |
+ |
+void MemoryChunk::AllocateLocalTracker() { |
+ DCHECK_NULL(local_tracker_); |
+ local_tracker_ = new LocalArrayBufferTracker(heap()); |
+} |
+ |
+void MemoryChunk::ReleaseLocalTracker() { |
+ DCHECK_NOT_NULL(local_tracker_); |
+ delete local_tracker_; |
+ local_tracker_ = nullptr; |
+} |
+ |
// ----------------------------------------------------------------------------- |
// PagedSpace implementation |
@@ -1101,7 +1116,9 @@ bool PagedSpace::HasBeenSetUp() { return true; } |
void PagedSpace::TearDown() { |
PageIterator iterator(this); |
while (iterator.has_next()) { |
- heap()->memory_allocator()->Free<MemoryAllocator::kFull>(iterator.next()); |
+ Page* page = iterator.next(); |
+ ArrayBufferTracker::FreeAll(page); |
+ heap()->memory_allocator()->Free<MemoryAllocator::kFull>(page); |
} |
anchor_.set_next_page(&anchor_); |
anchor_.set_prev_page(&anchor_); |
@@ -1719,7 +1736,14 @@ void SemiSpace::SetUp(int initial_capacity, int maximum_capacity) { |
void SemiSpace::TearDown() { |
// Properly uncommit memory to keep the allocator counters in sync. |
- if (is_committed()) Uncommit(); |
+ if (is_committed()) { |
+ NewSpacePageIterator it(this); |
+ while (it.has_next()) { |
+ Page* page = it.next(); |
+ ArrayBufferTracker::FreeAll(page); |
+ } |
+ Uncommit(); |
+ } |
current_capacity_ = maximum_capacity_ = 0; |
} |