summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/arch/mips64/asm_support_mips64.S8
-rw-r--r--runtime/arch/mips64/jni_entrypoints_mips64.S5
-rw-r--r--runtime/arch/mips64/quick_entrypoints_mips64.S64
-rw-r--r--runtime/arch/stub_test.cc4
4 files changed, 57 insertions, 24 deletions
diff --git a/runtime/arch/mips64/asm_support_mips64.S b/runtime/arch/mips64/asm_support_mips64.S
index 10976bb70d..26137777e3 100644
--- a/runtime/arch/mips64/asm_support_mips64.S
+++ b/runtime/arch/mips64/asm_support_mips64.S
@@ -27,7 +27,8 @@
#define rSELF $s1
- // Declare a function called name, sets up $gp.
+ // Declare a function called name, sets up $gp.
+ // This macro modifies t8.
.macro ENTRY name
.type \name, %function
.global \name
@@ -35,10 +36,11 @@
.balign 16
\name:
.cfi_startproc
+ // Set up $gp and store the previous $gp value to $t8. It will be pushed to the
+ // stack after the frame has been constructed.
+ .cpsetup $t9, $t8, \name
// Ensure we get a sane starting CFA.
.cfi_def_cfa $sp,0
- // Load $gp. We expect that ".set noreorder" is in effect.
- .cpload $t9
// Declare a local convenience label to be branched to when $gp is already set up.
.L\name\()_gp_set:
.endm
diff --git a/runtime/arch/mips64/jni_entrypoints_mips64.S b/runtime/arch/mips64/jni_entrypoints_mips64.S
index 10856668a2..70d7d9742c 100644
--- a/runtime/arch/mips64/jni_entrypoints_mips64.S
+++ b/runtime/arch/mips64/jni_entrypoints_mips64.S
@@ -44,8 +44,11 @@ ENTRY art_jni_dlsym_lookup_stub
.cfi_rel_offset 5, 8
sd $a0, 0($sp)
.cfi_rel_offset 4, 0
- jal artFindNativeMethod # (Thread*)
move $a0, $s1 # pass Thread::Current()
+ jal artFindNativeMethod # (Thread*)
+ .cpreturn # Restore gp from t8 in branch delay slot. gp is not used
+ # anymore, and t8 may be clobbered in artFindNativeMethod.
+
ld $a0, 0($sp) # restore registers from stack
.cfi_restore 4
ld $a1, 8($sp)
diff --git a/runtime/arch/mips64/quick_entrypoints_mips64.S b/runtime/arch/mips64/quick_entrypoints_mips64.S
index 8330d0c253..ff79b5d77c 100644
--- a/runtime/arch/mips64/quick_entrypoints_mips64.S
+++ b/runtime/arch/mips64/quick_entrypoints_mips64.S
@@ -27,6 +27,19 @@
.extern artDeliverPendingExceptionFromCode
/*
+ * Macro that sets up $gp and stores the previous $gp value to $t8.
+ * This macro modifies v1 and t8.
+ */
+.macro SETUP_GP
+ move $v1, $ra
+ bal 1f
+ nop
+1:
+ .cpsetup $ra, $t8, 1b
+ move $ra, $v1
+.endm
+
+ /*
* Macro that sets up the callee save frame to conform with
* Runtime::CreateCalleeSaveMethod(kSaveAll)
* callee-save: padding + $f24-$f31 + $s0-$s7 + $gp + $ra + $s8 = 19 total + 1x8 bytes padding
@@ -44,8 +57,8 @@
.cfi_rel_offset 31, 152
sd $s8, 144($sp)
.cfi_rel_offset 30, 144
- sd $gp, 136($sp)
- .cfi_rel_offset 28, 136
+ sd $t8, 136($sp) # t8 holds caller's gp, now save it to the stack.
+ .cfi_rel_offset 28, 136 # Value from gp is pushed, so set the cfi offset accordingly.
sd $s7, 128($sp)
.cfi_rel_offset 23, 128
sd $s6, 120($sp)
@@ -102,8 +115,8 @@
.cfi_rel_offset 31, 72
sd $s8, 64($sp)
.cfi_rel_offset 30, 64
- sd $gp, 56($sp)
- .cfi_rel_offset 28, 56
+ sd $t8, 56($sp) # t8 holds caller's gp, now save it to the stack.
+ .cfi_rel_offset 28, 56 # Value from gp is pushed, so set the cfi offset accordingly.
sd $s7, 48($sp)
.cfi_rel_offset 23, 48
sd $s6, 40($sp)
@@ -130,7 +143,7 @@
.cfi_restore 31
ld $s8, 64($sp)
.cfi_restore 30
- ld $gp, 56($sp)
+ ld $t8, 56($sp) # Restore gp back to it's temp storage.
.cfi_restore 28
ld $s7, 48($sp)
.cfi_restore 23
@@ -146,6 +159,7 @@
.cfi_restore 18
daddiu $sp, $sp, 80
.cfi_adjust_cfa_offset -80
+ .cpreturn
.endm
.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
@@ -153,7 +167,7 @@
.cfi_restore 31
ld $s8, 64($sp)
.cfi_restore 30
- ld $gp, 56($sp)
+ ld $t8, 56($sp) # Restore gp back to it's temp storage.
.cfi_restore 28
ld $s7, 48($sp)
.cfi_restore 23
@@ -167,6 +181,7 @@
.cfi_restore 19
ld $s2, 8($sp)
.cfi_restore 18
+ .cpreturn
jalr $zero, $ra
daddiu $sp, $sp, 80
.cfi_adjust_cfa_offset -80
@@ -188,8 +203,8 @@
.cfi_rel_offset 31, 200
sd $s8, 192($sp)
.cfi_rel_offset 30, 192
- sd $gp, 184($sp)
- .cfi_rel_offset 28, 184
+ sd $t8, 184($sp) # t8 holds caller's gp, now save it to the stack.
+ .cfi_rel_offset 28, 184 # Value from gp is pushed, so set the cfi offset accordingly.
sd $s7, 176($sp)
.cfi_rel_offset 23, 176
sd $s6, 168($sp)
@@ -257,7 +272,7 @@
.cfi_restore 31
ld $s8, 192($sp)
.cfi_restore 30
- ld $gp, 184($sp)
+ ld $t8, 184($sp) # Restore gp back to it's temp storage.
.cfi_restore 28
ld $s7, 176($sp)
.cfi_restore 23
@@ -296,6 +311,7 @@
l.d $f13, 24($sp)
l.d $f12, 16($sp)
+ .cpreturn
daddiu $sp, $sp, 208
.cfi_adjust_cfa_offset -208
.endm
@@ -306,6 +322,7 @@
* exception is Thread::Current()->exception_
*/
.macro DELIVER_PENDING_EXCEPTION
+ SETUP_GP
SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
dla $t9, artDeliverPendingExceptionFromCode
jalr $zero, $t9 # artDeliverPendingExceptionFromCode(Thread*)
@@ -347,7 +364,7 @@
* On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
* FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
*/
-ENTRY art_quick_do_long_jump
+ENTRY_NO_GP art_quick_do_long_jump
l.d $f0, 0($a1)
l.d $f1, 8($a1)
l.d $f2, 16($a1)
@@ -604,7 +621,7 @@ INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvo
* a4 = JValue* result
* a5 = shorty
*/
-ENTRY art_quick_invoke_stub
+ENTRY_NO_GP art_quick_invoke_stub
# push a4, a5, s0(rSUSPEND), s1(rSELF), s8, ra onto the stack
daddiu $sp, $sp, -48
.cfi_adjust_cfa_offset 48
@@ -706,7 +723,7 @@ END art_quick_invoke_stub
* a4 = JValue* result
* a5 = shorty
*/
-ENTRY art_quick_invoke_static_stub
+ENTRY_NO_GP art_quick_invoke_static_stub
# push a4, a5, s0(rSUSPEND), s1(rSELF), s8, ra, onto the stack
daddiu $sp, $sp, -48
@@ -850,7 +867,8 @@ ENTRY art_quick_check_cast
sd $a1, 8($sp)
sd $a0, 0($sp)
jal artIsAssignableFromCode
- nop
+ .cpreturn # Restore gp from t8 in branch delay slot.
+ # t8 may be clobbered in artIsAssignableFromCode.
beq $v0, $zero, .Lthrow_class_cast_exception
ld $ra, 24($sp)
jalr $zero, $ra
@@ -862,6 +880,7 @@ ENTRY art_quick_check_cast
ld $a0, 0($sp)
daddiu $sp, $sp, 32
.cfi_adjust_cfa_offset -32
+ SETUP_GP
SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
dla $t9, artThrowClassCastException
jalr $zero, $t9 # artThrowClassCastException (Class*, Class*, Thread*)
@@ -907,13 +926,13 @@ ENTRY art_quick_aput_obj
daddu $t1, $t1, $t0
sb $t0, ($t1)
jalr $zero, $ra
- nop
+ .cpreturn # Restore gp from t8 in branch delay slot.
.Ldo_aput_null:
dsll $a1, $a1, 2
daddu $t0, $a0, $a1
sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
jalr $zero, $ra
- nop
+ .cpreturn # Restore gp from t8 in branch delay slot.
.Lcheck_assignability:
daddiu $sp, $sp, -64
.cfi_adjust_cfa_offset 64
@@ -926,7 +945,8 @@ ENTRY art_quick_aput_obj
move $a1, $t1
move $a0, $t0
jal artIsAssignableFromCode # (Class*, Class*)
- nop
+ .cpreturn # Restore gp from t8 in branch delay slot.
+ # t8 may be clobbered in artIsAssignableFromCode.
ld $ra, 56($sp)
ld $t9, 24($sp)
ld $a2, 16($sp)
@@ -934,6 +954,7 @@ ENTRY art_quick_aput_obj
ld $a0, 0($sp)
daddiu $sp, $sp, 64
.cfi_adjust_cfa_offset -64
+ SETUP_GP
bne $v0, $zero, .Ldo_aput
nop
SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
@@ -1311,7 +1332,7 @@ ENTRY art_quick_test_suspend
bne $a0, $zero, 1f
daddiu rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
jalr $zero, $ra
- nop
+ .cpreturn # Restore gp from t8 in branch delay slot.
1:
SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
jal artTestSuspendFromCode # (Thread*)
@@ -1350,6 +1371,7 @@ ENTRY art_quick_imt_conflict_trampoline
dsll $t0, 2 # convert target method offset to bytes
daddu $a0, $t0 # get address of target method
dla $t9, art_quick_invoke_interface_trampoline
+ .cpreturn
jalr $zero, $t9
lwu $a0, MIRROR_OBJECT_ARRAY_DATA_OFFSET($a0) # load the target method
END art_quick_imt_conflict_trampoline
@@ -1478,8 +1500,7 @@ END art_quick_instrumentation_entry
.global art_quick_instrumentation_exit
art_quick_instrumentation_exit:
.cfi_startproc
- daddiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
- .cpload $t9
+ SETUP_GP
move $ra, $zero # link register is to here, so clobber with 0 for later checks
SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
move $t0, $sp # remember bottom of caller's frame
@@ -1491,8 +1512,11 @@ art_quick_instrumentation_exit:
mov.d $f15, $f0 # pass fpr result
move $a2, $v0 # pass gpr result
move $a1, $t0 # pass $sp
- jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
move $a0, rSELF # pass Thread::Current
+ jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
+ .cpreturn # Restore gp from t8 in branch delay slot. gp is not used anymore,
+ # and t8 may be clobbered in artInstrumentationMethodExitFromCode.
+
move $t9, $v0 # set aside returned link register
move $ra, $v1 # set link register for deoptimization
ld $v0, 0($sp) # restore return values
diff --git a/runtime/arch/stub_test.cc b/runtime/arch/stub_test.cc
index de7804f759..6291164cc4 100644
--- a/runtime/arch/stub_test.cc
+++ b/runtime/arch/stub_test.cc
@@ -1563,7 +1563,11 @@ static void GetSet32Static(ArtField* f, Thread* self, mirror::ArtMethod* referre
self,
referrer);
+#if defined(__mips__) && defined(__LP64__)
+ EXPECT_EQ(static_cast<uint32_t>(res), values[i]) << "Iteration " << i;
+#else
EXPECT_EQ(res, values[i]) << "Iteration " << i;
+#endif
}
#else
UNUSED(f, self, referrer, test);