Upgrade to latest dlmalloc. Refactor Heap and related APIs to use STL like naming.

We fail assertions in the existing heap code, as does Dalvik. This refactoring
is to clean the heap and space APIs and to reduce duplication of data
and thereby solve a failing assertion in the card table.

This change also wires up clearing of soft references including before
out-of-memory errors are reported.

In doing this change it was made clear that mspaces are buggy (and
violating invariants with the garbage collector). This
change upgrades to an un-Android molested version of dlmalloc-2.8.5 and
implements a version of the mspace morecore routine under ART control.

run-test 061-out-of-memory is updated for current heap sizes.

Change-Id: I377e83ab2a8c78afb9b1881f03356929e2c9dc64
diff --git a/src/oatdump.cc b/src/oatdump.cc
index be02d4d..bf9962c 100644
--- a/src/oatdump.cc
+++ b/src/oatdump.cc
@@ -84,11 +84,11 @@
     os << "EXECUTABLE OFFSET:\n";
     os << StringPrintf("%08x\n\n", oat_header.GetExecutableOffset());
 
-    os << "BASE:\n";
-    os << reinterpret_cast<const void*>(oat_file.GetBase()) << "\n\n";
+    os << "BEGIN:\n";
+    os << reinterpret_cast<const void*>(oat_file.Begin()) << "\n\n";
 
-    os << "LIMIT:\n";
-    os << reinterpret_cast<const void*>(oat_file.GetLimit()) << "\n\n";
+    os << "END:\n";
+    os << reinterpret_cast<const void*>(oat_file.End()) << "\n\n";
 
     os << std::flush;
 
@@ -207,17 +207,17 @@
     os << "MAGIC:\n";
     os << image_header.GetMagic() << "\n\n";
 
-    os << "IMAGE BASE:\n";
-    os << reinterpret_cast<void*>(image_header.GetImageBaseAddr()) << "\n\n";
+    os << "IMAGE BEGIN:\n";
+    os << reinterpret_cast<void*>(image_header.GetImageBegin()) << "\n\n";
 
     os << "OAT CHECKSUM:\n";
     os << StringPrintf("%08x\n\n", image_header.GetOatChecksum());
 
-    os << "OAT BASE:\n";
-    os << reinterpret_cast<void*>(image_header.GetOatBaseAddr()) << "\n\n";
+    os << "OAT BEGIN:\n";
+    os << reinterpret_cast<void*>(image_header.GetOatBegin()) << "\n\n";
 
-    os << "OAT LIMIT:\n";
-    os << reinterpret_cast<void*>(image_header.GetOatLimitAddr()) << "\n\n";
+    os << "OAT END:\n";
+    os << reinterpret_cast<void*>(image_header.GetOatEnd()) << "\n\n";
 
     os << "ROOTS:\n";
     os << reinterpret_cast<void*>(image_header.GetImageRoots()) << "\n";
@@ -381,8 +381,7 @@
   }
 
   bool InDumpSpace(const Object* object) {
-    const byte* o = reinterpret_cast<const byte*>(object);
-    return (o >= dump_space_.GetBase() && o < dump_space_.GetLimit());
+    return dump_space_.Contains(object);
   }
 
  public:
@@ -584,7 +583,7 @@
     return EXIT_FAILURE;
   }
 
-  Space* image_space = Heap::GetSpaces()[Heap::GetSpaces().size()-2];
+  ImageSpace* image_space = Heap::GetSpaces()[Heap::GetSpaces().size()-2]->AsImageSpace();
   CHECK(image_space != NULL);
   const ImageHeader& image_header = image_space->GetImageHeader();
   if (!image_header.IsValid()) {