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/compiler_llvm/compiler_llvm.h b/src/compiler_llvm/compiler_llvm.h
index e9ccd4d..39223ef 100644
--- a/src/compiler_llvm/compiler_llvm.h
+++ b/src/compiler_llvm/compiler_llvm.h
@@ -36,7 +36,7 @@
   class CompiledMethod;
   class Compiler;
   class OatCompilationUnit;
-  class Method;
+  class AbstractMethod;
 }
 
 
diff --git a/src/compiler_llvm/gbc_expander.cc b/src/compiler_llvm/gbc_expander.cc
index d482526..bcca08d 100644
--- a/src/compiler_llvm/gbc_expander.cc
+++ b/src/compiler_llvm/gbc_expander.cc
@@ -655,7 +655,7 @@
 llvm::Value*
 GBCExpanderPass::EmitLoadDexCacheStaticStorageFieldAddr(uint32_t type_idx) {
   llvm::Value* static_storage_dex_cache_addr =
-    EmitLoadDexCacheAddr(art::Method::DexCacheInitializedStaticStorageOffset());
+    EmitLoadDexCacheAddr(art::AbstractMethod::DexCacheInitializedStaticStorageOffset());
 
   llvm::Value* type_idx_value = irb_.getPtrEquivInt(type_idx);
 
@@ -665,7 +665,7 @@
 llvm::Value*
 GBCExpanderPass::EmitLoadDexCacheResolvedTypeFieldAddr(uint32_t type_idx) {
   llvm::Value* resolved_type_dex_cache_addr =
-    EmitLoadDexCacheAddr(art::Method::DexCacheResolvedTypesOffset());
+    EmitLoadDexCacheAddr(art::AbstractMethod::DexCacheResolvedTypesOffset());
 
   llvm::Value* type_idx_value = irb_.getPtrEquivInt(type_idx);
 
@@ -675,7 +675,7 @@
 llvm::Value* GBCExpanderPass::
 EmitLoadDexCacheResolvedMethodFieldAddr(uint32_t method_idx) {
   llvm::Value* resolved_method_dex_cache_addr =
-    EmitLoadDexCacheAddr(art::Method::DexCacheResolvedMethodsOffset());
+    EmitLoadDexCacheAddr(art::AbstractMethod::DexCacheResolvedMethodsOffset());
 
   llvm::Value* method_idx_value = irb_.getPtrEquivInt(method_idx);
 
@@ -685,7 +685,7 @@
 llvm::Value* GBCExpanderPass::
 EmitLoadDexCacheStringFieldAddr(uint32_t string_idx) {
   llvm::Value* string_dex_cache_addr =
-    EmitLoadDexCacheAddr(art::Method::DexCacheStringsOffset());
+    EmitLoadDexCacheAddr(art::AbstractMethod::DexCacheStringsOffset());
 
   llvm::Value* string_idx_value = irb_.getPtrEquivInt(string_idx);
 
@@ -983,7 +983,7 @@
 llvm::Value*
 GBCExpanderPass::Expand_LoadDeclaringClassSSB(llvm::Value* method_object_addr) {
   return irb_.LoadFromObjectOffset(method_object_addr,
-                                   art::Method::DeclaringClassOffset().Int32Value(),
+                                   art::AbstractMethod::DeclaringClassOffset().Int32Value(),
                                    irb_.getJObjectTy(),
                                    kTBAAConstJObject);
 }
@@ -1035,7 +1035,7 @@
 
   llvm::Value* code_addr =
     irb_.LoadFromObjectOffset(callee_method_object_addr,
-                              art::Method::GetCodeOffset().Int32Value(),
+                              art::AbstractMethod::GetCodeOffset().Int32Value(),
                               callee_method_type->getPointerTo(),
                               kTBAAJRuntime);
 
@@ -1710,7 +1710,7 @@
 
       static_storage_addr =
         irb_.LoadFromObjectOffset(method_object_addr,
-                                  art::Method::DeclaringClassOffset().Int32Value(),
+                                  art::AbstractMethod::DeclaringClassOffset().Int32Value(),
                                   irb_.getJObjectTy(),
                                   kTBAAConstJObject);
     } else {
@@ -1791,7 +1791,7 @@
 
       static_storage_addr =
         irb_.LoadFromObjectOffset(method_object_addr,
-                                  art::Method::DeclaringClassOffset().Int32Value(),
+                                  art::AbstractMethod::DeclaringClassOffset().Int32Value(),
                                   irb_.getJObjectTy(),
                                   kTBAAConstJObject);
     } else {
@@ -2168,7 +2168,7 @@
   } else {
     code_addr =
       irb_.LoadFromObjectOffset(callee_method_object_addr,
-                                art::Method::GetCodeOffset().Int32Value(),
+                                art::AbstractMethod::GetCodeOffset().Int32Value(),
                                 GetFunctionType(callee_method_idx, is_static)->getPointerTo(),
                                 kTBAAJRuntime);
   }
diff --git a/src/compiler_llvm/jni_compiler.cc b/src/compiler_llvm/jni_compiler.cc
index 8bb8b87..5bc3bfc 100644
--- a/src/compiler_llvm/jni_compiler.cc
+++ b/src/compiler_llvm/jni_compiler.cc
@@ -80,7 +80,7 @@
     // Load class object
     this_object_or_class_object =
         irb_.LoadFromObjectOffset(method_object_addr,
-                                  Method::DeclaringClassOffset().Int32Value(),
+                                  AbstractMethod::DeclaringClassOffset().Int32Value(),
                                   irb_.getJObjectTy(),
                                   kTBAAConstJObject);
   }
@@ -124,7 +124,7 @@
   // Get callee code_addr
   llvm::Value* code_addr =
       irb_.LoadFromObjectOffset(method_object_addr,
-                                Method::NativeMethodOffset().Int32Value(),
+                                AbstractMethod::NativeMethodOffset().Int32Value(),
                                 GetFunctionType(method_idx_, is_static, true)->getPointerTo(),
                                 kTBAAJRuntime);
 
diff --git a/src/compiler_llvm/jni_compiler.h b/src/compiler_llvm/jni_compiler.h
index 80494b6..c428775 100644
--- a/src/compiler_llvm/jni_compiler.h
+++ b/src/compiler_llvm/jni_compiler.h
@@ -26,7 +26,7 @@
   class Compiler;
   class DexCache;
   class DexFile;
-  class Method;
+  class AbstractMethod;
   class OatCompilationUnit;
 }
 
diff --git a/src/compiler_llvm/method_compiler.cc b/src/compiler_llvm/method_compiler.cc
index a74a6a4..61fffbe 100644
--- a/src/compiler_llvm/method_compiler.cc
+++ b/src/compiler_llvm/method_compiler.cc
@@ -2547,7 +2547,7 @@
 
       static_storage_addr =
         irb_.LoadFromObjectOffset(method_object_addr,
-                                  Method::DeclaringClassOffset().Int32Value(),
+                                  AbstractMethod::DeclaringClassOffset().Int32Value(),
                                   irb_.getJObjectTy(),
                                   kTBAAConstJObject);
     } else {
@@ -2626,7 +2626,7 @@
 
       static_storage_addr =
         irb_.LoadFromObjectOffset(method_object_addr,
-                                  Method::DeclaringClassOffset().Int32Value(),
+                                  AbstractMethod::DeclaringClassOffset().Int32Value(),
                                   irb_.getJObjectTy(),
                                   kTBAAConstJObject);
     } else {
@@ -2815,7 +2815,7 @@
   } else {
     code_addr =
       irb_.LoadFromObjectOffset(callee_method_object_addr,
-                                Method::GetCodeOffset().Int32Value(),
+                                AbstractMethod::GetCodeOffset().Int32Value(),
                                 GetFunctionType(callee_method_idx, is_static)->getPointerTo(),
                                 kTBAAJRuntime);
   }
