OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_SPACES_H_ | 5 #ifndef V8_HEAP_SPACES_H_ |
6 #define V8_HEAP_SPACES_H_ | 6 #define V8_HEAP_SPACES_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/atomic-utils.h" | 9 #include "src/atomic-utils.h" |
10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
(...skipping 2904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2915 MUST_USE_RESULT HeapObject* SweepAndRetryAllocation( | 2915 MUST_USE_RESULT HeapObject* SweepAndRetryAllocation( |
2916 int size_in_bytes) override; | 2916 int size_in_bytes) override; |
2917 }; | 2917 }; |
2918 | 2918 |
2919 | 2919 |
2920 // A collection of |CompactionSpace|s used by a single compaction task. | 2920 // A collection of |CompactionSpace|s used by a single compaction task. |
2921 class CompactionSpaceCollection : public Malloced { | 2921 class CompactionSpaceCollection : public Malloced { |
2922 public: | 2922 public: |
2923 explicit CompactionSpaceCollection(Heap* heap) | 2923 explicit CompactionSpaceCollection(Heap* heap) |
2924 : old_space_(heap, OLD_SPACE, Executability::NOT_EXECUTABLE), | 2924 : old_space_(heap, OLD_SPACE, Executability::NOT_EXECUTABLE), |
2925 code_space_(heap, CODE_SPACE, Executability::EXECUTABLE), | 2925 code_space_(heap, CODE_SPACE, Executability::EXECUTABLE) {} |
2926 duration_(0.0), | |
2927 bytes_compacted_(0) {} | |
2928 | 2926 |
2929 CompactionSpace* Get(AllocationSpace space) { | 2927 CompactionSpace* Get(AllocationSpace space) { |
2930 switch (space) { | 2928 switch (space) { |
2931 case OLD_SPACE: | 2929 case OLD_SPACE: |
2932 return &old_space_; | 2930 return &old_space_; |
2933 case CODE_SPACE: | 2931 case CODE_SPACE: |
2934 return &code_space_; | 2932 return &code_space_; |
2935 default: | 2933 default: |
2936 UNREACHABLE(); | 2934 UNREACHABLE(); |
2937 } | 2935 } |
2938 UNREACHABLE(); | 2936 UNREACHABLE(); |
2939 return nullptr; | 2937 return nullptr; |
2940 } | 2938 } |
2941 | 2939 |
2942 void ReportCompactionProgress(double duration, intptr_t bytes_compacted) { | |
2943 duration_ += duration; | |
2944 bytes_compacted_ += bytes_compacted; | |
2945 } | |
2946 | |
2947 double duration() const { return duration_; } | |
2948 intptr_t bytes_compacted() const { return bytes_compacted_; } | |
2949 | |
2950 private: | 2940 private: |
2951 CompactionSpace old_space_; | 2941 CompactionSpace old_space_; |
2952 CompactionSpace code_space_; | 2942 CompactionSpace code_space_; |
2953 | |
2954 // Book keeping. | |
2955 double duration_; | |
2956 intptr_t bytes_compacted_; | |
2957 }; | 2943 }; |
2958 | 2944 |
2959 | 2945 |
2960 // ----------------------------------------------------------------------------- | 2946 // ----------------------------------------------------------------------------- |
2961 // Old object space (includes the old space of objects and code space) | 2947 // Old object space (includes the old space of objects and code space) |
2962 | 2948 |
2963 class OldSpace : public PagedSpace { | 2949 class OldSpace : public PagedSpace { |
2964 public: | 2950 public: |
2965 // Creates an old space object. The constructor does not allocate pages | 2951 // Creates an old space object. The constructor does not allocate pages |
2966 // from OS. | 2952 // from OS. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3147 count = 0; | 3133 count = 0; |
3148 } | 3134 } |
3149 // Must be small, since an iteration is used for lookup. | 3135 // Must be small, since an iteration is used for lookup. |
3150 static const int kMaxComments = 64; | 3136 static const int kMaxComments = 64; |
3151 }; | 3137 }; |
3152 #endif | 3138 #endif |
3153 } // namespace internal | 3139 } // namespace internal |
3154 } // namespace v8 | 3140 } // namespace v8 |
3155 | 3141 |
3156 #endif // V8_HEAP_SPACES_H_ | 3142 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |