mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
fix mixed marshalling of mixed float/double argument lists on armhf
When we skip a single-precision register to ensure a double-precision load is aligned, we need to remember that in case we see another single-precision argument later on, which we must backfill into that register we skipped according to the ABI.
This commit is contained in:
parent
67ec092e9a
commit
2cb5a74991
@ -147,6 +147,7 @@ dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes,
|
||||
const unsigned VfpCount = 16;
|
||||
uintptr_t vfpTable[VfpCount];
|
||||
unsigned vfpIndex = 0;
|
||||
unsigned vfpBackfillIndex = 0;
|
||||
|
||||
uintptr_t stack[(argumentCount * 8) / BytesPerWord]; // is > argumentSize to account for padding
|
||||
unsigned stackIndex = 0;
|
||||
@ -159,6 +160,7 @@ dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes,
|
||||
{
|
||||
if (vfpIndex + Alignment <= VfpCount) {
|
||||
if (vfpIndex % Alignment) {
|
||||
vfpBackfillIndex = vfpIndex;
|
||||
++ vfpIndex;
|
||||
}
|
||||
|
||||
@ -177,7 +179,10 @@ dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes,
|
||||
} break;
|
||||
|
||||
case FLOAT_TYPE:
|
||||
if (vfpIndex < VfpCount) {
|
||||
if (vfpBackfillIndex) {
|
||||
vfpTable[vfpBackfillIndex] = arguments[ai];
|
||||
vfpBackfillIndex = 0;
|
||||
} else if (vfpIndex < VfpCount) {
|
||||
vfpTable[vfpIndex++] = arguments[ai];
|
||||
} else {
|
||||
stack[stackIndex++] = arguments[ai];
|
||||
|
@ -19,6 +19,12 @@ public class JNI {
|
||||
float a13, float a14, float a15, float a16, float a17, float a18,
|
||||
float a19, float a20);
|
||||
|
||||
private static native double addMix
|
||||
(float a1, double a2, float a3, double a4, float a5, float a6,
|
||||
float a7, float a8, float a9, float a10, float a11, float a12,
|
||||
float a13, float a14, float a15, double a16, float a17, float a18,
|
||||
float a19, float a20);
|
||||
|
||||
public static void main(String[] args) {
|
||||
expect(addDoubles
|
||||
(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, 9.0d, 10.0d, 11.0d,
|
||||
@ -29,5 +35,10 @@ public class JNI {
|
||||
(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f,
|
||||
12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f)
|
||||
== 210.0f);
|
||||
|
||||
expect(addMix
|
||||
(1.0f, 2.0d, 3.0f, 4.0d, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f,
|
||||
12.0f, 13.0f, 14.0f, 15.0f, 16.0d, 17.0f, 18.0f, 19.0f, 20.0f)
|
||||
== 210.0d);
|
||||
}
|
||||
}
|
||||
|
12
test/jni.cpp
12
test/jni.cpp
@ -24,3 +24,15 @@ Java_JNI_addFloats
|
||||
return a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10 + a11 + a12 + a13
|
||||
+ a14 + a15 + a16 + a17 + a18 + a19 + a20;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jdouble JNICALL
|
||||
Java_JNI_addMix
|
||||
(JNIEnv*, jclass,
|
||||
jfloat a1, jdouble a2, jfloat a3, jdouble a4, jfloat a5, jfloat a6,
|
||||
jfloat a7, jfloat a8, jfloat a9, jfloat a10, jfloat a11, jfloat a12,
|
||||
jfloat a13, jfloat a14, jfloat a15, jdouble a16, jfloat a17, jfloat a18,
|
||||
jfloat a19, jfloat a20)
|
||||
{
|
||||
return a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10 + a11 + a12 + a13
|
||||
+ a14 + a15 + a16 + a17 + a18 + a19 + a20;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user