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) {} |
2926 | 2928 |
2927 CompactionSpace* Get(AllocationSpace space) { | 2929 CompactionSpace* Get(AllocationSpace space) { |
2928 switch (space) { | 2930 switch (space) { |
2929 case OLD_SPACE: | 2931 case OLD_SPACE: |
2930 return &old_space_; | 2932 return &old_space_; |
2931 case CODE_SPACE: | 2933 case CODE_SPACE: |
2932 return &code_space_; | 2934 return &code_space_; |
2933 default: | 2935 default: |
2934 UNREACHABLE(); | 2936 UNREACHABLE(); |
2935 } | 2937 } |
2936 UNREACHABLE(); | 2938 UNREACHABLE(); |
2937 return nullptr; | 2939 return nullptr; |
2938 } | 2940 } |
2939 | 2941 |
| 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 |
2940 private: | 2950 private: |
2941 CompactionSpace old_space_; | 2951 CompactionSpace old_space_; |
2942 CompactionSpace code_space_; | 2952 CompactionSpace code_space_; |
| 2953 |
| 2954 // Book keeping. |
| 2955 double duration_; |
| 2956 intptr_t bytes_compacted_; |
2943 }; | 2957 }; |
2944 | 2958 |
2945 | 2959 |
2946 // ----------------------------------------------------------------------------- | 2960 // ----------------------------------------------------------------------------- |
2947 // Old object space (includes the old space of objects and code space) | 2961 // Old object space (includes the old space of objects and code space) |
2948 | 2962 |
2949 class OldSpace : public PagedSpace { | 2963 class OldSpace : public PagedSpace { |
2950 public: | 2964 public: |
2951 // Creates an old space object. The constructor does not allocate pages | 2965 // Creates an old space object. The constructor does not allocate pages |
2952 // from OS. | 2966 // from OS. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3133 count = 0; | 3147 count = 0; |
3134 } | 3148 } |
3135 // Must be small, since an iteration is used for lookup. | 3149 // Must be small, since an iteration is used for lookup. |
3136 static const int kMaxComments = 64; | 3150 static const int kMaxComments = 64; |
3137 }; | 3151 }; |
3138 #endif | 3152 #endif |
3139 } // namespace internal | 3153 } // namespace internal |
3140 } // namespace v8 | 3154 } // namespace v8 |
3141 | 3155 |
3142 #endif // V8_HEAP_SPACES_H_ | 3156 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |