Commit 92f461c0 authored by Rodrigo Bruno's avatar Rodrigo Bruno Committed by Commit Bot

[heap] Preparing memory chunks to contain external memory counters.

Bug: chromium:845409
Change-Id: Id4f1b93f0992e15ed592156c7dec7d15828e4c42
Reviewed-on: https://chromium-review.googlesource.com/1113552Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Rodrigo Bruno <rfbpb@google.com>
Cr-Commit-Position: refs/heads/master@{#54014}
parent 983456f5
...@@ -631,6 +631,12 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size, ...@@ -631,6 +631,12 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size,
chunk->young_generation_bitmap_ = nullptr; chunk->young_generation_bitmap_ = nullptr;
chunk->local_tracker_ = nullptr; chunk->local_tracker_ = nullptr;
chunk->external_backing_store_bytes_[ExternalBackingStoreType::kOther] = 0;
chunk->external_backing_store_bytes_[ExternalBackingStoreType::kArrayBuffer] =
0;
chunk->external_backing_store_bytes_
[ExternalBackingStoreType::kExternalString] = 0;
for (int i = kFirstCategory; i < kNumberOfCategories; i++) { for (int i = kFirstCategory; i < kNumberOfCategories; i++) {
chunk->categories_[i] = nullptr; chunk->categories_[i] = nullptr;
} }
......
...@@ -367,13 +367,15 @@ class MemoryChunk { ...@@ -367,13 +367,15 @@ class MemoryChunk {
+ kIntptrSize // std::atomic<intptr_t> live_byte_count_ + kIntptrSize // std::atomic<intptr_t> live_byte_count_
+ kPointerSize * NUMBER_OF_REMEMBERED_SET_TYPES // SlotSet* array + kPointerSize * NUMBER_OF_REMEMBERED_SET_TYPES // SlotSet* array
+ kPointerSize * NUMBER_OF_REMEMBERED_SET_TYPES // TypedSlotSet* array + kPointerSize * NUMBER_OF_REMEMBERED_SET_TYPES // TypedSlotSet* array
+ kPointerSize // InvalidatedSlots* invalidated_slots_ + kPointerSize // InvalidatedSlots* invalidated_slots_
+ kPointerSize // SkipList* skip_list_ + kPointerSize // SkipList* skip_list_
+ kPointerSize // AtomicValue high_water_mark_ + kPointerSize // AtomicValue high_water_mark_
+ kPointerSize // base::Mutex* mutex_ + kPointerSize // base::Mutex* mutex_
+ kPointerSize // base::AtomicWord concurrent_sweeping_ + kPointerSize // base::AtomicWord concurrent_sweeping_
+ kPointerSize // base::Mutex* page_protection_change_mutex_ + kPointerSize // base::Mutex* page_protection_change_mutex_
+ kPointerSize // unitptr_t write_unprotect_counter_ + kPointerSize // unitptr_t write_unprotect_counter_
+ kSizetSize * kNumTypes
// std::atomic<size_t> external_backing_store_bytes_
+ kSizetSize // size_t allocated_bytes_ + kSizetSize // size_t allocated_bytes_
+ kSizetSize // size_t wasted_memory_ + kSizetSize // size_t wasted_memory_
+ kPointerSize * 2 // base::ListNode + kPointerSize * 2 // base::ListNode
...@@ -536,6 +538,15 @@ class MemoryChunk { ...@@ -536,6 +538,15 @@ class MemoryChunk {
} }
} }
void IncrementExternalBackingStoreBytes(size_t amount,
ExternalBackingStoreType type) {
external_backing_store_bytes_[type] += amount;
}
void DecrementExternalBackingStoreBytes(size_t amount,
ExternalBackingStoreType type) {
external_backing_store_bytes_[type] -= amount;
}
inline uint32_t AddressToMarkbitIndex(Address addr) const { inline uint32_t AddressToMarkbitIndex(Address addr) const {
return static_cast<uint32_t>(addr - this->address()) >> kPointerSizeLog2; return static_cast<uint32_t>(addr - this->address()) >> kPointerSizeLog2;
} }
...@@ -691,6 +702,10 @@ class MemoryChunk { ...@@ -691,6 +702,10 @@ class MemoryChunk {
// Byte allocated on the page, which includes all objects on the page // Byte allocated on the page, which includes all objects on the page
// and the linear allocation area. // and the linear allocation area.
size_t allocated_bytes_; size_t allocated_bytes_;
// Tracks off-heap memory used by this memory chunk.
std::atomic<size_t> external_backing_store_bytes_[kNumTypes];
// Freed memory that was not added to the free list. // Freed memory that was not added to the free list.
size_t wasted_memory_; size_t wasted_memory_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment