Update mips and mips64 mterp assembly

Cargo-cult the changes from Icc5eb98590243969dc47c59a65e39a3a406660f2
and I45a39ec73abaefaecf5b8c636f3f9d519a0a8bb0 into mips and mips64.
This will fix errors from the mips genrules when all genrules are
run during checkbuilds.

Test: m libart_mterp.mips64 libart_mterp.mips
Change-Id: I7dab944d40dbc05893eae513f2323fc7c6ec6226
diff --git a/runtime/interpreter/mterp/mips/main.S b/runtime/interpreter/mterp/mips/main.S
index 3ebd3d7..b9e2e7a 100644
--- a/runtime/interpreter/mterp/mips/main.S
+++ b/runtime/interpreter/mterp/mips/main.S
@@ -803,21 +803,21 @@
     GOTO_OPCODE(t0)                        # jump to next instruction
     /* NOTE: no fallthrough */
 
-%def alt_stub():
-/*
- * Inter-instruction transfer stub.  Call out to MterpCheckBefore to handle
- * any interesting requests and then jump to the real instruction
- * handler.    Note that the call to MterpCheckBefore is done as a tail call.
- */
+%def dchecks_before_helper():
+    // Call C++ to do debug checks and return to the handler using tail call.
     .extern MterpCheckBefore
-    la     ra, artMterpAsmInstructionStart + (${opnum} * 128)   # Addr of primary handler
-    lw     rIBASE, THREAD_CURRENT_IBASE_OFFSET(rSELF)           # refresh IBASE
     move   a0, rSELF                    # arg0
     addu   a1, rFP, OFF_FP_SHADOWFRAME  # arg1
     move   a2, rPC
     la     t9, MterpCheckBefore
     jalr   zero, t9                     # Tail call to Mterp(self, shadow_frame, dex_pc_ptr)
 
+%def opcode_pre():
+%  add_helper(dchecks_before_helper, "Mterp_dchecks_before_helper")
+    #if !defined(NDEBUG)
+    jal    SYMBOL(Mterp_dchecks_before_helper)
+    #endif
+
 %def fallback():
 /* Transfer stub to alternate interpreter */
     b    MterpFallback
@@ -1128,24 +1128,17 @@
     .global artMterpAsmInstructionEnd
 artMterpAsmInstructionEnd:
 
-%def instruction_end_alt():
-
-    .global artMterpAsmAltInstructionEnd
-artMterpAsmAltInstructionEnd:
-
 %def instruction_start():
 
     .global artMterpAsmInstructionStart
 artMterpAsmInstructionStart = .L_op_nop
     .text
 
-%def instruction_start_alt():
-
-    .global artMterpAsmAltInstructionStart
-artMterpAsmAltInstructionStart = .L_ALT_op_nop
-    .text
-
 %def opcode_start():
 %  pass
 %def opcode_end():
 %  pass
+%def helper_start(name):
+    ENTRY ${name}
+%def helper_end(name):
+    END ${name}
diff --git a/runtime/interpreter/mterp/mips64/main.S b/runtime/interpreter/mterp/mips64/main.S
index 92bddb0..e26d8a5 100644
--- a/runtime/interpreter/mterp/mips64/main.S
+++ b/runtime/interpreter/mterp/mips64/main.S
@@ -424,22 +424,21 @@
 
     /* NOTE: no fallthrough */
 
-%def alt_stub():
-/*
- * Inter-instruction transfer stub.  Call out to MterpCheckBefore to handle
- * any interesting requests and then jump to the real instruction
- * handler.  Note that the call to MterpCheckBefore is done as a tail call.
- */
+%def dchecks_before_helper():
+    // Call C++ to do debug checks and return to the handler using tail call.
     .extern MterpCheckBefore
-    REFRESH_IBASE
-    dla     ra, artMterpAsmInstructionStart
     dla     t9, MterpCheckBefore
     move    a0, rSELF
     daddu   a1, rFP, OFF_FP_SHADOWFRAME
     move    a2, rPC
-    daddu   ra, ra, (${opnum} * 128)            # Addr of primary handler.
     jalr    zero, t9                            # (self, shadow_frame, dex_pc_ptr) Note: tail call.
 
+%def opcode_pre():
+%  add_helper(dchecks_before_helper, "Mterp_dchecks_before_helper")
+    #if !defined(NDEBUG)
+    jal    SYMBOL(Mterp_dchecks_before_helper)
+    #endif
+
 %def fallback():
 /* Transfer stub to alternate interpreter */
     b       MterpFallback
@@ -730,24 +729,17 @@
     .global artMterpAsmInstructionEnd
 artMterpAsmInstructionEnd:
 
-%def instruction_end_alt():
-
-    .global artMterpAsmAltInstructionEnd
-artMterpAsmAltInstructionEnd:
-
 %def instruction_start():
 
     .global artMterpAsmInstructionStart
 artMterpAsmInstructionStart = .L_op_nop
     .text
 
-%def instruction_start_alt():
-
-    .global artMterpAsmAltInstructionStart
-artMterpAsmAltInstructionStart = .L_ALT_op_nop
-    .text
-
 %def opcode_start():
 %  pass
 %def opcode_end():
 %  pass
+%def helper_start(name):
+    ENTRY ${name}
+%def helper_end(name):
+    END ${name}