Class cast, fill array and interface exception support.

This change uses the deliver exception mechanism to implement support
for a number of runtime exceptions. It also tidies up code in the
compiler and allocates a singular callee save method in the image.

Also adds a fix for JNI internal test where we weren't passing
Thread::Current() and that this value is now being used in generated code.

Change-Id: I57eefd9afe40e92fa3a7e737f1a2ed7e1094b5c1
diff --git a/src/oatdump.cc b/src/oatdump.cc
index 52cddb5..9d4b283 100644
--- a/src/oatdump.cc
+++ b/src/oatdump.cc
@@ -54,8 +54,9 @@
   exit(EXIT_FAILURE);
 }
 
-const char* image_roots_descriptions_[ImageHeader::kImageRootsMax] = {
+const char* image_roots_descriptions_[] = {
   "kJniStubArray",
+  "kCalleeSaveMethod"
 };
 
 class OatDump {
@@ -66,6 +67,7 @@
     os << image_header.GetMagic() << "\n\n";
 
     os << "ROOTS:\n";
+    CHECK(sizeof(image_roots_descriptions_)/(sizeof(char*)) == ImageHeader::kImageRootsMax);
     for (int i = 0; i < ImageHeader::kImageRootsMax; i++) {
       ImageHeader::ImageRoot image_root = static_cast<ImageHeader::ImageRoot>(i);
       os << StringPrintf("%s: %p\n",
@@ -82,7 +84,7 @@
 
  private:
 
-  OatDump(const Space& dump_space, std::ostream& os) : dump_space_(dump_space_), os_(os) {}
+  OatDump(const Space& dump_space, std::ostream& os) : dump_space_(dump_space), os_(os) {}
 
   static void Callback(Object* obj, void* arg) {
     DCHECK(obj != NULL);
@@ -118,9 +120,14 @@
     if (obj->IsMethod()) {
       Method* method = obj->AsMethod();
       const ByteArray* code = method->GetCodeArray();
-      StringAppendF(&summary, "\tCODE     %p-%p\n", code->GetData(), code->GetData() + code->GetLength());
-      const ByteArray* invoke = method->GetInvokeStubArray();
-      StringAppendF(&summary, "\tJNI STUB %p-%p\n", invoke->GetData(), invoke->GetData() + invoke->GetLength());
+      if (method->IsPhony()) {
+        CHECK(code == NULL);
+        StringAppendF(&summary, "\tPHONY\n");
+      } else {
+        StringAppendF(&summary, "\tCODE     %p-%p\n", code->GetData(), code->GetData() + code->GetLength());
+        const ByteArray* invoke = method->GetInvokeStubArray();
+        StringAppendF(&summary, "\tJNI STUB %p-%p\n", invoke->GetData(), invoke->GetData() + invoke->GetLength());
+      }
       if (method->IsNative()) {
         if (method->IsRegistered()) {
          StringAppendF(&summary, "\tNATIVE REGISTERED %p\n", method->GetNativeMethod());