Cleanup invoke in interpreter.

Some cleanup in invocation stuff:
- Get the number of invoke arguments from instruction (vA) rather than get it
from its code item. This benefits to native invoke since we no longer need to
parse the method's shorty. Also pass the low 16 bits of instructions to avoid
fetching it twice when reading vA.
- Remove "is_static" tests by taking advantage of invoke type template argument
rather than testing method's access flags.
- Ensure Instruction::GetArgs is inlined.
- Check exception when initializing method's class when transitioning from
interpreter to compiled code (artInterpreterToCompiledCodeBridge).
- Move UnstartedRuntimeInvoke function to interpreter_common.cc and make it
static as it's only used by DoInvoke and DoInvokeVirtualQuick functions.
- Avoid duplicating code in ShadowFrame::Create.

Performance remains the same according to benchmarks. Hopefully, this should be
addressed in next CLs, especially by improving new shadow frame initialization.

Bug: 10668955
Change-Id: I514b8f098d0ef3e35921ceb770383aac1a9c7902
diff --git a/runtime/dex_instruction-inl.h b/runtime/dex_instruction-inl.h
index 4d39024..207b0b6 100644
--- a/runtime/dex_instruction-inl.h
+++ b/runtime/dex_instruction-inl.h
@@ -281,7 +281,7 @@
   return Fetch16(2);
 }
 
-inline void Instruction::GetArgs(uint32_t arg[5]) const {
+inline void Instruction::GetArgs(uint32_t arg[5], uint16_t inst_data) const {
   DCHECK_EQ(FormatOf(Opcode()), k35c);
 
   /*
@@ -295,7 +295,8 @@
    * method constant (or equivalent) is always in vB.
    */
   uint16_t regList = Fetch16(2);
-  uint4_t count = InstB();  // This is labeled A in the spec.
+  uint4_t count = InstB(inst_data);  // This is labeled A in the spec.
+  DCHECK_LE(count, 5U) << "Invalid arg count in 35c (" << count << ")";
 
   /*
    * Copy the argument registers into the arg[] array, and
@@ -305,15 +306,13 @@
    * copies of those.) Note that cases 5..2 fall through.
    */
   switch (count) {
-    case 5: arg[4] = InstA();
+    case 5: arg[4] = InstA(inst_data);
     case 4: arg[3] = (regList >> 12) & 0x0f;
     case 3: arg[2] = (regList >> 8) & 0x0f;
     case 2: arg[1] = (regList >> 4) & 0x0f;
     case 1: arg[0] = regList & 0x0f; break;
-    case 0: break;  // Valid, but no need to do anything.
-    default:
-      LOG(ERROR) << "Invalid arg count in 35c (" << count << ")";
-      return;
+    default:  // case 0
+      break;  // Valid, but no need to do anything.
   }
 }