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_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 }; | 634 }; |
635 | 635 |
636 // Indicates whether live bytes adjustment is triggered | 636 // Indicates whether live bytes adjustment is triggered |
637 // - from within the GC code before sweeping started (SEQUENTIAL_TO_SWEEPER), | 637 // - from within the GC code before sweeping started (SEQUENTIAL_TO_SWEEPER), |
638 // - or from within GC (CONCURRENT_TO_SWEEPER), | 638 // - or from within GC (CONCURRENT_TO_SWEEPER), |
639 // - or mutator code (CONCURRENT_TO_SWEEPER). | 639 // - or mutator code (CONCURRENT_TO_SWEEPER). |
640 enum InvocationMode { SEQUENTIAL_TO_SWEEPER, CONCURRENT_TO_SWEEPER }; | 640 enum InvocationMode { SEQUENTIAL_TO_SWEEPER, CONCURRENT_TO_SWEEPER }; |
641 | 641 |
642 enum PretenuringFeedbackInsertionMode { kCached, kGlobal }; | 642 enum PretenuringFeedbackInsertionMode { kCached, kGlobal }; |
643 | 643 |
| 644 enum FindMementoMode { kForRuntime, kForGC }; |
| 645 |
644 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; | 646 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; |
645 | 647 |
646 // Taking this lock prevents the GC from entering a phase that relocates | 648 // Taking this lock prevents the GC from entering a phase that relocates |
647 // object references. | 649 // object references. |
648 class RelocationLock { | 650 class RelocationLock { |
649 public: | 651 public: |
650 explicit RelocationLock(Heap* heap) : heap_(heap) { | 652 explicit RelocationLock(Heap* heap) : heap_(heap) { |
651 heap_->relocation_mutex_.Lock(); | 653 heap_->relocation_mutex_.Lock(); |
652 } | 654 } |
653 | 655 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 | 925 |
924 // Print short heap statistics. | 926 // Print short heap statistics. |
925 void PrintShortHeapStatistics(); | 927 void PrintShortHeapStatistics(); |
926 | 928 |
927 inline HeapState gc_state() { return gc_state_; } | 929 inline HeapState gc_state() { return gc_state_; } |
928 | 930 |
929 inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; } | 931 inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; } |
930 | 932 |
931 // If an object has an AllocationMemento trailing it, return it, otherwise | 933 // If an object has an AllocationMemento trailing it, return it, otherwise |
932 // return NULL; | 934 // return NULL; |
| 935 template <FindMementoMode mode> |
933 inline AllocationMemento* FindAllocationMemento(HeapObject* object); | 936 inline AllocationMemento* FindAllocationMemento(HeapObject* object); |
934 | 937 |
935 // Returns false if not able to reserve. | 938 // Returns false if not able to reserve. |
936 bool ReserveSpace(Reservation* reservations); | 939 bool ReserveSpace(Reservation* reservations); |
937 | 940 |
938 // | 941 // |
939 // Support for the API. | 942 // Support for the API. |
940 // | 943 // |
941 | 944 |
942 void CreateApiObjects(); | 945 void CreateApiObjects(); |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 // Returns the available bytes in space w/o growing. | 1407 // Returns the available bytes in space w/o growing. |
1405 // Heap doesn't guarantee that it can allocate an object that requires | 1408 // Heap doesn't guarantee that it can allocate an object that requires |
1406 // all available bytes. Check MaxHeapObjectSize() instead. | 1409 // all available bytes. Check MaxHeapObjectSize() instead. |
1407 intptr_t Available(); | 1410 intptr_t Available(); |
1408 | 1411 |
1409 // Returns of size of all objects residing in the heap. | 1412 // Returns of size of all objects residing in the heap. |
1410 intptr_t SizeOfObjects(); | 1413 intptr_t SizeOfObjects(); |
1411 | 1414 |
1412 void UpdateSurvivalStatistics(int start_new_space_size); | 1415 void UpdateSurvivalStatistics(int start_new_space_size); |
1413 | 1416 |
1414 inline void IncrementPromotedObjectsSize(int object_size) { | 1417 inline void IncrementPromotedObjectsSize(intptr_t object_size) { |
1415 DCHECK_GE(object_size, 0); | 1418 DCHECK_GE(object_size, 0); |
1416 promoted_objects_size_ += object_size; | 1419 promoted_objects_size_ += object_size; |
1417 } | 1420 } |
1418 inline intptr_t promoted_objects_size() { return promoted_objects_size_; } | 1421 inline intptr_t promoted_objects_size() { return promoted_objects_size_; } |
1419 | 1422 |
1420 inline void IncrementSemiSpaceCopiedObjectSize(int object_size) { | 1423 inline void IncrementSemiSpaceCopiedObjectSize(intptr_t object_size) { |
1421 DCHECK_GE(object_size, 0); | 1424 DCHECK_GE(object_size, 0); |
1422 semi_space_copied_object_size_ += object_size; | 1425 semi_space_copied_object_size_ += object_size; |
1423 } | 1426 } |
1424 inline intptr_t semi_space_copied_object_size() { | 1427 inline intptr_t semi_space_copied_object_size() { |
1425 return semi_space_copied_object_size_; | 1428 return semi_space_copied_object_size_; |
1426 } | 1429 } |
1427 | 1430 |
1428 inline intptr_t SurvivedNewSpaceObjectSize() { | 1431 inline intptr_t SurvivedNewSpaceObjectSize() { |
1429 return promoted_objects_size_ + semi_space_copied_object_size_; | 1432 return promoted_objects_size_ + semi_space_copied_object_size_; |
1430 } | 1433 } |
1431 | 1434 |
1432 inline void IncrementNodesDiedInNewSpace() { nodes_died_in_new_space_++; } | 1435 inline void IncrementNodesDiedInNewSpace() { nodes_died_in_new_space_++; } |
1433 | 1436 |
1434 inline void IncrementNodesCopiedInNewSpace() { nodes_copied_in_new_space_++; } | 1437 inline void IncrementNodesCopiedInNewSpace() { nodes_copied_in_new_space_++; } |
1435 | 1438 |
1436 inline void IncrementNodesPromoted() { nodes_promoted_++; } | 1439 inline void IncrementNodesPromoted() { nodes_promoted_++; } |
1437 | 1440 |
1438 inline void IncrementYoungSurvivorsCounter(int survived) { | 1441 inline void IncrementYoungSurvivorsCounter(intptr_t survived) { |
1439 DCHECK(survived >= 0); | 1442 DCHECK_GE(survived, 0); |
1440 survived_last_scavenge_ = survived; | 1443 survived_last_scavenge_ = survived; |
1441 survived_since_last_expansion_ += survived; | 1444 survived_since_last_expansion_ += survived; |
1442 } | 1445 } |
1443 | 1446 |
1444 inline intptr_t PromotedTotalSize() { | 1447 inline intptr_t PromotedTotalSize() { |
1445 int64_t total = PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize(); | 1448 int64_t total = PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize(); |
1446 if (total > std::numeric_limits<intptr_t>::max()) { | 1449 if (total > std::numeric_limits<intptr_t>::max()) { |
1447 // TODO(erikcorry): Use uintptr_t everywhere we do heap size calculations. | 1450 // TODO(erikcorry): Use uintptr_t everywhere we do heap size calculations. |
1448 return std::numeric_limits<intptr_t>::max(); | 1451 return std::numeric_limits<intptr_t>::max(); |
1449 } | 1452 } |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 int initial_semispace_size_; | 2181 int initial_semispace_size_; |
2179 int target_semispace_size_; | 2182 int target_semispace_size_; |
2180 intptr_t max_old_generation_size_; | 2183 intptr_t max_old_generation_size_; |
2181 intptr_t initial_old_generation_size_; | 2184 intptr_t initial_old_generation_size_; |
2182 bool old_generation_size_configured_; | 2185 bool old_generation_size_configured_; |
2183 intptr_t max_executable_size_; | 2186 intptr_t max_executable_size_; |
2184 intptr_t maximum_committed_; | 2187 intptr_t maximum_committed_; |
2185 | 2188 |
2186 // For keeping track of how much data has survived | 2189 // For keeping track of how much data has survived |
2187 // scavenge since last new space expansion. | 2190 // scavenge since last new space expansion. |
2188 int survived_since_last_expansion_; | 2191 intptr_t survived_since_last_expansion_; |
2189 | 2192 |
2190 // ... and since the last scavenge. | 2193 // ... and since the last scavenge. |
2191 int survived_last_scavenge_; | 2194 intptr_t survived_last_scavenge_; |
2192 | 2195 |
2193 // This is not the depth of nested AlwaysAllocateScope's but rather a single | 2196 // This is not the depth of nested AlwaysAllocateScope's but rather a single |
2194 // count, as scopes can be acquired from multiple tasks (read: threads). | 2197 // count, as scopes can be acquired from multiple tasks (read: threads). |
2195 AtomicNumber<size_t> always_allocate_scope_count_; | 2198 AtomicNumber<size_t> always_allocate_scope_count_; |
2196 | 2199 |
2197 // For keeping track of context disposals. | 2200 // For keeping track of context disposals. |
2198 int contexts_disposed_; | 2201 int contexts_disposed_; |
2199 | 2202 |
2200 // The length of the retained_maps array at the time of context disposal. | 2203 // The length of the retained_maps array at the time of context disposal. |
2201 // This separates maps in the retained_maps array that were created before | 2204 // This separates maps in the retained_maps array that were created before |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2844 | 2847 |
2845 private: | 2848 private: |
2846 friend class NewSpace; | 2849 friend class NewSpace; |
2847 DISALLOW_COPY_AND_ASSIGN(InlineAllocationObserver); | 2850 DISALLOW_COPY_AND_ASSIGN(InlineAllocationObserver); |
2848 }; | 2851 }; |
2849 | 2852 |
2850 } // namespace internal | 2853 } // namespace internal |
2851 } // namespace v8 | 2854 } // namespace v8 |
2852 | 2855 |
2853 #endif // V8_HEAP_HEAP_H_ | 2856 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |