Commit 39177148 authored by Hannes Payer's avatar Hannes Payer Committed by Commit Bot

Cleanup: Use std::atomic<T> instead of base::AtomicNumber<T> in isolate.

Bug: chromium:842083

Change-Id: I015db53853c7da42c4879c791f437bf44eea7a00
Reviewed-on: https://chromium-review.googlesource.com/1130516Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54348}
parent ceb21bd1
...@@ -2392,12 +2392,11 @@ class VerboseAccountingAllocator : public AccountingAllocator { ...@@ -2392,12 +2392,11 @@ class VerboseAccountingAllocator : public AccountingAllocator {
size_t malloced_current = GetCurrentMemoryUsage(); size_t malloced_current = GetCurrentMemoryUsage();
size_t pooled_current = GetCurrentPoolSize(); size_t pooled_current = GetCurrentPoolSize();
if (last_memory_usage_.Value() + allocation_sample_bytes_ < if (last_memory_usage_ + allocation_sample_bytes_ < malloced_current ||
malloced_current || last_pool_size_ + pool_sample_bytes_ < pooled_current) {
last_pool_size_.Value() + pool_sample_bytes_ < pooled_current) {
PrintMemoryJSON(malloced_current, pooled_current); PrintMemoryJSON(malloced_current, pooled_current);
last_memory_usage_.SetValue(malloced_current); last_memory_usage_ = malloced_current;
last_pool_size_.SetValue(pooled_current); last_pool_size_ = pooled_current;
} }
} }
return memory; return memory;
...@@ -2408,22 +2407,21 @@ class VerboseAccountingAllocator : public AccountingAllocator { ...@@ -2408,22 +2407,21 @@ class VerboseAccountingAllocator : public AccountingAllocator {
size_t malloced_current = GetCurrentMemoryUsage(); size_t malloced_current = GetCurrentMemoryUsage();
size_t pooled_current = GetCurrentPoolSize(); size_t pooled_current = GetCurrentPoolSize();
if (malloced_current + allocation_sample_bytes_ < if (malloced_current + allocation_sample_bytes_ < last_memory_usage_ ||
last_memory_usage_.Value() || pooled_current + pool_sample_bytes_ < last_pool_size_) {
pooled_current + pool_sample_bytes_ < last_pool_size_.Value()) {
PrintMemoryJSON(malloced_current, pooled_current); PrintMemoryJSON(malloced_current, pooled_current);
last_memory_usage_.SetValue(malloced_current); last_memory_usage_ = malloced_current;
last_pool_size_.SetValue(pooled_current); last_pool_size_ = pooled_current;
} }
} }
void ZoneCreation(const Zone* zone) override { void ZoneCreation(const Zone* zone) override {
PrintZoneModificationSample(zone, "zonecreation"); PrintZoneModificationSample(zone, "zonecreation");
nesting_deepth_.Increment(1); nesting_deepth_++;
} }
void ZoneDestruction(const Zone* zone) override { void ZoneDestruction(const Zone* zone) override {
nesting_deepth_.Decrement(1); nesting_deepth_--;
PrintZoneModificationSample(zone, "zonedestruction"); PrintZoneModificationSample(zone, "zonedestruction");
} }
...@@ -2442,7 +2440,7 @@ class VerboseAccountingAllocator : public AccountingAllocator { ...@@ -2442,7 +2440,7 @@ class VerboseAccountingAllocator : public AccountingAllocator {
type, reinterpret_cast<void*>(heap_->isolate()), type, reinterpret_cast<void*>(heap_->isolate()),
heap_->isolate()->time_millis_since_init(), heap_->isolate()->time_millis_since_init(),
reinterpret_cast<const void*>(zone), zone->name(), reinterpret_cast<const void*>(zone), zone->name(),
zone->allocation_size(), nesting_deepth_.Value()); zone->allocation_size(), nesting_deepth_.load());
} }
void PrintMemoryJSON(size_t malloced, size_t pooled) { void PrintMemoryJSON(size_t malloced, size_t pooled) {
...@@ -2461,14 +2459,14 @@ class VerboseAccountingAllocator : public AccountingAllocator { ...@@ -2461,14 +2459,14 @@ class VerboseAccountingAllocator : public AccountingAllocator {
} }
Heap* heap_; Heap* heap_;
base::AtomicNumber<size_t> last_memory_usage_; std::atomic<size_t> last_memory_usage_;
base::AtomicNumber<size_t> last_pool_size_; std::atomic<size_t> last_pool_size_;
base::AtomicNumber<size_t> nesting_deepth_; std::atomic<size_t> nesting_deepth_;
size_t allocation_sample_bytes_, pool_sample_bytes_; size_t allocation_sample_bytes_, pool_sample_bytes_;
}; };
#ifdef DEBUG #ifdef DEBUG
base::AtomicNumber<size_t> Isolate::non_disposed_isolates_; std::atomic<size_t> Isolate::non_disposed_isolates_;
#endif // DEBUG #endif // DEBUG
Isolate::Isolate() Isolate::Isolate()
...@@ -2557,7 +2555,7 @@ Isolate::Isolate() ...@@ -2557,7 +2555,7 @@ Isolate::Isolate()
thread_manager_->isolate_ = this; thread_manager_->isolate_ = this;
#ifdef DEBUG #ifdef DEBUG
non_disposed_isolates_.Increment(1); non_disposed_isolates_++;
#endif // DEBUG #endif // DEBUG
handle_scope_data_.Initialize(); handle_scope_data_.Initialize();
...@@ -2619,7 +2617,7 @@ void Isolate::TearDown() { ...@@ -2619,7 +2617,7 @@ void Isolate::TearDown() {
} }
#ifdef DEBUG #ifdef DEBUG
non_disposed_isolates_.Decrement(1); non_disposed_isolates_--;
#endif // DEBUG #endif // DEBUG
delete this; delete this;
......
...@@ -1000,9 +1000,7 @@ class Isolate : private HiddenFactory { ...@@ -1000,9 +1000,7 @@ class Isolate : private HiddenFactory {
HeapProfiler* heap_profiler() const { return heap_profiler_; } HeapProfiler* heap_profiler() const { return heap_profiler_; }
#ifdef DEBUG #ifdef DEBUG
static size_t non_disposed_isolates() { static size_t non_disposed_isolates() { return non_disposed_isolates_; }
return non_disposed_isolates_.Value();
}
#endif #endif
v8::internal::Factory* factory() { v8::internal::Factory* factory() {
...@@ -1643,7 +1641,7 @@ class Isolate : private HiddenFactory { ...@@ -1643,7 +1641,7 @@ class Isolate : private HiddenFactory {
double time_millis_at_init_; double time_millis_at_init_;
#ifdef DEBUG #ifdef DEBUG
static base::AtomicNumber<size_t> non_disposed_isolates_; static std::atomic<size_t> non_disposed_isolates_;
JSObject::SpillInformation js_spill_information_; JSObject::SpillInformation js_spill_information_;
#endif #endif
......
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