Remove some unnecessary code from dlmalloc_space/rosalloc_space.

Removed GetTotalBytesAllocated(), GetTotalObjectsAllocated(), and
InternalAllocationSize().

No performance improvement observed.

Change-Id: Ie20433a0fd328fc7f61d4afd54d18fbdc4aa4a17
diff --git a/runtime/gc/space/dlmalloc_space.cc b/runtime/gc/space/dlmalloc_space.cc
index 10e9ed8..a4e6eda 100644
--- a/runtime/gc/space/dlmalloc_space.cc
+++ b/runtime/gc/space/dlmalloc_space.cc
@@ -38,7 +38,7 @@
 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), mspace_for_alloc_(mspace) {
+      mspace_(mspace), mspace_for_alloc_(mspace) {
   CHECK(mspace != NULL);
 }
 
@@ -148,9 +148,7 @@
     CHECK(ptr != NULL);
     CHECK(Contains(ptr)) << "Free (" << ptr << ") not in bounds of heap " << *this;
   }
-  const size_t bytes_freed = InternalAllocationSize(ptr);
-  total_bytes_freed_ += bytes_freed;
-  ++total_objects_freed_;
+  const size_t bytes_freed = AllocationSizeNonvirtual(ptr);
   if (kRecentFreeCount > 0) {
     RegisterRecentFree(ptr);
   }
@@ -170,7 +168,7 @@
       // The head of chunk for the allocation is sizeof(size_t) behind the allocation.
       __builtin_prefetch(reinterpret_cast<char*>(ptrs[i + look_ahead]) - sizeof(size_t));
     }
-    bytes_freed += InternalAllocationSize(ptr);
+    bytes_freed += AllocationSizeNonvirtual(ptr);
   }
 
   if (kRecentFreeCount > 0) {
@@ -196,8 +194,6 @@
 
   {
     MutexLock mu(self, lock_);
-    total_bytes_freed_ += bytes_freed;
-    total_objects_freed_ += num_ptrs;
     mspace_bulk_free(mspace_, reinterpret_cast<void**>(ptrs), num_ptrs);
     return bytes_freed;
   }
@@ -211,13 +207,8 @@
   return heap->GetNonMovingSpace()->MoreCore(increment);
 }
 
-// Virtual functions can't get inlined.
-inline size_t DlMallocSpace::InternalAllocationSize(const mirror::Object* obj) {
-  return AllocationSizeNonvirtual(obj);
-}
-
 size_t DlMallocSpace::AllocationSize(const mirror::Object* obj) {
-  return InternalAllocationSize(obj);
+  return AllocationSizeNonvirtual(obj);
 }
 
 size_t DlMallocSpace::Trim() {
diff --git a/runtime/gc/space/dlmalloc_space.h b/runtime/gc/space/dlmalloc_space.h
index d18d4ad..501c014 100644
--- a/runtime/gc/space/dlmalloc_space.h
+++ b/runtime/gc/space/dlmalloc_space.h
@@ -86,12 +86,6 @@
 
   uint64_t GetBytesAllocated();
   uint64_t GetObjectsAllocated();
-  uint64_t GetTotalBytesAllocated() {
-    return GetBytesAllocated() + total_bytes_freed_;
-  }
-  uint64_t GetTotalObjectsAllocated() {
-    return GetObjectsAllocated() + total_objects_freed_;
-  }
 
   // Returns the class of a recently freed object.
   mirror::Class* FindRecentFreedObject(const mirror::Object* obj);
@@ -112,8 +106,6 @@
                 byte* limit, size_t growth_limit);
 
  private:
-  size_t InternalAllocationSize(const mirror::Object* obj);
-
   mirror::Object* AllocWithoutGrowthLocked(Thread* self, size_t num_bytes, size_t* bytes_allocated)
       EXCLUSIVE_LOCKS_REQUIRED(lock_);
 
@@ -122,10 +114,6 @@
   }
   static void* CreateMspace(void* base, size_t morecore_start, size_t initial_size);
 
-  // Approximate number of bytes and objects which have been deallocated in the space.
-  size_t total_bytes_freed_;
-  size_t total_objects_freed_;
-
   // The boundary tag overhead.
   static const size_t kChunkOverhead = kWordSize;
 
