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 2968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2979 MUST_USE_RESULT HeapObject* SweepAndRetryAllocation( | 2979 MUST_USE_RESULT HeapObject* SweepAndRetryAllocation( |
2980 int size_in_bytes) override; | 2980 int size_in_bytes) override; |
2981 }; | 2981 }; |
2982 | 2982 |
2983 | 2983 |
2984 // A collection of |CompactionSpace|s used by a single compaction task. | 2984 // A collection of |CompactionSpace|s used by a single compaction task. |
2985 class CompactionSpaceCollection : public Malloced { | 2985 class CompactionSpaceCollection : public Malloced { |
2986 public: | 2986 public: |
2987 explicit CompactionSpaceCollection(Heap* heap) | 2987 explicit CompactionSpaceCollection(Heap* heap) |
2988 : old_space_(heap, OLD_SPACE, Executability::NOT_EXECUTABLE), | 2988 : old_space_(heap, OLD_SPACE, Executability::NOT_EXECUTABLE), |
2989 code_space_(heap, CODE_SPACE, Executability::EXECUTABLE), | 2989 code_space_(heap, CODE_SPACE, Executability::EXECUTABLE) {} |
2990 duration_(0.0), | |
2991 bytes_compacted_(0) {} | |
2992 | 2990 |
2993 CompactionSpace* Get(AllocationSpace space) { | 2991 CompactionSpace* Get(AllocationSpace space) { |
2994 switch (space) { | 2992 switch (space) { |
2995 case OLD_SPACE: | 2993 case OLD_SPACE: |
2996 return &old_space_; | 2994 return &old_space_; |
2997 case CODE_SPACE: | 2995 case CODE_SPACE: |
2998 return &code_space_; | 2996 return &code_space_; |
2999 default: | 2997 default: |
3000 UNREACHABLE(); | 2998 UNREACHABLE(); |
3001 } | 2999 } |
3002 UNREACHABLE(); | 3000 UNREACHABLE(); |
3003 return nullptr; | 3001 return nullptr; |
3004 } | 3002 } |
3005 | 3003 |
3006 void ReportCompactionProgress(double duration, intptr_t bytes_compacted) { | |
3007 duration_ += duration; | |
3008 bytes_compacted_ += bytes_compacted; | |
3009 } | |
3010 | |
3011 double duration() const { return duration_; } | |
3012 intptr_t bytes_compacted() const { return bytes_compacted_; } | |
3013 | |
3014 private: | 3004 private: |
3015 CompactionSpace old_space_; | 3005 CompactionSpace old_space_; |
3016 CompactionSpace code_space_; | 3006 CompactionSpace code_space_; |
3017 | |
3018 // Book keeping. | |
3019 double duration_; | |
3020 intptr_t bytes_compacted_; | |
3021 }; | 3007 }; |
3022 | 3008 |
3023 | 3009 |
3024 // ----------------------------------------------------------------------------- | 3010 // ----------------------------------------------------------------------------- |
3025 // Old object space (includes the old space of objects and code space) | 3011 // Old object space (includes the old space of objects and code space) |
3026 | 3012 |
3027 class OldSpace : public PagedSpace { | 3013 class OldSpace : public PagedSpace { |
3028 public: | 3014 public: |
3029 // Creates an old space object. The constructor does not allocate pages | 3015 // Creates an old space object. The constructor does not allocate pages |
3030 // from OS. | 3016 // from OS. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3211 count = 0; | 3197 count = 0; |
3212 } | 3198 } |
3213 // Must be small, since an iteration is used for lookup. | 3199 // Must be small, since an iteration is used for lookup. |
3214 static const int kMaxComments = 64; | 3200 static const int kMaxComments = 64; |
3215 }; | 3201 }; |
3216 #endif | 3202 #endif |
3217 } // namespace internal | 3203 } // namespace internal |
3218 } // namespace v8 | 3204 } // namespace v8 |
3219 | 3205 |
3220 #endif // V8_HEAP_SPACES_H_ | 3206 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |