diff options
author | Hiroshi Yamauchi <yamauchi@google.com> | 2013-11-19 18:46:42 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-11-19 18:46:43 +0000 |
commit | 43fddc8b1118d0dc34304ad646e202e28c5f088f (patch) | |
tree | d086a26229e72bdc2bdff5e49b870e7b45ae895a /runtime | |
parent | e24fa3e678b1432f8e7325b9b5718d5a31cb74e1 (diff) | |
parent | 4ce1f00cc74867188347e463f4a5ecb9fe55cde5 (diff) | |
download | android_art-43fddc8b1118d0dc34304ad646e202e28c5f088f.tar.gz android_art-43fddc8b1118d0dc34304ad646e202e28c5f088f.tar.bz2 android_art-43fddc8b1118d0dc34304ad646e202e28c5f088f.zip |
Merge "Fix a per-process dumpsys meminfo crash." into dalvik-dev
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/gc/space/dlmalloc_space-inl.h | 2 | ||||
-rw-r--r-- | runtime/gc/space/dlmalloc_space.cc | 26 | ||||
-rw-r--r-- | runtime/gc/space/dlmalloc_space.h | 8 | ||||
-rw-r--r-- | runtime/gc/space/rosalloc_space-inl.h | 5 | ||||
-rw-r--r-- | runtime/gc/space/rosalloc_space.cc | 23 | ||||
-rw-r--r-- | runtime/gc/space/rosalloc_space.h | 8 |
6 files changed, 33 insertions, 39 deletions
diff --git a/runtime/gc/space/dlmalloc_space-inl.h b/runtime/gc/space/dlmalloc_space-inl.h index fbbba1faf2..c14a4e1b3f 100644 --- a/runtime/gc/space/dlmalloc_space-inl.h +++ b/runtime/gc/space/dlmalloc_space-inl.h @@ -40,7 +40,7 @@ inline mirror::Object* DlMallocSpace::AllocNonvirtual(Thread* self, size_t num_b inline mirror::Object* DlMallocSpace::AllocWithoutGrowthLocked(Thread* /*self*/, size_t num_bytes, size_t* bytes_allocated) { - mirror::Object* result = reinterpret_cast<mirror::Object*>(mspace_malloc(mspace_, num_bytes)); + mirror::Object* result = reinterpret_cast<mirror::Object*>(mspace_malloc(mspace_for_alloc_, num_bytes)); if (LIKELY(result != NULL)) { if (kDebugSpaces) { CHECK(Contains(result)) << "Allocation (" << reinterpret_cast<void*>(result) diff --git a/runtime/gc/space/dlmalloc_space.cc b/runtime/gc/space/dlmalloc_space.cc index fcac58895a..b067bbc9cf 100644 --- a/runtime/gc/space/dlmalloc_space.cc +++ b/runtime/gc/space/dlmalloc_space.cc @@ -111,7 +111,7 @@ class ValgrindDlMallocSpace : public DlMallocSpace { DlMallocSpace::DlMallocSpace(const std::string& name, MemMap* mem_map, void* mspace, byte* begin, byte* end, byte* limit, size_t growth_limit) : MallocSpace(name, mem_map, begin, end, limit, growth_limit), - total_bytes_freed_(0), total_objects_freed_(0), mspace_(mspace) { + total_bytes_freed_(0), total_objects_freed_(0), mspace_(mspace), mspace_for_alloc_(mspace) { CHECK(mspace != NULL); } @@ -334,25 +334,17 @@ void DlMallocSpace::SetFootprintLimit(size_t new_size) { } uint64_t DlMallocSpace::GetBytesAllocated() { - if (mspace_ != nullptr) { - MutexLock mu(Thread::Current(), lock_); - size_t bytes_allocated = 0; - mspace_inspect_all(mspace_, DlmallocBytesAllocatedCallback, &bytes_allocated); - return bytes_allocated; - } else { - return Size(); - } + MutexLock mu(Thread::Current(), lock_); + size_t bytes_allocated = 0; + mspace_inspect_all(mspace_, DlmallocBytesAllocatedCallback, &bytes_allocated); + return bytes_allocated; } uint64_t DlMallocSpace::GetObjectsAllocated() { - if (mspace_ != nullptr) { - MutexLock mu(Thread::Current(), lock_); - size_t objects_allocated = 0; - mspace_inspect_all(mspace_, DlmallocObjectsAllocatedCallback, &objects_allocated); - return objects_allocated; - } else { - return 0; - } + MutexLock mu(Thread::Current(), lock_); + size_t objects_allocated = 0; + mspace_inspect_all(mspace_, DlmallocObjectsAllocatedCallback, &objects_allocated); + return objects_allocated; } #ifndef NDEBUG diff --git a/runtime/gc/space/dlmalloc_space.h b/runtime/gc/space/dlmalloc_space.h index 1cfee7a9eb..d18d4ad2a0 100644 --- a/runtime/gc/space/dlmalloc_space.h +++ b/runtime/gc/space/dlmalloc_space.h @@ -97,7 +97,7 @@ class DlMallocSpace : public MallocSpace { mirror::Class* FindRecentFreedObject(const mirror::Object* obj); virtual void InvalidateAllocator() { - mspace_ = nullptr; + mspace_for_alloc_ = nullptr; } virtual bool IsDlMallocSpace() const { @@ -130,7 +130,11 @@ class DlMallocSpace : public MallocSpace { static const size_t kChunkOverhead = kWordSize; // Underlying malloc space - void* mspace_; + void* const mspace_; + + // A mspace pointer used for allocation. Equals to what mspace_ + // points to or nullptr after InvalidateAllocator() is called. + void* mspace_for_alloc_; friend class collector::MarkSweep; diff --git a/runtime/gc/space/rosalloc_space-inl.h b/runtime/gc/space/rosalloc_space-inl.h index 92c69afa46..0fe5dd7a95 100644 --- a/runtime/gc/space/rosalloc_space-inl.h +++ b/runtime/gc/space/rosalloc_space-inl.h @@ -35,8 +35,9 @@ inline mirror::Object* RosAllocSpace::AllocNonvirtual(Thread* self, size_t num_b inline mirror::Object* RosAllocSpace::AllocWithoutGrowthLocked(Thread* self, size_t num_bytes, size_t* bytes_allocated) { size_t rosalloc_size = 0; - mirror::Object* result = reinterpret_cast<mirror::Object*>(rosalloc_->Alloc(self, num_bytes, - &rosalloc_size)); + mirror::Object* result = reinterpret_cast<mirror::Object*>( + rosalloc_for_alloc_->Alloc(self, num_bytes, + &rosalloc_size)); if (LIKELY(result != NULL)) { if (kDebugSpaces) { CHECK(Contains(result)) << "Allocation (" << reinterpret_cast<void*>(result) diff --git a/runtime/gc/space/rosalloc_space.cc b/runtime/gc/space/rosalloc_space.cc index 72692d6ca3..a3d2dfa20b 100644 --- a/runtime/gc/space/rosalloc_space.cc +++ b/runtime/gc/space/rosalloc_space.cc @@ -38,7 +38,8 @@ static const bool kPrefetchDuringRosAllocFreeList = true; RosAllocSpace::RosAllocSpace(const std::string& name, MemMap* mem_map, art::gc::allocator::RosAlloc* rosalloc, byte* begin, byte* end, byte* limit, size_t growth_limit) - : MallocSpace(name, mem_map, begin, end, limit, growth_limit), rosalloc_(rosalloc) { + : MallocSpace(name, mem_map, begin, end, limit, growth_limit), rosalloc_(rosalloc), + rosalloc_for_alloc_(rosalloc) { CHECK(rosalloc != NULL); } @@ -252,23 +253,15 @@ void RosAllocSpace::SetFootprintLimit(size_t new_size) { } uint64_t RosAllocSpace::GetBytesAllocated() { - if (rosalloc_ != NULL) { - size_t bytes_allocated = 0; - InspectAllRosAlloc(art::gc::allocator::RosAlloc::BytesAllocatedCallback, &bytes_allocated); - return bytes_allocated; - } else { - return Size(); - } + size_t bytes_allocated = 0; + InspectAllRosAlloc(art::gc::allocator::RosAlloc::BytesAllocatedCallback, &bytes_allocated); + return bytes_allocated; } uint64_t RosAllocSpace::GetObjectsAllocated() { - if (rosalloc_ != NULL) { - size_t objects_allocated = 0; - InspectAllRosAlloc(art::gc::allocator::RosAlloc::ObjectsAllocatedCallback, &objects_allocated); - return objects_allocated; - } else { - return 0; - } + size_t objects_allocated = 0; + InspectAllRosAlloc(art::gc::allocator::RosAlloc::ObjectsAllocatedCallback, &objects_allocated); + return objects_allocated; } void RosAllocSpace::InspectAllRosAlloc(void (*callback)(void *start, void *end, size_t num_bytes, void* callback_arg), diff --git a/runtime/gc/space/rosalloc_space.h b/runtime/gc/space/rosalloc_space.h index 8191ffb7f9..6311580d14 100644 --- a/runtime/gc/space/rosalloc_space.h +++ b/runtime/gc/space/rosalloc_space.h @@ -97,7 +97,7 @@ class RosAllocSpace : public MallocSpace { mirror::Class* FindRecentFreedObject(const mirror::Object* obj); virtual void InvalidateAllocator() { - rosalloc_ = NULL; + rosalloc_for_alloc_ = NULL; } virtual bool IsRosAllocSpace() const { @@ -130,7 +130,11 @@ class RosAllocSpace : public MallocSpace { AtomicInteger total_objects_freed_atomic_; // Underlying rosalloc. - art::gc::allocator::RosAlloc* rosalloc_; + art::gc::allocator::RosAlloc* const rosalloc_; + + // A rosalloc pointer used for allocation. Equals to what rosalloc_ + // points to or nullptr after InvalidateAllocator() is called. + art::gc::allocator::RosAlloc* rosalloc_for_alloc_; friend class collector::MarkSweep; |