diff --git a/runtime/gc/space/malloc_space.h b/runtime/gc/space/malloc_space.h
index 0f882d3..760fcdd 100644
--- a/runtime/gc/space/malloc_space.h
+++ b/runtime/gc/space/malloc_space.h
@@ -132,8 +132,6 @@
 
   virtual uint64_t GetBytesAllocated() = 0;
   virtual uint64_t GetObjectsAllocated() = 0;
-  virtual uint64_t GetTotalBytesAllocated() = 0;
-  virtual uint64_t GetTotalObjectsAllocated() = 0;
 
   // Returns the old mark bitmap.
   accounting::SpaceBitmap* BindLiveToMarkBitmap();
diff --git a/runtime/gc/space/rosalloc_space.cc b/runtime/gc/space/rosalloc_space.cc
index 1f8e324..9ddc14b 100644
--- a/runtime/gc/space/rosalloc_space.cc
+++ b/runtime/gc/space/rosalloc_space.cc
@@ -146,9 +146,7 @@
     CHECK(ptr != NULL);
     CHECK(Contains(ptr)) << "Free (" << ptr << ") not in bounds of heap " << *this;
   }
-  const size_t bytes_freed = InternalAllocationSize(ptr);
-  total_bytes_freed_atomic_.fetch_add(bytes_freed);
-  ++total_objects_freed_atomic_;
+  const size_t bytes_freed = AllocationSizeNonvirtual(ptr);
   if (kRecentFreeCount > 0) {
     MutexLock mu(self, lock_);
     RegisterRecentFree(ptr);
@@ -168,7 +166,7 @@
     if (kPrefetchDuringRosAllocFreeList && i + look_ahead < num_ptrs) {
       __builtin_prefetch(reinterpret_cast<char*>(ptrs[i + look_ahead]));
     }
-    bytes_freed += InternalAllocationSize(ptr);
+    bytes_freed += AllocationSizeNonvirtual(ptr);
   }
 
   if (kRecentFreeCount > 0) {
@@ -193,8 +191,6 @@
   }
 
   rosalloc_->BulkFree(self, reinterpret_cast<void**>(ptrs), num_ptrs);
-  total_bytes_freed_atomic_.fetch_add(bytes_freed);
-  total_objects_freed_atomic_.fetch_add(num_ptrs);
   return bytes_freed;
 }
 
@@ -206,13 +202,8 @@
   return heap->GetNonMovingSpace()->MoreCore(increment);
 }
 
-// Virtual functions can't get inlined.
-inline size_t RosAllocSpace::InternalAllocationSize(const mirror::Object* obj) {
-  return AllocationSizeNonvirtual(obj);
-}
-
 size_t RosAllocSpace::AllocationSize(const mirror::Object* obj) {
-  return InternalAllocationSize(obj);
+  return AllocationSizeNonvirtual(obj);
 }
 
 size_t RosAllocSpace::Trim() {
diff --git a/runtime/gc/space/rosalloc_space.h b/runtime/gc/space/rosalloc_space.h
index 6311580..5df9d88 100644
--- a/runtime/gc/space/rosalloc_space.h
+++ b/runtime/gc/space/rosalloc_space.h
@@ -83,12 +83,6 @@
 
   uint64_t GetBytesAllocated();
   uint64_t GetObjectsAllocated();
-  uint64_t GetTotalBytesAllocated() {
-    return GetBytesAllocated() + total_bytes_freed_atomic_;
-  }
-  uint64_t GetTotalObjectsAllocated() {
-    return GetObjectsAllocated() + total_objects_freed_atomic_;
-  }
 
   void RevokeThreadLocalBuffers(Thread* thread);
   void RevokeAllThreadLocalBuffers();
@@ -112,7 +106,6 @@
                 byte* begin, byte* end, byte* limit, size_t growth_limit);
 
  private:
-  size_t InternalAllocationSize(const mirror::Object* obj);
   mirror::Object* AllocWithoutGrowthLocked(Thread* self, size_t num_bytes, size_t* bytes_allocated);
 
   void* CreateAllocator(void* base, size_t morecore_start, size_t initial_size) {
@@ -125,10 +118,6 @@
                           void* arg)
       LOCKS_EXCLUDED(Locks::runtime_shutdown_lock_, Locks::thread_list_lock_);
 
-  // Approximate number of bytes and objects which have been deallocated in the space.
-  AtomicInteger total_bytes_freed_atomic_;
-  AtomicInteger total_objects_freed_atomic_;
-
   // Underlying rosalloc.
   art::gc::allocator::RosAlloc* const rosalloc_;