Refactor the use of Method by the compiler.

Remove the dependence on the Method object in dex2oat, allowing lazier
resolution.
Introduce new find and iterators in DexFile to simplify common
operations and avoid misuse of class data items.

Change-Id: I39fb8252190f543d89d8b233076355cec310fe08
diff --git a/src/object.h b/src/object.h
index dd2c1ca..6a91970 100644
--- a/src/object.h
+++ b/src/object.h
@@ -619,6 +619,8 @@
     return (GetAccessFlags() & kAccSynthetic) != 0;
   }
 
+  uint32_t GetDexMethodIndex() const;
+
   uint16_t GetMethodIndex() const;
 
   size_t GetVtableIndex() const {
@@ -644,10 +646,6 @@
   // Number of 32bit registers that would be required to hold all the arguments
   static size_t NumArgRegisters(const StringPiece& shorty);
 
-  // Number of argument bytes required for densely packing the
-  // arguments into an array of arguments.
-  size_t NumArgArrayBytes() const;
-
   uint16_t NumRegisters() const;
 
   void SetNumRegisters(uint16_t new_num_registers) {
@@ -1088,7 +1086,8 @@
   // Native invocation stub entry point for calling from native to managed code.
   const InvokeStub* invoke_stub_;
 
-  // Index of the return type
+  // Index of the return type in the declaring classes dex cache or dex file's type ids
+  // TODO: value is really just 16bit
   uint32_t java_return_type_idx_;
 
   // Mapping from native pc to dex pc
@@ -1498,10 +1497,7 @@
     return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, class_size_), false);
   }
 
-  void SetClassSize(size_t new_class_size) {
-    DCHECK_GE(new_class_size, GetClassSize()) << " class=" << PrettyTypeOf(this);
-    SetField32(OFFSET_OF_OBJECT_MEMBER(Class, class_size_), new_class_size, false);
-  }
+  void SetClassSize(size_t new_class_size);
 
   size_t GetObjectSize() const {
     CHECK(!IsVariableSize()) << " class=" << PrettyTypeOf(this);
@@ -2092,9 +2088,11 @@
 
   // Set in LoadClass, used to LinkClass
   // see also super_class_
+  // TODO: really 16bits
   uint32_t super_class_type_idx_;
 
   // type index from dex file
+  // TODO: really 16bits
   uint32_t type_idx_;
 
   // TODO: ?
@@ -2199,15 +2197,6 @@
   return result;
 }
 
-inline void Field::SetOffset(MemberOffset num_bytes) {
-  DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous());
-  Primitive::Type type = GetPrimitiveType();
-  if (type == Primitive::kPrimDouble || type == Primitive::kPrimLong) {
-    DCHECK_ALIGNED(num_bytes.Uint32Value(), 8);
-  }
-  SetField32(OFFSET_OF_OBJECT_MEMBER(Field, offset_), num_bytes.Uint32Value(), false);
-}
-
 inline Class* Field::GetDeclaringClass() const {
   Class* result = GetFieldObject<Class*>(OFFSET_OF_OBJECT_MEMBER(Field, declaring_class_), false);
   DCHECK(result != NULL);
@@ -2480,6 +2469,9 @@
 
   bool Equals(const String* that) const;
 
+  // Compare UTF-16 code point values not in a locale-sensitive manner
+  int Compare(int32_t utf16_length, const char* utf8_data_in);
+
   // TODO: do we need this overload? give it a more intention-revealing name.
   bool Equals(const uint16_t* that_chars, int32_t that_offset,
               int32_t that_length) const;
@@ -2615,7 +2607,7 @@
       this == String::GetJavaLangString() ||
       this == Field::GetJavaLangReflectField() ||
       this == Method::GetConstructorClass() ||
-      this == Method::GetMethodClass()) << PrettyClass(this);
+      this == Method::GetMethodClass());
   return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_), false);
 }