| OLD | NEW |
| 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 #ifndef V8_HEAP_H_ | 5 #ifndef V8_HEAP_H_ |
| 6 #define V8_HEAP_H_ | 6 #define V8_HEAP_H_ |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 } | 1229 } |
| 1230 | 1230 |
| 1231 void IncrementCodeGeneratedBytes(bool is_crankshafted, int size) { | 1231 void IncrementCodeGeneratedBytes(bool is_crankshafted, int size) { |
| 1232 if (is_crankshafted) { | 1232 if (is_crankshafted) { |
| 1233 crankshaft_codegen_bytes_generated_ += size; | 1233 crankshaft_codegen_bytes_generated_ += size; |
| 1234 } else { | 1234 } else { |
| 1235 full_codegen_bytes_generated_ += size; | 1235 full_codegen_bytes_generated_ += size; |
| 1236 } | 1236 } |
| 1237 } | 1237 } |
| 1238 | 1238 |
| 1239 // Update GC statistics that are tracked on the Heap. |
| 1240 void UpdateGCStatistics(double start_time, |
| 1241 double end_time, |
| 1242 double spent_in_mutator, |
| 1243 double marking_time); |
| 1244 |
| 1239 // Returns maximum GC pause. | 1245 // Returns maximum GC pause. |
| 1240 double get_max_gc_pause() { return max_gc_pause_; } | 1246 double get_max_gc_pause() { return max_gc_pause_; } |
| 1241 | 1247 |
| 1242 // Returns maximum size of objects alive after GC. | 1248 // Returns maximum size of objects alive after GC. |
| 1243 intptr_t get_max_alive_after_gc() { return max_alive_after_gc_; } | 1249 intptr_t get_max_alive_after_gc() { return max_alive_after_gc_; } |
| 1244 | 1250 |
| 1245 // Returns minimal interval between two subsequent collections. | 1251 // Returns minimal interval between two subsequent collections. |
| 1246 double get_min_in_mutator() { return min_in_mutator_; } | 1252 double get_min_in_mutator() { return min_in_mutator_; } |
| 1247 | 1253 |
| 1248 // TODO(hpayer): remove, should be handled by GCTracer | 1254 // TODO(hpayer): remove, should be handled by GCTracer |
| (...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2528 MC_EVACUATE_PAGES, | 2534 MC_EVACUATE_PAGES, |
| 2529 MC_UPDATE_NEW_TO_NEW_POINTERS, | 2535 MC_UPDATE_NEW_TO_NEW_POINTERS, |
| 2530 MC_UPDATE_ROOT_TO_NEW_POINTERS, | 2536 MC_UPDATE_ROOT_TO_NEW_POINTERS, |
| 2531 MC_UPDATE_OLD_TO_NEW_POINTERS, | 2537 MC_UPDATE_OLD_TO_NEW_POINTERS, |
| 2532 MC_UPDATE_POINTERS_TO_EVACUATED, | 2538 MC_UPDATE_POINTERS_TO_EVACUATED, |
| 2533 MC_UPDATE_POINTERS_BETWEEN_EVACUATED, | 2539 MC_UPDATE_POINTERS_BETWEEN_EVACUATED, |
| 2534 MC_UPDATE_MISC_POINTERS, | 2540 MC_UPDATE_MISC_POINTERS, |
| 2535 MC_WEAKCOLLECTION_PROCESS, | 2541 MC_WEAKCOLLECTION_PROCESS, |
| 2536 MC_WEAKCOLLECTION_CLEAR, | 2542 MC_WEAKCOLLECTION_CLEAR, |
| 2537 MC_FLUSH_CODE, | 2543 MC_FLUSH_CODE, |
| 2538 kNumberOfScopes | 2544 NUMBER_OF_SCOPES |
| 2539 }; | 2545 }; |
| 2540 | 2546 |
| 2541 Scope(GCTracer* tracer, ScopeId scope) | 2547 Scope(GCTracer* tracer, ScopeId scope) |
| 2542 : tracer_(tracer), | 2548 : tracer_(tracer), |
| 2543 scope_(scope) { | 2549 scope_(scope) { |
| 2544 start_time_ = base::OS::TimeCurrentMillis(); | 2550 start_time_ = base::OS::TimeCurrentMillis(); |
| 2545 } | 2551 } |
| 2546 | 2552 |
| 2547 ~Scope() { | 2553 ~Scope() { |
| 2548 ASSERT(scope_ < kNumberOfScopes); // scope_ is unsigned. | 2554 ASSERT(scope_ < NUMBER_OF_SCOPES); // scope_ is unsigned. |
| 2549 tracer_->scopes_[scope_] += base::OS::TimeCurrentMillis() - start_time_; | 2555 tracer_->scopes_[scope_] += base::OS::TimeCurrentMillis() - start_time_; |
| 2550 } | 2556 } |
| 2551 | 2557 |
| 2552 private: | 2558 private: |
| 2553 GCTracer* tracer_; | 2559 GCTracer* tracer_; |
| 2554 ScopeId scope_; | 2560 ScopeId scope_; |
| 2555 double start_time_; | 2561 double start_time_; |
| 2562 |
| 2563 DISALLOW_COPY_AND_ASSIGN(Scope); |
| 2556 }; | 2564 }; |
| 2557 | 2565 |
| 2558 explicit GCTracer(Heap* heap, | 2566 explicit GCTracer(Heap* heap, |
| 2567 GarbageCollector collector, |
| 2559 const char* gc_reason, | 2568 const char* gc_reason, |
| 2560 const char* collector_reason); | 2569 const char* collector_reason); |
| 2561 ~GCTracer(); | 2570 ~GCTracer(); |
| 2562 | 2571 |
| 2563 // Sets the collector. | |
| 2564 void set_collector(GarbageCollector collector) { collector_ = collector; } | |
| 2565 | |
| 2566 // Sets the GC count. | |
| 2567 void set_gc_count(unsigned int count) { gc_count_ = count; } | |
| 2568 | |
| 2569 // Sets the full GC count. | |
| 2570 void set_full_gc_count(int count) { full_gc_count_ = count; } | |
| 2571 | |
| 2572 void increment_nodes_died_in_new_space() { | 2572 void increment_nodes_died_in_new_space() { |
| 2573 nodes_died_in_new_space_++; | 2573 nodes_died_in_new_space_++; |
| 2574 } | 2574 } |
| 2575 | 2575 |
| 2576 void increment_nodes_copied_in_new_space() { | 2576 void increment_nodes_copied_in_new_space() { |
| 2577 nodes_copied_in_new_space_++; | 2577 nodes_copied_in_new_space_++; |
| 2578 } | 2578 } |
| 2579 | 2579 |
| 2580 void increment_nodes_promoted() { | 2580 void increment_nodes_promoted() { |
| 2581 nodes_promoted_++; | 2581 nodes_promoted_++; |
| 2582 } | 2582 } |
| 2583 | 2583 |
| 2584 private: | 2584 private: |
| 2585 // Returns a string matching the collector. | 2585 // Returns a string matching the collector. |
| 2586 const char* CollectorString(); | 2586 const char* CollectorString() const; |
| 2587 | 2587 |
| 2588 // Returns size of object in heap (in MB). | 2588 // Print one detailed trace line in name=value format. |
| 2589 inline double SizeOfHeapObjects(); | 2589 void PrintNVP() const; |
| 2590 |
| 2591 // Print one trace line. |
| 2592 void Print() const; |
| 2590 | 2593 |
| 2591 // Timestamp set in the constructor. | 2594 // Timestamp set in the constructor. |
| 2592 double start_time_; | 2595 double start_time_; |
| 2593 | 2596 |
| 2597 // Timestamp set in the destructor. |
| 2598 double end_time_; |
| 2599 |
| 2594 // Size of objects in heap set in constructor. | 2600 // Size of objects in heap set in constructor. |
| 2595 intptr_t start_object_size_; | 2601 intptr_t start_object_size_; |
| 2596 | 2602 |
| 2603 // Size of objects in heap set in destructor. |
| 2604 intptr_t end_object_size_; |
| 2605 |
| 2597 // Size of memory allocated from OS set in constructor. | 2606 // Size of memory allocated from OS set in constructor. |
| 2598 intptr_t start_memory_size_; | 2607 intptr_t start_memory_size_; |
| 2599 | 2608 |
| 2609 // Size of memory allocated from OS set in destructor. |
| 2610 intptr_t end_memory_size_; |
| 2611 |
| 2600 // Type of collector. | 2612 // Type of collector. |
| 2601 GarbageCollector collector_; | 2613 GarbageCollector collector_; |
| 2602 | 2614 |
| 2603 // A count (including this one, e.g. the first collection is 1) of the | |
| 2604 // number of garbage collections. | |
| 2605 unsigned int gc_count_; | |
| 2606 | |
| 2607 // A count (including this one) of the number of full garbage collections. | |
| 2608 int full_gc_count_; | |
| 2609 | |
| 2610 // Amounts of time spent in different scopes during GC. | 2615 // Amounts of time spent in different scopes during GC. |
| 2611 double scopes_[Scope::kNumberOfScopes]; | 2616 double scopes_[Scope::NUMBER_OF_SCOPES]; |
| 2612 | 2617 |
| 2613 // Total amount of space either wasted or contained in one of free lists | 2618 // Total amount of space either wasted or contained in one of free lists |
| 2614 // before the current GC. | 2619 // before the current GC. |
| 2615 intptr_t in_free_list_or_wasted_before_gc_; | 2620 intptr_t in_free_list_or_wasted_before_gc_; |
| 2616 | 2621 |
| 2617 // Difference between space used in the heap at the beginning of the current | 2622 // Difference between space used in the heap at the beginning of the current |
| 2618 // collection and the end of the previous collection. | 2623 // collection and the end of the previous collection. |
| 2619 intptr_t allocated_since_last_gc_; | 2624 intptr_t allocated_since_last_gc_; |
| 2620 | 2625 |
| 2621 // Amount of time spent in mutator that is time elapsed between end of the | 2626 // Amount of time spent in mutator that is time elapsed between end of the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2635 int steps_count_; | 2640 int steps_count_; |
| 2636 double steps_took_; | 2641 double steps_took_; |
| 2637 double longest_step_; | 2642 double longest_step_; |
| 2638 int steps_count_since_last_gc_; | 2643 int steps_count_since_last_gc_; |
| 2639 double steps_took_since_last_gc_; | 2644 double steps_took_since_last_gc_; |
| 2640 | 2645 |
| 2641 Heap* heap_; | 2646 Heap* heap_; |
| 2642 | 2647 |
| 2643 const char* gc_reason_; | 2648 const char* gc_reason_; |
| 2644 const char* collector_reason_; | 2649 const char* collector_reason_; |
| 2650 |
| 2651 DISALLOW_COPY_AND_ASSIGN(GCTracer); |
| 2645 }; | 2652 }; |
| 2646 | 2653 |
| 2647 | 2654 |
| 2648 class RegExpResultsCache { | 2655 class RegExpResultsCache { |
| 2649 public: | 2656 public: |
| 2650 enum ResultsCacheType { REGEXP_MULTIPLE_INDICES, STRING_SPLIT_SUBSTRINGS }; | 2657 enum ResultsCacheType { REGEXP_MULTIPLE_INDICES, STRING_SPLIT_SUBSTRINGS }; |
| 2651 | 2658 |
| 2652 // Attempt to retrieve a cached result. On failure, 0 is returned as a Smi. | 2659 // Attempt to retrieve a cached result. On failure, 0 is returned as a Smi. |
| 2653 // On success, the returned result is guaranteed to be a COW-array. | 2660 // On success, the returned result is guaranteed to be a COW-array. |
| 2654 static Object* Lookup(Heap* heap, | 2661 static Object* Lookup(Heap* heap, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2780 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2787 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 2781 | 2788 |
| 2782 private: | 2789 private: |
| 2783 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2790 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2784 }; | 2791 }; |
| 2785 #endif // DEBUG | 2792 #endif // DEBUG |
| 2786 | 2793 |
| 2787 } } // namespace v8::internal | 2794 } } // namespace v8::internal |
| 2788 | 2795 |
| 2789 #endif // V8_HEAP_H_ | 2796 #endif // V8_HEAP_H_ |
| OLD | NEW |