Chromium Code Reviews| Index: src/isolate.cc |
| diff --git a/src/isolate.cc b/src/isolate.cc |
| index ee3257cd274862dca0e9b6dbd6a49e4b9b7b23f4..e95d5c63eacb2f799183e89c15fe56c8b86dae0d 100644 |
| --- a/src/isolate.cc |
| +++ b/src/isolate.cc |
| @@ -1935,6 +1935,7 @@ class VerboseAccountingAllocator : public AccountingAllocator { |
| : heap_(heap), |
| last_memory_usage_(0), |
| last_pool_size_(0), |
| + nesting_deepth_(0), |
| allocation_sample_bytes_(allocation_sample_bytes), |
| pool_sample_bytes_(pool_sample_bytes) {} |
| @@ -1947,7 +1948,7 @@ class VerboseAccountingAllocator : public AccountingAllocator { |
| if (last_memory_usage_.Value() + allocation_sample_bytes_ < |
| malloced_current || |
| last_pool_size_.Value() + pool_sample_bytes_ < pooled_current) { |
| - PrintJSON(malloced_current, pooled_current); |
| + PrintMemoryJSON(malloced_current, pooled_current); |
| last_memory_usage_.SetValue(malloced_current); |
| last_pool_size_.SetValue(pooled_current); |
| } |
| @@ -1963,14 +1964,49 @@ class VerboseAccountingAllocator : public AccountingAllocator { |
| if (malloced_current + allocation_sample_bytes_ < |
| last_memory_usage_.Value() || |
| pooled_current + pool_sample_bytes_ < last_pool_size_.Value()) { |
| - PrintJSON(malloced_current, pooled_current); |
| + PrintMemoryJSON(malloced_current, pooled_current); |
| last_memory_usage_.SetValue(malloced_current); |
| last_pool_size_.SetValue(pooled_current); |
| } |
| } |
| + void ZoneCreation(const Zone* zone) override { |
| + double time = heap_->isolate()->time_millis_since_init(); |
| + PrintF( |
| + "{" |
| + "\"type\": \"zonecreation\", " |
| + "\"isolate\": \"%p\", " |
| + "\"time\": %f, " |
| + "\"ptr\": \"%p\", " |
| + "\"name\": \"%s\"," |
| + "\"nesting\": %zu" |
| + "}\n", |
| + reinterpret_cast<void*>(heap_->isolate()), time, |
| + reinterpret_cast<const void*>(zone), zone->name(), |
| + base::NoBarrier_Load(&nesting_deepth_)); |
| + base::NoBarrier_AtomicIncrement(&nesting_deepth_, 1); |
| + } |
| + |
| + void ZoneDestruction(const Zone* zone) override { |
| + base::NoBarrier_AtomicIncrement(&nesting_deepth_, -1); |
| + double time = heap_->isolate()->time_millis_since_init(); |
| + PrintF( |
| + "{" |
| + "\"type\": \"zonedestruction\", " |
| + "\"isolate\": \"%p\", " |
| + "\"time\": %f, " |
| + "\"ptr\": \"%p\", " |
| + "\"name\": \"%s\", " |
| + "\"size\": %zu," |
| + "\"nesting\": %zu" |
| + "}\n", |
| + reinterpret_cast<void*>(heap_->isolate()), time, |
| + reinterpret_cast<const void*>(zone), zone->name(), |
| + zone->allocation_size(), base::NoBarrier_Load(&nesting_deepth_)); |
| + } |
| + |
| private: |
| - void PrintJSON(size_t malloced, size_t pooled) { |
| + void PrintMemoryJSON(size_t malloced, size_t pooled) { |
| // Note: Neither isolate, nor heap is locked, so be careful with accesses |
| // as the allocator is potentially used on a concurrent thread. |
| double time = heap_->isolate()->time_millis_since_init(); |
| @@ -1988,6 +2024,7 @@ class VerboseAccountingAllocator : public AccountingAllocator { |
| Heap* heap_; |
| base::AtomicNumber<size_t> last_memory_usage_; |
| base::AtomicNumber<size_t> last_pool_size_; |
| + base::AtomicWord nesting_deepth_; |
|
Michael Lippautz
2016/10/11 11:25:19
You should use base::AtomicNumber<size_t/intptr_t>
|
| size_t allocation_sample_bytes_, pool_sample_bytes_; |
| }; |