Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_RUNTIME_GC_COLLECTOR_SEMI_SPACE_H_ |
| 18 | #define ART_RUNTIME_GC_COLLECTOR_SEMI_SPACE_H_ |
| 19 | |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 20 | #include <memory> |
| 21 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 22 | #include "atomic.h" |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 23 | #include "base/macros.h" |
| 24 | #include "base/mutex.h" |
| 25 | #include "garbage_collector.h" |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 26 | #include "gc/accounting/heap_bitmap.h" |
Mathieu Chartier | 8d56210 | 2014-03-12 17:42:10 -0700 | [diff] [blame] | 27 | #include "immune_region.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame^] | 28 | #include "mirror/object_reference.h" |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 29 | #include "object_callbacks.h" |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 30 | #include "offsets.h" |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 31 | |
| 32 | namespace art { |
| 33 | |
Mathieu Chartier | 4aeec17 | 2014-03-27 16:09:46 -0700 | [diff] [blame] | 34 | class Thread; |
| 35 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 36 | namespace mirror { |
| 37 | class Class; |
| 38 | class Object; |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 39 | } // namespace mirror |
| 40 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 41 | namespace gc { |
| 42 | |
Mathieu Chartier | 4aeec17 | 2014-03-27 16:09:46 -0700 | [diff] [blame] | 43 | class Heap; |
| 44 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 45 | namespace accounting { |
| 46 | template <typename T> class AtomicStack; |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 47 | typedef AtomicStack<mirror::Object*> ObjectStack; |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 48 | } // namespace accounting |
| 49 | |
| 50 | namespace space { |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 51 | class ContinuousMemMapAllocSpace; |
| 52 | class ContinuousSpace; |
| 53 | } // namespace space |
| 54 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 55 | namespace collector { |
| 56 | |
| 57 | class SemiSpace : public GarbageCollector { |
| 58 | public: |
Hiroshi Yamauchi | 38e68e9 | 2014-03-07 13:59:08 -0800 | [diff] [blame] | 59 | // If true, use remembered sets in the generational mode. |
| 60 | static constexpr bool kUseRememberedSet = true; |
| 61 | |
Mathieu Chartier | 0e54cd0 | 2014-03-20 12:41:23 -0700 | [diff] [blame] | 62 | explicit SemiSpace(Heap* heap, bool generational = false, const std::string& name_prefix = ""); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 63 | |
| 64 | ~SemiSpace() {} |
| 65 | |
Mathieu Chartier | 6f365cc | 2014-04-23 12:42:27 -0700 | [diff] [blame] | 66 | virtual void RunPhases() OVERRIDE NO_THREAD_SAFETY_ANALYSIS; |
| 67 | virtual void InitializePhase(); |
| 68 | virtual void MarkingPhase() EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_) |
Mathieu Chartier | 0e54cd0 | 2014-03-20 12:41:23 -0700 | [diff] [blame] | 69 | LOCKS_EXCLUDED(Locks::heap_bitmap_lock_); |
Mathieu Chartier | 6f365cc | 2014-04-23 12:42:27 -0700 | [diff] [blame] | 70 | virtual void ReclaimPhase() EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_) |
Mathieu Chartier | 0e54cd0 | 2014-03-20 12:41:23 -0700 | [diff] [blame] | 71 | LOCKS_EXCLUDED(Locks::heap_bitmap_lock_); |
Mathieu Chartier | 6f365cc | 2014-04-23 12:42:27 -0700 | [diff] [blame] | 72 | virtual void FinishPhase() EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mathieu Chartier | 0e54cd0 | 2014-03-20 12:41:23 -0700 | [diff] [blame] | 73 | void MarkReachableObjects() |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 74 | EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_, Locks::heap_bitmap_lock_); |
Mathieu Chartier | 0e54cd0 | 2014-03-20 12:41:23 -0700 | [diff] [blame] | 75 | virtual GcType GetGcType() const OVERRIDE { |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 76 | return kGcTypePartial; |
| 77 | } |
Hiroshi Yamauchi | 3e41780 | 2014-03-20 12:03:02 -0700 | [diff] [blame] | 78 | virtual CollectorType GetCollectorType() const OVERRIDE { |
| 79 | return generational_ ? kCollectorTypeGSS : kCollectorTypeSS; |
| 80 | } |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 81 | |
| 82 | // Sets which space we will be copying objects to. |
| 83 | void SetToSpace(space::ContinuousMemMapAllocSpace* to_space); |
| 84 | |
| 85 | // Set the space where we copy objects from. |
| 86 | void SetFromSpace(space::ContinuousMemMapAllocSpace* from_space); |
| 87 | |
Mathieu Chartier | 6f365cc | 2014-04-23 12:42:27 -0700 | [diff] [blame] | 88 | // Set whether or not we swap the semi spaces in the heap. This needs to be done with mutators |
| 89 | // suspended. |
| 90 | void SetSwapSemiSpaces(bool swap_semi_spaces) { |
| 91 | swap_semi_spaces_ = swap_semi_spaces; |
| 92 | } |
| 93 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 94 | // Initializes internal structures. |
| 95 | void Init(); |
| 96 | |
| 97 | // Find the default mark bitmap. |
| 98 | void FindDefaultMarkBitmap(); |
| 99 | |
| 100 | // Returns the new address of the object. |
Mathieu Chartier | 3b05e9b | 2014-03-25 09:29:43 -0700 | [diff] [blame] | 101 | template<bool kPoisonReferences> |
| 102 | void MarkObject(mirror::ObjectReference<kPoisonReferences, mirror::Object>* obj_ptr) |
Mathieu Chartier | 0651d41 | 2014-04-29 14:37:57 -0700 | [diff] [blame] | 103 | EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 104 | |
| 105 | void ScanObject(mirror::Object* obj) |
Mathieu Chartier | 0651d41 | 2014-04-29 14:37:57 -0700 | [diff] [blame] | 106 | EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 107 | |
Hiroshi Yamauchi | 38e68e9 | 2014-03-07 13:59:08 -0800 | [diff] [blame] | 108 | void VerifyNoFromSpaceReferences(mirror::Object* obj) |
| 109 | SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_); |
| 110 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 111 | // Marks the root set at the start of a garbage collection. |
| 112 | void MarkRoots() |
| 113 | EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_); |
| 114 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 115 | // Bind the live bits to the mark bits of bitmaps for spaces that are never collected, ie |
| 116 | // the image. Mark that portion of the heap as immune. |
Mathieu Chartier | 0e54cd0 | 2014-03-20 12:41:23 -0700 | [diff] [blame] | 117 | virtual void BindBitmaps() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) |
| 118 | LOCKS_EXCLUDED(Locks::heap_bitmap_lock_); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 119 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 120 | void UnBindBitmaps() |
| 121 | EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_); |
| 122 | |
Mathieu Chartier | 0e54cd0 | 2014-03-20 12:41:23 -0700 | [diff] [blame] | 123 | void ProcessReferences(Thread* self) EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_) |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 124 | EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 125 | |
| 126 | // Sweeps unmarked objects to complete the garbage collection. |
| 127 | virtual void Sweep(bool swap_bitmaps) EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_); |
| 128 | |
| 129 | // Sweeps unmarked objects to complete the garbage collection. |
| 130 | void SweepLargeObjects(bool swap_bitmaps) EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_); |
| 131 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 132 | void SweepSystemWeaks() |
| 133 | SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_); |
| 134 | |
Mathieu Chartier | 815873e | 2014-02-13 18:02:13 -0800 | [diff] [blame] | 135 | static void MarkRootCallback(mirror::Object** root, void* arg, uint32_t /*tid*/, |
| 136 | RootType /*root_type*/) |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 137 | EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_); |
| 138 | |
Mathieu Chartier | 3bb57c7 | 2014-02-18 11:38:45 -0800 | [diff] [blame] | 139 | static mirror::Object* MarkObjectCallback(mirror::Object* root, void* arg) |
Mathieu Chartier | 39e3261 | 2013-11-12 16:28:05 -0800 | [diff] [blame] | 140 | EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_); |
| 141 | |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 142 | static void MarkHeapReferenceCallback(mirror::HeapReference<mirror::Object>* obj_ptr, void* arg) |
| 143 | EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_); |
| 144 | |
Mathieu Chartier | 3bb57c7 | 2014-02-18 11:38:45 -0800 | [diff] [blame] | 145 | static void ProcessMarkStackCallback(void* arg) |
| 146 | EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_, Locks::heap_bitmap_lock_); |
| 147 | |
Hiroshi Yamauchi | 4db7449 | 2014-04-22 17:10:48 -0700 | [diff] [blame] | 148 | static void DelayReferenceReferentCallback(mirror::Class* klass, mirror::Reference* ref, |
| 149 | void* arg) |
| 150 | SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_); |
| 151 | |
Mathieu Chartier | 85a43c0 | 2014-01-07 17:59:00 -0800 | [diff] [blame] | 152 | virtual mirror::Object* MarkNonForwardedObject(mirror::Object* obj) |
Mathieu Chartier | 0651d41 | 2014-04-29 14:37:57 -0700 | [diff] [blame] | 153 | EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_); |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 154 | |
| 155 | // Schedules an unmarked object for reference processing. |
| 156 | void DelayReferenceReferent(mirror::Class* klass, mirror::Reference* reference) |
| 157 | SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_); |
Mathieu Chartier | 85a43c0 | 2014-01-07 17:59:00 -0800 | [diff] [blame] | 158 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 159 | protected: |
| 160 | // Returns null if the object is not marked, otherwise returns the forwarding address (same as |
| 161 | // object for non movable things). |
Mathieu Chartier | 0e54cd0 | 2014-03-20 12:41:23 -0700 | [diff] [blame] | 162 | mirror::Object* GetMarkedForwardAddress(mirror::Object* object) const |
| 163 | EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_) |
| 164 | SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 165 | |
Mathieu Chartier | 308351a | 2014-06-15 12:39:02 -0700 | [diff] [blame] | 166 | static bool HeapReferenceMarkedCallback(mirror::HeapReference<mirror::Object>* object, void* arg) |
| 167 | EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_) |
| 168 | SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_); |
| 169 | |
Mathieu Chartier | 39e3261 | 2013-11-12 16:28:05 -0800 | [diff] [blame] | 170 | static mirror::Object* MarkedForwardingAddressCallback(mirror::Object* object, void* arg) |
Mathieu Chartier | 0e54cd0 | 2014-03-20 12:41:23 -0700 | [diff] [blame] | 171 | EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_) |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 172 | SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_); |
| 173 | |
| 174 | // Marks or unmarks a large object based on whether or not set is true. If set is true, then we |
| 175 | // mark, otherwise we unmark. |
| 176 | bool MarkLargeObject(const mirror::Object* obj) |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 177 | EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_) |
| 178 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 179 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 180 | // Expand mark stack to 2x its current size. |
| 181 | void ResizeMarkStack(size_t new_size); |
| 182 | |
Mathieu Chartier | 85a43c0 | 2014-01-07 17:59:00 -0800 | [diff] [blame] | 183 | // Returns true if we should sweep the space. |
Mathieu Chartier | a1602f2 | 2014-01-13 17:19:19 -0800 | [diff] [blame] | 184 | virtual bool ShouldSweepSpace(space::ContinuousSpace* space) const; |
Mathieu Chartier | 85a43c0 | 2014-01-07 17:59:00 -0800 | [diff] [blame] | 185 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 186 | // Push an object onto the mark stack. |
Mathieu Chartier | 0e54cd0 | 2014-03-20 12:41:23 -0700 | [diff] [blame] | 187 | void MarkStackPush(mirror::Object* obj); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 188 | |
| 189 | void UpdateAndMarkModUnion() |
| 190 | EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_) |
| 191 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 192 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 193 | // Recursively blackens objects on the mark stack. |
Mathieu Chartier | 3bb57c7 | 2014-02-18 11:38:45 -0800 | [diff] [blame] | 194 | void ProcessMarkStack() |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 195 | EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_, Locks::heap_bitmap_lock_); |
| 196 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 197 | inline mirror::Object* GetForwardingAddressInFromSpace(mirror::Object* obj) const |
| 198 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 199 | |
Hiroshi Yamauchi | c93c530 | 2014-03-20 16:15:37 -0700 | [diff] [blame] | 200 | // Revoke all the thread-local buffers. |
| 201 | void RevokeAllThreadLocalBuffers(); |
| 202 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 203 | // Current space, we check this space first to avoid searching for the appropriate space for an |
| 204 | // object. |
| 205 | accounting::ObjectStack* mark_stack_; |
| 206 | |
Mathieu Chartier | 8d56210 | 2014-03-12 17:42:10 -0700 | [diff] [blame] | 207 | // Immune region, every object inside the immune region is assumed to be marked. |
| 208 | ImmuneRegion immune_region_; |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 209 | |
Hiroshi Yamauchi | 05e713a | 2014-01-09 13:24:51 -0800 | [diff] [blame] | 210 | // If true, the large object space is immune. |
| 211 | bool is_large_object_space_immune_; |
| 212 | |
Mathieu Chartier | e6da9af | 2013-12-16 11:54:42 -0800 | [diff] [blame] | 213 | // Destination and source spaces (can be any type of ContinuousMemMapAllocSpace which either has |
| 214 | // a live bitmap or doesn't). |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 215 | space::ContinuousMemMapAllocSpace* to_space_; |
Mathieu Chartier | a8e8f9c | 2014-04-09 14:51:05 -0700 | [diff] [blame] | 216 | // Cached live bitmap as an optimization. |
| 217 | accounting::ContinuousSpaceBitmap* to_space_live_bitmap_; |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 218 | space::ContinuousMemMapAllocSpace* from_space_; |
Mathieu Chartier | bbd695c | 2014-04-16 09:48:48 -0700 | [diff] [blame] | 219 | // Cached mark bitmap as an optimization. |
| 220 | accounting::HeapBitmap* mark_bitmap_; |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 221 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 222 | Thread* self_; |
| 223 | |
Hiroshi Yamauchi | 6f4ffe4 | 2014-01-13 12:30:44 -0800 | [diff] [blame] | 224 | // When true, the generational mode (promotion and the bump pointer |
| 225 | // space only collection) is enabled. TODO: move these to a new file |
| 226 | // as a new garbage collector? |
Ian Rogers | 6fac447 | 2014-02-25 17:01:10 -0800 | [diff] [blame] | 227 | const bool generational_; |
Hiroshi Yamauchi | 6f4ffe4 | 2014-01-13 12:30:44 -0800 | [diff] [blame] | 228 | |
| 229 | // Used for the generational mode. the end/top of the bump |
| 230 | // pointer space at the end of the last collection. |
Hiroshi Yamauchi | 4b1782f | 2013-12-05 16:46:22 -0800 | [diff] [blame] | 231 | byte* last_gc_to_space_end_; |
| 232 | |
Hiroshi Yamauchi | 6f4ffe4 | 2014-01-13 12:30:44 -0800 | [diff] [blame] | 233 | // Used for the generational mode. During a collection, keeps track |
| 234 | // of how many bytes of objects have been copied so far from the |
| 235 | // bump pointer space to the non-moving space. |
Hiroshi Yamauchi | 4b1782f | 2013-12-05 16:46:22 -0800 | [diff] [blame] | 236 | uint64_t bytes_promoted_; |
| 237 | |
Hiroshi Yamauchi | df386c5 | 2014-04-08 16:21:52 -0700 | [diff] [blame] | 238 | // Used for the generational mode. Keeps track of how many bytes of |
| 239 | // objects have been copied so far from the bump pointer space to |
| 240 | // the non-moving space, since the last whole heap collection. |
| 241 | uint64_t bytes_promoted_since_last_whole_heap_collection_; |
| 242 | |
Hiroshi Yamauchi | 24faeb2 | 2014-05-07 13:12:43 -0700 | [diff] [blame] | 243 | // Used for the generational mode. Keeps track of how many bytes of |
| 244 | // large objects were allocated at the last whole heap collection. |
| 245 | uint64_t large_object_bytes_allocated_at_last_whole_heap_collection_; |
| 246 | |
Hiroshi Yamauchi | 6f4ffe4 | 2014-01-13 12:30:44 -0800 | [diff] [blame] | 247 | // Used for the generational mode. When true, collect the whole |
| 248 | // heap. When false, collect only the bump pointer spaces. |
Hiroshi Yamauchi | 05e713a | 2014-01-09 13:24:51 -0800 | [diff] [blame] | 249 | bool whole_heap_collection_; |
| 250 | |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 251 | // How many objects and bytes we moved, used so that we don't need to Get the size of the |
Mathieu Chartier | 4d7f61d | 2014-04-17 14:43:39 -0700 | [diff] [blame] | 252 | // to_space_ when calculating how many objects and bytes we freed. |
| 253 | size_t bytes_moved_; |
| 254 | size_t objects_moved_; |
| 255 | |
Mathieu Chartier | ad35d90 | 2014-02-11 16:20:42 -0800 | [diff] [blame] | 256 | // How many bytes we avoided dirtying. |
| 257 | size_t saved_bytes_; |
| 258 | |
Hiroshi Yamauchi | df386c5 | 2014-04-08 16:21:52 -0700 | [diff] [blame] | 259 | // The name of the collector. |
| 260 | std::string collector_name_; |
| 261 | |
Hiroshi Yamauchi | 6f4ffe4 | 2014-01-13 12:30:44 -0800 | [diff] [blame] | 262 | // Used for the generational mode. The default interval of the whole |
| 263 | // heap collection. If N, the whole heap collection occurs every N |
| 264 | // collections. |
Hiroshi Yamauchi | 05e713a | 2014-01-09 13:24:51 -0800 | [diff] [blame] | 265 | static constexpr int kDefaultWholeHeapCollectionInterval = 5; |
| 266 | |
Mathieu Chartier | 6f365cc | 2014-04-23 12:42:27 -0700 | [diff] [blame] | 267 | // Whether or not we swap the semi spaces in the heap during the marking phase. |
| 268 | bool swap_semi_spaces_; |
| 269 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 270 | private: |
Mathieu Chartier | bbd695c | 2014-04-16 09:48:48 -0700 | [diff] [blame] | 271 | friend class BitmapSetSlowPathVisitor; |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 272 | DISALLOW_COPY_AND_ASSIGN(SemiSpace); |
| 273 | }; |
| 274 | |
| 275 | } // namespace collector |
| 276 | } // namespace gc |
| 277 | } // namespace art |
| 278 | |
| 279 | #endif // ART_RUNTIME_GC_COLLECTOR_SEMI_SPACE_H_ |