| 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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 }; | 631 }; |
| 632 | 632 |
| 633 // Indicates whether live bytes adjustment is triggered | 633 // Indicates whether live bytes adjustment is triggered |
| 634 // - from within the GC code before sweeping started (SEQUENTIAL_TO_SWEEPER), | 634 // - from within the GC code before sweeping started (SEQUENTIAL_TO_SWEEPER), |
| 635 // - or from within GC (CONCURRENT_TO_SWEEPER), | 635 // - or from within GC (CONCURRENT_TO_SWEEPER), |
| 636 // - or mutator code (CONCURRENT_TO_SWEEPER). | 636 // - or mutator code (CONCURRENT_TO_SWEEPER). |
| 637 enum InvocationMode { SEQUENTIAL_TO_SWEEPER, CONCURRENT_TO_SWEEPER }; | 637 enum InvocationMode { SEQUENTIAL_TO_SWEEPER, CONCURRENT_TO_SWEEPER }; |
| 638 | 638 |
| 639 enum PretenuringFeedbackInsertionMode { kCached, kGlobal }; | 639 enum PretenuringFeedbackInsertionMode { kCached, kGlobal }; |
| 640 | 640 |
| 641 enum FindMementoMode { kForRuntime, kForGC }; |
| 642 |
| 641 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; | 643 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; |
| 642 | 644 |
| 643 // Taking this lock prevents the GC from entering a phase that relocates | 645 // Taking this lock prevents the GC from entering a phase that relocates |
| 644 // object references. | 646 // object references. |
| 645 class RelocationLock { | 647 class RelocationLock { |
| 646 public: | 648 public: |
| 647 explicit RelocationLock(Heap* heap) : heap_(heap) { | 649 explicit RelocationLock(Heap* heap) : heap_(heap) { |
| 648 heap_->relocation_mutex_.Lock(); | 650 heap_->relocation_mutex_.Lock(); |
| 649 } | 651 } |
| 650 | 652 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 static inline void CopyBlock(Address dst, Address src, int byte_size); | 788 static inline void CopyBlock(Address dst, Address src, int byte_size); |
| 787 | 789 |
| 788 // Optimized version of memmove for blocks with pointer size aligned sizes and | 790 // Optimized version of memmove for blocks with pointer size aligned sizes and |
| 789 // pointer size aligned addresses. | 791 // pointer size aligned addresses. |
| 790 static inline void MoveBlock(Address dst, Address src, int byte_size); | 792 static inline void MoveBlock(Address dst, Address src, int byte_size); |
| 791 | 793 |
| 792 // Determines a static visitor id based on the given {map} that can then be | 794 // Determines a static visitor id based on the given {map} that can then be |
| 793 // stored on the map to facilitate fast dispatch for {StaticVisitorBase}. | 795 // stored on the map to facilitate fast dispatch for {StaticVisitorBase}. |
| 794 static int GetStaticVisitorIdForMap(Map* map); | 796 static int GetStaticVisitorIdForMap(Map* map); |
| 795 | 797 |
| 798 static inline uint32_t ObjectHash(Address address); |
| 799 |
| 796 // Notifies the heap that is ok to start marking or other activities that | 800 // Notifies the heap that is ok to start marking or other activities that |
| 797 // should not happen during deserialization. | 801 // should not happen during deserialization. |
| 798 void NotifyDeserializationComplete(); | 802 void NotifyDeserializationComplete(); |
| 799 | 803 |
| 800 intptr_t old_generation_allocation_limit() const { | 804 intptr_t old_generation_allocation_limit() const { |
| 801 return old_generation_allocation_limit_; | 805 return old_generation_allocation_limit_; |
| 802 } | 806 } |
| 803 | 807 |
| 804 bool always_allocate() { return always_allocate_scope_count_.Value() != 0; } | 808 bool always_allocate() { return always_allocate_scope_count_.Value() != 0; } |
| 805 | 809 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 | 924 |
| 921 // Print short heap statistics. | 925 // Print short heap statistics. |
| 922 void PrintShortHeapStatistics(); | 926 void PrintShortHeapStatistics(); |
| 923 | 927 |
| 924 inline HeapState gc_state() { return gc_state_; } | 928 inline HeapState gc_state() { return gc_state_; } |
| 925 | 929 |
| 926 inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; } | 930 inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; } |
| 927 | 931 |
| 928 // If an object has an AllocationMemento trailing it, return it, otherwise | 932 // If an object has an AllocationMemento trailing it, return it, otherwise |
| 929 // return NULL; | 933 // return NULL; |
| 934 template <FindMementoMode mode> |
| 930 inline AllocationMemento* FindAllocationMemento(HeapObject* object); | 935 inline AllocationMemento* FindAllocationMemento(HeapObject* object); |
| 931 | 936 |
| 932 // Returns false if not able to reserve. | 937 // Returns false if not able to reserve. |
| 933 bool ReserveSpace(Reservation* reservations); | 938 bool ReserveSpace(Reservation* reservations); |
| 934 | 939 |
| 935 // | 940 // |
| 936 // Support for the API. | 941 // Support for the API. |
| 937 // | 942 // |
| 938 | 943 |
| 939 void CreateApiObjects(); | 944 void CreateApiObjects(); |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1401 // Returns the available bytes in space w/o growing. | 1406 // Returns the available bytes in space w/o growing. |
| 1402 // Heap doesn't guarantee that it can allocate an object that requires | 1407 // Heap doesn't guarantee that it can allocate an object that requires |
| 1403 // all available bytes. Check MaxHeapObjectSize() instead. | 1408 // all available bytes. Check MaxHeapObjectSize() instead. |
| 1404 intptr_t Available(); | 1409 intptr_t Available(); |
| 1405 | 1410 |
| 1406 // Returns of size of all objects residing in the heap. | 1411 // Returns of size of all objects residing in the heap. |
| 1407 intptr_t SizeOfObjects(); | 1412 intptr_t SizeOfObjects(); |
| 1408 | 1413 |
| 1409 void UpdateSurvivalStatistics(int start_new_space_size); | 1414 void UpdateSurvivalStatistics(int start_new_space_size); |
| 1410 | 1415 |
| 1411 inline void IncrementPromotedObjectsSize(int object_size) { | 1416 inline void IncrementPromotedObjectsSize(intptr_t object_size) { |
| 1412 DCHECK_GE(object_size, 0); | 1417 DCHECK_GE(object_size, 0); |
| 1413 promoted_objects_size_ += object_size; | 1418 promoted_objects_size_ += object_size; |
| 1414 } | 1419 } |
| 1415 inline intptr_t promoted_objects_size() { return promoted_objects_size_; } | 1420 inline intptr_t promoted_objects_size() { return promoted_objects_size_; } |
| 1416 | 1421 |
| 1417 inline void IncrementSemiSpaceCopiedObjectSize(int object_size) { | 1422 inline void IncrementSemiSpaceCopiedObjectSize(intptr_t object_size) { |
| 1418 DCHECK_GE(object_size, 0); | 1423 DCHECK_GE(object_size, 0); |
| 1419 semi_space_copied_object_size_ += object_size; | 1424 semi_space_copied_object_size_ += object_size; |
| 1420 } | 1425 } |
| 1421 inline intptr_t semi_space_copied_object_size() { | 1426 inline intptr_t semi_space_copied_object_size() { |
| 1422 return semi_space_copied_object_size_; | 1427 return semi_space_copied_object_size_; |
| 1423 } | 1428 } |
| 1424 | 1429 |
| 1425 inline intptr_t SurvivedNewSpaceObjectSize() { | 1430 inline intptr_t SurvivedNewSpaceObjectSize() { |
| 1426 return promoted_objects_size_ + semi_space_copied_object_size_; | 1431 return promoted_objects_size_ + semi_space_copied_object_size_; |
| 1427 } | 1432 } |
| 1428 | 1433 |
| 1429 inline void IncrementNodesDiedInNewSpace() { nodes_died_in_new_space_++; } | 1434 inline void IncrementNodesDiedInNewSpace() { nodes_died_in_new_space_++; } |
| 1430 | 1435 |
| 1431 inline void IncrementNodesCopiedInNewSpace() { nodes_copied_in_new_space_++; } | 1436 inline void IncrementNodesCopiedInNewSpace() { nodes_copied_in_new_space_++; } |
| 1432 | 1437 |
| 1433 inline void IncrementNodesPromoted() { nodes_promoted_++; } | 1438 inline void IncrementNodesPromoted() { nodes_promoted_++; } |
| 1434 | 1439 |
| 1435 inline void IncrementYoungSurvivorsCounter(int survived) { | 1440 inline void IncrementYoungSurvivorsCounter(intptr_t survived) { |
| 1436 DCHECK(survived >= 0); | 1441 DCHECK_GE(survived, 0); |
| 1437 survived_last_scavenge_ = survived; | 1442 survived_last_scavenge_ = survived; |
| 1438 survived_since_last_expansion_ += survived; | 1443 survived_since_last_expansion_ += survived; |
| 1439 } | 1444 } |
| 1440 | 1445 |
| 1441 inline intptr_t PromotedTotalSize() { | 1446 inline intptr_t PromotedTotalSize() { |
| 1442 int64_t total = PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize(); | 1447 int64_t total = PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize(); |
| 1443 if (total > std::numeric_limits<intptr_t>::max()) { | 1448 if (total > std::numeric_limits<intptr_t>::max()) { |
| 1444 // TODO(erikcorry): Use uintptr_t everywhere we do heap size calculations. | 1449 // TODO(erikcorry): Use uintptr_t everywhere we do heap size calculations. |
| 1445 return std::numeric_limits<intptr_t>::max(); | 1450 return std::numeric_limits<intptr_t>::max(); |
| 1446 } | 1451 } |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2175 int initial_semispace_size_; | 2180 int initial_semispace_size_; |
| 2176 int target_semispace_size_; | 2181 int target_semispace_size_; |
| 2177 intptr_t max_old_generation_size_; | 2182 intptr_t max_old_generation_size_; |
| 2178 intptr_t initial_old_generation_size_; | 2183 intptr_t initial_old_generation_size_; |
| 2179 bool old_generation_size_configured_; | 2184 bool old_generation_size_configured_; |
| 2180 intptr_t max_executable_size_; | 2185 intptr_t max_executable_size_; |
| 2181 intptr_t maximum_committed_; | 2186 intptr_t maximum_committed_; |
| 2182 | 2187 |
| 2183 // For keeping track of how much data has survived | 2188 // For keeping track of how much data has survived |
| 2184 // scavenge since last new space expansion. | 2189 // scavenge since last new space expansion. |
| 2185 int survived_since_last_expansion_; | 2190 intptr_t survived_since_last_expansion_; |
| 2186 | 2191 |
| 2187 // ... and since the last scavenge. | 2192 // ... and since the last scavenge. |
| 2188 int survived_last_scavenge_; | 2193 intptr_t survived_last_scavenge_; |
| 2189 | 2194 |
| 2190 // This is not the depth of nested AlwaysAllocateScope's but rather a single | 2195 // This is not the depth of nested AlwaysAllocateScope's but rather a single |
| 2191 // count, as scopes can be acquired from multiple tasks (read: threads). | 2196 // count, as scopes can be acquired from multiple tasks (read: threads). |
| 2192 AtomicNumber<size_t> always_allocate_scope_count_; | 2197 AtomicNumber<size_t> always_allocate_scope_count_; |
| 2193 | 2198 |
| 2194 // For keeping track of context disposals. | 2199 // For keeping track of context disposals. |
| 2195 int contexts_disposed_; | 2200 int contexts_disposed_; |
| 2196 | 2201 |
| 2197 // The length of the retained_maps array at the time of context disposal. | 2202 // The length of the retained_maps array at the time of context disposal. |
| 2198 // This separates maps in the retained_maps array that were created before | 2203 // This separates maps in the retained_maps array that were created before |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2787 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2792 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 2788 | 2793 |
| 2789 private: | 2794 private: |
| 2790 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2795 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2791 }; | 2796 }; |
| 2792 #endif // DEBUG | 2797 #endif // DEBUG |
| 2793 } // namespace internal | 2798 } // namespace internal |
| 2794 } // namespace v8 | 2799 } // namespace v8 |
| 2795 | 2800 |
| 2796 #endif // V8_HEAP_HEAP_H_ | 2801 #endif // V8_HEAP_HEAP_H_ |
| OLD | NEW |