summaryrefslogtreecommitdiffstats
path: root/runtime/gc/accounting
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/gc/accounting')
-rw-r--r--runtime/gc/accounting/atomic_stack.h2
-rw-r--r--runtime/gc/accounting/card_table-inl.h60
-rw-r--r--runtime/gc/accounting/card_table.cc20
-rw-r--r--runtime/gc/accounting/card_table.h38
-rw-r--r--runtime/gc/accounting/card_table_test.cc40
-rw-r--r--runtime/gc/accounting/mod_union_table.cc18
-rw-r--r--runtime/gc/accounting/mod_union_table.h6
-rw-r--r--runtime/gc/accounting/remembered_set.cc12
-rw-r--r--runtime/gc/accounting/remembered_set.h4
-rw-r--r--runtime/gc/accounting/space_bitmap-inl.h36
-rw-r--r--runtime/gc/accounting/space_bitmap.cc48
-rw-r--r--runtime/gc/accounting/space_bitmap.h22
-rw-r--r--runtime/gc/accounting/space_bitmap_test.cc18
13 files changed, 162 insertions, 162 deletions
diff --git a/runtime/gc/accounting/atomic_stack.h b/runtime/gc/accounting/atomic_stack.h
index 2c72ba1..929a1d2 100644
--- a/runtime/gc/accounting/atomic_stack.h
+++ b/runtime/gc/accounting/atomic_stack.h
@@ -213,7 +213,7 @@ class AtomicStack {
mem_map_.reset(MemMap::MapAnonymous(name_.c_str(), NULL, capacity_ * sizeof(T),
PROT_READ | PROT_WRITE, false, &error_msg));
CHECK(mem_map_.get() != NULL) << "couldn't allocate mark stack.\n" << error_msg;
- byte* addr = mem_map_->Begin();
+ uint8_t* addr = mem_map_->Begin();
CHECK(addr != NULL);
debug_is_sorted_ = true;
begin_ = reinterpret_cast<T*>(addr);
diff --git a/runtime/gc/accounting/card_table-inl.h b/runtime/gc/accounting/card_table-inl.h
index 3b06f74..15562e5 100644
--- a/runtime/gc/accounting/card_table-inl.h
+++ b/runtime/gc/accounting/card_table-inl.h
@@ -27,9 +27,9 @@ namespace art {
namespace gc {
namespace accounting {
-static inline bool byte_cas(byte old_value, byte new_value, byte* address) {
+static inline bool byte_cas(uint8_t old_value, uint8_t new_value, uint8_t* address) {
#if defined(__i386__) || defined(__x86_64__)
- Atomic<byte>* byte_atomic = reinterpret_cast<Atomic<byte>*>(address);
+ Atomic<uint8_t>* byte_atomic = reinterpret_cast<Atomic<uint8_t>*>(address);
return byte_atomic->CompareExchangeWeakRelaxed(old_value, new_value);
#else
// Little endian means most significant byte is on the left.
@@ -49,19 +49,19 @@ static inline bool byte_cas(byte old_value, byte new_value, byte* address) {
}
template <typename Visitor>
-inline size_t CardTable::Scan(ContinuousSpaceBitmap* bitmap, byte* scan_begin, byte* scan_end,
- const Visitor& visitor, const byte minimum_age) const {
- DCHECK_GE(scan_begin, reinterpret_cast<byte*>(bitmap->HeapBegin()));
+inline size_t CardTable::Scan(ContinuousSpaceBitmap* bitmap, uint8_t* scan_begin, uint8_t* scan_end,
+ const Visitor& visitor, const uint8_t minimum_age) const {
+ DCHECK_GE(scan_begin, reinterpret_cast<uint8_t*>(bitmap->HeapBegin()));
// scan_end is the byte after the last byte we scan.
- DCHECK_LE(scan_end, reinterpret_cast<byte*>(bitmap->HeapLimit()));
- byte* card_cur = CardFromAddr(scan_begin);
- byte* card_end = CardFromAddr(AlignUp(scan_end, kCardSize));
+ DCHECK_LE(scan_end, reinterpret_cast<uint8_t*>(bitmap->HeapLimit()));
+ uint8_t* card_cur = CardFromAddr(scan_begin);
+ uint8_t* card_end = CardFromAddr(AlignUp(scan_end, kCardSize));
CheckCardValid(card_cur);
CheckCardValid(card_end);
size_t cards_scanned = 0;
// Handle any unaligned cards at the start.
- while (!IsAligned<sizeof(word)>(card_cur) && card_cur < card_end) {
+ while (!IsAligned<sizeof(intptr_t)>(card_cur) && card_cur < card_end) {
if (*card_cur >= minimum_age) {
uintptr_t start = reinterpret_cast<uintptr_t>(AddrFromCard(card_cur));
bitmap->VisitMarkedRange(start, start + kCardSize, visitor);
@@ -70,7 +70,7 @@ inline size_t CardTable::Scan(ContinuousSpaceBitmap* bitmap, byte* scan_begin, b
++card_cur;
}
- byte* aligned_end = card_end -
+ uint8_t* aligned_end = card_end -
(reinterpret_cast<uintptr_t>(card_end) & (sizeof(uintptr_t) - 1));
uintptr_t* word_end = reinterpret_cast<uintptr_t*>(aligned_end);
@@ -85,14 +85,14 @@ inline size_t CardTable::Scan(ContinuousSpaceBitmap* bitmap, byte* scan_begin, b
// Find the first dirty card.
uintptr_t start_word = *word_cur;
- uintptr_t start = reinterpret_cast<uintptr_t>(AddrFromCard(reinterpret_cast<byte*>(word_cur)));
+ uintptr_t start = reinterpret_cast<uintptr_t>(AddrFromCard(reinterpret_cast<uint8_t*>(word_cur)));
// TODO: Investigate if processing continuous runs of dirty cards with a single bitmap visit is
// more efficient.
for (size_t i = 0; i < sizeof(uintptr_t); ++i) {
- if (static_cast<byte>(start_word) >= minimum_age) {
- auto* card = reinterpret_cast<byte*>(word_cur) + i;
- DCHECK(*card == static_cast<byte>(start_word) || *card == kCardDirty)
- << "card " << static_cast<size_t>(*card) << " word " << (start_word & 0xFF);
+ if (static_cast<uint8_t>(start_word) >= minimum_age) {
+ auto* card = reinterpret_cast<uint8_t*>(word_cur) + i;
+ DCHECK(*card == static_cast<uint8_t>(start_word) || *card == kCardDirty)
+ << "card " << static_cast<size_t>(*card) << " intptr_t " << (start_word & 0xFF);
bitmap->VisitMarkedRange(start, start + kCardSize, visitor);
++cards_scanned;
}
@@ -103,7 +103,7 @@ inline size_t CardTable::Scan(ContinuousSpaceBitmap* bitmap, byte* scan_begin, b
exit_for:
// Handle any unaligned cards at the end.
- card_cur = reinterpret_cast<byte*>(word_end);
+ card_cur = reinterpret_cast<uint8_t*>(word_end);
while (card_cur < card_end) {
if (*card_cur >= minimum_age) {
uintptr_t start = reinterpret_cast<uintptr_t>(AddrFromCard(card_cur));
@@ -125,16 +125,16 @@ inline size_t CardTable::Scan(ContinuousSpaceBitmap* bitmap, byte* scan_begin, b
* us to know which cards got cleared.
*/
template <typename Visitor, typename ModifiedVisitor>
-inline void CardTable::ModifyCardsAtomic(byte* scan_begin, byte* scan_end, const Visitor& visitor,
+inline void CardTable::ModifyCardsAtomic(uint8_t* scan_begin, uint8_t* scan_end, const Visitor& visitor,
const ModifiedVisitor& modified) {
- byte* card_cur = CardFromAddr(scan_begin);
- byte* card_end = CardFromAddr(AlignUp(scan_end, kCardSize));
+ uint8_t* card_cur = CardFromAddr(scan_begin);
+ uint8_t* card_end = CardFromAddr(AlignUp(scan_end, kCardSize));
CheckCardValid(card_cur);
CheckCardValid(card_end);
// Handle any unaligned cards at the start.
- while (!IsAligned<sizeof(word)>(card_cur) && card_cur < card_end) {
- byte expected, new_value;
+ while (!IsAligned<sizeof(intptr_t)>(card_cur) && card_cur < card_end) {
+ uint8_t expected, new_value;
do {
expected = *card_cur;
new_value = visitor(expected);
@@ -146,9 +146,9 @@ inline void CardTable::ModifyCardsAtomic(byte* scan_begin, byte* scan_end, const
}
// Handle unaligned cards at the end.
- while (!IsAligned<sizeof(word)>(card_end) && card_end > card_cur) {
+ while (!IsAligned<sizeof(intptr_t)>(card_end) && card_end > card_cur) {
--card_end;
- byte expected, new_value;
+ uint8_t expected, new_value;
do {
expected = *card_end;
new_value = visitor(expected);
@@ -184,10 +184,10 @@ inline void CardTable::ModifyCardsAtomic(byte* scan_begin, byte* scan_end, const
Atomic<uintptr_t>* atomic_word = reinterpret_cast<Atomic<uintptr_t>*>(word_cur);
if (LIKELY(atomic_word->CompareExchangeWeakRelaxed(expected_word, new_word))) {
for (size_t i = 0; i < sizeof(uintptr_t); ++i) {
- const byte expected_byte = expected_bytes[i];
- const byte new_byte = new_bytes[i];
+ const uint8_t expected_byte = expected_bytes[i];
+ const uint8_t new_byte = new_bytes[i];
if (expected_byte != new_byte) {
- modified(reinterpret_cast<byte*>(word_cur) + i, expected_byte, new_byte);
+ modified(reinterpret_cast<uint8_t*>(word_cur) + i, expected_byte, new_byte);
}
}
break;
@@ -197,7 +197,7 @@ inline void CardTable::ModifyCardsAtomic(byte* scan_begin, byte* scan_end, const
}
}
-inline void* CardTable::AddrFromCard(const byte *card_addr) const {
+inline void* CardTable::AddrFromCard(const uint8_t *card_addr) const {
DCHECK(IsValidCard(card_addr))
<< " card_addr: " << reinterpret_cast<const void*>(card_addr)
<< " begin: " << reinterpret_cast<void*>(mem_map_->Begin() + offset_)
@@ -206,15 +206,15 @@ inline void* CardTable::AddrFromCard(const byte *card_addr) const {
return reinterpret_cast<void*>(offset << kCardShift);
}
-inline byte* CardTable::CardFromAddr(const void *addr) const {
- byte *card_addr = biased_begin_ + (reinterpret_cast<uintptr_t>(addr) >> kCardShift);
+inline uint8_t* CardTable::CardFromAddr(const void *addr) const {
+ uint8_t *card_addr = biased_begin_ + (reinterpret_cast<uintptr_t>(addr) >> kCardShift);
// Sanity check the caller was asking for address covered by the card table
DCHECK(IsValidCard(card_addr)) << "addr: " << addr
<< " card_addr: " << reinterpret_cast<void*>(card_addr);
return card_addr;
}
-inline void CardTable::CheckCardValid(byte* card) const {
+inline void CardTable::CheckCardValid(uint8_t* card) const {
DCHECK(IsValidCard(card))
<< " card_addr: " << reinterpret_cast<const void*>(card)
<< " begin: " << reinterpret_cast<void*>(mem_map_->Begin() + offset_)
diff --git a/runtime/gc/accounting/card_table.cc b/runtime/gc/accounting/card_table.cc
index 0498550..9a6f2b2 100644
--- a/runtime/gc/accounting/card_table.cc
+++ b/runtime/gc/accounting/card_table.cc
@@ -55,7 +55,7 @@ constexpr uint8_t CardTable::kCardDirty;
* byte is equal to GC_DIRTY_CARD. See CardTable::Create for details.
*/
-CardTable* CardTable::Create(const byte* heap_begin, size_t heap_capacity) {
+CardTable* CardTable::Create(const uint8_t* heap_begin, size_t heap_capacity) {
/* Set up the card table */
size_t capacity = heap_capacity / kCardSize;
/* Allocate an extra 256 bytes to allow fixed low-byte of base */
@@ -68,13 +68,13 @@ CardTable* CardTable::Create(const byte* heap_begin, size_t heap_capacity) {
// don't clear the card table to avoid unnecessary pages being allocated
COMPILE_ASSERT(kCardClean == 0, card_clean_must_be_0);
- byte* cardtable_begin = mem_map->Begin();
+ uint8_t* cardtable_begin = mem_map->Begin();
CHECK(cardtable_begin != NULL);
// We allocated up to a bytes worth of extra space to allow biased_begin's byte value to equal
// kCardDirty, compute a offset value to make this the case
size_t offset = 0;
- byte* biased_begin = reinterpret_cast<byte*>(reinterpret_cast<uintptr_t>(cardtable_begin) -
+ uint8_t* biased_begin = reinterpret_cast<uint8_t*>(reinterpret_cast<uintptr_t>(cardtable_begin) -
(reinterpret_cast<uintptr_t>(heap_begin) >> kCardShift));
uintptr_t biased_byte = reinterpret_cast<uintptr_t>(biased_begin) & 0xff;
if (biased_byte != kCardDirty) {
@@ -86,14 +86,14 @@ CardTable* CardTable::Create(const byte* heap_begin, size_t heap_capacity) {
return new CardTable(mem_map.release(), biased_begin, offset);
}
-CardTable::CardTable(MemMap* mem_map, byte* biased_begin, size_t offset)
+CardTable::CardTable(MemMap* mem_map, uint8_t* biased_begin, size_t offset)
: mem_map_(mem_map), biased_begin_(biased_begin), offset_(offset) {
}
void CardTable::ClearSpaceCards(space::ContinuousSpace* space) {
// TODO: clear just the range of the table that has been modified
- byte* card_start = CardFromAddr(space->Begin());
- byte* card_end = CardFromAddr(space->End()); // Make sure to round up.
+ uint8_t* card_start = CardFromAddr(space->Begin());
+ uint8_t* card_end = CardFromAddr(space->End()); // Make sure to round up.
memset(reinterpret_cast<void*>(card_start), kCardClean, card_end - card_start);
}
@@ -106,10 +106,10 @@ bool CardTable::AddrIsInCardTable(const void* addr) const {
return IsValidCard(biased_begin_ + ((uintptr_t)addr >> kCardShift));
}
-void CardTable::CheckAddrIsInCardTable(const byte* addr) const {
- byte* card_addr = biased_begin_ + ((uintptr_t)addr >> kCardShift);
- byte* begin = mem_map_->Begin() + offset_;
- byte* end = mem_map_->End();
+void CardTable::CheckAddrIsInCardTable(const uint8_t* addr) const {
+ uint8_t* card_addr = biased_begin_ + ((uintptr_t)addr >> kCardShift);
+ uint8_t* begin = mem_map_->Begin() + offset_;
+ uint8_t* end = mem_map_->End();
CHECK(AddrIsInCardTable(addr))
<< "Card table " << this
<< " begin: " << reinterpret_cast<void*>(begin)
diff --git a/runtime/gc/accounting/card_table.h b/runtime/gc/accounting/card_table.h
index fbeea85..e1343c8 100644
--- a/runtime/gc/accounting/card_table.h
+++ b/runtime/gc/accounting/card_table.h
@@ -51,11 +51,11 @@ class CardTable {
static constexpr uint8_t kCardClean = 0x0;
static constexpr uint8_t kCardDirty = 0x70;
- static CardTable* Create(const byte* heap_begin, size_t heap_capacity);
+ static CardTable* Create(const uint8_t* heap_begin, size_t heap_capacity);
// Set the card associated with the given address to GC_CARD_DIRTY.
void MarkCard(const void *addr) {
- byte* card_addr = CardFromAddr(addr);
+ uint8_t* card_addr = CardFromAddr(addr);
*card_addr = kCardDirty;
}
@@ -65,16 +65,16 @@ class CardTable {
}
// Return the state of the card at an address.
- byte GetCard(const mirror::Object* obj) const {
+ uint8_t GetCard(const mirror::Object* obj) const {
return *CardFromAddr(obj);
}
// Visit and clear cards within memory range, only visits dirty cards.
template <typename Visitor>
void VisitClear(const void* start, const void* end, const Visitor& visitor) {
- byte* card_start = CardFromAddr(start);
- byte* card_end = CardFromAddr(end);
- for (byte* it = card_start; it != card_end; ++it) {
+ uint8_t* card_start = CardFromAddr(start);
+ uint8_t* card_end = CardFromAddr(end);
+ for (uint8_t* it = card_start; it != card_end; ++it) {
if (*it == kCardDirty) {
*it = kCardClean;
visitor(it);
@@ -84,7 +84,7 @@ class CardTable {
// Returns a value that when added to a heap address >> GC_CARD_SHIFT will address the appropriate
// card table byte. For convenience this value is cached in every Thread
- byte* GetBiasedBegin() const {
+ uint8_t* GetBiasedBegin() const {
return biased_begin_;
}
@@ -97,20 +97,20 @@ class CardTable {
* us to know which cards got cleared.
*/
template <typename Visitor, typename ModifiedVisitor>
- void ModifyCardsAtomic(byte* scan_begin, byte* scan_end, const Visitor& visitor,
+ void ModifyCardsAtomic(uint8_t* scan_begin, uint8_t* scan_end, const Visitor& visitor,
const ModifiedVisitor& modified);
// For every dirty at least minumum age between begin and end invoke the visitor with the
// specified argument. Returns how many cards the visitor was run on.
template <typename Visitor>
- size_t Scan(SpaceBitmap<kObjectAlignment>* bitmap, byte* scan_begin, byte* scan_end,
+ size_t Scan(SpaceBitmap<kObjectAlignment>* bitmap, uint8_t* scan_begin, uint8_t* scan_end,
const Visitor& visitor,
- const byte minimum_age = kCardDirty) const
+ const uint8_t minimum_age = kCardDirty) const
EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Assertion used to check the given address is covered by the card table
- void CheckAddrIsInCardTable(const byte* addr) const;
+ void CheckAddrIsInCardTable(const uint8_t* addr) const;
// Resets all of the bytes in the card table to clean.
void ClearCardTable();
@@ -119,24 +119,24 @@ class CardTable {
void ClearSpaceCards(space::ContinuousSpace* space);
// Returns the first address in the heap which maps to this card.
- void* AddrFromCard(const byte *card_addr) const ALWAYS_INLINE;
+ void* AddrFromCard(const uint8_t *card_addr) const ALWAYS_INLINE;
// Returns the address of the relevant byte in the card table, given an address on the heap.
- byte* CardFromAddr(const void *addr) const ALWAYS_INLINE;
+ uint8_t* CardFromAddr(const void *addr) const ALWAYS_INLINE;
bool AddrIsInCardTable(const void* addr) const;
private:
- CardTable(MemMap* begin, byte* biased_begin, size_t offset);
+ CardTable(MemMap* begin, uint8_t* biased_begin, size_t offset);
// Returns true iff the card table address is within the bounds of the card table.
- bool IsValidCard(const byte* card_addr) const {
- byte* begin = mem_map_->Begin() + offset_;
- byte* end = mem_map_->End();
+ bool IsValidCard(const uint8_t* card_addr) const {
+ uint8_t* begin = mem_map_->Begin() + offset_;
+ uint8_t* end = mem_map_->End();
return card_addr >= begin && card_addr < end;
}
- void CheckCardValid(byte* card) const ALWAYS_INLINE;
+ void CheckCardValid(uint8_t* card) const ALWAYS_INLINE;
// Verifies that all gray objects are on a dirty card.
void VerifyCardTable();
@@ -144,7 +144,7 @@ class CardTable {
// Mmapped pages for the card table
std::unique_ptr<MemMap> mem_map_;
// Value used to compute card table addresses from object addresses, see GetBiasedBegin
- byte* const biased_begin_;
+ uint8_t* const biased_begin_;
// Card table doesn't begin at the beginning of the mem_map_, instead it is displaced by offset
// to allow the byte value of biased_begin_ to equal GC_CARD_DIRTY
const size_t offset_;
diff --git a/runtime/gc/accounting/card_table_test.cc b/runtime/gc/accounting/card_table_test.cc
index 433855a..819cb85 100644
--- a/runtime/gc/accounting/card_table_test.cc
+++ b/runtime/gc/accounting/card_table_test.cc
@@ -49,45 +49,45 @@ class CardTableTest : public CommonRuntimeTest {
}
}
// Default values for the test, not random to avoid undeterministic behaviour.
- CardTableTest() : heap_begin_(reinterpret_cast<byte*>(0x2000000)), heap_size_(2 * MB) {
+ CardTableTest() : heap_begin_(reinterpret_cast<uint8_t*>(0x2000000)), heap_size_(2 * MB) {
}
void ClearCardTable() {
card_table_->ClearCardTable();
}
- byte* HeapBegin() const {
+ uint8_t* HeapBegin() const {
return heap_begin_;
}
- byte* HeapLimit() const {
+ uint8_t* HeapLimit() const {
return HeapBegin() + heap_size_;
}
// Return a pseudo random card for an address.
- byte PseudoRandomCard(const byte* addr) const {
+ uint8_t PseudoRandomCard(const uint8_t* addr) const {
size_t offset = RoundDown(addr - heap_begin_, CardTable::kCardSize);
return 1 + offset % 254;
}
void FillRandom() {
- for (const byte* addr = HeapBegin(); addr != HeapLimit(); addr += CardTable::kCardSize) {
+ for (const uint8_t* addr = HeapBegin(); addr != HeapLimit(); addr += CardTable::kCardSize) {
EXPECT_TRUE(card_table_->AddrIsInCardTable(addr));
- byte* card = card_table_->CardFromAddr(addr);
+ uint8_t* card = card_table_->CardFromAddr(addr);
*card = PseudoRandomCard(addr);
}
}
private:
- byte* const heap_begin_;
+ uint8_t* const heap_begin_;
const size_t heap_size_;
};
TEST_F(CardTableTest, TestMarkCard) {
CommonSetup();
- for (const byte* addr = HeapBegin(); addr < HeapLimit(); addr += kObjectAlignment) {
+ for (const uint8_t* addr = HeapBegin(); addr < HeapLimit(); addr += kObjectAlignment) {
auto obj = reinterpret_cast<const mirror::Object*>(addr);
EXPECT_EQ(card_table_->GetCard(obj), CardTable::kCardClean);
EXPECT_TRUE(!card_table_->IsDirty(obj));
card_table_->MarkCard(addr);
EXPECT_TRUE(card_table_->IsDirty(obj));
EXPECT_EQ(card_table_->GetCard(obj), CardTable::kCardDirty);
- byte* card_addr = card_table_->CardFromAddr(addr);
+ uint8_t* card_addr = card_table_->CardFromAddr(addr);
EXPECT_EQ(*card_addr, CardTable::kCardDirty);
*card_addr = CardTable::kCardClean;
EXPECT_EQ(*card_addr, CardTable::kCardClean);
@@ -96,10 +96,10 @@ TEST_F(CardTableTest, TestMarkCard) {
class UpdateVisitor {
public:
- byte operator()(byte c) const {
+ uint8_t operator()(uint8_t c) const {
return c * 93 + 123;
}
- void operator()(byte* /*card*/, byte /*expected_value*/, byte /*new_value*/) const {
+ void operator()(uint8_t* /*card*/, uint8_t /*expected_value*/, uint8_t /*new_value*/) const {
}
};
@@ -110,32 +110,32 @@ TEST_F(CardTableTest, TestModifyCardsAtomic) {
8U * CardTable::kCardSize);
UpdateVisitor visitor;
size_t start_offset = 0;
- for (byte* cstart = HeapBegin(); cstart < HeapBegin() + delta; cstart += CardTable::kCardSize) {
+ for (uint8_t* cstart = HeapBegin(); cstart < HeapBegin() + delta; cstart += CardTable::kCardSize) {
start_offset = (start_offset + kObjectAlignment) % CardTable::kCardSize;
size_t end_offset = 0;
- for (byte* cend = HeapLimit() - delta; cend < HeapLimit(); cend += CardTable::kCardSize) {
+ for (uint8_t* cend = HeapLimit() - delta; cend < HeapLimit(); cend += CardTable::kCardSize) {
// Don't always start at a card boundary.
- byte* start = cstart + start_offset;
- byte* end = cend - end_offset;
+ uint8_t* start = cstart + start_offset;
+ uint8_t* end = cend - end_offset;
end_offset = (end_offset + kObjectAlignment) % CardTable::kCardSize;
// Modify cards.
card_table_->ModifyCardsAtomic(start, end, visitor, visitor);
// Check adjacent cards not modified.
- for (byte* cur = start - CardTable::kCardSize; cur >= HeapBegin();
+ for (uint8_t* cur = start - CardTable::kCardSize; cur >= HeapBegin();
cur -= CardTable::kCardSize) {
EXPECT_EQ(card_table_->GetCard(reinterpret_cast<mirror::Object*>(cur)),
PseudoRandomCard(cur));
}
- for (byte* cur = end + CardTable::kCardSize; cur < HeapLimit();
+ for (uint8_t* cur = end + CardTable::kCardSize; cur < HeapLimit();
cur += CardTable::kCardSize) {
EXPECT_EQ(card_table_->GetCard(reinterpret_cast<mirror::Object*>(cur)),
PseudoRandomCard(cur));
}
// Verify Range.
- for (byte* cur = start; cur < AlignUp(end, CardTable::kCardSize);
+ for (uint8_t* cur = start; cur < AlignUp(end, CardTable::kCardSize);
cur += CardTable::kCardSize) {
- byte* card = card_table_->CardFromAddr(cur);
- byte value = PseudoRandomCard(cur);
+ uint8_t* card = card_table_->CardFromAddr(cur);
+ uint8_t value = PseudoRandomCard(cur);
EXPECT_EQ(visitor(value), *card);
// Restore for next iteration.
*card = value;
diff --git a/runtime/gc/accounting/mod_union_table.cc b/runtime/gc/accounting/mod_union_table.cc
index 3acf80d..753b42d 100644
--- a/runtime/gc/accounting/mod_union_table.cc
+++ b/runtime/gc/accounting/mod_union_table.cc
@@ -45,7 +45,7 @@ class ModUnionClearCardSetVisitor {
: cleared_cards_(cleared_cards) {
}
- inline void operator()(byte* card, byte expected_value, byte new_value) const {
+ inline void operator()(uint8_t* card, uint8_t expected_value, uint8_t new_value) const {
if (expected_value == CardTable::kCardDirty) {
cleared_cards_->insert(card);
}
@@ -57,17 +57,17 @@ class ModUnionClearCardSetVisitor {
class ModUnionClearCardVisitor {
public:
- explicit ModUnionClearCardVisitor(std::vector<byte*>* cleared_cards)
+ explicit ModUnionClearCardVisitor(std::vector<uint8_t*>* cleared_cards)
: cleared_cards_(cleared_cards) {
}
- void operator()(byte* card, byte expected_card, byte new_card) const {
+ void operator()(uint8_t* card, uint8_t expected_card, uint8_t new_card) const {
if (expected_card == CardTable::kCardDirty) {
cleared_cards_->push_back(card);
}
}
private:
- std::vector<byte*>* const cleared_cards_;
+ std::vector<uint8_t*>* const cleared_cards_;
};
class ModUnionUpdateObjectReferencesVisitor {
@@ -242,7 +242,7 @@ void ModUnionTableReferenceCache::Verify() {
CardTable* card_table = heap_->GetCardTable();
ContinuousSpaceBitmap* live_bitmap = space_->GetLiveBitmap();
for (const auto& ref_pair : references_) {
- const byte* card = ref_pair.first;
+ const uint8_t* card = ref_pair.first;
if (*card == CardTable::kCardClean) {
std::set<const Object*> reference_set;
for (mirror::HeapReference<Object>* obj_ptr : ref_pair.second) {
@@ -258,14 +258,14 @@ void ModUnionTableReferenceCache::Verify() {
void ModUnionTableReferenceCache::Dump(std::ostream& os) {
CardTable* card_table = heap_->GetCardTable();
os << "ModUnionTable cleared cards: [";
- for (byte* card_addr : cleared_cards_) {
+ for (uint8_t* card_addr : cleared_cards_) {
uintptr_t start = reinterpret_cast<uintptr_t>(card_table->AddrFromCard(card_addr));
uintptr_t end = start + CardTable::kCardSize;
os << reinterpret_cast<void*>(start) << "-" << reinterpret_cast<void*>(end) << ",";
}
os << "]\nModUnionTable references: [";
for (const auto& ref_pair : references_) {
- const byte* card_addr = ref_pair.first;
+ const uint8_t* card_addr = ref_pair.first;
uintptr_t start = reinterpret_cast<uintptr_t>(card_table->AddrFromCard(card_addr));
uintptr_t end = start + CardTable::kCardSize;
os << reinterpret_cast<void*>(start) << "-" << reinterpret_cast<void*>(end) << "->{";
@@ -349,7 +349,7 @@ void ModUnionTableCardCache::UpdateAndMarkReferences(MarkHeapReferenceCallback*
void ModUnionTableCardCache::Dump(std::ostream& os) {
CardTable* card_table = heap_->GetCardTable();
os << "ModUnionTable dirty cards: [";
- for (const byte* card_addr : cleared_cards_) {
+ for (const uint8_t* card_addr : cleared_cards_) {
auto start = reinterpret_cast<uintptr_t>(card_table->AddrFromCard(card_addr));
auto end = start + CardTable::kCardSize;
os << reinterpret_cast<void*>(start) << "-" << reinterpret_cast<void*>(end) << "\n";
@@ -359,7 +359,7 @@ void ModUnionTableCardCache::Dump(std::ostream& os) {
void ModUnionTableCardCache::SetCards() {
CardTable* card_table = heap_->GetCardTable();
- for (byte* addr = space_->Begin(); addr < AlignUp(space_->End(), CardTable::kCardSize);
+ for (uint8_t* addr = space_->Begin(); addr < AlignUp(space_->End(), CardTable::kCardSize);
addr += CardTable::kCardSize) {
cleared_cards_.insert(card_table->CardFromAddr(addr));
}
diff --git a/runtime/gc/accounting/mod_union_table.h b/runtime/gc/accounting/mod_union_table.h
index d0e11e0..d6342cf 100644
--- a/runtime/gc/accounting/mod_union_table.h
+++ b/runtime/gc/accounting/mod_union_table.h
@@ -50,8 +50,8 @@ class HeapBitmap;
// cleared between GC phases, reducing the number of dirty cards that need to be scanned.
class ModUnionTable {
public:
- typedef std::set<byte*, std::less<byte*>,
- TrackingAllocator<byte*, kAllocatorTagModUnionCardSet>> CardSet;
+ typedef std::set<uint8_t*, std::less<uint8_t*>,
+ TrackingAllocator<uint8_t*, kAllocatorTagModUnionCardSet>> CardSet;
explicit ModUnionTable(const std::string& name, Heap* heap, space::ContinuousSpace* space)
: name_(name),
@@ -131,7 +131,7 @@ class ModUnionTableReferenceCache : public ModUnionTable {
ModUnionTable::CardSet cleared_cards_;
// Maps from dirty cards to their corresponding alloc space references.
- AllocationTrackingSafeMap<const byte*, std::vector<mirror::HeapReference<mirror::Object>*>,
+ AllocationTrackingSafeMap<const uint8_t*, std::vector<mirror::HeapReference<mirror::Object>*>,
kAllocatorTagModUnionReferenceArray> references_;
};
diff --git a/runtime/gc/accounting/remembered_set.cc b/runtime/gc/accounting/remembered_set.cc
index 3ff5874..d43dc0a 100644
--- a/runtime/gc/accounting/remembered_set.cc
+++ b/runtime/gc/accounting/remembered_set.cc
@@ -42,7 +42,7 @@ class RememberedSetCardVisitor {
explicit RememberedSetCardVisitor(RememberedSet::CardSet* const dirty_cards)
: dirty_cards_(dirty_cards) {}
- void operator()(byte* card, byte expected_value, byte new_value) const {
+ void operator()(uint8_t* card, uint8_t expected_value, uint8_t new_value) const {
if (expected_value == CardTable::kCardDirty) {
dirty_cards_->insert(card);
}
@@ -129,7 +129,7 @@ void RememberedSet::UpdateAndMarkReferences(MarkHeapReferenceCallback* callback,
&contains_reference_to_target_space, arg);
ContinuousSpaceBitmap* bitmap = space_->GetLiveBitmap();
CardSet remove_card_set;
- for (byte* const card_addr : dirty_cards_) {
+ for (uint8_t* const card_addr : dirty_cards_) {
contains_reference_to_target_space = false;
uintptr_t start = reinterpret_cast<uintptr_t>(card_table->AddrFromCard(card_addr));
DCHECK(space_->HasAddress(reinterpret_cast<mirror::Object*>(start)));
@@ -145,7 +145,7 @@ void RememberedSet::UpdateAndMarkReferences(MarkHeapReferenceCallback* callback,
// Remove the cards that didn't contain a reference to the target
// space from the dirty card set.
- for (byte* const card_addr : remove_card_set) {
+ for (uint8_t* const card_addr : remove_card_set) {
DCHECK(dirty_cards_.find(card_addr) != dirty_cards_.end());
dirty_cards_.erase(card_addr);
}
@@ -154,7 +154,7 @@ void RememberedSet::UpdateAndMarkReferences(MarkHeapReferenceCallback* callback,
void RememberedSet::Dump(std::ostream& os) {
CardTable* card_table = heap_->GetCardTable();
os << "RememberedSet dirty cards: [";
- for (const byte* card_addr : dirty_cards_) {
+ for (const uint8_t* card_addr : dirty_cards_) {
auto start = reinterpret_cast<uintptr_t>(card_table->AddrFromCard(card_addr));
auto end = start + CardTable::kCardSize;
os << reinterpret_cast<void*>(start) << "-" << reinterpret_cast<void*>(end) << "\n";
@@ -164,8 +164,8 @@ void RememberedSet::Dump(std::ostream& os) {
void RememberedSet::AssertAllDirtyCardsAreWithinSpace() const {
CardTable* card_table = heap_->GetCardTable();
- for (const byte* card_addr : dirty_cards_) {
- auto start = reinterpret_cast<byte*>(card_table->AddrFromCard(card_addr));
+ for (const uint8_t* card_addr : dirty_cards_) {
+ auto start = reinterpret_cast<uint8_t*>(card_table->AddrFromCard(card_addr));
auto end = start + CardTable::kCardSize;
DCHECK_LE(space_->Begin(), start);
DCHECK_LE(end, space_->Limit());
diff --git a/runtime/gc/accounting/remembered_set.h b/runtime/gc/accounting/remembered_set.h
index 8d66e0e..c51e26d 100644
--- a/runtime/gc/accounting/remembered_set.h
+++ b/runtime/gc/accounting/remembered_set.h
@@ -43,8 +43,8 @@ namespace accounting {
// from the free list spaces to the bump pointer spaces.
class RememberedSet {
public:
- typedef std::set<byte*, std::less<byte*>,
- TrackingAllocator<byte*, kAllocatorTagRememberedSet>> CardSet;
+ typedef std::set<uint8_t*, std::less<uint8_t*>,
+ TrackingAllocator<uint8_t*, kAllocatorTagRememberedSet>> CardSet;
explicit RememberedSet(const std::string& name, Heap* heap, space::ContinuousSpace* space)
: name_(name), heap_(heap), space_(space) {}
diff --git a/runtime/gc/accounting/space_bitmap-inl.h b/runtime/gc/accounting/space_bitmap-inl.h
index fc4213e..11347a5 100644
--- a/runtime/gc/accounting/space_bitmap-inl.h
+++ b/runtime/gc/accounting/space_bitmap-inl.h
@@ -35,10 +35,10 @@ inline bool SpaceBitmap<kAlignment>::AtomicTestAndSet(const mirror::Object* obj)
DCHECK_GE(addr, heap_begin_);
const uintptr_t offset = addr - heap_begin_;
const size_t index = OffsetToIndex(offset);
- const uword mask = OffsetToMask(offset);
- Atomic<uword>* atomic_entry = reinterpret_cast<Atomic<uword>*>(&bitmap_begin_[index]);
- DCHECK_LT(index, bitmap_size_ / kWordSize) << " bitmap_size_ = " << bitmap_size_;
- uword old_word;
+ const uintptr_t mask = OffsetToMask(offset);
+ Atomic<uintptr_t>* atomic_entry = reinterpret_cast<Atomic<uintptr_t>*>(&bitmap_begin_[index]);
+ DCHECK_LT(index, bitmap_size_ / sizeof(intptr_t)) << " bitmap_size_ = " << bitmap_size_;
+ uintptr_t old_word;
do {
old_word = atomic_entry->LoadRelaxed();
// Fast path: The bit is already set.
@@ -82,8 +82,8 @@ inline void SpaceBitmap<kAlignment>::VisitMarkedRange(uintptr_t visit_begin, uin
const uintptr_t index_start = OffsetToIndex(offset_start);
const uintptr_t index_end = OffsetToIndex(offset_end);
- const size_t bit_start = (offset_start / kAlignment) % kBitsPerWord;
- const size_t bit_end = (offset_end / kAlignment) % kBitsPerWord;
+ const size_t bit_start = (offset_start / kAlignment) % kBitsPerIntPtrT;
+ const size_t bit_end = (offset_end / kAlignment) % kBitsPerIntPtrT;
// Index(begin) ... Index(end)
// [xxxxx???][........][????yyyy]
@@ -93,12 +93,12 @@ inline void SpaceBitmap<kAlignment>::VisitMarkedRange(uintptr_t visit_begin, uin
//
// Left edge.
- uword left_edge = bitmap_begin_[index_start];
+ uintptr_t left_edge = bitmap_begin_[index_start];
// Mark of lower bits that are not in range.
- left_edge &= ~((static_cast<uword>(1) << bit_start) - 1);
+ left_edge &= ~((static_cast<uintptr_t>(1) << bit_start) - 1);
// Right edge. Either unique, or left_edge.
- uword right_edge;
+ uintptr_t right_edge;
if (index_start < index_end) {
// Left edge != right edge.
@@ -110,20 +110,20 @@ inline void SpaceBitmap<kAlignment>::VisitMarkedRange(uintptr_t visit_begin, uin
const size_t shift = CTZ(left_edge);
mirror::Object* obj = reinterpret_cast<mirror::Object*>(ptr_base + shift * kAlignment);
visitor(obj);
- left_edge ^= (static_cast<uword>(1)) << shift;
+ left_edge ^= (static_cast<uintptr_t>(1)) << shift;
} while (left_edge != 0);
}
// Traverse the middle, full part.
for (size_t i = index_start + 1; i < index_end; ++i) {
- uword w = bitmap_begin_[i];
+ uintptr_t w = bitmap_begin_[i];
if (w != 0) {
const uintptr_t ptr_base = IndexToOffset(i) + heap_begin_;
do {
const size_t shift = CTZ(w);
mirror::Object* obj = reinterpret_cast<mirror::Object*>(ptr_base + shift * kAlignment);
visitor(obj);
- w ^= (static_cast<uword>(1)) << shift;
+ w ^= (static_cast<uintptr_t>(1)) << shift;
} while (w != 0);
}
}
@@ -142,14 +142,14 @@ inline void SpaceBitmap<kAlignment>::VisitMarkedRange(uintptr_t visit_begin, uin
}
// Right edge handling.
- right_edge &= ((static_cast<uword>(1) << bit_end) - 1);
+ right_edge &= ((static_cast<uintptr_t>(1) << bit_end) - 1);
if (right_edge != 0) {
const uintptr_t ptr_base = IndexToOffset(index_end) + heap_begin_;
do {
const size_t shift = CTZ(right_edge);
mirror::Object* obj = reinterpret_cast<mirror::Object*>(ptr_base + shift * kAlignment);
visitor(obj);
- right_edge ^= (static_cast<uword>(1)) << shift;
+ right_edge ^= (static_cast<uintptr_t>(1)) << shift;
} while (right_edge != 0);
}
#endif
@@ -161,10 +161,10 @@ inline bool SpaceBitmap<kAlignment>::Modify(const mirror::Object* obj) {
DCHECK_GE(addr, heap_begin_);
const uintptr_t offset = addr - heap_begin_;
const size_t index = OffsetToIndex(offset);
- const uword mask = OffsetToMask(offset);
- DCHECK_LT(index, bitmap_size_ / kWordSize) << " bitmap_size_ = " << bitmap_size_;
- uword* address = &bitmap_begin_[index];
- uword old_word = *address;
+ const uintptr_t mask = OffsetToMask(offset);
+ DCHECK_LT(index, bitmap_size_ / sizeof(intptr_t)) << " bitmap_size_ = " << bitmap_size_;
+ uintptr_t* address = &bitmap_begin_[index];
+ uintptr_t old_word = *address;
if (kSetBit) {
*address = old_word | mask;
} else {
diff --git a/runtime/gc/accounting/space_bitmap.cc b/runtime/gc/accounting/space_bitmap.cc
index 39d1f9e..feb9565 100644
--- a/runtime/gc/accounting/space_bitmap.cc
+++ b/runtime/gc/accounting/space_bitmap.cc
@@ -29,21 +29,21 @@ namespace accounting {
template<size_t kAlignment>
size_t SpaceBitmap<kAlignment>::ComputeBitmapSize(uint64_t capacity) {
- const uint64_t kBytesCoveredPerWord = kAlignment * kBitsPerWord;
- return (RoundUp(capacity, kBytesCoveredPerWord) / kBytesCoveredPerWord) * kWordSize;
+ const uint64_t kBytesCoveredPerWord = kAlignment * kBitsPerIntPtrT;
+ return (RoundUp(capacity, kBytesCoveredPerWord) / kBytesCoveredPerWord) * sizeof(intptr_t);
}
template<size_t kAlignment>
SpaceBitmap<kAlignment>* SpaceBitmap<kAlignment>::CreateFromMemMap(
- const std::string& name, MemMap* mem_map, byte* heap_begin, size_t heap_capacity) {
+ const std::string& name, MemMap* mem_map, uint8_t* heap_begin, size_t heap_capacity) {
CHECK(mem_map != nullptr);
- uword* bitmap_begin = reinterpret_cast<uword*>(mem_map->Begin());
+ uintptr_t* bitmap_begin = reinterpret_cast<uintptr_t*>(mem_map->Begin());
const size_t bitmap_size = ComputeBitmapSize(heap_capacity);
return new SpaceBitmap(name, mem_map, bitmap_begin, bitmap_size, heap_begin);
}
template<size_t kAlignment>
-SpaceBitmap<kAlignment>::SpaceBitmap(const std::string& name, MemMap* mem_map, uword* bitmap_begin,
+SpaceBitmap<kAlignment>::SpaceBitmap(const std::string& name, MemMap* mem_map, uintptr_t* bitmap_begin,
size_t bitmap_size, const void* heap_begin)
: mem_map_(mem_map), bitmap_begin_(bitmap_begin), bitmap_size_(bitmap_size),
heap_begin_(reinterpret_cast<uintptr_t>(heap_begin)),
@@ -57,7 +57,7 @@ SpaceBitmap<kAlignment>::~SpaceBitmap() {}
template<size_t kAlignment>
SpaceBitmap<kAlignment>* SpaceBitmap<kAlignment>::Create(
- const std::string& name, byte* heap_begin, size_t heap_capacity) {
+ const std::string& name, uint8_t* heap_begin, size_t heap_capacity) {
// Round up since heap_capacity is not necessarily a multiple of kAlignment * kBitsPerWord.
const size_t bitmap_size = ComputeBitmapSize(heap_capacity);
std::string error_msg;
@@ -72,8 +72,8 @@ SpaceBitmap<kAlignment>* SpaceBitmap<kAlignment>::Create(
template<size_t kAlignment>
void SpaceBitmap<kAlignment>::SetHeapLimit(uintptr_t new_end) {
- DCHECK(IsAligned<kBitsPerWord * kAlignment>(new_end));
- size_t new_size = OffsetToIndex(new_end - heap_begin_) * kWordSize;
+ DCHECK(IsAligned<kBitsPerIntPtrT * kAlignment>(new_end));
+ size_t new_size = OffsetToIndex(new_end - heap_begin_) * sizeof(intptr_t);
if (new_size < bitmap_size_) {
bitmap_size_ = new_size;
}
@@ -97,7 +97,7 @@ void SpaceBitmap<kAlignment>::Clear() {
template<size_t kAlignment>
void SpaceBitmap<kAlignment>::CopyFrom(SpaceBitmap* source_bitmap) {
DCHECK_EQ(Size(), source_bitmap->Size());
- std::copy(source_bitmap->Begin(), source_bitmap->Begin() + source_bitmap->Size() / kWordSize, Begin());
+ std::copy(source_bitmap->Begin(), source_bitmap->Begin() + source_bitmap->Size() / sizeof(intptr_t), Begin());
}
template<size_t kAlignment>
@@ -106,16 +106,16 @@ void SpaceBitmap<kAlignment>::Walk(ObjectCallback* callback, void* arg) {
CHECK(callback != NULL);
uintptr_t end = OffsetToIndex(HeapLimit() - heap_begin_ - 1);
- uword* bitmap_begin = bitmap_begin_;
+ uintptr_t* bitmap_begin = bitmap_begin_;
for (uintptr_t i = 0; i <= end; ++i) {
- uword w = bitmap_begin[i];
+ uintptr_t w = bitmap_begin[i];
if (w != 0) {
uintptr_t ptr_base = IndexToOffset(i) + heap_begin_;
do {
const size_t shift = CTZ(w);
mirror::Object* obj = reinterpret_cast<mirror::Object*>(ptr_base + shift * kAlignment);
(*callback)(obj, arg);
- w ^= (static_cast<uword>(1)) << shift;
+ w ^= (static_cast<uintptr_t>(1)) << shift;
} while (w != 0);
}
}
@@ -139,7 +139,7 @@ void SpaceBitmap<kAlignment>::SweepWalk(const SpaceBitmap<kAlignment>& live_bitm
}
// TODO: rewrite the callbacks to accept a std::vector<mirror::Object*> rather than a mirror::Object**?
- constexpr size_t buffer_size = kWordSize * kBitsPerWord;
+ constexpr size_t buffer_size = sizeof(intptr_t) * kBitsPerIntPtrT;
#ifdef __LP64__
// Heap-allocate for smaller stack frame.
std::unique_ptr<mirror::Object*[]> pointer_buf_ptr(new mirror::Object*[buffer_size]);
@@ -152,21 +152,21 @@ void SpaceBitmap<kAlignment>::SweepWalk(const SpaceBitmap<kAlignment>& live_bitm
size_t start = OffsetToIndex(sweep_begin - live_bitmap.heap_begin_);
size_t end = OffsetToIndex(sweep_end - live_bitmap.heap_begin_ - 1);
- CHECK_LT(end, live_bitmap.Size() / kWordSize);
- uword* live = live_bitmap.bitmap_begin_;
- uword* mark = mark_bitmap.bitmap_begin_;
+ CHECK_LT(end, live_bitmap.Size() / sizeof(intptr_t));
+ uintptr_t* live = live_bitmap.bitmap_begin_;
+ uintptr_t* mark = mark_bitmap.bitmap_begin_;
for (size_t i = start; i <= end; i++) {
- uword garbage = live[i] & ~mark[i];
+ uintptr_t garbage = live[i] & ~mark[i];
if (UNLIKELY(garbage != 0)) {
uintptr_t ptr_base = IndexToOffset(i) + live_bitmap.heap_begin_;
do {
const size_t shift = CTZ(garbage);
- garbage ^= (static_cast<uword>(1)) << shift;
+ garbage ^= (static_cast<uintptr_t>(1)) << shift;
*pb++ = reinterpret_cast<mirror::Object*>(ptr_base + shift * kAlignment);
} while (garbage != 0);
// Make sure that there are always enough slots available for an
// entire word of one bits.
- if (pb >= &pointer_buf[buffer_size - kBitsPerWord]) {
+ if (pb >= &pointer_buf[buffer_size - kBitsPerIntPtrT]) {
(*callback)(pb - &pointer_buf[0], &pointer_buf[0], arg);
pb = &pointer_buf[0];
}
@@ -245,21 +245,21 @@ void SpaceBitmap<kAlignment>::WalkFieldsInOrder(SpaceBitmap<kAlignment>* visited
template<size_t kAlignment>
void SpaceBitmap<kAlignment>::InOrderWalk(ObjectCallback* callback, void* arg) {
std::unique_ptr<SpaceBitmap<kAlignment>> visited(
- Create("bitmap for in-order walk", reinterpret_cast<byte*>(heap_begin_),
- IndexToOffset(bitmap_size_ / kWordSize)));
+ Create("bitmap for in-order walk", reinterpret_cast<uint8_t*>(heap_begin_),
+ IndexToOffset(bitmap_size_ / sizeof(intptr_t))));
CHECK(bitmap_begin_ != nullptr);
CHECK(callback != nullptr);
- uintptr_t end = Size() / kWordSize;
+ uintptr_t end = Size() / sizeof(intptr_t);
for (uintptr_t i = 0; i < end; ++i) {
// Need uint for unsigned shift.
- uword w = bitmap_begin_[i];
+ uintptr_t w = bitmap_begin_[i];
if (UNLIKELY(w != 0)) {
uintptr_t ptr_base = IndexToOffset(i) + heap_begin_;
while (w != 0) {
const size_t shift = CTZ(w);
mirror::Object* obj = reinterpret_cast<mirror::Object*>(ptr_base + shift * kAlignment);
WalkFieldsInOrder(visited.get(), callback, obj, arg);
- w ^= (static_cast<uword>(1)) << shift;
+ w ^= (static_cast<uintptr_t>(1)) << shift;
}
}
}
diff --git a/runtime/gc/accounting/space_bitmap.h b/runtime/gc/accounting/space_bitmap.h
index f72b30f..e73166b 100644
--- a/runtime/gc/accounting/space_bitmap.h
+++ b/runtime/gc/accounting/space_bitmap.h
@@ -45,13 +45,13 @@ class SpaceBitmap {
// Initialize a space bitmap so that it points to a bitmap large enough to cover a heap at
// heap_begin of heap_capacity bytes, where objects are guaranteed to be kAlignment-aligned.
- static SpaceBitmap* Create(const std::string& name, byte* heap_begin, size_t heap_capacity);
+ static SpaceBitmap* Create(const std::string& name, uint8_t* heap_begin, size_t heap_capacity);
// Initialize a space bitmap using the provided mem_map as the live bits. Takes ownership of the
// mem map. The address range covered starts at heap_begin and is of size equal to heap_capacity.
// Objects are kAlignement-aligned.
static SpaceBitmap* CreateFromMemMap(const std::string& name, MemMap* mem_map,
- byte* heap_begin, size_t heap_capacity);
+ uint8_t* heap_begin, size_t heap_capacity);
~SpaceBitmap();
@@ -59,17 +59,17 @@ class SpaceBitmap {
// <index> is the index of .bits that contains the bit representing
// <offset>.
static constexpr size_t OffsetToIndex(size_t offset) {
- return offset / kAlignment / kBitsPerWord;
+ return offset / kAlignment / kBitsPerIntPtrT;
}
template<typename T>
static constexpr T IndexToOffset(T index) {
- return static_cast<T>(index * kAlignment * kBitsPerWord);
+ return static_cast<T>(index * kAlignment * kBitsPerIntPtrT);
}
// Bits are packed in the obvious way.
- static constexpr uword OffsetToMask(uintptr_t offset) {
- return (static_cast<size_t>(1)) << ((offset / kAlignment) % kBitsPerWord);
+ static constexpr uintptr_t OffsetToMask(uintptr_t offset) {
+ return (static_cast<size_t>(1)) << ((offset / kAlignment) % kBitsPerIntPtrT);
}
bool Set(const mirror::Object* obj) ALWAYS_INLINE {
@@ -95,7 +95,7 @@ class SpaceBitmap {
// bitmap.
const uintptr_t offset = reinterpret_cast<uintptr_t>(obj) - heap_begin_;
const size_t index = OffsetToIndex(offset);
- return index < bitmap_size_ / kWordSize;
+ return index < bitmap_size_ / sizeof(intptr_t);
}
void VisitRange(uintptr_t base, uintptr_t max, ObjectCallback* callback, void* arg) const;
@@ -146,7 +146,7 @@ class SpaceBitmap {
void CopyFrom(SpaceBitmap* source_bitmap);
// Starting address of our internal storage.
- uword* Begin() {
+ uintptr_t* Begin() {
return bitmap_begin_;
}
@@ -157,7 +157,7 @@ class SpaceBitmap {
// Size in bytes of the memory that the bitmaps spans.
uint64_t HeapSize() const {
- return IndexToOffset<uint64_t>(Size() / kWordSize);
+ return IndexToOffset<uint64_t>(Size() / sizeof(intptr_t));
}
uintptr_t HeapBegin() const {
@@ -192,7 +192,7 @@ class SpaceBitmap {
private:
// TODO: heap_end_ is initialized so that the heap bitmap is empty, this doesn't require the -1,
// however, we document that this is expected on heap_end_
- SpaceBitmap(const std::string& name, MemMap* mem_map, uword* bitmap_begin, size_t bitmap_size,
+ SpaceBitmap(const std::string& name, MemMap* mem_map, uintptr_t* bitmap_begin, size_t bitmap_size,
const void* heap_begin);
// Helper function for computing bitmap size based on a 64 bit capacity.
@@ -214,7 +214,7 @@ class SpaceBitmap {
std::unique_ptr<MemMap> mem_map_;
// This bitmap itself, word sized for efficiency in scanning.
- uword* const bitmap_begin_;
+ uintptr_t* const bitmap_begin_;
// Size of this bitmap.
size_t bitmap_size_;
diff --git a/runtime/gc/accounting/space_bitmap_test.cc b/runtime/gc/accounting/space_bitmap_test.cc
index a30bb25..40856fc 100644
--- a/runtime/gc/accounting/space_bitmap_test.cc
+++ b/runtime/gc/accounting/space_bitmap_test.cc
@@ -30,7 +30,7 @@ namespace accounting {
class SpaceBitmapTest : public CommonRuntimeTest {};
TEST_F(SpaceBitmapTest, Init) {
- byte* heap_begin = reinterpret_cast<byte*>(0x10000000);
+ uint8_t* heap_begin = reinterpret_cast<uint8_t*>(0x10000000);
size_t heap_capacity = 16 * MB;
std::unique_ptr<ContinuousSpaceBitmap> space_bitmap(
ContinuousSpaceBitmap::Create("test bitmap", heap_begin, heap_capacity));
@@ -51,21 +51,21 @@ class BitmapVerify {
EXPECT_EQ(bitmap_->Test(obj), ((reinterpret_cast<uintptr_t>(obj) & 0xF) != 0));
}
- ContinuousSpaceBitmap* bitmap_;
+ ContinuousSpaceBitmap* const bitmap_;
const mirror::Object* begin_;
const mirror::Object* end_;
};
TEST_F(SpaceBitmapTest, ScanRange) {
- byte* heap_begin = reinterpret_cast<byte*>(0x10000000);
+ uint8_t* heap_begin = reinterpret_cast<uint8_t*>(0x10000000);
size_t heap_capacity = 16 * MB;
std::unique_ptr<ContinuousSpaceBitmap> space_bitmap(
ContinuousSpaceBitmap::Create("test bitmap", heap_begin, heap_capacity));
EXPECT_TRUE(space_bitmap.get() != NULL);
- // Set all the odd bits in the first BitsPerWord * 3 to one.
- for (size_t j = 0; j < kBitsPerWord * 3; ++j) {
+ // Set all the odd bits in the first BitsPerIntPtrT * 3 to one.
+ for (size_t j = 0; j < kBitsPerIntPtrT * 3; ++j) {
const mirror::Object* obj =
reinterpret_cast<mirror::Object*>(heap_begin + j * kObjectAlignment);
if (reinterpret_cast<uintptr_t>(obj) & 0xF) {
@@ -76,10 +76,10 @@ TEST_F(SpaceBitmapTest, ScanRange) {
// possible length up to a maximum of kBitsPerWord * 2 - 1 bits.
// This handles all the cases, having runs which start and end on the same word, and different
// words.
- for (size_t i = 0; i < static_cast<size_t>(kBitsPerWord); ++i) {
+ for (size_t i = 0; i < static_cast<size_t>(kBitsPerIntPtrT); ++i) {
mirror::Object* start =
reinterpret_cast<mirror::Object*>(heap_begin + i * kObjectAlignment);
- for (size_t j = 0; j < static_cast<size_t>(kBitsPerWord * 2); ++j) {
+ for (size_t j = 0; j < static_cast<size_t>(kBitsPerIntPtrT * 2); ++j) {
mirror::Object* end =
reinterpret_cast<mirror::Object*>(heap_begin + (i + j) * kObjectAlignment);
BitmapVerify(space_bitmap.get(), start, end);
@@ -95,7 +95,7 @@ class SimpleCounter {
(*count_)++;
}
- size_t* count_;
+ size_t* const count_;
};
class RandGen {
@@ -112,7 +112,7 @@ class RandGen {
template <size_t kAlignment>
void RunTest() NO_THREAD_SAFETY_ANALYSIS {
- byte* heap_begin = reinterpret_cast<byte*>(0x10000000);
+ uint8_t* heap_begin = reinterpret_cast<uint8_t*>(0x10000000);
size_t heap_capacity = 16 * MB;
// Seed with 0x1234 for reproducability.