Merge "MIPS: Fix polymorphic invokes."
diff --git a/runtime/arch/mips/entrypoints_init_mips.cc b/runtime/arch/mips/entrypoints_init_mips.cc
index 5c56923..7a0bd3e 100644
--- a/runtime/arch/mips/entrypoints_init_mips.cc
+++ b/runtime/arch/mips/entrypoints_init_mips.cc
@@ -262,6 +262,7 @@
       art_quick_invoke_virtual_trampoline_with_access_check;
   static_assert(!IsDirectEntrypoint(kQuickInvokeVirtualTrampolineWithAccessCheck),
                 "Non-direct C stub marked direct.");
+  qpoints->pInvokePolymorphic = art_quick_invoke_polymorphic;
 
   // Thread
   qpoints->pTestSuspend = art_quick_test_suspend;
diff --git a/runtime/arch/mips/quick_entrypoints_mips.S b/runtime/arch/mips/quick_entrypoints_mips.S
index 3acc0a9..3566325 100644
--- a/runtime/arch/mips/quick_entrypoints_mips.S
+++ b/runtime/arch/mips/quick_entrypoints_mips.S
@@ -2285,15 +2285,12 @@
 ENTRY art_quick_invoke_polymorphic
     SETUP_SAVE_REFS_AND_ARGS_FRAME
     move  $a2, rSELF                          # Make $a2 an alias for the current Thread.
-    move  $a3, $sp                            # Make $a3 a pointer to the saved frame context.
-    addiu $sp, $sp, -24                       # Reserve space for JValue result and 4 words for callee.
-    .cfi_adjust_cfa_offset 24
+    addiu $a3, $sp, ARG_SLOT_SIZE             # Make $a3 a pointer to the saved frame context.
     sw    $zero, 20($sp)                      # Initialize JValue result.
     sw    $zero, 16($sp)
-    addiu $a0, $sp, 16                        # Make $a0 a pointer to the JValue result
     la    $t9, artInvokePolymorphic
     jalr  $t9                                 # (result, receiver, Thread*, context)
-    nop
+    addiu $a0, $sp, 16                        # Make $a0 a pointer to the JValue result
 .macro MATCH_RETURN_TYPE c, handler
     li    $t0, \c
     beq   $v0, $t0, \handler
@@ -2307,18 +2304,17 @@
     MATCH_RETURN_TYPE 'D', .Lstore_double_result
     MATCH_RETURN_TYPE 'F', .Lstore_float_result
     MATCH_RETURN_TYPE 'S', .Lstore_int_result
+    MATCH_RETURN_TYPE 'Z', .Lstore_boolean_result
 .purgem MATCH_RETURN_TYPE
     nop
     b .Lcleanup_and_return
     nop
 .Lstore_boolean_result:
+    b .Lcleanup_and_return
     lbu   $v0, 16($sp)                        # Move byte from JValue result to return value register.
-    b .Lcleanup_and_return
-    nop
 .Lstore_char_result:
-    lhu   $v0, 16($sp)                        # Move char from JValue result to return value register.
     b .Lcleanup_and_return
-    nop
+    lhu   $v0, 16($sp)                        # Move char from JValue result to return value register.
 .Lstore_double_result:
 .Lstore_float_result:
     LDu   $f0, $f1, 16, $sp, $t0              # Move double/float from JValue result to return value register.
@@ -2331,8 +2327,6 @@
     lw    $v0, 16($sp)                        # Move lower bits from JValue result to return value register.
     // Fall-through to clean up and return.
 .Lcleanup_and_return:
-    addiu $sp, $sp, 24                        # Remove space for JValue result and the 4 words for the callee.
-    .cfi_adjust_cfa_offset -24
     lw    $t7, THREAD_EXCEPTION_OFFSET(rSELF) # Load Thread::Current()->exception_
     RESTORE_SAVE_REFS_AND_ARGS_FRAME
     bnez  $t7, 1f                             # Success if no exception is pending.
diff --git a/runtime/arch/mips64/quick_entrypoints_mips64.S b/runtime/arch/mips64/quick_entrypoints_mips64.S
index ae786fe..400926c 100644
--- a/runtime/arch/mips64/quick_entrypoints_mips64.S
+++ b/runtime/arch/mips64/quick_entrypoints_mips64.S
@@ -2132,9 +2132,8 @@
     daddiu $sp, $sp, -8                        # Reserve space for JValue result.
     .cfi_adjust_cfa_offset 8
     sd     $zero, 0($sp)                       # Initialize JValue result.
-    move   $a0, $sp                            # Make $a0 a pointer to the JValue result
     jal    artInvokePolymorphic                # (result, receiver, Thread*, context)
-    nop
+    move   $a0, $sp                            # Make $a0 a pointer to the JValue result
 .macro MATCH_RETURN_TYPE c, handler
     li     $t0, \c
     beq    $v0, $t0, \handler
@@ -2148,27 +2147,24 @@
     MATCH_RETURN_TYPE 'D', .Lstore_double_result
     MATCH_RETURN_TYPE 'F', .Lstore_float_result
     MATCH_RETURN_TYPE 'S', .Lstore_long_result
+    MATCH_RETURN_TYPE 'Z', .Lstore_boolean_result
 .purgem MATCH_RETURN_TYPE
     nop
     b .Lcleanup_and_return
     nop
 .Lstore_boolean_result:
+    b      .Lcleanup_and_return
     lbu    $v0, 0($sp)                         # Move byte from JValue result to return value register.
-    b      .Lcleanup_and_return
-    nop
 .Lstore_char_result:
-    lhu    $v0, 0($sp)                         # Move char from JValue result to return value register.
     b      .Lcleanup_and_return
-    nop
+    lhu    $v0, 0($sp)                         # Move char from JValue result to return value register.
 .Lstore_double_result:
 .Lstore_float_result:
+    b      .Lcleanup_and_return
     l.d    $f0, 0($sp)                         # Move double/float from JValue result to return value register.
-    b      .Lcleanup_and_return
-    nop
 .Lstore_ref_result:
-    lwu    $v0, 0($sp)                         # Move zero extended lower 32-bits to return value register.
     b      .Lcleanup_and_return
-    nop
+    lwu    $v0, 0($sp)                         # Move zero extended lower 32-bits to return value register.
 .Lstore_long_result:
     ld     $v0, 0($sp)                         # Move long from JValue result to return value register.
     // Fall-through to clean up and return.