Change dex cache to be java object instead of array, add pointer to dex file in dex cache.

Generic clean up to facilitate having GDB macros for Pretty* helper functions.

Improved cleanliness of DexCache since having it as an object array was not the best solution.

Fixed a bug in InOrderWalk caused by ResolveType sometimes allocating classes.

Rename C++ Method to AbstractMethod and add two new classes Constructor, Method which both inherit from AbstractMethod.

Rename done to have the C++ code be closer to the java code.

Change-Id: I4995b4c5e47a3822192b08afa24a639d3b1f4da9
diff --git a/src/object_utils.h b/src/object_utils.h
index f6158f3..035f689 100644
--- a/src/object_utils.h
+++ b/src/object_utils.h
@@ -199,13 +199,10 @@
   }
 
   const DexFile& GetDexFile() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
-    const DexFile* result = dex_file_;
-    if (result == NULL) {
-      const DexCache* dex_cache = GetDexCache();
-      result = &GetClassLinker()->FindDexFile(dex_cache);
-      dex_file_ = result;
+    if (dex_file_ == NULL) {
+      dex_file_ = GetDexCache()->GetDexFile();
     }
-    return *result;
+    return *dex_file_;
   }
 
   DexCache* GetDexCache() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -366,13 +363,10 @@
     return result;
   }
   const DexFile& GetDexFile() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
-    const DexFile* result = dex_file_;
-    if (result == NULL) {
-      const DexCache* dex_cache = GetDexCache();
-      result = &GetClassLinker()->FindDexFile(dex_cache);
-      dex_file_ = result;
+    if (dex_file_ == NULL) {
+      dex_file_ = GetDexCache()->GetDexFile();
     }
-    return *result;
+    return *dex_file_;
   }
 
   ClassLinker* class_linker_;
@@ -390,21 +384,21 @@
      : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL),
        shorty_len_(0) {}
 
-  explicit MethodHelper(const Method* m)
+  explicit MethodHelper(const AbstractMethod* m)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
       : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL),
         shorty_len_(0) {
     SetMethod(m);
   }
 
-  MethodHelper(const Method* m, ClassLinker* l)
+  MethodHelper(const AbstractMethod* m, ClassLinker* l)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
       : class_linker_(l), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL),
         shorty_len_(0) {
     SetMethod(m);
   }
 
-  void ChangeMethod(Method* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  void ChangeMethod(AbstractMethod* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
     DCHECK(new_m != NULL);
     if (dex_cache_ != NULL) {
       Class* klass = new_m->GetDeclaringClass();
@@ -675,12 +669,12 @@
  private:
   // Set the method_ field, for proxy methods looking up the interface method via the resolved
   // methods table.
-  void SetMethod(const Method* method)
+  void SetMethod(const AbstractMethod* method)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
     if (method != NULL) {
       Class* klass = method->GetDeclaringClass();
       if (klass->IsProxyClass()) {
-        Method* interface_method =
+        AbstractMethod* interface_method =
             method->GetDexCacheResolvedMethods()->Get(method->GetDexMethodIndex());
         CHECK(interface_method != NULL);
         CHECK(interface_method == GetClassLinker()->FindMethodForProxy(klass, method));
@@ -702,7 +696,7 @@
   ClassLinker* class_linker_;
   DexCache* dex_cache_;
   const DexFile* dex_file_;
-  const Method* method_;
+  const AbstractMethod* method_;
   const char* shorty_;
   uint32_t shorty_len_;