Clean up art_quick_check_instance_of entrypoints.

Test: Rely on TreeHugger.
Change-Id: I848b8b711ac6bfa90999701a518e2e70b42c3d57
diff --git a/runtime/arch/arm/quick_entrypoints_arm.S b/runtime/arch/arm/quick_entrypoints_arm.S
index c09baea..737d2a8 100644
--- a/runtime/arch/arm/quick_entrypoints_arm.S
+++ b/runtime/arch/arm/quick_entrypoints_arm.S
@@ -794,27 +794,24 @@
     .extern artInstanceOfFromCode
     .extern artThrowClassCastExceptionForObject
 ENTRY art_quick_check_instance_of
-    push {r0-r1, lr}                    @ save arguments, link register and pad
-    .cfi_adjust_cfa_offset 12
+    push {r0-r2, lr}                    @ save arguments, padding (r2) and link register
+    .cfi_adjust_cfa_offset 16
     .cfi_rel_offset r0, 0
     .cfi_rel_offset r1, 4
-    .cfi_rel_offset lr, 8
-    sub sp, #4
-    .cfi_adjust_cfa_offset 4
+    .cfi_rel_offset r2, 8
+    .cfi_rel_offset lr, 12
     bl artInstanceOfFromCode
     cbz    r0, .Lthrow_class_cast_exception
-    add sp, #4
-    .cfi_adjust_cfa_offset -4
-    pop {r0-r1, pc}
-    .cfi_adjust_cfa_offset 4        @ Reset unwind info so following code unwinds.
+    pop {r0-r2, pc}
+
 .Lthrow_class_cast_exception:
-    add sp, #4
-    .cfi_adjust_cfa_offset -4
-    pop {r0-r1, lr}
-    .cfi_adjust_cfa_offset -12
+    pop {r0-r2, lr}
+    .cfi_adjust_cfa_offset -16
     .cfi_restore r0
     .cfi_restore r1
+    .cfi_restore r2
     .cfi_restore lr
+
     SETUP_SAVE_ALL_CALLEE_SAVES_FRAME r2       @ save all registers as basis for long jump context
     mov r2, r9                      @ pass Thread::Current
     bl  artThrowClassCastExceptionForObject  @ (Object*, Class*, Thread*)
diff --git a/runtime/arch/arm64/quick_entrypoints_arm64.S b/runtime/arch/arm64/quick_entrypoints_arm64.S
index 96a1cad..b0e7b0a 100644
--- a/runtime/arch/arm64/quick_entrypoints_arm64.S
+++ b/runtime/arch/arm64/quick_entrypoints_arm64.S
@@ -1341,12 +1341,14 @@
     // Call runtime code
     bl artInstanceOfFromCode
 
+    // Restore LR.
+    RESTORE_REG xLR, 24
+
     // Check for exception
     cbz x0, .Lthrow_class_cast_exception
 
     // Restore and return
     .cfi_remember_state
-    RESTORE_REG xLR, 24
     RESTORE_TWO_REGS_DECREASE_FRAME x0, x1, 32
     ret
     .cfi_restore_state                // Reset unwind info so following code unwinds.
@@ -1354,7 +1356,6 @@
 
 .Lthrow_class_cast_exception:
     // Restore
-    RESTORE_REG xLR, 24
     RESTORE_TWO_REGS_DECREASE_FRAME x0, x1, 32
 
     SETUP_SAVE_ALL_CALLEE_SAVES_FRAME // save all registers as basis for long jump context
diff --git a/runtime/arch/x86/quick_entrypoints_x86.S b/runtime/arch/x86/quick_entrypoints_x86.S
index 93cb665..5a28120 100644
--- a/runtime/arch/x86/quick_entrypoints_x86.S
+++ b/runtime/arch/x86/quick_entrypoints_x86.S
@@ -1436,17 +1436,18 @@
     PUSH eax                              // pass arg1 - obj
     call SYMBOL(artInstanceOfFromCode)    // (Object* obj, Class* ref_klass)
     testl %eax, %eax
-    jz 1f                                 // jump forward if not assignable
+    jz .Lthrow_class_cast_exception       // jump forward if not assignable
     addl LITERAL(12), %esp                // pop arguments
     CFI_ADJUST_CFA_OFFSET(-12)
     ret
-
     CFI_ADJUST_CFA_OFFSET(12)             // Reset unwind info so following code unwinds.
-1:
+
+.Lthrow_class_cast_exception:
     POP eax                               // pop arguments
     POP ecx
     addl LITERAL(4), %esp
     CFI_ADJUST_CFA_OFFSET(-4)
+
     SETUP_SAVE_ALL_CALLEE_SAVES_FRAME ebx, ebx // save all registers as basis for long jump context
     // Outgoing argument set up
     PUSH eax                              // alignment padding
diff --git a/runtime/arch/x86_64/quick_entrypoints_x86_64.S b/runtime/arch/x86_64/quick_entrypoints_x86_64.S
index 85f9723..781ade9 100644
--- a/runtime/arch/x86_64/quick_entrypoints_x86_64.S
+++ b/runtime/arch/x86_64/quick_entrypoints_x86_64.S
@@ -1410,21 +1410,21 @@
     SETUP_FP_CALLEE_SAVE_FRAME
     call SYMBOL(artInstanceOfFromCode)  // (Object* obj, Class* ref_klass)
     testq %rax, %rax
-    jz 1f                             // jump forward if not assignable
+    jz .Lthrow_class_cast_exception   // jump forward if not assignable
+    CFI_REMEMBER_STATE
     RESTORE_FP_CALLEE_SAVE_FRAME
     addq LITERAL(24), %rsp            // pop arguments
     CFI_ADJUST_CFA_OFFSET(-24)
-
-.Lreturn:
     ret
+    CFI_RESTORE_STATE                 // Reset unwind info so following code unwinds.
 
-    CFI_ADJUST_CFA_OFFSET(24 + 4 * 8)  // Reset unwind info so following code unwinds.
-1:
+.Lthrow_class_cast_exception:
     RESTORE_FP_CALLEE_SAVE_FRAME
     addq LITERAL(8), %rsp             // pop padding
     CFI_ADJUST_CFA_OFFSET(-8)
     POP rsi                           // Pop arguments
     POP rdi
+
     SETUP_SAVE_ALL_CALLEE_SAVES_FRAME // save all registers as basis for long jump context
     mov %gs:THREAD_SELF_OFFSET, %rdx  // pass Thread::Current()
     call SYMBOL(artThrowClassCastExceptionForObject)  // (Object* src, Class* dest, Thread*)