• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "heap_bitmap.h"
18 
19 #include "gc/accounting/space_bitmap-inl.h"
20 #include "gc/space/space.h"
21 
22 namespace art {
23 namespace gc {
24 namespace accounting {
25 
AddContinuousSpaceBitmap(accounting::ContinuousSpaceBitmap * bitmap)26 void HeapBitmap::AddContinuousSpaceBitmap(accounting::ContinuousSpaceBitmap* bitmap) {
27   DCHECK(bitmap != nullptr);
28   // Check that there is no bitmap overlap.
29   for (const auto& cur_bitmap : continuous_space_bitmaps_) {
30     CHECK(bitmap->HeapBegin() >= cur_bitmap->HeapLimit() ||
31           bitmap->HeapLimit() <= cur_bitmap->HeapBegin())
32               << "Bitmap " << bitmap->Dump() << " overlaps with existing bitmap "
33               << cur_bitmap->Dump();
34   }
35   continuous_space_bitmaps_.push_back(bitmap);
36 }
37 
RemoveContinuousSpaceBitmap(accounting::ContinuousSpaceBitmap * bitmap)38 void HeapBitmap::RemoveContinuousSpaceBitmap(accounting::ContinuousSpaceBitmap* bitmap) {
39   DCHECK(bitmap != nullptr);
40   auto it = std::find(continuous_space_bitmaps_.begin(), continuous_space_bitmaps_.end(), bitmap);
41   DCHECK(it != continuous_space_bitmaps_.end());
42   continuous_space_bitmaps_.erase(it);
43 }
44 
AddLargeObjectBitmap(LargeObjectBitmap * bitmap)45 void HeapBitmap::AddLargeObjectBitmap(LargeObjectBitmap* bitmap) {
46   DCHECK(bitmap != nullptr);
47   large_object_bitmaps_.push_back(bitmap);
48 }
49 
RemoveLargeObjectBitmap(LargeObjectBitmap * bitmap)50 void HeapBitmap::RemoveLargeObjectBitmap(LargeObjectBitmap* bitmap) {
51   DCHECK(bitmap != nullptr);
52   auto it = std::find(large_object_bitmaps_.begin(), large_object_bitmaps_.end(), bitmap);
53   DCHECK(it != large_object_bitmaps_.end());
54   large_object_bitmaps_.erase(it);
55 }
56 
57 }  // namespace accounting
58 }  // namespace gc
59 }  // namespace art
60