Chromium Code Reviews| Index: src/isolate.cc | 
| diff --git a/src/isolate.cc b/src/isolate.cc | 
| index ee3257cd274862dca0e9b6dbd6a49e4b9b7b23f4..1a63ebd58b2e85c8b93b0d3c0c5c91a2e82159b3 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), | 
| 
 
Toon Verwaest
2016/10/11 12:04:10
nesting_depth
 
 | 
| 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(), | 
| + nesting_deepth_.Value()); | 
| + nesting_deepth_.Increment(1); | 
| + } | 
| + | 
| + void ZoneDestruction(const Zone* zone) override { | 
| + nesting_deepth_.Decrement(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(), nesting_deepth_.Value()); | 
| + } | 
| + | 
| 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::AtomicNumber<size_t> nesting_deepth_; | 
| size_t allocation_sample_bytes_, pool_sample_bytes_; | 
| }; |