blob: d24650b60d1a314d1f18462c90f44f5cc862c878 [file] [log] [blame]
Ian Rogers1d54e732013-05-02 21:10:01 -07001/*
2 * Copyright (C) 2011 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
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_GC_SPACE_SPACE_H_
18#define ART_RUNTIME_GC_SPACE_SPACE_H_
Ian Rogers1d54e732013-05-02 21:10:01 -070019
Ian Rogers700a4022014-05-19 16:49:03 -070020#include <memory>
Ian Rogers1d54e732013-05-02 21:10:01 -070021#include <string>
22
Ian Rogersbe2a1df2014-07-10 00:56:36 -070023#include "atomic.h"
Ian Rogers1d54e732013-05-02 21:10:01 -070024#include "base/macros.h"
25#include "base/mutex.h"
26#include "gc/accounting/space_bitmap.h"
Mathieu Chartier10fb83a2014-06-15 15:15:43 -070027#include "gc/collector/garbage_collector.h"
Ian Rogers1d54e732013-05-02 21:10:01 -070028#include "globals.h"
29#include "image.h"
30#include "mem_map.h"
31
32namespace art {
33namespace mirror {
34 class Object;
35} // namespace mirror
36
37namespace gc {
38
Ian Rogers1d54e732013-05-02 21:10:01 -070039class Heap;
40
41namespace space {
42
Mathieu Chartier590fee92013-09-13 13:46:47 -070043class AllocSpace;
Mathieu Chartier7410f292013-11-24 13:17:35 -080044class BumpPointerSpace;
Mathieu Chartiera1602f22014-01-13 17:19:19 -080045class ContinuousMemMapAllocSpace;
Mathieu Chartier590fee92013-09-13 13:46:47 -070046class ContinuousSpace;
Mathieu Chartier590fee92013-09-13 13:46:47 -070047class DiscontinuousSpace;
Hiroshi Yamauchicf58d4a2013-09-26 14:21:22 -070048class MallocSpace;
49class DlMallocSpace;
50class RosAllocSpace;
Ian Rogers1d54e732013-05-02 21:10:01 -070051class ImageSpace;
52class LargeObjectSpace;
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080053class RegionSpace;
Mathieu Chartiera1602f22014-01-13 17:19:19 -080054class ZygoteSpace;
Ian Rogers1d54e732013-05-02 21:10:01 -070055
Mathieu Chartier0f72e412013-09-06 16:40:01 -070056static constexpr bool kDebugSpaces = kIsDebugBuild;
Ian Rogers1d54e732013-05-02 21:10:01 -070057
58// See Space::GetGcRetentionPolicy.
59enum GcRetentionPolicy {
60 // Objects are retained forever with this policy for a space.
61 kGcRetentionPolicyNeverCollect,
62 // Every GC cycle will attempt to collect objects in this space.
63 kGcRetentionPolicyAlwaysCollect,
64 // Objects will be considered for collection only in "full" GC cycles, ie faster partial
65 // collections won't scan these areas such as the Zygote.
66 kGcRetentionPolicyFullCollect,
67};
68std::ostream& operator<<(std::ostream& os, const GcRetentionPolicy& policy);
69
70enum SpaceType {
71 kSpaceTypeImageSpace,
Mathieu Chartiera1602f22014-01-13 17:19:19 -080072 kSpaceTypeMallocSpace,
Ian Rogers1d54e732013-05-02 21:10:01 -070073 kSpaceTypeZygoteSpace,
Mathieu Chartier590fee92013-09-13 13:46:47 -070074 kSpaceTypeBumpPointerSpace,
Ian Rogers1d54e732013-05-02 21:10:01 -070075 kSpaceTypeLargeObjectSpace,
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080076 kSpaceTypeRegionSpace,
Ian Rogers1d54e732013-05-02 21:10:01 -070077};
78std::ostream& operator<<(std::ostream& os, const SpaceType& space_type);
79
80// A space contains memory allocated for managed objects.
81class Space {
82 public:
83 // Dump space. Also key method for C++ vtables.
84 virtual void Dump(std::ostream& os) const;
85
86 // Name of the space. May vary, for example before/after the Zygote fork.
87 const char* GetName() const {
88 return name_.c_str();
89 }
90
91 // The policy of when objects are collected associated with this space.
92 GcRetentionPolicy GetGcRetentionPolicy() const {
93 return gc_retention_policy_;
94 }
95
Ian Rogers1d54e732013-05-02 21:10:01 -070096 // Is the given object contained within this space?
97 virtual bool Contains(const mirror::Object* obj) const = 0;
98
99 // The kind of space this: image, alloc, zygote, large object.
100 virtual SpaceType GetType() const = 0;
101
102 // Is this an image space, ie one backed by a memory mapped image file.
103 bool IsImageSpace() const {
104 return GetType() == kSpaceTypeImageSpace;
105 }
106 ImageSpace* AsImageSpace();
107
108 // Is this a dlmalloc backed allocation space?
Hiroshi Yamauchicf58d4a2013-09-26 14:21:22 -0700109 bool IsMallocSpace() const {
Ian Rogers1d54e732013-05-02 21:10:01 -0700110 SpaceType type = GetType();
Mathieu Chartiera1602f22014-01-13 17:19:19 -0800111 return type == kSpaceTypeMallocSpace;
Ian Rogers1d54e732013-05-02 21:10:01 -0700112 }
Hiroshi Yamauchicf58d4a2013-09-26 14:21:22 -0700113 MallocSpace* AsMallocSpace();
114
115 virtual bool IsDlMallocSpace() const {
116 return false;
117 }
Ian Rogers6fac4472014-02-25 17:01:10 -0800118 virtual DlMallocSpace* AsDlMallocSpace();
119
Hiroshi Yamauchicf58d4a2013-09-26 14:21:22 -0700120 virtual bool IsRosAllocSpace() const {
121 return false;
122 }
Ian Rogers6fac4472014-02-25 17:01:10 -0800123 virtual RosAllocSpace* AsRosAllocSpace();
Ian Rogers1d54e732013-05-02 21:10:01 -0700124
Ian Rogers6fac4472014-02-25 17:01:10 -0800125 // Is this the space allocated into by the Zygote and no-longer in use for allocation?
Ian Rogers1d54e732013-05-02 21:10:01 -0700126 bool IsZygoteSpace() const {
127 return GetType() == kSpaceTypeZygoteSpace;
128 }
Ian Rogers6fac4472014-02-25 17:01:10 -0800129 virtual ZygoteSpace* AsZygoteSpace();
Ian Rogers1d54e732013-05-02 21:10:01 -0700130
Mathieu Chartier590fee92013-09-13 13:46:47 -0700131 // Is this space a bump pointer space?
132 bool IsBumpPointerSpace() const {
133 return GetType() == kSpaceTypeBumpPointerSpace;
134 }
Ian Rogers6fac4472014-02-25 17:01:10 -0800135 virtual BumpPointerSpace* AsBumpPointerSpace();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700136
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800137 bool IsRegionSpace() const {
138 return GetType() == kSpaceTypeRegionSpace;
139 }
140 virtual RegionSpace* AsRegionSpace();
141
Ian Rogers1d54e732013-05-02 21:10:01 -0700142 // Does this space hold large objects and implement the large object space abstraction?
143 bool IsLargeObjectSpace() const {
144 return GetType() == kSpaceTypeLargeObjectSpace;
145 }
146 LargeObjectSpace* AsLargeObjectSpace();
147
Mathieu Chartier590fee92013-09-13 13:46:47 -0700148 virtual bool IsContinuousSpace() const {
149 return false;
150 }
151 ContinuousSpace* AsContinuousSpace();
152
153 virtual bool IsDiscontinuousSpace() const {
154 return false;
155 }
156 DiscontinuousSpace* AsDiscontinuousSpace();
157
158 virtual bool IsAllocSpace() const {
159 return false;
160 }
Ian Rogers6fac4472014-02-25 17:01:10 -0800161 virtual AllocSpace* AsAllocSpace();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700162
Mathieu Chartiera1602f22014-01-13 17:19:19 -0800163 virtual bool IsContinuousMemMapAllocSpace() const {
164 return false;
165 }
Ian Rogers6fac4472014-02-25 17:01:10 -0800166 virtual ContinuousMemMapAllocSpace* AsContinuousMemMapAllocSpace();
Mathieu Chartiera1602f22014-01-13 17:19:19 -0800167
Mathieu Chartier31f44142014-04-08 14:40:03 -0700168 // Returns true if objects in the space are movable.
169 virtual bool CanMoveObjects() const = 0;
170
Ian Rogers1d54e732013-05-02 21:10:01 -0700171 virtual ~Space() {}
172
173 protected:
174 Space(const std::string& name, GcRetentionPolicy gc_retention_policy);
175
176 void SetGcRetentionPolicy(GcRetentionPolicy gc_retention_policy) {
177 gc_retention_policy_ = gc_retention_policy;
178 }
179
180 // Name of the space that may vary due to the Zygote fork.
181 std::string name_;
182
Mathieu Chartier590fee92013-09-13 13:46:47 -0700183 protected:
Ian Rogers1d54e732013-05-02 21:10:01 -0700184 // When should objects within this space be reclaimed? Not constant as we vary it in the case
185 // of Zygote forking.
186 GcRetentionPolicy gc_retention_policy_;
187
Mathieu Chartier590fee92013-09-13 13:46:47 -0700188 private:
Ian Rogers1d54e732013-05-02 21:10:01 -0700189 friend class art::gc::Heap;
Ian Rogers1d54e732013-05-02 21:10:01 -0700190 DISALLOW_COPY_AND_ASSIGN(Space);
191};
192std::ostream& operator<<(std::ostream& os, const Space& space);
193
194// AllocSpace interface.
195class AllocSpace {
196 public:
197 // Number of bytes currently allocated.
Hiroshi Yamauchibe031ff2013-10-08 16:42:37 -0700198 virtual uint64_t GetBytesAllocated() = 0;
Ian Rogers1d54e732013-05-02 21:10:01 -0700199 // Number of objects currently allocated.
Hiroshi Yamauchibe031ff2013-10-08 16:42:37 -0700200 virtual uint64_t GetObjectsAllocated() = 0;
Ian Rogers1d54e732013-05-02 21:10:01 -0700201
Hiroshi Yamauchi50b29282013-07-30 13:58:37 -0700202 // Allocate num_bytes without allowing growth. If the allocation
203 // succeeds, the output parameter bytes_allocated will be set to the
204 // actually allocated bytes which is >= num_bytes.
Mathieu Chartier0651d412014-04-29 14:37:57 -0700205 // Alloc can be called from multiple threads at the same time and must be thread-safe.
Ian Rogers6fac4472014-02-25 17:01:10 -0800206 virtual mirror::Object* Alloc(Thread* self, size_t num_bytes, size_t* bytes_allocated,
207 size_t* usable_size) = 0;
Ian Rogers1d54e732013-05-02 21:10:01 -0700208
Mathieu Chartier0651d412014-04-29 14:37:57 -0700209 // Thread-unsafe allocation for when mutators are suspended, used by the semispace collector.
210 virtual mirror::Object* AllocThreadUnsafe(Thread* self, size_t num_bytes, size_t* bytes_allocated,
211 size_t* usable_size)
212 EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_) {
213 return Alloc(self, num_bytes, bytes_allocated, usable_size);
214 }
215
Ian Rogers1d54e732013-05-02 21:10:01 -0700216 // Return the storage space required by obj.
Ian Rogers6fac4472014-02-25 17:01:10 -0800217 virtual size_t AllocationSize(mirror::Object* obj, size_t* usable_size) = 0;
Ian Rogers1d54e732013-05-02 21:10:01 -0700218
219 // Returns how many bytes were freed.
220 virtual size_t Free(Thread* self, mirror::Object* ptr) = 0;
221
222 // Returns how many bytes were freed.
223 virtual size_t FreeList(Thread* self, size_t num_ptrs, mirror::Object** ptrs) = 0;
224
Ian Rogers6fac4472014-02-25 17:01:10 -0800225 // Revoke any sort of thread-local buffers that are used to speed up allocations for the given
226 // thread, if the alloc space implementation uses any.
227 virtual void RevokeThreadLocalBuffers(Thread* thread) = 0;
Hiroshi Yamauchicf58d4a2013-09-26 14:21:22 -0700228
Ian Rogers6fac4472014-02-25 17:01:10 -0800229 // Revoke any sort of thread-local buffers that are used to speed up allocations for all the
230 // threads, if the alloc space implementation uses any.
231 virtual void RevokeAllThreadLocalBuffers() = 0;
Hiroshi Yamauchicf58d4a2013-09-26 14:21:22 -0700232
Mathieu Chartierb363f662014-07-16 13:28:58 -0700233 virtual void LogFragmentationAllocFailure(std::ostream& os, size_t failed_alloc_bytes) = 0;
234
Ian Rogers1d54e732013-05-02 21:10:01 -0700235 protected:
Mathieu Chartier10fb83a2014-06-15 15:15:43 -0700236 struct SweepCallbackContext {
237 SweepCallbackContext(bool swap_bitmaps, space::Space* space);
238 const bool swap_bitmaps;
239 space::Space* const space;
240 Thread* const self;
241 collector::ObjectBytePair freed;
242 };
243
Ian Rogers1d54e732013-05-02 21:10:01 -0700244 AllocSpace() {}
245 virtual ~AllocSpace() {}
246
247 private:
248 DISALLOW_COPY_AND_ASSIGN(AllocSpace);
249};
250
251// Continuous spaces have bitmaps, and an address range. Although not required, objects within
252// continuous spaces can be marked in the card table.
253class ContinuousSpace : public Space {
254 public:
Mathieu Chartier590fee92013-09-13 13:46:47 -0700255 // Address at which the space begins.
Ian Rogers13735952014-10-08 12:43:28 -0700256 uint8_t* Begin() const {
Ian Rogers1d54e732013-05-02 21:10:01 -0700257 return begin_;
258 }
259
Mathieu Chartier590fee92013-09-13 13:46:47 -0700260 // Current address at which the space ends, which may vary as the space is filled.
Ian Rogers13735952014-10-08 12:43:28 -0700261 uint8_t* End() const {
Ian Rogersbe2a1df2014-07-10 00:56:36 -0700262 return end_.LoadRelaxed();
Ian Rogers1d54e732013-05-02 21:10:01 -0700263 }
264
Mathieu Chartier590fee92013-09-13 13:46:47 -0700265 // The end of the address range covered by the space.
Ian Rogers13735952014-10-08 12:43:28 -0700266 uint8_t* Limit() const {
Mathieu Chartier590fee92013-09-13 13:46:47 -0700267 return limit_;
268 }
269
270 // Change the end of the space. Be careful with use since changing the end of a space to an
271 // invalid value may break the GC.
Ian Rogers13735952014-10-08 12:43:28 -0700272 void SetEnd(uint8_t* end) {
Ian Rogersbe2a1df2014-07-10 00:56:36 -0700273 end_.StoreRelaxed(end);
Mathieu Chartier590fee92013-09-13 13:46:47 -0700274 }
275
Ian Rogers13735952014-10-08 12:43:28 -0700276 void SetLimit(uint8_t* limit) {
Mathieu Chartier590fee92013-09-13 13:46:47 -0700277 limit_ = limit;
278 }
279
Ian Rogers1d54e732013-05-02 21:10:01 -0700280 // Current size of space
281 size_t Size() const {
282 return End() - Begin();
283 }
284
Mathieu Chartiera8e8f9c2014-04-09 14:51:05 -0700285 virtual accounting::ContinuousSpaceBitmap* GetLiveBitmap() const = 0;
286 virtual accounting::ContinuousSpaceBitmap* GetMarkBitmap() const = 0;
Ian Rogers1d54e732013-05-02 21:10:01 -0700287
Mathieu Chartier590fee92013-09-13 13:46:47 -0700288 // Maximum which the mapped space can grow to.
289 virtual size_t Capacity() const {
290 return Limit() - Begin();
291 }
292
Ian Rogers1d54e732013-05-02 21:10:01 -0700293 // Is object within this space? We check to see if the pointer is beyond the end first as
294 // continuous spaces are iterated over from low to high.
295 bool HasAddress(const mirror::Object* obj) const {
Ian Rogers13735952014-10-08 12:43:28 -0700296 const uint8_t* byte_ptr = reinterpret_cast<const uint8_t*>(obj);
Mathieu Chartier590fee92013-09-13 13:46:47 -0700297 return byte_ptr >= Begin() && byte_ptr < Limit();
Ian Rogers1d54e732013-05-02 21:10:01 -0700298 }
299
300 bool Contains(const mirror::Object* obj) const {
301 return HasAddress(obj);
302 }
303
Mathieu Chartier590fee92013-09-13 13:46:47 -0700304 virtual bool IsContinuousSpace() const {
305 return true;
306 }
307
Ian Rogers1d54e732013-05-02 21:10:01 -0700308 virtual ~ContinuousSpace() {}
309
310 protected:
311 ContinuousSpace(const std::string& name, GcRetentionPolicy gc_retention_policy,
Ian Rogers13735952014-10-08 12:43:28 -0700312 uint8_t* begin, uint8_t* end, uint8_t* limit) :
Mathieu Chartier590fee92013-09-13 13:46:47 -0700313 Space(name, gc_retention_policy), begin_(begin), end_(end), limit_(limit) {
Ian Rogers1d54e732013-05-02 21:10:01 -0700314 }
315
Ian Rogers1d54e732013-05-02 21:10:01 -0700316 // The beginning of the storage for fast access.
Ian Rogers13735952014-10-08 12:43:28 -0700317 uint8_t* begin_;
Ian Rogers1d54e732013-05-02 21:10:01 -0700318
319 // Current end of the space.
Ian Rogers13735952014-10-08 12:43:28 -0700320 Atomic<uint8_t*> end_;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700321
322 // Limit of the space.
Ian Rogers13735952014-10-08 12:43:28 -0700323 uint8_t* limit_;
Ian Rogers1d54e732013-05-02 21:10:01 -0700324
325 private:
326 DISALLOW_COPY_AND_ASSIGN(ContinuousSpace);
327};
328
329// A space where objects may be allocated higgledy-piggledy throughout virtual memory. Currently
330// the card table can't cover these objects and so the write barrier shouldn't be triggered. This
331// is suitable for use for large primitive arrays.
332class DiscontinuousSpace : public Space {
333 public:
Mathieu Chartierbbd695c2014-04-16 09:48:48 -0700334 accounting::LargeObjectBitmap* GetLiveBitmap() const {
335 return live_bitmap_.get();
Ian Rogers1d54e732013-05-02 21:10:01 -0700336 }
337
Mathieu Chartierbbd695c2014-04-16 09:48:48 -0700338 accounting::LargeObjectBitmap* GetMarkBitmap() const {
339 return mark_bitmap_.get();
Ian Rogers1d54e732013-05-02 21:10:01 -0700340 }
341
Mathieu Chartierbbd695c2014-04-16 09:48:48 -0700342 virtual bool IsDiscontinuousSpace() const OVERRIDE {
Mathieu Chartier590fee92013-09-13 13:46:47 -0700343 return true;
344 }
345
Ian Rogers1d54e732013-05-02 21:10:01 -0700346 virtual ~DiscontinuousSpace() {}
347
348 protected:
349 DiscontinuousSpace(const std::string& name, GcRetentionPolicy gc_retention_policy);
350
Ian Rogers700a4022014-05-19 16:49:03 -0700351 std::unique_ptr<accounting::LargeObjectBitmap> live_bitmap_;
352 std::unique_ptr<accounting::LargeObjectBitmap> mark_bitmap_;
Ian Rogers1d54e732013-05-02 21:10:01 -0700353
354 private:
355 DISALLOW_COPY_AND_ASSIGN(DiscontinuousSpace);
356};
357
358class MemMapSpace : public ContinuousSpace {
359 public:
Ian Rogers1d54e732013-05-02 21:10:01 -0700360 // Size of the space without a limit on its growth. By default this is just the Capacity, but
361 // for the allocation space we support starting with a small heap and then extending it.
362 virtual size_t NonGrowthLimitCapacity() const {
363 return Capacity();
364 }
365
Ian Rogers1d54e732013-05-02 21:10:01 -0700366 MemMap* GetMemMap() {
367 return mem_map_.get();
368 }
369
370 const MemMap* GetMemMap() const {
371 return mem_map_.get();
372 }
373
Mathieu Chartiere6da9af2013-12-16 11:54:42 -0800374 MemMap* ReleaseMemMap() {
375 return mem_map_.release();
376 }
377
Mathieu Chartier590fee92013-09-13 13:46:47 -0700378 protected:
Ian Rogers13735952014-10-08 12:43:28 -0700379 MemMapSpace(const std::string& name, MemMap* mem_map, uint8_t* begin, uint8_t* end, uint8_t* limit,
Mathieu Chartier590fee92013-09-13 13:46:47 -0700380 GcRetentionPolicy gc_retention_policy)
381 : ContinuousSpace(name, gc_retention_policy, begin, end, limit),
382 mem_map_(mem_map) {
383 }
384
Ian Rogers1d54e732013-05-02 21:10:01 -0700385 // Underlying storage of the space
Ian Rogers700a4022014-05-19 16:49:03 -0700386 std::unique_ptr<MemMap> mem_map_;
Ian Rogers1d54e732013-05-02 21:10:01 -0700387
Mathieu Chartier590fee92013-09-13 13:46:47 -0700388 private:
Ian Rogers1d54e732013-05-02 21:10:01 -0700389 DISALLOW_COPY_AND_ASSIGN(MemMapSpace);
390};
391
Mathieu Chartier590fee92013-09-13 13:46:47 -0700392// Used by the heap compaction interface to enable copying from one type of alloc space to another.
393class ContinuousMemMapAllocSpace : public MemMapSpace, public AllocSpace {
394 public:
Ian Rogers6fac4472014-02-25 17:01:10 -0800395 bool IsAllocSpace() const OVERRIDE {
Mathieu Chartier590fee92013-09-13 13:46:47 -0700396 return true;
397 }
Ian Rogers6fac4472014-02-25 17:01:10 -0800398 AllocSpace* AsAllocSpace() OVERRIDE {
Mathieu Chartier590fee92013-09-13 13:46:47 -0700399 return this;
400 }
401
Ian Rogers6fac4472014-02-25 17:01:10 -0800402 bool IsContinuousMemMapAllocSpace() const OVERRIDE {
Mathieu Chartiera1602f22014-01-13 17:19:19 -0800403 return true;
404 }
Ian Rogers6fac4472014-02-25 17:01:10 -0800405 ContinuousMemMapAllocSpace* AsContinuousMemMapAllocSpace() {
Mathieu Chartiera1602f22014-01-13 17:19:19 -0800406 return this;
407 }
408
409 bool HasBoundBitmaps() const EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_);
410 void BindLiveToMarkBitmap()
411 EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_);
412 void UnBindBitmaps() EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_);
Mathieu Chartier1f3b5352014-02-03 14:00:42 -0800413 // Swap the live and mark bitmaps of this space. This is used by the GC for concurrent sweeping.
414 void SwapBitmaps();
Mathieu Chartiera1602f22014-01-13 17:19:19 -0800415
Mathieu Chartiera8e8f9c2014-04-09 14:51:05 -0700416 // Clear the space back to an empty space.
Ian Rogers6fac4472014-02-25 17:01:10 -0800417 virtual void Clear() = 0;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700418
Mathieu Chartier4c13a3f2014-07-14 14:57:16 -0700419 accounting::ContinuousSpaceBitmap* GetLiveBitmap() const OVERRIDE {
Mathieu Chartiera1602f22014-01-13 17:19:19 -0800420 return live_bitmap_.get();
421 }
Ian Rogers6fac4472014-02-25 17:01:10 -0800422
Mathieu Chartier4c13a3f2014-07-14 14:57:16 -0700423 accounting::ContinuousSpaceBitmap* GetMarkBitmap() const OVERRIDE {
Mathieu Chartiera1602f22014-01-13 17:19:19 -0800424 return mark_bitmap_.get();
425 }
426
Mathieu Chartier10fb83a2014-06-15 15:15:43 -0700427 collector::ObjectBytePair Sweep(bool swap_bitmaps);
Mathieu Chartiera8e8f9c2014-04-09 14:51:05 -0700428 virtual accounting::ContinuousSpaceBitmap::SweepCallback* GetSweepCallback() = 0;
Mathieu Chartiera1602f22014-01-13 17:19:19 -0800429
Mathieu Chartier590fee92013-09-13 13:46:47 -0700430 protected:
Ian Rogers700a4022014-05-19 16:49:03 -0700431 std::unique_ptr<accounting::ContinuousSpaceBitmap> live_bitmap_;
432 std::unique_ptr<accounting::ContinuousSpaceBitmap> mark_bitmap_;
433 std::unique_ptr<accounting::ContinuousSpaceBitmap> temp_bitmap_;
Mathieu Chartiera1602f22014-01-13 17:19:19 -0800434
Ian Rogers13735952014-10-08 12:43:28 -0700435 ContinuousMemMapAllocSpace(const std::string& name, MemMap* mem_map, uint8_t* begin,
436 uint8_t* end, uint8_t* limit, GcRetentionPolicy gc_retention_policy)
Mathieu Chartier590fee92013-09-13 13:46:47 -0700437 : MemMapSpace(name, mem_map, begin, end, limit, gc_retention_policy) {
438 }
439
440 private:
Mathieu Chartiera1602f22014-01-13 17:19:19 -0800441 friend class gc::Heap;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700442 DISALLOW_COPY_AND_ASSIGN(ContinuousMemMapAllocSpace);
443};
444
Ian Rogers1d54e732013-05-02 21:10:01 -0700445} // namespace space
446} // namespace gc
447} // namespace art
448
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700449#endif // ART_RUNTIME_GC_SPACE_SPACE_H_