Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/heap/heap.cc

Issue 1097683002: Clean up output of heap object tracing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compile error Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 6273 matching lines...) Expand 10 before | Expand all | Expand 10 after
6284 if (clear_last_time_stats) { 6284 if (clear_last_time_stats) {
6285 memset(object_counts_last_time_, 0, sizeof(object_counts_last_time_)); 6285 memset(object_counts_last_time_, 0, sizeof(object_counts_last_time_));
6286 memset(object_sizes_last_time_, 0, sizeof(object_sizes_last_time_)); 6286 memset(object_sizes_last_time_, 0, sizeof(object_sizes_last_time_));
6287 } 6287 }
6288 } 6288 }
6289 6289
6290 6290
6291 static base::LazyMutex object_stats_mutex = LAZY_MUTEX_INITIALIZER; 6291 static base::LazyMutex object_stats_mutex = LAZY_MUTEX_INITIALIZER;
6292 6292
6293 6293
6294 static void TraceObjectStat(const char* name, int count, int size) { 6294 void Heap::TraceObjectStat(const char* name, int count, int size, double time) {
6295 if (size > 0) { 6295 PrintPID("heap:%p, time:%f, gc:%d, type:%s, count:%d, size:%d\n",
6296 PrintF("%40s\tcount= %6d\t size= %6d kb\n", name, count, size); 6296 static_cast<void*>(this), time, ms_count_, name, count, size);
6297 }
6298 } 6297 }
6299 6298
6300 6299
6301 void Heap::TraceObjectStats() { 6300 void Heap::TraceObjectStats() {
6302 base::LockGuard<base::Mutex> lock_guard(object_stats_mutex.Pointer()); 6301 base::LockGuard<base::Mutex> lock_guard(object_stats_mutex.Pointer());
6303 int index; 6302 int index;
6304 int count; 6303 int count;
6305 int size; 6304 int size;
6306 int total_size = 0; 6305 int total_size = 0;
6306 double time = isolate_->time_millis_since_init();
6307 #define TRACE_OBJECT_COUNT(name) \ 6307 #define TRACE_OBJECT_COUNT(name) \
6308 count = static_cast<int>(object_counts_[name]); \ 6308 count = static_cast<int>(object_counts_[name]); \
6309 size = static_cast<int>(object_sizes_[name]) / KB; \ 6309 size = static_cast<int>(object_sizes_[name]) / KB; \
6310 total_size += size; \ 6310 total_size += size; \
6311 TraceObjectStat(#name, count, size); 6311 TraceObjectStat(#name, count, size, time);
6312 INSTANCE_TYPE_LIST(TRACE_OBJECT_COUNT) 6312 INSTANCE_TYPE_LIST(TRACE_OBJECT_COUNT)
6313 #undef TRACE_OBJECT_COUNT 6313 #undef TRACE_OBJECT_COUNT
6314 #define TRACE_OBJECT_COUNT(name) \ 6314 #define TRACE_OBJECT_COUNT(name) \
6315 index = FIRST_CODE_KIND_SUB_TYPE + Code::name; \ 6315 index = FIRST_CODE_KIND_SUB_TYPE + Code::name; \
6316 count = static_cast<int>(object_counts_[index]); \ 6316 count = static_cast<int>(object_counts_[index]); \
6317 size = static_cast<int>(object_sizes_[index]) / KB; \ 6317 size = static_cast<int>(object_sizes_[index]) / KB; \
6318 TraceObjectStat("CODE_" #name, count, size); 6318 TraceObjectStat("*CODE_" #name, count, size, time);
6319 CODE_KIND_LIST(TRACE_OBJECT_COUNT) 6319 CODE_KIND_LIST(TRACE_OBJECT_COUNT)
6320 #undef TRACE_OBJECT_COUNT 6320 #undef TRACE_OBJECT_COUNT
6321 #define TRACE_OBJECT_COUNT(name) \ 6321 #define TRACE_OBJECT_COUNT(name) \
6322 index = FIRST_FIXED_ARRAY_SUB_TYPE + name; \ 6322 index = FIRST_FIXED_ARRAY_SUB_TYPE + name; \
6323 count = static_cast<int>(object_counts_[index]); \ 6323 count = static_cast<int>(object_counts_[index]); \
6324 size = static_cast<int>(object_sizes_[index]) / KB; \ 6324 size = static_cast<int>(object_sizes_[index]) / KB; \
6325 TraceObjectStat("FIXED_ARRAY_" #name, count, size); 6325 TraceObjectStat("*FIXED_ARRAY_" #name, count, size, time);
6326 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(TRACE_OBJECT_COUNT) 6326 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(TRACE_OBJECT_COUNT)
6327 #undef TRACE_OBJECT_COUNT 6327 #undef TRACE_OBJECT_COUNT
6328 #define TRACE_OBJECT_COUNT(name) \ 6328 #define TRACE_OBJECT_COUNT(name) \
6329 index = \ 6329 index = \
6330 FIRST_CODE_AGE_SUB_TYPE + Code::k##name##CodeAge - Code::kFirstCodeAge; \ 6330 FIRST_CODE_AGE_SUB_TYPE + Code::k##name##CodeAge - Code::kFirstCodeAge; \
6331 count = static_cast<int>(object_counts_[index]); \ 6331 count = static_cast<int>(object_counts_[index]); \
6332 size = static_cast<int>(object_sizes_[index]) / KB; \ 6332 size = static_cast<int>(object_sizes_[index]) / KB; \
6333 TraceObjectStat("CODE_AGE_" #name, count, size); 6333 TraceObjectStat("*CODE_AGE_" #name, count, size, time);
6334 CODE_AGE_LIST_COMPLETE(TRACE_OBJECT_COUNT) 6334 CODE_AGE_LIST_COMPLETE(TRACE_OBJECT_COUNT)
6335 #undef TRACE_OBJECT_COUNT 6335 #undef TRACE_OBJECT_COUNT
6336 PrintF("Total size= %d kb\n", total_size);
6337 } 6336 }
6338 6337
6339 6338
6340 void Heap::CheckpointObjectStats() { 6339 void Heap::CheckpointObjectStats() {
6341 base::LockGuard<base::Mutex> lock_guard(object_stats_mutex.Pointer()); 6340 base::LockGuard<base::Mutex> lock_guard(object_stats_mutex.Pointer());
6342 Counters* counters = isolate()->counters(); 6341 Counters* counters = isolate()->counters();
6343 #define ADJUST_LAST_TIME_OBJECT_COUNT(name) \ 6342 #define ADJUST_LAST_TIME_OBJECT_COUNT(name) \
6344 counters->count_of_##name()->Increment( \ 6343 counters->count_of_##name()->Increment( \
6345 static_cast<int>(object_counts_[name])); \ 6344 static_cast<int>(object_counts_[name])); \
6346 counters->count_of_##name()->Decrement( \ 6345 counters->count_of_##name()->Decrement( \
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
6389 static_cast<int>(object_sizes_last_time_[index])); 6388 static_cast<int>(object_sizes_last_time_[index]));
6390 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6389 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6391 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6390 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6392 6391
6393 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6392 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6394 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6393 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6395 ClearObjectStats(); 6394 ClearObjectStats();
6396 } 6395 }
6397 } 6396 }
6398 } // namespace v8::internal 6397 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698