Mathieu Chartier | 2b82db4 | 2012-11-14 17:29:05 -0800 | [diff] [blame] | 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 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 17 | #include "partial_mark_sweep.h" |
| 18 | |
| 19 | #include "heap.h" |
Mathieu Chartier | 2b82db4 | 2012-11-14 17:29:05 -0800 | [diff] [blame] | 20 | #include "large_object_space.h" |
| 21 | #include "partial_mark_sweep.h" |
| 22 | #include "space.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 23 | #include "thread.h" |
Mathieu Chartier | 2b82db4 | 2012-11-14 17:29:05 -0800 | [diff] [blame] | 24 | |
| 25 | namespace art { |
Mathieu Chartier | 2b82db4 | 2012-11-14 17:29:05 -0800 | [diff] [blame] | 26 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 27 | PartialMarkSweep::PartialMarkSweep(Heap* heap, bool is_concurrent) |
| 28 | : MarkSweep(heap, is_concurrent) { |
| 29 | cumulative_timings_.SetName(GetName()); |
| 30 | } |
Mathieu Chartier | 2b82db4 | 2012-11-14 17:29:05 -0800 | [diff] [blame] | 31 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 32 | PartialMarkSweep::~PartialMarkSweep() { |
Mathieu Chartier | 2b82db4 | 2012-11-14 17:29:05 -0800 | [diff] [blame] | 33 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 34 | } |
Mathieu Chartier | 2b82db4 | 2012-11-14 17:29:05 -0800 | [diff] [blame] | 35 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 36 | void 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 Chartier | 2b82db4 | 2012-11-14 17:29:05 -0800 | [diff] [blame] | 47 | } |
| 48 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 49 | } |
| 50 | |
Mathieu Chartier | 2b82db4 | 2012-11-14 17:29:05 -0800 | [diff] [blame] | 51 | } // namespace art |