blob: 984779484ef151ca41ee4905dd6b2119e1e5e33f [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
Ian Rogers1d54e732013-05-02 21:10:01 -070019#include "gc/heap.h"
20#include "gc/space/space.h"
Mathieu Chartier2b82db42012-11-14 17:29:05 -080021#include "partial_mark_sweep.h"
Brian Carlstroma3d27182013-11-05 23:22:27 -080022#include "thread-inl.h"
Mathieu Chartier2b82db42012-11-14 17:29:05 -080023
24namespace art {
Ian Rogers1d54e732013-05-02 21:10:01 -070025namespace gc {
26namespace collector {
Mathieu Chartier2b82db42012-11-14 17:29:05 -080027
Ian Rogers1d54e732013-05-02 21:10:01 -070028PartialMarkSweep::PartialMarkSweep(Heap* heap, bool is_concurrent, const std::string& name_prefix)
Mathieu Chartier590fee92013-09-13 13:46:47 -070029 : MarkSweep(heap, is_concurrent, name_prefix.empty() ? "partial " : name_prefix) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080030 cumulative_timings_.SetName(GetName());
31}
Mathieu Chartier2b82db42012-11-14 17:29:05 -080032
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080033void PartialMarkSweep::BindBitmaps() {
34 MarkSweep::BindBitmaps();
35
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080036 WriterMutexLock mu(Thread::Current(), *Locks::heap_bitmap_lock_);
37 // For partial GCs we need to bind the bitmap of the zygote space so that all objects in the
38 // zygote space are viewed as marked.
Mathieu Chartier02e25112013-08-14 16:14:24 -070039 for (const auto& space : GetHeap()->GetContinuousSpaces()) {
Ian Rogers1d54e732013-05-02 21:10:01 -070040 if (space->GetGcRetentionPolicy() == space::kGcRetentionPolicyFullCollect) {
41 CHECK(space->IsZygoteSpace());
Mathieu Chartier763a31e2015-11-16 16:05:55 -080042 immune_spaces_.AddSpace(space);
Mathieu Chartier2b82db42012-11-14 17:29:05 -080043 }
44 }
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080045}
46
Ian Rogers1d54e732013-05-02 21:10:01 -070047} // namespace collector
48} // namespace gc
Mathieu Chartier2b82db42012-11-14 17:29:05 -080049} // namespace art