blob: a862802b212c4216092da2b5ce41d78ea6bbd9c3 [file] [log] [blame]
Hiroshi Yamauchid5307ec2014-03-27 21:07:51 -07001/*
2 * Copyright (C) 2014 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_CONCURRENT_COPYING_H_
18#define ART_RUNTIME_GC_COLLECTOR_CONCURRENT_COPYING_H_
19
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080020#include "barrier.h"
Hiroshi Yamauchid5307ec2014-03-27 21:07:51 -070021#include "garbage_collector.h"
Mathieu Chartier763a31e2015-11-16 16:05:55 -080022#include "immune_spaces.h"
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080023#include "jni.h"
24#include "object_callbacks.h"
25#include "offsets.h"
26#include "gc/accounting/atomic_stack.h"
27#include "gc/accounting/read_barrier_table.h"
28#include "gc/accounting/space_bitmap.h"
29#include "mirror/object.h"
30#include "mirror/object_reference.h"
31#include "safe_map.h"
32
33#include <unordered_map>
34#include <vector>
Hiroshi Yamauchid5307ec2014-03-27 21:07:51 -070035
36namespace art {
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080037class RootInfo;
38
Hiroshi Yamauchid5307ec2014-03-27 21:07:51 -070039namespace gc {
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080040
41namespace accounting {
42 typedef SpaceBitmap<kObjectAlignment> ContinuousSpaceBitmap;
43 class HeapBitmap;
44} // namespace accounting
45
46namespace space {
47 class RegionSpace;
48} // namespace space
49
Hiroshi Yamauchid5307ec2014-03-27 21:07:51 -070050namespace collector {
51
52class ConcurrentCopying : public GarbageCollector {
53 public:
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080054 // Enable the no-from-space-refs verification at the pause.
Hiroshi Yamauchidaf61a12016-06-10 14:27:38 -070055 static constexpr bool kEnableNoFromSpaceRefsVerification = kIsDebugBuild;
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080056 // Enable the from-space bytes/objects check.
Hiroshi Yamauchidaf61a12016-06-10 14:27:38 -070057 static constexpr bool kEnableFromSpaceAccountingCheck = kIsDebugBuild;
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080058 // Enable verbose mode.
Hiroshi Yamauchi3c448932016-01-22 16:26:50 -080059 static constexpr bool kVerboseMode = false;
Mathieu Chartier36a270a2016-07-28 18:08:51 -070060 // If kGrayDirtyImmuneObjects is true then we gray dirty objects in the GC pause to prevent dirty
61 // pages.
62 static constexpr bool kGrayDirtyImmuneObjects = true;
Hiroshi Yamauchid5307ec2014-03-27 21:07:51 -070063
Mathieu Chartier56fe2582016-07-14 13:30:03 -070064 ConcurrentCopying(Heap* heap,
65 const std::string& name_prefix = "",
66 bool measure_read_barrier_slow_path = false);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080067 ~ConcurrentCopying();
Hiroshi Yamauchid5307ec2014-03-27 21:07:51 -070068
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -070069 virtual void RunPhases() OVERRIDE
Mathieu Chartier56fe2582016-07-14 13:30:03 -070070 REQUIRES(!immune_gray_stack_lock_,
71 !mark_stack_lock_,
72 !rb_slow_path_histogram_lock_,
73 !skipped_blocks_lock_);
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -070074 void InitializePhase() SHARED_REQUIRES(Locks::mutator_lock_)
75 REQUIRES(!mark_stack_lock_, !immune_gray_stack_lock_);
Mathieu Chartier90443472015-07-16 20:32:27 -070076 void MarkingPhase() SHARED_REQUIRES(Locks::mutator_lock_)
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -070077 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_, !immune_gray_stack_lock_);
Mathieu Chartier90443472015-07-16 20:32:27 -070078 void ReclaimPhase() SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!mark_stack_lock_);
Mathieu Chartier56fe2582016-07-14 13:30:03 -070079 void FinishPhase() REQUIRES(!mark_stack_lock_,
80 !rb_slow_path_histogram_lock_,
81 !skipped_blocks_lock_);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080082
Mathieu Chartier90443472015-07-16 20:32:27 -070083 void BindBitmaps() SHARED_REQUIRES(Locks::mutator_lock_)
84 REQUIRES(!Locks::heap_bitmap_lock_);
Hiroshi Yamauchid5307ec2014-03-27 21:07:51 -070085 virtual GcType GetGcType() const OVERRIDE {
86 return kGcTypePartial;
87 }
88 virtual CollectorType GetCollectorType() const OVERRIDE {
89 return kCollectorTypeCC;
90 }
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080091 virtual void RevokeAllThreadLocalBuffers() OVERRIDE;
92 void SetRegionSpace(space::RegionSpace* region_space) {
93 DCHECK(region_space != nullptr);
94 region_space_ = region_space;
95 }
96 space::RegionSpace* RegionSpace() {
97 return region_space_;
98 }
99 void AssertToSpaceInvariant(mirror::Object* obj, MemberOffset offset, mirror::Object* ref)
Mathieu Chartier90443472015-07-16 20:32:27 -0700100 SHARED_REQUIRES(Locks::mutator_lock_);
Hiroshi Yamauchi3f64f252015-06-12 18:35:06 -0700101 void AssertToSpaceInvariant(GcRootSource* gc_root_source, mirror::Object* ref)
Mathieu Chartier90443472015-07-16 20:32:27 -0700102 SHARED_REQUIRES(Locks::mutator_lock_);
103 bool IsInToSpace(mirror::Object* ref) SHARED_REQUIRES(Locks::mutator_lock_) {
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800104 DCHECK(ref != nullptr);
105 return IsMarked(ref) == ref;
106 }
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700107 template<bool kGrayImmuneObject = true>
Mathieu Chartier56fe2582016-07-14 13:30:03 -0700108 ALWAYS_INLINE mirror::Object* Mark(mirror::Object* from_ref)
109 SHARED_REQUIRES(Locks::mutator_lock_)
110 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_, !immune_gray_stack_lock_);
111 ALWAYS_INLINE mirror::Object* MarkFromReadBarrier(mirror::Object* from_ref)
112 SHARED_REQUIRES(Locks::mutator_lock_)
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700113 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_, !immune_gray_stack_lock_);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800114 bool IsMarking() const {
115 return is_marking_;
116 }
117 bool IsActive() const {
118 return is_active_;
119 }
120 Barrier& GetBarrier() {
121 return *gc_barrier_;
122 }
Hiroshi Yamauchi0b713572015-06-16 18:29:23 -0700123 bool IsWeakRefAccessEnabled() {
124 return weak_ref_access_enabled_.LoadRelaxed();
125 }
Mathieu Chartier90443472015-07-16 20:32:27 -0700126 void RevokeThreadLocalMarkStack(Thread* thread) SHARED_REQUIRES(Locks::mutator_lock_)
127 REQUIRES(!mark_stack_lock_);
Hiroshi Yamauchid5307ec2014-03-27 21:07:51 -0700128
129 private:
Mathieu Chartier90443472015-07-16 20:32:27 -0700130 void PushOntoMarkStack(mirror::Object* obj) SHARED_REQUIRES(Locks::mutator_lock_)
131 REQUIRES(!mark_stack_lock_);
132 mirror::Object* Copy(mirror::Object* from_ref) SHARED_REQUIRES(Locks::mutator_lock_)
Mathieu Chartierd6636d32016-07-28 11:02:38 -0700133 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_, !immune_gray_stack_lock_);
Mathieu Chartier90443472015-07-16 20:32:27 -0700134 void Scan(mirror::Object* to_ref) SHARED_REQUIRES(Locks::mutator_lock_)
135 REQUIRES(!mark_stack_lock_);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800136 void Process(mirror::Object* obj, MemberOffset offset)
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700137 SHARED_REQUIRES(Locks::mutator_lock_)
138 REQUIRES(!mark_stack_lock_ , !skipped_blocks_lock_, !immune_gray_stack_lock_);
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -0700139 virtual void VisitRoots(mirror::Object*** roots, size_t count, const RootInfo& info)
Mathieu Chartier90443472015-07-16 20:32:27 -0700140 OVERRIDE SHARED_REQUIRES(Locks::mutator_lock_)
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700141 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_, !immune_gray_stack_lock_);
142 template<bool kGrayImmuneObject>
Mathieu Chartierda7c6502015-07-23 16:01:26 -0700143 void MarkRoot(mirror::CompressedReference<mirror::Object>* root)
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700144 SHARED_REQUIRES(Locks::mutator_lock_)
145 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_, !immune_gray_stack_lock_);
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -0700146 virtual void VisitRoots(mirror::CompressedReference<mirror::Object>** roots, size_t count,
147 const RootInfo& info)
Mathieu Chartier90443472015-07-16 20:32:27 -0700148 OVERRIDE SHARED_REQUIRES(Locks::mutator_lock_)
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700149 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_, !immune_gray_stack_lock_);
Mathieu Chartier90443472015-07-16 20:32:27 -0700150 void VerifyNoFromSpaceReferences() REQUIRES(Locks::mutator_lock_);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800151 accounting::ObjectStack* GetAllocationStack();
152 accounting::ObjectStack* GetLiveStack();
Mathieu Chartier90443472015-07-16 20:32:27 -0700153 virtual void ProcessMarkStack() OVERRIDE SHARED_REQUIRES(Locks::mutator_lock_)
154 REQUIRES(!mark_stack_lock_);
155 bool ProcessMarkStackOnce() SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!mark_stack_lock_);
156 void ProcessMarkStackRef(mirror::Object* to_ref) SHARED_REQUIRES(Locks::mutator_lock_)
157 REQUIRES(!mark_stack_lock_);
Mathieu Chartier21328a12016-07-22 10:47:45 -0700158 void GrayAllDirtyImmuneObjects()
159 REQUIRES(Locks::mutator_lock_)
160 REQUIRES(!mark_stack_lock_);
161 void VerifyGrayImmuneObjects()
162 REQUIRES(Locks::mutator_lock_)
163 REQUIRES(!mark_stack_lock_);
Hiroshi Yamauchi0b713572015-06-16 18:29:23 -0700164 size_t ProcessThreadLocalMarkStacks(bool disable_weak_ref_access)
Mathieu Chartier90443472015-07-16 20:32:27 -0700165 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!mark_stack_lock_);
Hiroshi Yamauchi0b713572015-06-16 18:29:23 -0700166 void RevokeThreadLocalMarkStacks(bool disable_weak_ref_access)
Mathieu Chartier90443472015-07-16 20:32:27 -0700167 SHARED_REQUIRES(Locks::mutator_lock_);
168 void SwitchToSharedMarkStackMode() SHARED_REQUIRES(Locks::mutator_lock_)
169 REQUIRES(!mark_stack_lock_);
170 void SwitchToGcExclusiveMarkStackMode() SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartier97509952015-07-13 14:35:43 -0700171 virtual void DelayReferenceReferent(mirror::Class* klass, mirror::Reference* reference) OVERRIDE
Mathieu Chartier90443472015-07-16 20:32:27 -0700172 SHARED_REQUIRES(Locks::mutator_lock_);
173 void ProcessReferences(Thread* self) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartier97509952015-07-13 14:35:43 -0700174 virtual mirror::Object* MarkObject(mirror::Object* from_ref) OVERRIDE
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700175 SHARED_REQUIRES(Locks::mutator_lock_)
176 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_, !immune_gray_stack_lock_);
Mathieu Chartier97509952015-07-13 14:35:43 -0700177 virtual void MarkHeapReference(mirror::HeapReference<mirror::Object>* from_ref) OVERRIDE
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700178 SHARED_REQUIRES(Locks::mutator_lock_)
179 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_, !immune_gray_stack_lock_);
Mathieu Chartier97509952015-07-13 14:35:43 -0700180 virtual mirror::Object* IsMarked(mirror::Object* from_ref) OVERRIDE
Mathieu Chartier90443472015-07-16 20:32:27 -0700181 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartier97509952015-07-13 14:35:43 -0700182 virtual bool IsMarkedHeapReference(mirror::HeapReference<mirror::Object>* field) OVERRIDE
Mathieu Chartier90443472015-07-16 20:32:27 -0700183 SHARED_REQUIRES(Locks::mutator_lock_);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800184 void SweepSystemWeaks(Thread* self)
Mathieu Chartier90443472015-07-16 20:32:27 -0700185 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Locks::heap_bitmap_lock_);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800186 void Sweep(bool swap_bitmaps)
Mathieu Chartier90443472015-07-16 20:32:27 -0700187 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(Locks::heap_bitmap_lock_, !mark_stack_lock_);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800188 void SweepLargeObjects(bool swap_bitmaps)
Mathieu Chartier90443472015-07-16 20:32:27 -0700189 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(Locks::heap_bitmap_lock_);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800190 void FillWithDummyObject(mirror::Object* dummy_obj, size_t byte_size)
Mathieu Chartierd6636d32016-07-28 11:02:38 -0700191 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_, !immune_gray_stack_lock_)
Mathieu Chartier90443472015-07-16 20:32:27 -0700192 SHARED_REQUIRES(Locks::mutator_lock_);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800193 mirror::Object* AllocateInSkippedBlock(size_t alloc_size)
Mathieu Chartierd6636d32016-07-28 11:02:38 -0700194 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_, !immune_gray_stack_lock_)
195 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartier90443472015-07-16 20:32:27 -0700196 void CheckEmptyMarkStack() SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!mark_stack_lock_);
197 void IssueEmptyCheckpoint() SHARED_REQUIRES(Locks::mutator_lock_);
198 bool IsOnAllocStack(mirror::Object* ref) SHARED_REQUIRES(Locks::mutator_lock_);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800199 mirror::Object* GetFwdPtr(mirror::Object* from_ref)
Mathieu Chartier90443472015-07-16 20:32:27 -0700200 SHARED_REQUIRES(Locks::mutator_lock_);
201 void FlipThreadRoots() REQUIRES(!Locks::mutator_lock_);
Mathieu Chartiera4f6af92015-08-11 17:35:25 -0700202 void SwapStacks() SHARED_REQUIRES(Locks::mutator_lock_);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800203 void RecordLiveStackFreezeSize(Thread* self);
204 void ComputeUnevacFromSpaceLiveRatio();
Hiroshi Yamauchi3f64f252015-06-12 18:35:06 -0700205 void LogFromSpaceRefHolder(mirror::Object* obj, MemberOffset offset)
Mathieu Chartier90443472015-07-16 20:32:27 -0700206 SHARED_REQUIRES(Locks::mutator_lock_);
Hiroshi Yamauchi3f64f252015-06-12 18:35:06 -0700207 void AssertToSpaceInvariantInNonMovingSpace(mirror::Object* obj, mirror::Object* ref)
Mathieu Chartier90443472015-07-16 20:32:27 -0700208 SHARED_REQUIRES(Locks::mutator_lock_);
209 void ReenableWeakRefAccess(Thread* self) SHARED_REQUIRES(Locks::mutator_lock_);
Hiroshi Yamauchi00370822015-08-18 14:47:25 -0700210 void DisableMarking() SHARED_REQUIRES(Locks::mutator_lock_);
211 void IssueDisableMarkingCheckpoint() SHARED_REQUIRES(Locks::mutator_lock_);
Hiroshi Yamauchi19eab402015-10-23 19:59:58 -0700212 void ExpandGcMarkStack() SHARED_REQUIRES(Locks::mutator_lock_);
Hiroshi Yamauchi723e6ce2015-10-28 20:59:47 -0700213 mirror::Object* MarkNonMoving(mirror::Object* from_ref) SHARED_REQUIRES(Locks::mutator_lock_)
214 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_);
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700215 ALWAYS_INLINE mirror::Object* MarkUnevacFromSpaceRegion(mirror::Object* from_ref,
Hiroshi Yamauchi8e674652015-12-22 11:09:18 -0800216 accounting::SpaceBitmap<kObjectAlignment>* bitmap)
217 SHARED_REQUIRES(Locks::mutator_lock_)
218 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_);
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700219 template<bool kGrayImmuneObject>
220 ALWAYS_INLINE mirror::Object* MarkImmuneSpace(mirror::Object* from_ref)
221 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!immune_gray_stack_lock_);
Hiroshi Yamauchi8e674652015-12-22 11:09:18 -0800222 void PushOntoFalseGrayStack(mirror::Object* obj) SHARED_REQUIRES(Locks::mutator_lock_)
223 REQUIRES(!mark_stack_lock_);
224 void ProcessFalseGrayStack() SHARED_REQUIRES(Locks::mutator_lock_)
225 REQUIRES(!mark_stack_lock_);
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700226 void ScanImmuneObject(mirror::Object* obj)
227 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!mark_stack_lock_);
Mathieu Chartier56fe2582016-07-14 13:30:03 -0700228 mirror::Object* MarkFromReadBarrierWithMeasurements(mirror::Object* from_ref)
229 SHARED_REQUIRES(Locks::mutator_lock_)
230 REQUIRES(!mark_stack_lock_, !skipped_blocks_lock_, !immune_gray_stack_lock_);
231 void DumpPerformanceInfo(std::ostream& os) OVERRIDE REQUIRES(!rb_slow_path_histogram_lock_);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800232
233 space::RegionSpace* region_space_; // The underlying region space.
234 std::unique_ptr<Barrier> gc_barrier_;
Hiroshi Yamauchi0b713572015-06-16 18:29:23 -0700235 std::unique_ptr<accounting::ObjectStack> gc_mark_stack_;
Mathieu Chartier36a270a2016-07-28 18:08:51 -0700236 std::unique_ptr<accounting::ObjectStack> rb_mark_bit_stack_;
237 bool rb_mark_bit_stack_full_;
Hiroshi Yamauchi8e674652015-12-22 11:09:18 -0800238 std::vector<mirror::Object*> false_gray_stack_ GUARDED_BY(mark_stack_lock_);
Hiroshi Yamauchi0b713572015-06-16 18:29:23 -0700239 Mutex mark_stack_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
240 std::vector<accounting::ObjectStack*> revoked_mark_stacks_
241 GUARDED_BY(mark_stack_lock_);
242 static constexpr size_t kMarkStackSize = kPageSize;
243 static constexpr size_t kMarkStackPoolSize = 256;
244 std::vector<accounting::ObjectStack*> pooled_mark_stacks_
245 GUARDED_BY(mark_stack_lock_);
246 Thread* thread_running_gc_;
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800247 bool is_marking_; // True while marking is ongoing.
248 bool is_active_; // True while the collection is ongoing.
249 bool is_asserting_to_space_invariant_; // True while asserting the to-space invariant.
Mathieu Chartier763a31e2015-11-16 16:05:55 -0800250 ImmuneSpaces immune_spaces_;
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800251 accounting::SpaceBitmap<kObjectAlignment>* region_space_bitmap_;
252 // A cache of Heap::GetMarkBitmap().
253 accounting::HeapBitmap* heap_mark_bitmap_;
254 size_t live_stack_freeze_size_;
255 size_t from_space_num_objects_at_first_pause_;
256 size_t from_space_num_bytes_at_first_pause_;
Hiroshi Yamauchi0b713572015-06-16 18:29:23 -0700257 Atomic<int> is_mark_stack_push_disallowed_;
258 enum MarkStackMode {
259 kMarkStackModeOff = 0, // Mark stack is off.
260 kMarkStackModeThreadLocal, // All threads except for the GC-running thread push refs onto
261 // thread-local mark stacks. The GC-running thread pushes onto and
262 // pops off the GC mark stack without a lock.
263 kMarkStackModeShared, // All threads share the GC mark stack with a lock.
264 kMarkStackModeGcExclusive // The GC-running thread pushes onto and pops from the GC mark stack
265 // without a lock. Other threads won't access the mark stack.
266 };
267 Atomic<MarkStackMode> mark_stack_mode_;
268 Atomic<bool> weak_ref_access_enabled_;
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800269
270 // How many objects and bytes we moved. Used for accounting.
271 Atomic<size_t> bytes_moved_;
272 Atomic<size_t> objects_moved_;
273
274 // The skipped blocks are memory blocks/chucks that were copies of
275 // objects that were unused due to lost races (cas failures) at
276 // object copy/forward pointer install. They are reused.
277 Mutex skipped_blocks_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
278 std::multimap<size_t, uint8_t*> skipped_blocks_map_ GUARDED_BY(skipped_blocks_lock_);
279 Atomic<size_t> to_space_bytes_skipped_;
280 Atomic<size_t> to_space_objects_skipped_;
281
Mathieu Chartier56fe2582016-07-14 13:30:03 -0700282 // If measure_read_barrier_slow_path_ is true, we count how long is spent in MarkFromReadBarrier
283 // and also log.
284 bool measure_read_barrier_slow_path_;
285 // mark_from_read_barrier_measurements_ is true if systrace is enabled or
286 // measure_read_barrier_time_ is true.
287 bool mark_from_read_barrier_measurements_;
288 Atomic<uint64_t> rb_slow_path_ns_;
289 Atomic<uint64_t> rb_slow_path_count_;
290 Atomic<uint64_t> rb_slow_path_count_gc_;
291 mutable Mutex rb_slow_path_histogram_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
292 Histogram<uint64_t> rb_slow_path_time_histogram_ GUARDED_BY(rb_slow_path_histogram_lock_);
293 uint64_t rb_slow_path_count_total_ GUARDED_BY(rb_slow_path_histogram_lock_);
294 uint64_t rb_slow_path_count_gc_total_ GUARDED_BY(rb_slow_path_histogram_lock_);
295
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800296 accounting::ReadBarrierTable* rb_table_;
297 bool force_evacuate_all_; // True if all regions are evacuated.
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700298 Atomic<bool> updated_all_immune_objects_;
299 bool gc_grays_immune_objects_;
300 Mutex immune_gray_stack_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
301 std::vector<mirror::Object*> immune_gray_stack_ GUARDED_BY(immune_gray_stack_lock_);
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800302
Mathieu Chartiera07f5592016-06-16 11:44:28 -0700303 class AssertToSpaceInvariantFieldVisitor;
304 class AssertToSpaceInvariantObjectVisitor;
305 class AssertToSpaceInvariantRefsVisitor;
306 class ClearBlackPtrsVisitor;
307 class ComputeUnevacFromSpaceLiveRatioVisitor;
308 class DisableMarkingCheckpoint;
309 class FlipCallback;
Mathieu Chartier21328a12016-07-22 10:47:45 -0700310 class GrayImmuneObjectVisitor;
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700311 class ImmuneSpaceScanObjVisitor;
Mathieu Chartiera07f5592016-06-16 11:44:28 -0700312 class LostCopyVisitor;
313 class RefFieldsVisitor;
314 class RevokeThreadLocalMarkStackCheckpoint;
Hiroshi Yamauchid8db5a22016-06-28 14:07:41 -0700315 class ScopedGcGraysImmuneObjects;
316 class ThreadFlipVisitor;
Mathieu Chartier21328a12016-07-22 10:47:45 -0700317 class VerifyGrayImmuneObjectsVisitor;
Mathieu Chartiera07f5592016-06-16 11:44:28 -0700318 class VerifyNoFromSpaceRefsFieldVisitor;
319 class VerifyNoFromSpaceRefsObjectVisitor;
320 class VerifyNoFromSpaceRefsVisitor;
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800321
Mathieu Chartier3130cdf2015-05-03 15:20:23 -0700322 DISALLOW_IMPLICIT_CONSTRUCTORS(ConcurrentCopying);
Hiroshi Yamauchid5307ec2014-03-27 21:07:51 -0700323};
324
325} // namespace collector
326} // namespace gc
327} // namespace art
328
329#endif // ART_RUNTIME_GC_COLLECTOR_CONCURRENT_COPYING_H_