Commit 66e9596c authored by Hannes Payer's avatar Hannes Payer Committed by Commit Bot

[heap] Cleanup: Use std::atomic<T> instead of base::AtomicNumber<T> in mark-compact.

Bug: chromium:842083
Change-Id: Ie09b02bfe3fbc4f9ad2486843349d0f896b87b39
Reviewed-on: https://chromium-review.googlesource.com/1075532
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53401}
parent d4258eb1
...@@ -3962,10 +3962,9 @@ class YoungGenerationMarkingTask : public ItemParallelJob::Task { ...@@ -3962,10 +3962,9 @@ class YoungGenerationMarkingTask : public ItemParallelJob::Task {
class PageMarkingItem : public MarkingItem { class PageMarkingItem : public MarkingItem {
public: public:
explicit PageMarkingItem(MemoryChunk* chunk, explicit PageMarkingItem(MemoryChunk* chunk, std::atomic<int>* global_slots)
base::AtomicNumber<intptr_t>* global_slots)
: chunk_(chunk), global_slots_(global_slots), slots_(0) {} : chunk_(chunk), global_slots_(global_slots), slots_(0) {}
virtual ~PageMarkingItem() { global_slots_->Increment(slots_); } virtual ~PageMarkingItem() { *global_slots_ = *global_slots_ + slots_; }
void Process(YoungGenerationMarkingTask* task) override { void Process(YoungGenerationMarkingTask* task) override {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.gc"), TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.gc"),
...@@ -4016,8 +4015,8 @@ class PageMarkingItem : public MarkingItem { ...@@ -4016,8 +4015,8 @@ class PageMarkingItem : public MarkingItem {
} }
MemoryChunk* chunk_; MemoryChunk* chunk_;
base::AtomicNumber<intptr_t>* global_slots_; std::atomic<int>* global_slots_;
intptr_t slots_; int slots_;
}; };
class GlobalHandlesMarkingItem : public MarkingItem { class GlobalHandlesMarkingItem : public MarkingItem {
...@@ -4067,7 +4066,7 @@ class GlobalHandlesMarkingItem : public MarkingItem { ...@@ -4067,7 +4066,7 @@ class GlobalHandlesMarkingItem : public MarkingItem {
void MinorMarkCompactCollector::MarkRootSetInParallel( void MinorMarkCompactCollector::MarkRootSetInParallel(
RootMarkingVisitor* root_visitor) { RootMarkingVisitor* root_visitor) {
base::AtomicNumber<intptr_t> slots; std::atomic<int> slots;
{ {
ItemParallelJob job(isolate()->cancelable_task_manager(), ItemParallelJob job(isolate()->cancelable_task_manager(),
&page_parallel_job_semaphore_); &page_parallel_job_semaphore_);
...@@ -4100,7 +4099,7 @@ void MinorMarkCompactCollector::MarkRootSetInParallel( ...@@ -4100,7 +4099,7 @@ void MinorMarkCompactCollector::MarkRootSetInParallel(
DCHECK(worklist()->IsGlobalEmpty()); DCHECK(worklist()->IsGlobalEmpty());
} }
} }
old_to_new_slots_ = static_cast<int>(slots.Value()); old_to_new_slots_ = slots;
} }
void MinorMarkCompactCollector::MarkLiveObjects() { void MinorMarkCompactCollector::MarkLiveObjects() {
......
...@@ -315,21 +315,15 @@ class MinorMarkingState final ...@@ -315,21 +315,15 @@ class MinorMarkingState final
} }
void IncrementLiveBytes(MemoryChunk* chunk, intptr_t by) { void IncrementLiveBytes(MemoryChunk* chunk, intptr_t by) {
reinterpret_cast<base::AtomicNumber<intptr_t>*>( chunk->young_generation_live_byte_count_ += by;
&chunk->young_generation_live_byte_count_)
->Increment(by);
} }
intptr_t live_bytes(MemoryChunk* chunk) const { intptr_t live_bytes(MemoryChunk* chunk) const {
return reinterpret_cast<base::AtomicNumber<intptr_t>*>( return chunk->young_generation_live_byte_count_;
&chunk->young_generation_live_byte_count_)
->Value();
} }
void SetLiveBytes(MemoryChunk* chunk, intptr_t value) { void SetLiveBytes(MemoryChunk* chunk, intptr_t value) {
reinterpret_cast<base::AtomicNumber<intptr_t>*>( chunk->young_generation_live_byte_count_ = value;
&chunk->young_generation_live_byte_count_)
->SetValue(value);
} }
}; };
...@@ -384,19 +378,15 @@ class MajorAtomicMarkingState final ...@@ -384,19 +378,15 @@ class MajorAtomicMarkingState final
} }
void IncrementLiveBytes(MemoryChunk* chunk, intptr_t by) { void IncrementLiveBytes(MemoryChunk* chunk, intptr_t by) {
reinterpret_cast<base::AtomicNumber<intptr_t>*>(&chunk->live_byte_count_) chunk->live_byte_count_ += by;
->Increment(by);
} }
intptr_t live_bytes(MemoryChunk* chunk) const { intptr_t live_bytes(MemoryChunk* chunk) const {
return reinterpret_cast<base::AtomicNumber<intptr_t>*>( return chunk->live_byte_count_;
&chunk->live_byte_count_)
->Value();
} }
void SetLiveBytes(MemoryChunk* chunk, intptr_t value) { void SetLiveBytes(MemoryChunk* chunk, intptr_t value) {
reinterpret_cast<base::AtomicNumber<intptr_t>*>(&chunk->live_byte_count_) chunk->live_byte_count_ = value;
->SetValue(value);
} }
}; };
......
...@@ -357,7 +357,7 @@ class MemoryChunk { ...@@ -357,7 +357,7 @@ class MemoryChunk {
+ kPointerSize // Address owner_ + kPointerSize // Address owner_
+ kPointerSize // Heap* heap_ + kPointerSize // Heap* heap_
+ kIntptrSize // intptr_t progress_bar_ + kIntptrSize // intptr_t progress_bar_
+ kIntptrSize // 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_
...@@ -372,8 +372,8 @@ class MemoryChunk { ...@@ -372,8 +372,8 @@ class MemoryChunk {
+ kPointerSize * 2 // base::ListNode + kPointerSize * 2 // base::ListNode
+ kPointerSize * kNumberOfCategories + kPointerSize * kNumberOfCategories
// FreeListCategory categories_[kNumberOfCategories] // FreeListCategory categories_[kNumberOfCategories]
+ kPointerSize // LocalArrayBufferTracker* local_tracker_ + kPointerSize // LocalArrayBufferTracker* local_tracker_
+ kIntptrSize // intptr_t young_generation_live_byte_count_ + kIntptrSize // std::atomic<intptr_t> young_generation_live_byte_count_
+ kPointerSize; // Bitmap* young_generation_bitmap_ + kPointerSize; // Bitmap* young_generation_bitmap_
// We add some more space to the computed header size to amount for missing // We add some more space to the computed header size to amount for missing
...@@ -649,7 +649,7 @@ class MemoryChunk { ...@@ -649,7 +649,7 @@ class MemoryChunk {
intptr_t progress_bar_; intptr_t progress_bar_;
// Count of bytes marked black on page. // Count of bytes marked black on page.
intptr_t live_byte_count_; std::atomic<intptr_t> live_byte_count_;
// A single slot set for small pages (of size kPageSize) or an array of slot // A single slot set for small pages (of size kPageSize) or an array of slot
// set for large pages. In the latter case the number of entries in the array // set for large pages. In the latter case the number of entries in the array
...@@ -696,7 +696,7 @@ class MemoryChunk { ...@@ -696,7 +696,7 @@ class MemoryChunk {
LocalArrayBufferTracker* local_tracker_; LocalArrayBufferTracker* local_tracker_;
intptr_t young_generation_live_byte_count_; std::atomic<intptr_t> young_generation_live_byte_count_;
Bitmap* young_generation_bitmap_; Bitmap* young_generation_bitmap_;
private: private:
......
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