OSDN Git Service

Add Heap::RunningOnValgrind and call it from the spaces.
authorMathieu Chartier <mathieuc@google.com>
Thu, 20 Mar 2014 22:40:37 +0000 (15:40 -0700)
committerMathieu Chartier <mathieuc@google.com>
Thu, 20 Mar 2014 22:40:37 +0000 (15:40 -0700)
Makes it easier to disable valgrind support.

Change-Id: I1bde792f1b76a2dd968fa03c6142e92fcc3670b0

runtime/gc/heap.h
runtime/gc/space/dlmalloc_space.cc
runtime/gc/space/rosalloc_space.cc

index eb53ba9..f650005 100644 (file)
@@ -553,6 +553,9 @@ class Heap {
   void RemoveRememberedSet(space::Space* space);
 
   bool IsCompilingBoot() const;
+  bool RunningOnValgrind() const {
+    return running_on_valgrind_;
+  }
   bool HasImageSpace() const;
 
  private:
index 0597422..30c2edb 100644 (file)
@@ -60,7 +60,7 @@ DlMallocSpace* DlMallocSpace::CreateFromMemMap(MemMap* mem_map, const std::strin
 
   // Everything is set so record in immutable structure and leave
   byte* begin = mem_map->Begin();
-  if (RUNNING_ON_VALGRIND > 0) {
+  if (Runtime::Current()->GetHeap()->RunningOnValgrind()) {
     return new ValgrindMallocSpace<DlMallocSpace, void*>(
         name, mem_map, mspace, begin, end, begin + capacity, growth_limit, initial_size);
   } else {
index 80c7ca7..fbb2afe 100644 (file)
@@ -65,7 +65,7 @@ RosAllocSpace* RosAllocSpace::CreateFromMemMap(MemMap* mem_map, const std::strin
   byte* begin = mem_map->Begin();
   // TODO: Fix RosAllocSpace to support valgrind. There is currently some issues with
   // AllocationSize caused by redzones. b/12944686
-  if (false && RUNNING_ON_VALGRIND > 0) {
+  if (false && Runtime::Current()->GetHeap()->RunningOnValgrind()) {
     return new ValgrindMallocSpace<RosAllocSpace, allocator::RosAlloc*>(
         name, mem_map, rosalloc, begin, end, begin + capacity, growth_limit, initial_size);
   } else {