ART: Use reinterpret_cast{32,64}<> when appropriate.

And fix UnstartedRuntime checking for null arguments in all
functions where we now use reinterpret_cast32<>.

This is a follow-up to
    https://android-review.googlesource.com/783607 .

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Pixel 2 XL boots.
Test: m test-art-target-gtest
Test: testrunner.py --target --optimizing
Bug: 117427174
Change-Id: I58f8ad59f70e3fbb1d06aef419cd26555706fa65
diff --git a/runtime/imtable.h b/runtime/imtable.h
index aa0a504..3c52fb8 100644
--- a/runtime/imtable.h
+++ b/runtime/imtable.h
@@ -21,6 +21,7 @@
 #error IMT_SIZE not defined
 #endif
 
+#include "base/casts.h"
 #include "base/enums.h"
 #include "base/macros.h"
 #include "base/mutex.h"
@@ -46,10 +47,10 @@
     uint8_t* ptr = AddressOfElement(index, pointer_size);
     if (pointer_size == PointerSize::k32) {
       uint32_t value = *reinterpret_cast<uint32_t*>(ptr);
-      return reinterpret_cast<ArtMethod*>(value);
+      return reinterpret_cast32<ArtMethod*>(value);
     } else {
       uint64_t value = *reinterpret_cast<uint64_t*>(ptr);
-      return reinterpret_cast<ArtMethod*>(value);
+      return reinterpret_cast64<ArtMethod*>(value);
     }
   }
 
@@ -57,11 +58,9 @@
     DCHECK_LT(index, kSize);
     uint8_t* ptr = AddressOfElement(index, pointer_size);
     if (pointer_size == PointerSize::k32) {
-      uintptr_t value = reinterpret_cast<uintptr_t>(method);
-      DCHECK_EQ(static_cast<uint32_t>(value), value);  // Check that we dont lose any non 0 bits.
-      *reinterpret_cast<uint32_t*>(ptr) = static_cast<uint32_t>(value);
+      *reinterpret_cast<uint32_t*>(ptr) = reinterpret_cast32<uint32_t>(method);
     } else {
-      *reinterpret_cast<uint64_t*>(ptr) = reinterpret_cast<uint64_t>(method);
+      *reinterpret_cast<uint64_t*>(ptr) = reinterpret_cast64<uint64_t>(method);
     }
   }