Chromium Code Reviews| Index: src/heap.h | 
| diff --git a/src/heap.h b/src/heap.h | 
| index a6a14f6a6069838d096b4599fa898b4e0306349b..dbc9a5dd1a977053a37034df6acbc0648631e115 100644 | 
| --- a/src/heap.h | 
| +++ b/src/heap.h | 
| @@ -549,6 +549,163 @@ enum ArrayStorageAllocationMode { | 
| }; | 
| +// GCTracer collects and prints ONE line after each garbage collector | 
| +// invocation IFF --trace_gc is used. | 
| + | 
| +class GCTracer BASE_EMBEDDED { | 
| + public: | 
| + class Scope BASE_EMBEDDED { | 
| + public: | 
| + enum ScopeId { | 
| + EXTERNAL, | 
| + MC_MARK, | 
| + MC_SWEEP, | 
| + MC_SWEEP_NEWSPACE, | 
| + MC_SWEEP_OLDSPACE, | 
| + MC_SWEEP_CODE, | 
| + MC_SWEEP_CELL, | 
| + MC_SWEEP_MAP, | 
| + MC_EVACUATE_PAGES, | 
| + MC_UPDATE_NEW_TO_NEW_POINTERS, | 
| + MC_UPDATE_ROOT_TO_NEW_POINTERS, | 
| + MC_UPDATE_OLD_TO_NEW_POINTERS, | 
| + MC_UPDATE_POINTERS_TO_EVACUATED, | 
| + MC_UPDATE_POINTERS_BETWEEN_EVACUATED, | 
| + MC_UPDATE_MISC_POINTERS, | 
| + MC_WEAKCOLLECTION_PROCESS, | 
| + MC_WEAKCOLLECTION_CLEAR, | 
| + MC_FLUSH_CODE, | 
| + kNumberOfScopes | 
| 
 
jochen (gone - plz use gerrit)
2014/07/14 11:55:32
it's a bit odd to mix MACRO_STYLE and kStyle in th
 
 | 
| + }; | 
| + | 
| + Scope(GCTracer* tracer, ScopeId scope) | 
| + : tracer_(tracer), | 
| + scope_(scope) { | 
| + start_time_ = base::OS::TimeCurrentMillis(); | 
| + } | 
| + | 
| + ~Scope() { | 
| + ASSERT(scope_ < kNumberOfScopes); // scope_ is unsigned. | 
| + tracer_->scopes_[scope_] += base::OS::TimeCurrentMillis() - start_time_; | 
| + } | 
| + | 
| + private: | 
| + GCTracer* tracer_; | 
| + ScopeId scope_; | 
| + double start_time_; | 
| + }; | 
| 
 
jochen (gone - plz use gerrit)
2014/07/14 11:55:32
DISALLOW_COPY_AND_ASSIGN()
 
 | 
| + | 
| + explicit GCTracer(Heap* heap); | 
| + ~GCTracer(); | 
| + | 
| + void start(const char* gc_reason, const char* collector_reason); | 
| + void stop(); | 
| + | 
| + // Sets the collector. | 
| + void set_collector(GarbageCollector collector) { collector_ = collector; } | 
| + | 
| + // Sets the GC count. | 
| + void set_gc_count(unsigned int count) { gc_count_ = count; } | 
| + | 
| + // Sets the full GC count. | 
| + void set_full_gc_count(int count) { full_gc_count_ = count; } | 
| + | 
| + 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_++; | 
| + } | 
| + | 
| + int steps_count() { return steps_count_; } | 
| + | 
| + void add_step(double duration) { | 
| + steps_count_++; | 
| + steps_count_since_last_gc_++; | 
| + steps_took_ += duration; | 
| + steps_took_since_last_gc_ += duration; | 
| + longest_step_ = Max(longest_step_, duration); | 
| + } | 
| + | 
| + void reset_step_counters(bool reset_all_counters) { | 
| + if (reset_all_counters) { | 
| + steps_count_ = 0; | 
| + steps_took_ = 0.0; | 
| + } | 
| + steps_count_since_last_gc_ = 0; | 
| + steps_took_since_last_gc_ = 0.0; | 
| + longest_step_ = 0.0; | 
| + } | 
| + | 
| + private: | 
| + // Returns a string matching the collector. | 
| + const char* CollectorString(); | 
| + | 
| + // Returns size of object in heap (in MB). | 
| + inline double SizeOfHeapObjects(); | 
| + | 
| + // 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. | 
| + unsigned int gc_count_; | 
| + | 
| + // A count (including this one) of the number of full garbage collections. | 
| + int full_gc_count_; | 
| + | 
| + // Amounts of time spent in different scopes during GC. | 
| + double scopes_[Scope::kNumberOfScopes]; | 
| + | 
| + // Total amount of space either wasted or contained in one of free lists | 
| + // before the current GC. | 
| + intptr_t in_free_list_or_wasted_before_gc_; | 
| + | 
| + // Difference between space used in the heap at the beginning of the current | 
| + // collection and the end of the previous collection. | 
| + intptr_t allocated_since_last_gc_; | 
| + | 
| + // Amount of time spent in mutator that is time elapsed between end of the | 
| + // previous collection and the beginning of the current one. | 
| + double spent_in_mutator_; | 
| + | 
| + // 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. | 
| + int steps_count_; | 
| + double steps_took_; | 
| + double longest_step_; | 
| + int steps_count_since_last_gc_; | 
| + double steps_took_since_last_gc_; | 
| + | 
| + Heap* heap_; | 
| + | 
| + const char* gc_reason_; | 
| + const char* collector_reason_; | 
| +}; | 
| 
 
jochen (gone - plz use gerrit)
2014/07/14 11:55:33
disallopw copy/assign
 
 | 
