Interpreter: Add support for method handle transforms [Part 1].

Method handle transformations are implemented in Java by
subclasses of java.lang.invoke.Transformers.Transformer. Transformer
extends MethodHandle and provides a transformer method defined like so:

public static class TransformerImpl extends Transformer {
    @Override
    public void transform(EmulatedStackFrame emulatedStackFrame) throws Throwable {
    }
}

An EmulatedStackFrame is synthesized by the runtime based on the
caller stack frame and arguments specified by the instruction. It will
contain all input arguments to the method their associated types. It
will also exactly match the method type specified by the target handle
(i.e, argument coversions are performed by the runtime).

The transformer method operates on supplied EmulatedStackFrame
and other instance state to synthesize the transformation. In some
cases, these transformations will end up calling other signature
polymorphic methods. In those cases, the transformer can construct
an EmulatedStackFrame and issue the invoke passing that through as
the single input argument. For e.g,

  EmulatedStackFrame sf = EmulatedStackFrame.newInstance();
  sf.pushArgument("foo", String.class);
  sf.pushIntArgument(42);

  // The callsite type for this polymorphic invoke is
  // (Ldalvik/system/EmulatedStackFrame)V;
  delegate.invoke(sf);

The runtime will treat such polymorphic invokes specially and unmarshal
this EmulatedStackFrame on to the callee stack frame based on the type
and number of arguments contained in the EmulatedStackFrame and the
declared type of the target method handle.

In this change :

Adds the basic plumbing for transformer invokes. In particular, the code
for marshaling and unmarshaling emulated stack frames isn't implemented
and will be added in a follow up method. This plumbing is sufficient to
implement a test case of a method handle transform that doesn't need any
input arguments, so is trivially implementable without proper
EmulatedStackFrame support.

bug: 30550796
Test: make test-art-host
Change-Id: Iafa29accaef26d0a33f8b83713bed5d929df547e
diff --git a/runtime/method_handles-inl.h b/runtime/method_handles-inl.h
index 7a77bda..b488133 100644
--- a/runtime/method_handles-inl.h
+++ b/runtime/method_handles-inl.h
@@ -162,14 +162,14 @@
 }
 
 template <bool is_range>
-bool PerformArgumentConversions(Thread* self,
-                                Handle<mirror::MethodType> callsite_type,
-                                Handle<mirror::MethodType> callee_type,
-                                const ShadowFrame& caller_frame,
-                                uint32_t first_src_reg,
-                                uint32_t first_dest_reg,
-                                const uint32_t (&arg)[Instruction::kMaxVarArgRegs],
-                                ShadowFrame* callee_frame) {
+bool ConvertAndCopyArgumentsFromCallerFrame(Thread* self,
+                                            Handle<mirror::MethodType> callsite_type,
+                                            Handle<mirror::MethodType> callee_type,
+                                            const ShadowFrame& caller_frame,
+                                            uint32_t first_src_reg,
+                                            uint32_t first_dest_reg,
+                                            const uint32_t (&arg)[Instruction::kMaxVarArgRegs],
+                                            ShadowFrame* callee_frame) {
   StackHandleScope<4> hs(self);
   Handle<mirror::ObjectArray<mirror::Class>> from_types(hs.NewHandle(callsite_type->GetPTypes()));
   Handle<mirror::ObjectArray<mirror::Class>> to_types(hs.NewHandle(callee_type->GetPTypes()));
@@ -244,6 +244,25 @@
   return true;
 }
 
+// Similar to |ConvertAndCopyArgumentsFromCallerFrame|, except that the
+// arguments are copied from an |EmulatedStackFrame|.
+template <bool is_range>
+bool ConvertAndCopyArgumentsFromEmulatedStackFrame(Thread* self,
+                                                   ObjPtr<mirror::Object> emulated_stack_frame,
+                                                   Handle<mirror::MethodType> callee_type,
+                                                   const uint32_t first_dest_reg,
+                                                   ShadowFrame* callee_frame) {
+  UNUSED(self);
+  UNUSED(emulated_stack_frame);
+  UNUSED(callee_type);
+  UNUSED(first_dest_reg);
+  UNUSED(callee_frame);
+
+  UNIMPLEMENTED(FATAL) << "ConvertAndCopyArgumentsFromEmulatedStackFrame is unimplemented";
+  return false;
+}
+
+
 }  // namespace art
 
 #endif  // ART_RUNTIME_METHOD_HANDLES_INL_H_