Added caching of indexes for annotations.

This is a multiproject change, along with changes to libcore and
frameworks/base.

Change-Id: I333ffd264f58667f1ee25845e1de12ca99a8c299
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 7dc0b7d..9d8a1f1 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -1153,7 +1153,9 @@
   DCHECK(klass->GetPrimitiveType() == Primitive::kPrimNot);
   klass->SetStatus(Class::kStatusIdx);
 
+  klass->SetTypeIdx(dex_class_def.class_idx_);
   klass->SetSuperClassTypeIdx(dex_class_def.superclass_idx_);
+  klass->SetAnnotationsOffset(dex_class_def.annotations_off_);
 
   size_t num_static_fields = header.static_fields_size_;
   size_t num_instance_fields = header.instance_fields_size_;
diff --git a/src/class_linker_test.cc b/src/class_linker_test.cc
index 54da19f..5448a51 100644
--- a/src/class_linker_test.cc
+++ b/src/class_linker_test.cc
@@ -495,6 +495,7 @@
 
     // alphabetical 32-bit
     offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, access_flags_),                  "shadow$_access_flags_"));
+    offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, annotations_offset_),            "shadow$_annotations_offset_"));
     offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, class_size_),                    "shadow$_class_size_"));
     offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, clinit_thread_id_),              "shadow$_clinit_thread_id_"));
     offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, num_reference_instance_fields_), "shadow$_num_reference_instance_fields_"));
@@ -505,6 +506,7 @@
     offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, reference_static_offsets_),      "shadow$_reference_static_offsets_"));
     offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, status_),                        "shadow$_status_"));
     offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, super_class_type_idx_),          "shadow$_super_class_type_idx_"));
+    offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, type_idx_),                      "shadow$_type_idx_"));
   };
 };
 
diff --git a/src/object.h b/src/object.h
index 0fe134a..6610871 100644
--- a/src/object.h
+++ b/src/object.h
@@ -1951,6 +1951,22 @@
     klass->SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, verify_error_class_), klass, false);
   }
 
+  uint32_t GetAnnotationsOffset() {
+    return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, annotations_offset_), false);
+  }
+
+  void SetAnnotationsOffset(uint32_t annotations_offset) {
+    SetField32(OFFSET_OF_OBJECT_MEMBER(Class, annotations_offset_), annotations_offset, false);
+  }
+
+  uint32_t GetTypeIdx() {
+    return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, type_idx_), false);
+  }
+
+  void SetTypeIdx(uint32_t type_idx) {
+    SetField32(OFFSET_OF_OBJECT_MEMBER(Class, type_idx_), type_idx, false);
+  }
+
   String* GetSourceFile() const;
 
   void SetSourceFile(String* new_source_file);
@@ -2041,6 +2057,9 @@
   // access flags; low 16 bits are defined by VM spec
   uint32_t access_flags_;
 
+  // annotation directory offset from dex file
+  uint32_t annotations_offset_;
+
   // Total size of the Class instance; used when allocating storage on gc heap.
   // See also object_size_.
   size_t class_size_;
@@ -2075,6 +2094,9 @@
   // see also super_class_
   uint32_t super_class_type_idx_;
 
+  // type index from dex file
+  uint32_t type_idx_;
+
   // TODO: ?
   // initiating class loader list
   // NOTE: for classes with low serialNumber, these are unused, and the