| + | 
| + | 
| class Heap { | 
| public: | 
| // Configure heap size in MB before setup. Return false if the heap has been | 
| @@ -1218,7 +1375,7 @@ class Heap { | 
| void ClearNormalizedMapCaches(); | 
| - GCTracer* tracer() { return tracer_; } | 
| + GCTracer* tracer() { return &tracer_; } | 
| // Returns the size of objects residing in non new spaces. | 
| intptr_t PromotedSpaceSizeOfObjects(); | 
| @@ -1734,7 +1891,6 @@ class Heap { | 
| // collect more garbage. | 
| bool PerformGarbageCollection( | 
| GarbageCollector collector, | 
| - GCTracer* tracer, | 
| const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); | 
| inline void UpdateOldSpaceLimits(); | 
| @@ -1960,7 +2116,7 @@ class Heap { | 
| StoreBufferEvent event); | 
| // Performs a major collection in the whole heap. | 
| - void MarkCompact(GCTracer* tracer); | 
| + void MarkCompact(); | 
| // Code to be run before and after mark-compact. | 
| void MarkCompactPrologue(); | 
| @@ -1991,7 +2147,7 @@ class Heap { | 
| // Total RegExp code ever generated | 
| double total_regexp_code_generated_; | 
| - GCTracer* tracer_; | 
| + GCTracer tracer_; | 
| // Creates and installs the full-sized number string cache. | 
| int FullSizeNumberStringCacheLength(); | 
| @@ -2509,142 +2665,6 @@ class DescriptorLookupCache { | 
| }; | 
| -// GCTracer collects and prints ONE line after each garbage collector | 
| -// invocation IFF --trace_gc is used. | 
| - | 
| -class GCTracer BASE_EMBEDDED { | 
| - public: | 
| - class Scope BASE_EMBEDDED { | 
| - public: | 
| - enum ScopeId { | 
| - EXTERNAL, | 
| - MC_MARK, | 
| - MC_SWEEP, | 
| - MC_SWEEP_NEWSPACE, | 
| - MC_SWEEP_OLDSPACE, | 
| - MC_SWEEP_CODE, | 
| - MC_SWEEP_CELL, | 
| - MC_SWEEP_MAP, | 
| - MC_EVACUATE_PAGES, | 
| - MC_UPDATE_NEW_TO_NEW_POINTERS, | 
| - MC_UPDATE_ROOT_TO_NEW_POINTERS, | 
| - MC_UPDATE_OLD_TO_NEW_POINTERS, | 
| - MC_UPDATE_POINTERS_TO_EVACUATED, | 
| - MC_UPDATE_POINTERS_BETWEEN_EVACUATED, | 
| - MC_UPDATE_MISC_POINTERS, | 
| - MC_WEAKCOLLECTION_PROCESS, | 
| - MC_WEAKCOLLECTION_CLEAR, | 
| - MC_FLUSH_CODE, | 
| - kNumberOfScopes | 
| - }; | 
| - | 
| - Scope(GCTracer* tracer, ScopeId scope) | 
| - : tracer_(tracer), | 
| - scope_(scope) { | 
| - start_time_ = base::OS::TimeCurrentMillis(); | 
| - } | 
| - | 
| - ~Scope() { | 
| - ASSERT(scope_ < kNumberOfScopes); // scope_ is unsigned. | 
| - tracer_->scopes_[scope_] += base::OS::TimeCurrentMillis() - start_time_; | 
| - } | 
| - | 
| - private: | 
| - GCTracer* tracer_; | 
| - ScopeId scope_; | 
| - double start_time_; | 
| - }; | 
| - | 
| - explicit GCTracer(Heap* heap, | 
| - const char* gc_reason, | 
| - const char* collector_reason); | 
| - ~GCTracer(); | 
| - | 
| - // Sets the collector. | 
| - void set_collector(GarbageCollector collector) { collector_ = collector; } | 
| - | 
| - // Sets the GC count. | 
| - void set_gc_count(unsigned int count) { gc_count_ = count; } | 
| - | 
| - // Sets the full GC count. | 
| - void set_full_gc_count(int count) { full_gc_count_ = count; } | 
| - | 
| - 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: | 
| - // Returns a string matching the collector. | 
| - const char* CollectorString(); | 
| - | 
| - // Returns size of object in heap (in MB). | 
| - inline double SizeOfHeapObjects(); | 
| - | 
| - // 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. | 
| - unsigned int gc_count_; | 
| - | 
| - // A count (including this one) of the number of full garbage collections. | 
| - int full_gc_count_; | 
| - | 
| - // Amounts of time spent in different scopes during GC. | 
| - double scopes_[Scope::kNumberOfScopes]; | 
| - | 
| - // Total amount of space either wasted or contained in one of free lists | 
| - // before the current GC. | 
| - intptr_t in_free_list_or_wasted_before_gc_; | 
| - | 
| - // Difference between space used in the heap at the beginning of the current | 
| - // collection and the end of the previous collection. | 
| - intptr_t allocated_since_last_gc_; | 
| - | 
| - // Amount of time spent in mutator that is time elapsed between end of the | 
| - // previous collection and the beginning of the current one. | 
| - double spent_in_mutator_; | 
| - | 
| - // 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. | 
| - int steps_count_; | 
| - double steps_took_; | 
| - double longest_step_; | 
| - int steps_count_since_last_gc_; | 
| - double steps_took_since_last_gc_; | 
| - | 
| - Heap* heap_; | 
| - | 
| - const char* gc_reason_; | 
| - const char* collector_reason_; | 
| -}; | 
| - | 
| - | 
| class RegExpResultsCache { | 
| public: | 
| enum ResultsCacheType { REGEXP_MULTIPLE_INDICES, STRING_SPLIT_SUBSTRINGS }; |