blob: 79597ec72d06e112a1369f0e633b6813200bec3a [file] [log] [blame]
Carl Shapiro69759ea2011-07-21 18:13:35 -07001// Copyright 2011 Google Inc. All Rights Reserved.
Carl Shapiro69759ea2011-07-21 18:13:35 -07002
Brian Carlstrom578bbdc2011-07-21 14:07:47 -07003#include "mark_sweep.h"
Carl Shapiro69759ea2011-07-21 18:13:35 -07004
Carl Shapiro58551df2011-07-24 03:09:51 -07005#include <climits>
6#include <vector>
7
Elliott Hughes410c0c82011-09-01 17:58:25 -07008#include "class_loader.h"
Brian Carlstrom693267a2011-09-06 09:25:34 -07009#include "dex_cache.h"
Carl Shapiro58551df2011-07-24 03:09:51 -070010#include "heap.h"
Elliott Hughes410c0c82011-09-01 17:58:25 -070011#include "indirect_reference_table.h"
12#include "intern_table.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070013#include "logging.h"
14#include "macros.h"
15#include "mark_stack.h"
Elliott Hughesc33a32b2011-10-11 18:18:07 -070016#include "monitor.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070017#include "object.h"
Brian Carlstrom1f870082011-08-23 16:02:11 -070018#include "runtime.h"
Carl Shapiro58551df2011-07-24 03:09:51 -070019#include "space.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070020#include "thread.h"
Carl Shapiro69759ea2011-07-21 18:13:35 -070021
Carl Shapiro69759ea2011-07-21 18:13:35 -070022namespace art {
23
Carl Shapiro58551df2011-07-24 03:09:51 -070024bool MarkSweep::Init() {
Brian Carlstrom4a289ed2011-08-16 17:17:49 -070025 mark_stack_ = MarkStack::Create();
Carl Shapiro58551df2011-07-24 03:09:51 -070026 if (mark_stack_ == NULL) {
27 return false;
28 }
29
30 mark_bitmap_ = Heap::GetMarkBits();
31 live_bitmap_ = Heap::GetLiveBits();
32
33 // TODO: if concurrent, clear the card table.
34
buzbee0d966cf2011-09-08 17:34:58 -070035 // TODO: if concurrent, enable card marking in compiler
36
Carl Shapiro58551df2011-07-24 03:09:51 -070037 // TODO: check that the mark bitmap is entirely clear.
38
39 return true;
40}
41
Carl Shapiro69759ea2011-07-21 18:13:35 -070042void MarkSweep::MarkObject0(const Object* obj, bool check_finger) {
43 DCHECK(obj != NULL);
44 if (obj < condemned_) {
45 DCHECK(IsMarked(obj));
46 return;
47 }
48 bool is_marked = mark_bitmap_->Test(obj);
49 // This object was not previously marked.
50 if (!is_marked) {
51 mark_bitmap_->Set(obj);
52 if (check_finger && obj < finger_) {
53 // The object must be pushed on to the mark stack.
54 mark_stack_->Push(obj);
55 }
56 }
57}
58
59// Used to mark objects when recursing. Recursion is done by moving
60// the finger across the bitmaps in address order and marking child
61// objects. Any newly-marked objects whose addresses are lower than
62// the finger won't be visited by the bitmap scan, so those objects
63// need to be added to the mark stack.
64void MarkSweep::MarkObject(const Object* obj) {
65 if (obj != NULL) {
66 MarkObject0(obj, true);
67 }
68}
69
Elliott Hughescf4c6c42011-09-01 15:16:42 -070070void MarkSweep::MarkObjectVisitor(const Object* root, void* arg) {
Brian Carlstrom1f870082011-08-23 16:02:11 -070071 DCHECK(root != NULL);
72 DCHECK(arg != NULL);
73 MarkSweep* mark_sweep = reinterpret_cast<MarkSweep*>(arg);
74 mark_sweep->MarkObject0(root, true);
75}
76
Carl Shapiro69759ea2011-07-21 18:13:35 -070077// Marks all objects in the root set.
78void MarkSweep::MarkRoots() {
Brian Carlstrom1f870082011-08-23 16:02:11 -070079 Runtime::Current()->VisitRoots(MarkObjectVisitor, this);
Carl Shapiro69759ea2011-07-21 18:13:35 -070080}
81
Carl Shapiro58551df2011-07-24 03:09:51 -070082void MarkSweep::ScanBitmapCallback(Object* obj, void* finger, void* arg) {
83 MarkSweep* mark_sweep = reinterpret_cast<MarkSweep*>(arg);
84 mark_sweep->finger_ = reinterpret_cast<Object*>(finger);
85 mark_sweep->ScanObject(obj);
86}
87
88// Populates the mark stack based on the set of marked objects and
89// recursively marks until the mark stack is emptied.
90void MarkSweep::RecursiveMark() {
Brian Carlstrom1f870082011-08-23 16:02:11 -070091
92 // RecursiveMark will build the lists of known instances of the Reference classes.
93 // See DelayReferenceReferent for details.
94 CHECK(soft_reference_list_ == NULL);
95 CHECK(weak_reference_list_ == NULL);
96 CHECK(finalizer_reference_list_ == NULL);
97 CHECK(phantom_reference_list_ == NULL);
98 CHECK(cleared_reference_list_ == NULL);
99
Carl Shapiro58551df2011-07-24 03:09:51 -0700100 void* arg = reinterpret_cast<void*>(this);
101 const std::vector<Space*>& spaces = Heap::GetSpaces();
102 for (size_t i = 0; i < spaces.size(); ++i) {
103 if (spaces[i]->IsCondemned()) {
104 uintptr_t base = reinterpret_cast<uintptr_t>(spaces[i]->GetBase());
Brian Carlstrom1f870082011-08-23 16:02:11 -0700105 mark_bitmap_->ScanWalk(base, &MarkSweep::ScanBitmapCallback, arg);
Carl Shapiro58551df2011-07-24 03:09:51 -0700106 }
107 }
108 finger_ = reinterpret_cast<Object*>(~0);
109 ProcessMarkStack();
110}
111
112void MarkSweep::ReMarkRoots() {
Elliott Hughes53b61312011-08-12 18:28:20 -0700113 UNIMPLEMENTED(FATAL);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700114}
115
Elliott Hughes410c0c82011-09-01 17:58:25 -0700116void MarkSweep::SweepJniWeakGlobals() {
117 JavaVMExt* vm = Runtime::Current()->GetJavaVM();
118 MutexLock mu(vm->weak_globals_lock);
119 IndirectReferenceTable* table = &vm->weak_globals;
120 typedef IndirectReferenceTable::iterator It; // TODO: C++0x auto
121 for (It it = table->begin(), end = table->end(); it != end; ++it) {
122 const Object** entry = *it;
123 if (!IsMarked(*entry)) {
124 *entry = kClearedJniWeakGlobal;
125 }
126 }
127}
128
Elliott Hughes410c0c82011-09-01 17:58:25 -0700129void MarkSweep::SweepSystemWeaks() {
Elliott Hughesc33a32b2011-10-11 18:18:07 -0700130 Runtime::Current()->GetInternTable()->SweepInternTableWeaks(IsMarked, this);
131 Runtime::Current()->GetMonitorList()->SweepMonitorList(IsMarked, this);
Elliott Hughes410c0c82011-09-01 17:58:25 -0700132 SweepJniWeakGlobals();
Carl Shapiro58551df2011-07-24 03:09:51 -0700133}
134
Brian Carlstrom78128a62011-09-15 17:21:19 -0700135void MarkSweep::SweepCallback(size_t num_ptrs, void** ptrs, void* arg) {
Carl Shapiro58551df2011-07-24 03:09:51 -0700136 // TODO, lock heap if concurrent
137 Space* space = static_cast<Space*>(arg);
138 for (size_t i = 0; i < num_ptrs; ++i) {
139 Object* obj = static_cast<Object*>(ptrs[i]);
Elliott Hughes92b3b562011-09-08 16:32:26 -0700140 Heap::RecordFreeLocked(space, obj);
Carl Shapiro58551df2011-07-24 03:09:51 -0700141 space->Free(obj);
142 }
143 // TODO, unlock heap if concurrent
144}
145
146void MarkSweep::Sweep() {
Elliott Hughes2da50362011-10-10 16:57:08 -0700147 SweepSystemWeaks();
148
Carl Shapiro58551df2011-07-24 03:09:51 -0700149 const std::vector<Space*>& spaces = Heap::GetSpaces();
150 for (size_t i = 0; i < spaces.size(); ++i) {
151 if (spaces[i]->IsCondemned()) {
152 uintptr_t base = reinterpret_cast<uintptr_t>(spaces[i]->GetBase());
153 uintptr_t limit = reinterpret_cast<uintptr_t>(spaces[i]->GetLimit());
154 void* arg = static_cast<void*>(spaces[i]);
155 HeapBitmap::SweepWalk(*live_bitmap_, *mark_bitmap_, base, limit,
156 &MarkSweep::SweepCallback, arg);
157 }
158 }
159}
160
Carl Shapiro69759ea2011-07-21 18:13:35 -0700161// Scans instance fields.
162void MarkSweep::ScanInstanceFields(const Object* obj) {
163 DCHECK(obj != NULL);
Brian Carlstrom4873d462011-08-21 15:23:39 -0700164 Class* klass = obj->GetClass();
165 DCHECK(klass != NULL);
Elliott Hughes2da50362011-10-10 16:57:08 -0700166 ScanFields(obj, klass->GetReferenceInstanceOffsets(), false);
Brian Carlstrom4873d462011-08-21 15:23:39 -0700167}
168
169// Scans static storage on a Class.
170void MarkSweep::ScanStaticFields(const Class* klass) {
171 DCHECK(klass != NULL);
Elliott Hughesadb460d2011-10-05 17:02:34 -0700172 ScanFields(klass, klass->GetReferenceStaticOffsets(), true);
Brian Carlstrom4873d462011-08-21 15:23:39 -0700173}
174
Elliott Hughes2da50362011-10-10 16:57:08 -0700175void MarkSweep::ScanFields(const Object* obj, uint32_t ref_offsets, bool is_static) {
Carl Shapiro69759ea2011-07-21 18:13:35 -0700176 if (ref_offsets != CLASS_WALK_SUPER) {
177 // Found a reference offset bitmap. Mark the specified offsets.
178 while (ref_offsets != 0) {
179 size_t right_shift = CLZ(ref_offsets);
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700180 MemberOffset byte_offset = CLASS_OFFSET_FROM_CLZ(right_shift);
181 const Object* ref = obj->GetFieldObject<const Object*>(byte_offset, false);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700182 MarkObject(ref);
183 ref_offsets &= ~(CLASS_HIGH_BIT >> right_shift);
184 }
185 } else {
Brian Carlstrom4873d462011-08-21 15:23:39 -0700186 // There is no reference offset bitmap. In the non-static case,
187 // walk up the class inheritance hierarchy and find reference
188 // offsets the hard way. In the static case, just consider this
189 // class.
190 for (const Class* klass = is_static ? obj->AsClass() : obj->GetClass();
Carl Shapiro69759ea2011-07-21 18:13:35 -0700191 klass != NULL;
Brian Carlstrom4873d462011-08-21 15:23:39 -0700192 klass = is_static ? NULL : klass->GetSuperClass()) {
193 size_t num_reference_fields = (is_static
194 ? klass->NumReferenceStaticFields()
195 : klass->NumReferenceInstanceFields());
196 for (size_t i = 0; i < num_reference_fields; ++i) {
197 Field* field = (is_static
198 ? klass->GetStaticField(i)
199 : klass->GetInstanceField(i));
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700200 MemberOffset field_offset = field->GetOffset();
201 const Object* ref = obj->GetFieldObject<const Object*>(field_offset, false);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700202 MarkObject(ref);
203 }
204 }
205 }
206}
207
Carl Shapiro69759ea2011-07-21 18:13:35 -0700208// Scans the header, static field references, and interface pointers
209// of a class object.
210void MarkSweep::ScanClass(const Object* obj) {
211 DCHECK(obj != NULL);
212 DCHECK(obj->IsClass());
213 const Class* klass = obj->AsClass();
214 MarkObject(klass->GetClass());
Brian Carlstrom693267a2011-09-06 09:25:34 -0700215 ScanInstanceFields(obj);
216 MarkObject(klass->GetDescriptor());
217 MarkObject(klass->GetDexCache());
218 MarkObject(klass->GetVerifyErrorClass());
Brian Carlstromb63ec392011-08-27 17:38:27 -0700219 if (klass->IsArrayClass()) {
Carl Shapiro69759ea2011-07-21 18:13:35 -0700220 MarkObject(klass->GetComponentType());
221 }
222 if (klass->IsLoaded()) {
223 MarkObject(klass->GetSuperClass());
224 }
225 MarkObject(klass->GetClassLoader());
Carl Shapiro69759ea2011-07-21 18:13:35 -0700226 if (klass->IsLoaded()) {
Brian Carlstrom693267a2011-09-06 09:25:34 -0700227 MarkObject(klass->GetInterfaces());
228 MarkObject(klass->GetDirectMethods());
229 MarkObject(klass->GetVirtualMethods());
230 MarkObject(klass->GetIFields());
231 MarkObject(klass->GetSFields());
Carl Shapiro69759ea2011-07-21 18:13:35 -0700232 }
Brian Carlstrom693267a2011-09-06 09:25:34 -0700233 ScanStaticFields(klass);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700234}
235
236// Scans the header of all array objects. If the array object is
237// specialized to a reference type, scans the array data as well.
Brian Carlstrom4873d462011-08-21 15:23:39 -0700238void MarkSweep::ScanArray(const Object* obj) {
Carl Shapiro69759ea2011-07-21 18:13:35 -0700239 DCHECK(obj != NULL);
240 DCHECK(obj->GetClass() != NULL);
241 MarkObject(obj->GetClass());
242 if (obj->IsObjectArray()) {
Brian Carlstromdb4d5402011-08-09 12:18:28 -0700243 const ObjectArray<Object>* array = obj->AsObjectArray<Object>();
Elliott Hughesd8ddfd52011-08-15 14:32:53 -0700244 for (int32_t i = 0; i < array->GetLength(); ++i) {
Carl Shapiro69759ea2011-07-21 18:13:35 -0700245 const Object* element = array->Get(i);
246 MarkObject(element);
247 }
248 }
249}
250
Carl Shapiro69759ea2011-07-21 18:13:35 -0700251// Process the "referent" field in a java.lang.ref.Reference. If the
252// referent has not yet been marked, put it on the appropriate list in
253// the gcHeap for later processing.
254void MarkSweep::DelayReferenceReferent(Object* obj) {
255 DCHECK(obj != NULL);
Brian Carlstrom1f870082011-08-23 16:02:11 -0700256 Class* klass = obj->GetClass();
257 DCHECK(klass != NULL);
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700258 DCHECK(klass->IsReferenceClass());
259 Object* pending = obj->GetFieldObject<Object*>(Heap::GetReferencePendingNextOffset(), false);
Elliott Hughesadb460d2011-10-05 17:02:34 -0700260 Object* referent = Heap::GetReferenceReferent(obj);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700261 if (pending == NULL && referent != NULL && !IsMarked(referent)) {
Brian Carlstrom4873d462011-08-21 15:23:39 -0700262 Object** list = NULL;
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700263 if (klass->IsSoftReferenceClass()) {
Carl Shapiro69759ea2011-07-21 18:13:35 -0700264 list = &soft_reference_list_;
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700265 } else if (klass->IsWeakReferenceClass()) {
Carl Shapiro69759ea2011-07-21 18:13:35 -0700266 list = &weak_reference_list_;
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700267 } else if (klass->IsFinalizerReferenceClass()) {
Carl Shapiro69759ea2011-07-21 18:13:35 -0700268 list = &finalizer_reference_list_;
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700269 } else if (klass->IsPhantomReferenceClass()) {
Carl Shapiro69759ea2011-07-21 18:13:35 -0700270 list = &phantom_reference_list_;
271 }
272 DCHECK(list != NULL);
Elliott Hughesadb460d2011-10-05 17:02:34 -0700273 Heap::EnqueuePendingReference(obj, list);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700274 }
275}
276
277// Scans the header and field references of a data object. If the
278// scanned object is a reference subclass, it is scheduled for later
Elliott Hughesadb460d2011-10-05 17:02:34 -0700279// processing.
Carl Shapiro58551df2011-07-24 03:09:51 -0700280void MarkSweep::ScanOther(const Object* obj) {
Carl Shapiro69759ea2011-07-21 18:13:35 -0700281 DCHECK(obj != NULL);
Brian Carlstrom1f870082011-08-23 16:02:11 -0700282 Class* klass = obj->GetClass();
283 DCHECK(klass != NULL);
284 MarkObject(klass);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700285 ScanInstanceFields(obj);
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700286 if (klass->IsReferenceClass()) {
Carl Shapiro69759ea2011-07-21 18:13:35 -0700287 DelayReferenceReferent(const_cast<Object*>(obj));
288 }
289}
290
291// Scans an object reference. Determines the type of the reference
292// and dispatches to a specialized scanning routine.
293void MarkSweep::ScanObject(const Object* obj) {
294 DCHECK(obj != NULL);
295 DCHECK(obj->GetClass() != NULL);
296 DCHECK(IsMarked(obj));
297 if (obj->IsClass()) {
298 ScanClass(obj);
Brian Carlstromb63ec392011-08-27 17:38:27 -0700299 } else if (obj->IsArrayInstance()) {
Carl Shapiro69759ea2011-07-21 18:13:35 -0700300 ScanArray(obj);
301 } else {
Carl Shapiro58551df2011-07-24 03:09:51 -0700302 ScanOther(obj);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700303 }
304}
305
306// Scan anything that's on the mark stack. We can't use the bitmaps
307// anymore, so use a finger that points past the end of them.
308void MarkSweep::ProcessMarkStack() {
309 while (!mark_stack_->IsEmpty()) {
Brian Carlstrom4873d462011-08-21 15:23:39 -0700310 const Object* obj = mark_stack_->Pop();
Carl Shapiro69759ea2011-07-21 18:13:35 -0700311 ScanObject(obj);
312 }
313}
314
315void MarkSweep::ScanDirtyObjects() {
316 ProcessMarkStack();
317}
318
Carl Shapiro69759ea2011-07-21 18:13:35 -0700319// Walks the reference list marking any references subject to the
320// reference clearing policy. References with a black referent are
321// removed from the list. References with white referents biased
322// toward saving are blackened and also removed from the list.
323void MarkSweep::PreserveSomeSoftReferences(Object** list) {
324 DCHECK(list != NULL);
325 Object* clear = NULL;
326 size_t counter = 0;
327 while (*list != NULL) {
Elliott Hughesadb460d2011-10-05 17:02:34 -0700328 Object* ref = Heap::DequeuePendingReference(list);
329 Object* referent = Heap::GetReferenceReferent(ref);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700330 if (referent == NULL) {
331 // Referent was cleared by the user during marking.
332 continue;
333 }
334 bool is_marked = IsMarked(referent);
335 if (!is_marked && ((++counter) & 1)) {
336 // Referent is white and biased toward saving, mark it.
337 MarkObject(referent);
338 is_marked = true;
339 }
340 if (!is_marked) {
341 // Referent is white, queue it for clearing.
Elliott Hughesadb460d2011-10-05 17:02:34 -0700342 Heap::EnqueuePendingReference(ref, &clear);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700343 }
344 }
345 *list = clear;
346 // Restart the mark with the newly black references added to the
347 // root set.
348 ProcessMarkStack();
349}
350
351// Unlink the reference list clearing references objects with white
352// referents. Cleared references registered to a reference queue are
353// scheduled for appending by the heap worker thread.
354void MarkSweep::ClearWhiteReferences(Object** list) {
355 DCHECK(list != NULL);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700356 while (*list != NULL) {
Elliott Hughesadb460d2011-10-05 17:02:34 -0700357 Object* ref = Heap::DequeuePendingReference(list);
358 Object* referent = Heap::GetReferenceReferent(ref);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700359 if (referent != NULL && !IsMarked(referent)) {
360 // Referent is white, clear it.
Elliott Hughesadb460d2011-10-05 17:02:34 -0700361 Heap::ClearReferenceReferent(ref);
362 if (Heap::IsEnqueuable(ref)) {
363 Heap::EnqueueReference(ref, &cleared_reference_list_);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700364 }
365 }
366 }
367 DCHECK(*list == NULL);
368}
369
370// Enqueues finalizer references with white referents. White
371// referents are blackened, moved to the zombie field, and the
372// referent field is cleared.
373void MarkSweep::EnqueueFinalizerReferences(Object** list) {
374 DCHECK(list != NULL);
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700375 MemberOffset zombie_offset = Heap::GetFinalizerReferenceZombieOffset();
Carl Shapiro69759ea2011-07-21 18:13:35 -0700376 bool has_enqueued = false;
377 while (*list != NULL) {
Elliott Hughesadb460d2011-10-05 17:02:34 -0700378 Object* ref = Heap::DequeuePendingReference(list);
379 Object* referent = Heap::GetReferenceReferent(ref);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700380 if (referent != NULL && !IsMarked(referent)) {
381 MarkObject(referent);
382 // If the referent is non-null the reference must queuable.
Elliott Hughesadb460d2011-10-05 17:02:34 -0700383 DCHECK(Heap::IsEnqueuable(ref));
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700384 ref->SetFieldObject(zombie_offset, referent, false);
Elliott Hughesadb460d2011-10-05 17:02:34 -0700385 Heap::ClearReferenceReferent(ref);
386 Heap::EnqueueReference(ref, &cleared_reference_list_);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700387 has_enqueued = true;
388 }
389 }
390 if (has_enqueued) {
391 ProcessMarkStack();
392 }
393 DCHECK(*list == NULL);
394}
395
Carl Shapiro58551df2011-07-24 03:09:51 -0700396// Process reference class instances and schedule finalizations.
Carl Shapiro69759ea2011-07-21 18:13:35 -0700397void MarkSweep::ProcessReferences(Object** soft_references, bool clear_soft,
398 Object** weak_references,
399 Object** finalizer_references,
400 Object** phantom_references) {
401 DCHECK(soft_references != NULL);
402 DCHECK(weak_references != NULL);
403 DCHECK(finalizer_references != NULL);
404 DCHECK(phantom_references != NULL);
405
406 // Unless we are in the zygote or required to clear soft references
407 // with white references, preserve some white referents.
408 if (clear_soft) {
409 PreserveSomeSoftReferences(soft_references);
410 }
411
412 // Clear all remaining soft and weak references with white
413 // referents.
414 ClearWhiteReferences(soft_references);
415 ClearWhiteReferences(weak_references);
416
417 // Preserve all white objects with finalize methods and schedule
418 // them for finalization.
419 EnqueueFinalizerReferences(finalizer_references);
420
421 // Clear all f-reachable soft and weak references with white
422 // referents.
423 ClearWhiteReferences(soft_references);
424 ClearWhiteReferences(weak_references);
425
426 // Clear all phantom references with white referents.
427 ClearWhiteReferences(phantom_references);
428
429 // At this point all reference lists should be empty.
430 DCHECK(*soft_references == NULL);
431 DCHECK(*weak_references == NULL);
432 DCHECK(*finalizer_references == NULL);
433 DCHECK(*phantom_references == NULL);
434}
435
Carl Shapiro69759ea2011-07-21 18:13:35 -0700436MarkSweep::~MarkSweep() {
Carl Shapiro58551df2011-07-24 03:09:51 -0700437 delete mark_stack_;
Carl Shapiro69759ea2011-07-21 18:13:35 -0700438 mark_bitmap_->Clear();
439}
440
441} // namespace art