@@ -3479,7 +3479,7 @@
 llvm::Value* MethodCompiler::
 EmitLoadDexCacheStaticStorageFieldAddr(uint32_t type_idx) {
   llvm::Value* static_storage_dex_cache_addr =
-    EmitLoadDexCacheAddr(Method::DexCacheInitializedStaticStorageOffset());
+    EmitLoadDexCacheAddr(AbstractMethod::DexCacheInitializedStaticStorageOffset());
 
   llvm::Value* type_idx_value = irb_.getPtrEquivInt(type_idx);
 
@@ -3490,7 +3490,7 @@
 llvm::Value* MethodCompiler::
 EmitLoadDexCacheResolvedTypeFieldAddr(uint32_t type_idx) {
   llvm::Value* resolved_type_dex_cache_addr =
-    EmitLoadDexCacheAddr(Method::DexCacheResolvedTypesOffset());
+    EmitLoadDexCacheAddr(AbstractMethod::DexCacheResolvedTypesOffset());
 
   llvm::Value* type_idx_value = irb_.getPtrEquivInt(type_idx);
 
@@ -3501,7 +3501,7 @@
 llvm::Value* MethodCompiler::
 EmitLoadDexCacheResolvedMethodFieldAddr(uint32_t method_idx) {
   llvm::Value* resolved_method_dex_cache_addr =
-    EmitLoadDexCacheAddr(Method::DexCacheResolvedMethodsOffset());
+    EmitLoadDexCacheAddr(AbstractMethod::DexCacheResolvedMethodsOffset());
 
   llvm::Value* method_idx_value = irb_.getPtrEquivInt(method_idx);
 
@@ -3512,7 +3512,7 @@
 llvm::Value* MethodCompiler::
 EmitLoadDexCacheStringFieldAddr(uint32_t string_idx) {
   llvm::Value* string_dex_cache_addr =
-    EmitLoadDexCacheAddr(Method::DexCacheStringsOffset());
+    EmitLoadDexCacheAddr(AbstractMethod::DexCacheStringsOffset());
 
   llvm::Value* string_idx_value = irb_.getPtrEquivInt(string_idx);
 
diff --git a/src/compiler_llvm/runtime_support_llvm.h b/src/compiler_llvm/runtime_support_llvm.h
index c900717..626fe4f 100644
--- a/src/compiler_llvm/runtime_support_llvm.h
+++ b/src/compiler_llvm/runtime_support_llvm.h
@@ -26,7 +26,7 @@
 //----------------------------------------------------------------------------
 
 ShadowFrame* art_push_shadow_frame_from_code(Thread* thread, ShadowFrame* new_shadow_frame,
-                                             Method* method, uint32_t size);
+                                             AbstractMethod* method, uint32_t size);
 
 void art_pop_shadow_frame_from_code(void*);
 
@@ -49,7 +49,7 @@
 
 void art_throw_exception_from_code(Object* exception);
 
-int32_t art_find_catch_block_from_code(Method* current_method,
+int32_t art_find_catch_block_from_code(AbstractMethod* current_method,
                                        uint32_t ti_offset);
 
 
diff --git a/src/compiler_llvm/stub_compiler.cc b/src/compiler_llvm/stub_compiler.cc
index 46c6f21..3ac5f2a 100644
--- a/src/compiler_llvm/stub_compiler.cc
+++ b/src/compiler_llvm/stub_compiler.cc
@@ -142,7 +142,7 @@
 
   // Invoke managed method now!
   llvm::Value* code_field_offset_value =
-    irb_.getPtrEquivInt(Method::GetCodeOffset().Int32Value());
+    irb_.getPtrEquivInt(AbstractMethod::GetCodeOffset().Int32Value());
 
   llvm::Value* code_field_addr =
     irb_.CreatePtrDisp(method_object_addr, code_field_offset_value,