| Index: src/heap/spaces.cc
|
| diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
|
| index 332d59114b2c601b2a27ae1ac21eb8557d3ac00c..6b6725a01eab8977cad4a511d3df146b6e7f399c 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);
|
| @@ -984,6 +986,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) {
|
| @@ -1035,6 +1038,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
|
|
|
| @@ -1075,7 +1090,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_);
|
| @@ -1693,7 +1710,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;
|
| }
|
|
|
|
|