blob: 9cab8c2064f4729efff11c92dd8bfe6fefb9cefd [file] [log] [blame]
Elliott Hughes5e71b522011-10-20 13:12:32 -07001#include "heap_bitmap.h"
Mathieu Chartiercc236d72012-07-20 10:29:05 -07002#include "space.h"
Carl Shapiro69759ea2011-07-21 18:13:35 -07003
Mathieu Chartier654d3a22012-07-11 17:54:18 -07004namespace art {
5
6void HeapBitmap::ReplaceBitmap(SpaceBitmap* old_bitmap, SpaceBitmap* new_bitmap) {
7 // TODO: C++0x auto
Mathieu Chartiercc236d72012-07-20 10:29:05 -07008 for (Bitmaps::iterator it = bitmaps_.begin(); it != bitmaps_.end(); ++it) {
9 if (*it == old_bitmap) {
10 *it = new_bitmap;
Mathieu Chartier654d3a22012-07-11 17:54:18 -070011 return;
12 }
13 }
14 LOG(FATAL) << "bitmap " << static_cast<const void*>(old_bitmap) << " not found";
15}
16
Mathieu Chartiercc236d72012-07-20 10:29:05 -070017void HeapBitmap::AddSpaceBitmap(SpaceBitmap* bitmap) {
18 DCHECK(bitmap != NULL);
19
20 // Check for interval overlap.
21 for (Bitmaps::const_iterator it = bitmaps_.begin(); it != bitmaps_.end(); ++it) {
22 SpaceBitmap* cur_bitmap = *it;
Mathieu Chartier357e9be2012-08-01 11:00:14 -070023 if (bitmap->HeapBegin() < cur_bitmap->HeapLimit() &&
24 bitmap->HeapLimit() > cur_bitmap->HeapBegin()) {
Mathieu Chartiercc236d72012-07-20 10:29:05 -070025 LOG(FATAL) << "Overlapping space bitmaps added to heap bitmap!";
26 }
27 }
28 bitmaps_.push_back(bitmap);
29}
30
Mathieu Chartier654d3a22012-07-11 17:54:18 -070031} // namespace art