Update the Begin() of LargeObjectMapSpace
Root cause:
LargeObjectMapSpace's begin_ is initialized by nullptr.
so, it's always 0 after std::min
Solution:
Consider the nullptr case when update begin_
Notes:
Remove the nullptr check for end_ since it's not needed
Test: make test-art-host-gtest-large_object_space_test
Change-Id: I9918c30916e5d359f0ab23ec2bdb0fc9f093a85f
diff --git a/runtime/gc/space/large_object_space.cc b/runtime/gc/space/large_object_space.cc
index 0030326..2d5d7cb 100644
--- a/runtime/gc/space/large_object_space.cc
+++ b/runtime/gc/space/large_object_space.cc
@@ -155,11 +155,12 @@
large_objects_.Put(obj, LargeObject {mem_map, false /* not zygote */});
const size_t allocation_size = mem_map->BaseSize();
DCHECK(bytes_allocated != nullptr);
- begin_ = std::min(begin_, reinterpret_cast<uint8_t*>(obj));
- uint8_t* obj_end = reinterpret_cast<uint8_t*>(obj) + allocation_size;
- if (end_ == nullptr || obj_end > end_) {
- end_ = obj_end;
+
+ if (begin_ == nullptr || begin_ > reinterpret_cast<uint8_t*>(obj)) {
+ begin_ = reinterpret_cast<uint8_t*>(obj);
}
+ end_ = std::max(end_, reinterpret_cast<uint8_t*>(obj) + allocation_size);
+
*bytes_allocated = allocation_size;
if (usable_size != nullptr) {
*usable_size = allocation_size;