1 /*
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 
17 #include "partial_mark_sweep.h"
18 
19 #include "gc/heap.h"
20 #include "gc/space/space.h"
21 #include "partial_mark_sweep.h"
22 #include "thread-current-inl.h"
23 
24 namespace art {
25 namespace gc {
26 namespace collector {
27 
PartialMarkSweep(Heap * heap,bool is_concurrent,const std::string & name_prefix)28 PartialMarkSweep::PartialMarkSweep(Heap* heap, bool is_concurrent, const std::string& name_prefix)
29     : MarkSweep(heap, is_concurrent, name_prefix.empty() ? "partial " : name_prefix) {
30   cumulative_timings_.SetName(GetName());
31 }
32 
BindBitmaps()33 void PartialMarkSweep::BindBitmaps() {
34   MarkSweep::BindBitmaps();
35 
36   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.
39   for (const auto& space : GetHeap()->GetContinuousSpaces()) {
40     if (space->GetGcRetentionPolicy() == space::kGcRetentionPolicyFullCollect) {
41       CHECK(space->IsZygoteSpace());
42       immune_spaces_.AddSpace(space);
43     }
44   }
45 }
46 
47 }  // namespace collector
48 }  // namespace gc
49 }  // namespace art
50