Floating point callee save support in exception delivery.
Untested until we promote floating point values in the compiler.
Change-Id: I20fe66cb59e2f31b21043479dde898326aec668f
diff --git a/src/context_arm.cc b/src/context_arm.cc
index 0d25278..c99c774 100644
--- a/src/context_arm.cc
+++ b/src/context_arm.cc
@@ -13,15 +13,18 @@
for (int i=0; i < 16; i++) {
gprs_[i] = 0xEBAD6070+i;
}
+ for (int i=0; i < 32; i++) {
+ fprs_[i] = 0xEBAD8070+i;
+ }
#endif
- memset(fprs_, 0, sizeof(fprs_));
}
void ArmContext::FillCalleeSaves(const Frame& fr) {
Method* method = fr.GetMethod();
uint32_t core_spills = method->GetCoreSpillMask();
+ uint32_t fp_core_spills = method->GetFpSpillMask();
size_t spill_count = __builtin_popcount(core_spills);
- CHECK_EQ(method->GetFpSpillMask(), 0u);
+ size_t fp_spill_count = __builtin_popcount(fp_core_spills);
if (spill_count > 0) {
// Lowest number spill is furthest away, walk registers and fill into context
int j = 1;
@@ -32,27 +35,28 @@
}
}
}
+ if (fp_spill_count > 0) {
+ // Lowest number spill is furthest away, walk registers and fill into context
+ int j = 1;
+ for(int i = 0; i < 32; i++) {
+ if (((fp_core_spills >> i) & 1) != 0) {
+ fprs_[i] = fr.LoadCalleeSave(spill_count + fp_spill_count - j);
+ j++;
+ }
+ }
+ }
}
void ArmContext::DoLongJump() {
#if defined(__arm__)
- // TODO: Load all GPRs and FPRs, currently the code restores registers R4 to PC
- asm volatile ( "mov %%r0, %0\n"
+ // TODO: Load all GPRs, currently R0 to R3 aren't restored
+ asm volatile ( "vldm %2, {%%s0-%%s31}\n"
+ "mov %%r0, %0\n"
"mov %%r1, %1\n"
- "ldm %%r0, {%%r4, %%r5, %%r6, %%r7,%%r8,%%r9,%%r10,%%r11,%%r12,%%r13,%%r14}\n"
+ "ldm %%r0, {%%r4-%%r14}\n"
"mov %%pc,%%r1\n"
: // output
- : "r"(&gprs_[4]), "r"(gprs_[R15]) // input
-#if 0 // TODO: FPRs..
- "w0" (fprs_[0] ), "w1" (fprs_[1] ), "w2" (fprs_[2] ), "w3" (fprs_[3]),
- "w4" (fprs_[4] ), "w5" (fprs_[5] ), "w6" (fprs_[6] ), "w7" (fprs_[7]),
- "w8" (fprs_[8] ), "w9" (fprs_[9] ), "w10"(fprs_[10]), "w11"(fprs_[11]),
- "w12"(fprs_[12]), "w13"(fprs_[13]), "w14"(fprs_[14]), "w15"(fprs_[15]),
- "w16"(fprs_[16]), "w17"(fprs_[17]), "w18"(fprs_[18]), "w19"(fprs_[19]),
- "w20"(fprs_[20]), "w21"(fprs_[21]), "w22"(fprs_[22]), "w23"(fprs_[23]),
- "w24"(fprs_[24]), "w25"(fprs_[25]), "w26"(fprs_[26]), "w27"(fprs_[27]),
- "w28"(fprs_[28]), "w29"(fprs_[29]), "w30"(fprs_[30]), "w31"(fprs_[31])
-#endif
+ : "r"(&gprs_[4]), "r"(gprs_[R15]), "r"(&fprs_[S0]) // input
:); // clobber
#else
UNIMPLEMENTED(FATAL);
diff --git a/src/context_arm.h b/src/context_arm.h
index e5a5118..31a1a2a 100644
--- a/src/context_arm.h
+++ b/src/context_arm.h
@@ -28,7 +28,7 @@
private:
uintptr_t gprs_[16];
- float fprs_[32];
+ uint32_t fprs_[32];
};
} // namespace arm
diff --git a/src/runtime.cc b/src/runtime.cc
index 42bf874..e1950f3 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -581,8 +581,9 @@
method->SetSignature(intern_table_->InternStrong("()V"));
method->SetCode(NULL, insns, NULL);
if ((insns == kThumb2) || (insns == kArm)) {
- method->SetFrameSizeInBytes(64);
- method->SetReturnPcOffsetInBytes(60);
+ size_t frame_size = (12 /* gprs */ + 32 /* fprs */ + 4 /* data */) * kPointerSize;
+ method->SetFrameSizeInBytes(frame_size);
+ method->SetReturnPcOffsetInBytes(frame_size - kPointerSize);
method->SetCoreSpillMask((1 << art::arm::R1) |
(1 << art::arm::R2) |
(1 << art::arm::R3) |
@@ -595,7 +596,38 @@
(1 << art::arm::R10) |
(1 << art::arm::R11) |
(1 << art::arm::LR));
- method->SetFpSpillMask(0);
+ method->SetFpSpillMask((1 << art::arm::S0) |
+ (1 << art::arm::S1) |
+ (1 << art::arm::S2) |
+ (1 << art::arm::S3) |
+ (1 << art::arm::S4) |
+ (1 << art::arm::S5) |
+ (1 << art::arm::S6) |
+ (1 << art::arm::S7) |
+ (1 << art::arm::S8) |
+ (1 << art::arm::S9) |
+ (1 << art::arm::S10) |
+ (1 << art::arm::S11) |
+ (1 << art::arm::S12) |
+ (1 << art::arm::S13) |
+ (1 << art::arm::S14) |
+ (1 << art::arm::S15) |
+ (1 << art::arm::S16) |
+ (1 << art::arm::S17) |
+ (1 << art::arm::S18) |
+ (1 << art::arm::S19) |
+ (1 << art::arm::S20) |
+ (1 << art::arm::S21) |
+ (1 << art::arm::S22) |
+ (1 << art::arm::S23) |
+ (1 << art::arm::S24) |
+ (1 << art::arm::S25) |
+ (1 << art::arm::S26) |
+ (1 << art::arm::S27) |
+ (1 << art::arm::S28) |
+ (1 << art::arm::S29) |
+ (1 << art::arm::S30) |
+ (1 << art::arm::S31));
} else if (insns == kX86) {
method->SetFrameSizeInBytes(32);
method->SetReturnPcOffsetInBytes(28);
diff --git a/src/runtime_support.S b/src/runtime_support.S
index 1b2c39b..dee8cc4 100644
--- a/src/runtime_support.S
+++ b/src/runtime_support.S
@@ -9,6 +9,13 @@
/* Deliver an exception pending on a thread */
.extern artDeliverPendingException
+ /* Macro that sets up the callee save frame to conform with Runtime::CreateCalleeSaveMethod */
+.macro SETUP_CALLEE_SAVE_FRAME
+ push {r1-r11, lr}
+ vpush {s0-s31}
+ sub sp, #16 @ 4 words of space, bottom word will hold Method*
+.endm
+
.global art_deliver_exception_from_code
/*
* Called by managed code, saves mosts registers (forms basis of long jump context) and passes
@@ -16,8 +23,7 @@
* the bottom of the thread. On entry r0 holds Throwable*
*/
art_deliver_exception_from_code:
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r1, r9 @ pass Thread::Current
mov r2, sp @ pass SP
b artDeliverExceptionFromCode @ artDeliverExceptionFromCode(Throwable*, Thread*, SP)
@@ -28,8 +34,7 @@
* Called by managed code to create and deliver a NullPointerException
*/
art_throw_null_pointer_exception_from_code:
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r0, r9 @ pass Thread::Current
mov r1, sp @ pass SP
b artThrowNullPointerExceptionFromCode @ artThrowNullPointerExceptionFromCode(Thread*, SP)
@@ -40,8 +45,7 @@
* Called by managed code to create and deliver an ArithmeticException
*/
art_throw_div_zero_from_code:
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r0, r9 @ pass Thread::Current
mov r1, sp @ pass SP
b artThrowDivZeroFromCode @ artThrowDivZeroFromCode(Thread*, SP)
@@ -52,8 +56,7 @@
* Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
*/
art_throw_array_bounds_from_code:
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r2, r9 @ pass Thread::Current
mov r3, sp @ pass SP
b artThrowArrayBoundsFromCode @ artThrowArrayBoundsFromCode(index, limit, Thread*, SP)
@@ -61,8 +64,7 @@
.global art_throw_stack_overflow_from_code
.extern artThrowStackOverflowFromCode
art_throw_stack_overflow_from_code:
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r1, r9 @ pass Thread::Current
mov r2, sp @ pass SP
b artThrowStackOverflowFromCode @ artThrowStackOverflowFromCode(method, Thread*, SP)
@@ -70,8 +72,7 @@
.global art_throw_neg_array_size_from_code
.extern artThrowNegArraySizeFromCode
art_throw_neg_array_size_from_code:
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r1, r9 @ pass Thread::Current
mov r2, sp @ pass SP
b artThrowNegArraySizeFromCode @ artThrowNegArraySizeFromCode(size, Thread*, SP)
@@ -79,8 +80,7 @@
.global art_throw_internal_error_from_code
.extern artThrowInternalErrorFromCode
art_throw_internal_error_from_code:
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r1, r9 @ pass Thread::Current
mov r2, sp @ pass SP
b artThrowInternalErrorFromCode @ artThrowInternalErrorFromCode(errnum, Thread*, SP)
@@ -88,8 +88,7 @@
.global art_throw_no_such_method_from_code
.extern artThrowNoSuchMethodFromCode
art_throw_no_such_method_from_code:
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r1, r9 @ pass Thread::Current
mov r2, sp @ pass SP
b artThrowNoSuchMethodFromCode @ artThrowNoSuchMethodFromCode(method_idx, Thread*, SP)
@@ -97,8 +96,7 @@
.global art_throw_runtime_exception_from_code
.extern artThrowRuntimeExceptionFromCode
art_throw_runtime_exception_from_code:
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r1, r9 @ pass Thread::Current
mov r2, sp @ pass SP
b artThrowRuntimeExceptionFromCode @ artThrowRuntimeExceptionFromCode(errnum, Thread*, SP)
@@ -106,8 +104,7 @@
.global art_throw_verification_error_from_code
.extern artThrowVerificationErrorFromCode
art_throw_verification_error_from_code:
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r2, r9 @ pass Thread::Current
mov r3, sp @ pass SP
b artThrowVerificationErrorFromCode @ artThrowVerificationErrorFromCode(src1, ref, Thread*, SP)
@@ -141,8 +138,7 @@
cmp r0, #0 @ did we find the target?
bxne r12 @ tail call to target if so
@ set up for throwing exception
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r0, r9 @ pass Thread::Current
mov r1, sp @ pass SP
b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
@@ -164,8 +160,7 @@
cmp r0, #0 @ success?
moveq pc, lr @ return on success
@ set up for throwing exception
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r0, r9 @ pass Thread::Current
mov r1, sp @ pass SP
b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
@@ -186,8 +181,7 @@
cmp r0, #0 @ success?
moveq pc, lr @ return on success
@ set up for throwing exception
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r0, r9 @ pass Thread::Current
mov r1, sp @ pass SP
b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
@@ -208,8 +202,7 @@
cmp r0, #0 @ success?
moveq pc, lr @ return on success
@ set up for throwing exception
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r0, r9 @ pass Thread::Current
mov r1, sp @ pass SP
b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
@@ -233,8 +226,7 @@
cmp r0, #0 @ success?
moveq pc, lr @ return on success
@ set up for throwing exception
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r0, r9 @ pass Thread::Current
mov r1, sp @ pass SP
b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
@@ -258,8 +250,7 @@
cmp r0, #0 @ success if result is non-null
movne pc, lr @ return on success
@ set up for throwing exception
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r0, r9 @ pass Thread::Current
mov r1, sp @ pass SP
b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
@@ -280,8 +271,7 @@
cmp r0, #0 @ success if result is non-null
movne pc, lr @ return on success
@ set up for throwing exception
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r0, r9 @ pass Thread::Current
mov r1, sp @ pass SP
b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
@@ -302,8 +292,7 @@
cmp r0, #0 @ success if result is non-null
movne pc, lr @ return on success
@ set up for throwing exception
- stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
- sub sp, #16 @ 4 words of space, bottom word will hold Method*
+ SETUP_CALLEE_SAVE_FRAME
mov r0, r9 @ pass Thread::Current
mov r1, sp @ pass SP
b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
diff --git a/src/stub_arm.cc b/src/stub_arm.cc
index 79a581d..a35bfe2 100644
--- a/src/stub_arm.cc
+++ b/src/stub_arm.cc
@@ -18,6 +18,7 @@
RegList save = (1 << R1) | (1 << R2) | (1 << R3) | (1 << R4) | (1 << R5) | (1 << R6) | (1 << R7) |
(1 << R8) | (1 << R9) | (1 << R10) | (1 << R11) | (1 << LR);
__ PushList(save);
+ __ Emit(0xed2d0a20); // vpush {s0-s31}
__ IncreaseFrameSize(16); // 4 words of space, bottom word will hold callee save Method*
// R0 is the Method* already