blob: f9c17870454a3bae9a4a8b186023a3a60659337d [file] [log] [blame]
Mathieu Chartier2b82db42012-11-14 17:29:05 -08001/*
2 * Copyright (C) 2012 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
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080017#include "partial_mark_sweep.h"
18
19#include "heap.h"
Mathieu Chartier2b82db42012-11-14 17:29:05 -080020#include "large_object_space.h"
21#include "partial_mark_sweep.h"
22#include "space.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080023#include "thread.h"
Mathieu Chartier2b82db42012-11-14 17:29:05 -080024
25namespace art {
Mathieu Chartier2b82db42012-11-14 17:29:05 -080026
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080027PartialMarkSweep::PartialMarkSweep(Heap* heap, bool is_concurrent)
28 : MarkSweep(heap, is_concurrent) {
29 cumulative_timings_.SetName(GetName());
30}
Mathieu Chartier2b82db42012-11-14 17:29:05 -080031
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080032PartialMarkSweep::~PartialMarkSweep() {
Mathieu Chartier2b82db42012-11-14 17:29:05 -080033
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080034}
Mathieu Chartier2b82db42012-11-14 17:29:05 -080035
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080036void PartialMarkSweep::BindBitmaps() {
37 MarkSweep::BindBitmaps();
38
39 Spaces& spaces = GetHeap()->GetSpaces();
40 WriterMutexLock mu(Thread::Current(), *Locks::heap_bitmap_lock_);
41 // For partial GCs we need to bind the bitmap of the zygote space so that all objects in the
42 // zygote space are viewed as marked.
43 for (Spaces::iterator it = spaces.begin(); it != spaces.end(); ++it) {
44 ContinuousSpace* space = *it;
45 if (space->GetGcRetentionPolicy() == kGcRetentionPolicyFullCollect) {
46 ImmuneSpace(space);
Mathieu Chartier2b82db42012-11-14 17:29:05 -080047 }
48 }
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080049}
50
Mathieu Chartier2b82db42012-11-14 17:29:05 -080051} // namespace art