Add GCTracer metrics for a scavenger GC for DOM wrappers

This patch adds the following three metrics for the --trace_gc_nvp option.

nodes_died_in_new_space_; // Number of died nodes in the new space.
nodes_copied_in_new_space_; // Number of copied nodes to the new space.
nodes_promoted; // Number of promoted nodes to the old space.

BUG=
TEST=Manually confirmed that the "--trace_gc --trace_gc_nvp" option prints the metrics

Review URL: https://codereview.chromium.org/11365146
Patch from Kentaro Hara <haraken@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13159 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 17def81f
...@@ -597,7 +597,7 @@ bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, ...@@ -597,7 +597,7 @@ bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v,
bool GlobalHandles::PostGarbageCollectionProcessing( bool GlobalHandles::PostGarbageCollectionProcessing(
GarbageCollector collector) { GarbageCollector collector, GCTracer* tracer) {
// Process weak global handle callbacks. This must be done after the // Process weak global handle callbacks. This must be done after the
// GC is completely done, because the callbacks may invoke arbitrary // GC is completely done, because the callbacks may invoke arbitrary
// API functions. // API functions.
...@@ -647,10 +647,17 @@ bool GlobalHandles::PostGarbageCollectionProcessing( ...@@ -647,10 +647,17 @@ bool GlobalHandles::PostGarbageCollectionProcessing(
for (int i = 0; i < new_space_nodes_.length(); ++i) { for (int i = 0; i < new_space_nodes_.length(); ++i) {
Node* node = new_space_nodes_[i]; Node* node = new_space_nodes_[i];
ASSERT(node->is_in_new_space_list()); ASSERT(node->is_in_new_space_list());
if (node->IsRetainer() && isolate_->heap()->InNewSpace(node->object())) { if (node->IsRetainer()) {
if (isolate_->heap()->InNewSpace(node->object())) {
new_space_nodes_[last++] = node; new_space_nodes_[last++] = node;
tracer->increment_nodes_copied_in_new_space();
} else { } else {
node->set_in_new_space_list(false); node->set_in_new_space_list(false);
tracer->increment_nodes_promoted();
}
} else {
node->set_in_new_space_list(false);
tracer->increment_nodes_died_in_new_space();
} }
} }
new_space_nodes_.Rewind(last); new_space_nodes_.Rewind(last);
......
...@@ -168,7 +168,8 @@ class GlobalHandles { ...@@ -168,7 +168,8 @@ class GlobalHandles {
// Process pending weak handles. // Process pending weak handles.
// Returns true if next major GC is likely to collect more garbage. // Returns true if next major GC is likely to collect more garbage.
bool PostGarbageCollectionProcessing(GarbageCollector collector); bool PostGarbageCollectionProcessing(GarbageCollector collector,
GCTracer* tracer);
// Iterates over all strong handles. // Iterates over all strong handles.
void IterateStrongRoots(ObjectVisitor* v); void IterateStrongRoots(ObjectVisitor* v);
......
...@@ -965,7 +965,8 @@ bool Heap::PerformGarbageCollection(GarbageCollector collector, ...@@ -965,7 +965,8 @@ bool Heap::PerformGarbageCollection(GarbageCollector collector,
{ DisableAssertNoAllocation allow_allocation; { DisableAssertNoAllocation allow_allocation;
GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL);
next_gc_likely_to_collect_more = next_gc_likely_to_collect_more =
isolate_->global_handles()->PostGarbageCollectionProcessing(collector); isolate_->global_handles()->PostGarbageCollectionProcessing(
collector, tracer);
} }
gc_post_processing_depth_--; gc_post_processing_depth_--;
...@@ -6864,6 +6865,9 @@ GCTracer::GCTracer(Heap* heap, ...@@ -6864,6 +6865,9 @@ GCTracer::GCTracer(Heap* heap,
allocated_since_last_gc_(0), allocated_since_last_gc_(0),
spent_in_mutator_(0), spent_in_mutator_(0),
promoted_objects_size_(0), promoted_objects_size_(0),
nodes_died_in_new_space_(0),
nodes_copied_in_new_space_(0),
nodes_promoted_(0),
heap_(heap), heap_(heap),
gc_reason_(gc_reason), gc_reason_(gc_reason),
collector_reason_(collector_reason) { collector_reason_(collector_reason) {
...@@ -7004,6 +7008,9 @@ GCTracer::~GCTracer() { ...@@ -7004,6 +7008,9 @@ GCTracer::~GCTracer() {
PrintF("allocated=%" V8_PTR_PREFIX "d ", allocated_since_last_gc_); PrintF("allocated=%" V8_PTR_PREFIX "d ", allocated_since_last_gc_);
PrintF("promoted=%" V8_PTR_PREFIX "d ", promoted_objects_size_); PrintF("promoted=%" V8_PTR_PREFIX "d ", promoted_objects_size_);
PrintF("nodes_died_in_new=%d ", nodes_died_in_new_space_);
PrintF("nodes_copied_in_new=%d ", nodes_copied_in_new_space_);
PrintF("nodes_promoted=%d ", nodes_promoted_);
if (collector_ == SCAVENGER) { if (collector_ == SCAVENGER) {
PrintF("stepscount=%d ", steps_count_since_last_gc_); PrintF("stepscount=%d ", steps_count_since_last_gc_);
......
...@@ -2549,6 +2549,18 @@ class GCTracer BASE_EMBEDDED { ...@@ -2549,6 +2549,18 @@ class GCTracer BASE_EMBEDDED {
promoted_objects_size_ += object_size; promoted_objects_size_ += object_size;
} }
void increment_nodes_died_in_new_space() {
nodes_died_in_new_space_++;
}
void increment_nodes_copied_in_new_space() {
nodes_copied_in_new_space_++;
}
void increment_nodes_promoted() {
nodes_promoted_++;
}
private: private:
// Returns a string matching the collector. // Returns a string matching the collector.
const char* CollectorString(); const char* CollectorString();
...@@ -2593,6 +2605,15 @@ class GCTracer BASE_EMBEDDED { ...@@ -2593,6 +2605,15 @@ class GCTracer BASE_EMBEDDED {
// Size of objects promoted during the current collection. // Size of objects promoted during the current collection.
intptr_t promoted_objects_size_; intptr_t promoted_objects_size_;
// Number of died nodes in the new space.
int nodes_died_in_new_space_;
// Number of copied nodes to the new space.
int nodes_copied_in_new_space_;
// Number of promoted nodes to the old space.
int nodes_promoted_;
// Incremental marking steps counters. // Incremental marking steps counters.
int steps_count_; int steps_count_;
double steps_took_; double steps_took_;
......
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