Extend --trace-gc to output amount of memory reserved for V8 heap.

This allows one to spot fragmentation issues just by looking at --trace-gc output.

R=erik.corry@gmail.com

Review URL: https://chromiumcodereview.appspot.com/9316060

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10584 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
vegorov@chromium.org 2012-02-02 11:47:23 +00:00
parent f39ae6d5e0
commit 6f20db9767
2 changed files with 24 additions and 9 deletions

View File

@ -6513,7 +6513,8 @@ static intptr_t CountTotalHolesSize() {
GCTracer::GCTracer(Heap* heap)
: start_time_(0.0),
start_size_(0),
start_object_size_(0),
start_memory_size_(0),
gc_count_(0),
full_gc_count_(0),
allocated_since_last_gc_(0),
@ -6522,7 +6523,8 @@ GCTracer::GCTracer(Heap* heap)
heap_(heap) {
if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return;
start_time_ = OS::TimeCurrentMillis();
start_size_ = heap_->SizeOfObjects();
start_object_size_ = heap_->SizeOfObjects();
start_memory_size_ = heap_->isolate()->memory_allocator()->Size();
for (int i = 0; i < Scope::kNumberOfScopes; i++) {
scopes_[i] = 0;
@ -6572,10 +6574,15 @@ GCTracer::~GCTracer() {
if (!FLAG_trace_gc_nvp) {
int external_time = static_cast<int>(scopes_[Scope::EXTERNAL]);
PrintF("%s %.1f -> %.1f MB, ",
double end_memory_size_mb =
static_cast<double>(heap_->isolate()->memory_allocator()->Size()) / MB;
PrintF("%s %.1f (%.1f) -> %.1f (%.1f) MB, ",
CollectorString(),
static_cast<double>(start_size_) / MB,
SizeOfHeapObjects());
static_cast<double>(start_object_size_) / MB,
static_cast<double>(start_memory_size_) / MB,
SizeOfHeapObjects(),
end_memory_size_mb);
if (external_time > 0) PrintF("%d / ", external_time);
PrintF("%d ms", time);
@ -6629,7 +6636,7 @@ GCTracer::~GCTracer() {
PrintF("misc_compaction=%d ",
static_cast<int>(scopes_[Scope::MC_UPDATE_MISC_POINTERS]));
PrintF("total_size_before=%" V8_PTR_PREFIX "d ", start_size_);
PrintF("total_size_before=%" V8_PTR_PREFIX "d ", start_object_size_);
PrintF("total_size_after=%" V8_PTR_PREFIX "d ", heap_->SizeOfObjects());
PrintF("holes_size_before=%" V8_PTR_PREFIX "d ",
in_free_list_or_wasted_before_gc_);

View File

@ -2387,9 +2387,17 @@ class GCTracer BASE_EMBEDDED {
// Returns size of object in heap (in MB).
inline double SizeOfHeapObjects();
double start_time_; // Timestamp set in the constructor.
intptr_t start_size_; // Size of objects in heap set in constructor.
GarbageCollector collector_; // Type of collector.
// Timestamp set in the constructor.
double start_time_;
// Size of objects in heap set in constructor.
intptr_t start_object_size_;
// Size of memory allocated from OS set in constructor.
intptr_t start_memory_size_;
// Type of collector.
GarbageCollector collector_;
// A count (including this one, e.g. the first collection is 1) of the
// number of garbage collections.