diff --git a/src/plugins/SqueakFFIPrims/ARM64FFIPlugin.c b/src/plugins/SqueakFFIPrims/ARM64FFIPlugin.c index c22a10c7cf..fc05118487 100644 --- a/src/plugins/SqueakFFIPrims/ARM64FFIPlugin.c +++ b/src/plugins/SqueakFFIPrims/ARM64FFIPlugin.c @@ -1,9 +1,9 @@ /* Automatically generated by - VMPluginCodeGenerator VMMaker.oscog-eem.2498 uuid: f4233232-2c6b-452e-bdab-b814d48cc4a8 + VMPluginCodeGenerator * VMMaker.oscog-eem.2508 uuid: 0562ff91-dad2-41f0-980e-87e9f5bd7eda from - ThreadedARM64FFIPlugin VMMaker.oscog-eem.2498 uuid: f4233232-2c6b-452e-bdab-b814d48cc4a8 + ThreadedARM64FFIPlugin * VMMaker.oscog-eem.2508 uuid: 0562ff91-dad2-41f0-980e-87e9f5bd7eda */ -static char __buildInfo[] = "ThreadedARM64FFIPlugin VMMaker.oscog-eem.2498 uuid: f4233232-2c6b-452e-bdab-b814d48cc4a8 " __DATE__ ; +static char __buildInfo[] = "ThreadedARM64FFIPlugin * VMMaker.oscog-eem.2508 uuid: 0562ff91-dad2-41f0-980e-87e9f5bd7eda " __DATE__ ; @@ -47,6 +47,19 @@ static char __buildInfo[] = "ThreadedARM64FFIPlugin VMMaker.oscog-eem.2498 uuid: # define setsp(sp) asm volatile ("movl %0,%%esp" : : "m"(sp)) # elif defined(__GNUC__) && (defined(__amd64__) || defined(__x86_64__) || defined(__amd64) || defined(__x86_64)) # define setsp(sp) asm volatile ("movq %0,%%rsp" : : "m"(sp)) +# elif defined(__arm64__) || defined(__aarch64__) || defined(ARM64) + /* https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Extended-Asm + * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0024a/index.html + */ +# if __GNUC__ +# define getfp() ({ usqIntptr_t fp; \ + asm volatile ("mov x0, x29" : "=r"(x29) : ); \ + fp; }) +# define getsp() ({ usqIntptr_t sp; \ + asm volatile ("mov x0, sp" : "=r"(sp) : ); \ + sp; }) +# define setsp(sp) asm volatile ("ldr x16, %0 \n\t" "mov sp, x16" : : "m"(sp) ) +# endif # elif defined(__GNUC__) && (defined(__arm__)) # define setsp(sp) asm volatile ("ldr %%sp, %0" : : "m"(sp)) #endif @@ -213,6 +226,7 @@ typedef struct { float floatRegisters [NumFloatRegArgs]; } CalloutState; +#define ThreadedFFICalloutStateForARM64 CalloutState #define ThreadedFFICalloutStateForARM CalloutState #define ThreadedFFICalloutState CalloutState @@ -501,9 +515,9 @@ extern struct VirtualMachine* interpreterProxy; static const char *moduleName = #ifdef SQUEAK_BUILTIN_PLUGIN - "ARM64FFIPlugin VMMaker.oscog-eem.2498 (i)" + "ARM64FFIPlugin * VMMaker.oscog-eem.2508 (i)" #else - "ARM64FFIPlugin VMMaker.oscog-eem.2498 (e)" + "ARM64FFIPlugin * VMMaker.oscog-eem.2508 (e)" #endif ; @@ -514,6 +528,7 @@ static const char *moduleName = #define dispatchFunctionPointer(aFunctionPointer) (aFunctionPointer)() #define dispatchFunctionPointerwithwithwithwith(aFunctionPointer, int1, int2, int3, int4) (aFunctionPointer)(int1, int2, int3, int4) #define dispatchFunctionPointerwithwithwithwithwithwith(aFunctionPointer, int1, int2, int3, int4, int5, int6) (aFunctionPointer)(int1, int2, int3, int4, int5, int6) +#define dispatchFunctionPointerwithwithwithwithwithwithwithwith(aFunctionPointer, int1, int2, int3, int4, int5, int6, int7, int8) (aFunctionPointer)(int1, int2, int3, int4, int5, int6, int7, int8) #define ffiAlloc(bytes) (usqInt)malloc(bytes) #define ffiFree(pointer) free((void *)(pointer)) #define isCalleePopsConvention(callType) (PLATFORM_API_USES_CALLEE_POPS_CONVENTION && (callType) == FFICallTypeApi) @@ -734,14 +749,8 @@ ffiArgByValuein(sqInt oop, CalloutState *calloutState) if (atomicType == FFITypeSingleFloat) { /* begin ffiPushSingleFloat:in: */ if (((calloutState->floatRegisterIndex)) < NumFloatRegArgs) { - if (((calloutState->backfillFloatRegisterIndex)) > 0) { - ((calloutState->floatRegisters))[(calloutState->backfillFloatRegisterIndex)] = floatValue; - (calloutState->backfillFloatRegisterIndex = 0); - } - else { - ((calloutState->floatRegisters))[(calloutState->floatRegisterIndex)] = floatValue; - (calloutState->floatRegisterIndex = ((calloutState->floatRegisterIndex)) + 1); - } + ((calloutState->floatRegisters))[(calloutState->floatRegisterIndex)] = (((double) floatValue)); + (calloutState->floatRegisterIndex = ((calloutState->floatRegisterIndex)) + 2); } else { if ((((calloutState->currentArg)) + BytesPerWord) > ((calloutState->limit))) { @@ -755,20 +764,16 @@ ffiArgByValuein(sqInt oop, CalloutState *calloutState) else { /* begin ffiPushDoubleFloat:in: */ if (((calloutState->floatRegisterIndex)) < (NumFloatRegArgs - 1)) { - if ((((calloutState->floatRegisterIndex)) & 1) == 1) { - (calloutState->backfillFloatRegisterIndex = (calloutState->floatRegisterIndex)); - (calloutState->floatRegisterIndex = ((calloutState->floatRegisterIndex)) + 1); - } (((double*) ((&(((calloutState->floatRegisters))[(calloutState->floatRegisterIndex)])))))[0] = floatValue; (calloutState->floatRegisterIndex = ((calloutState->floatRegisterIndex)) + 2); } else { - if ((((calloutState->currentArg)) + 8) > ((calloutState->limit))) { + if ((((calloutState->currentArg)) + BytesPerWord) > ((calloutState->limit))) { return FFIErrorCallFrameTooBig; } (calloutState->floatRegisterIndex = NumFloatRegArgs); storeFloatAtPointerfrom((calloutState->currentArg), floatValue); - (calloutState->currentArg = ((calloutState->currentArg)) + 8); + (calloutState->currentArg = ((calloutState->currentArg)) + BytesPerWord); } return 0; } @@ -896,7 +901,7 @@ ffiArgumentSpecClassin(sqInt oop, sqInt argSpec, sqInt argClass, CalloutState *c structSize = ((calloutState->ffiArgHeader)) & FFIStructSizeMask; argSpec2 = (calloutState->ffiArgSpec); argSpecSize = (calloutState->ffiArgSpecSize); - availableRegisterSpace = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * 4; + availableRegisterSpace = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * BytesPerWord; stackPartSize = structSize; if (availableRegisterSpace > 0) { if (structSize <= availableRegisterSpace) { @@ -952,7 +957,7 @@ ffiArgumentSpecClassin(sqInt oop, sqInt argSpec, sqInt argClass, CalloutState *c structSize1 = ((calloutState->ffiArgHeader)) & FFIStructSizeMask; argSpec1 = (calloutState->ffiArgSpec); argSpecSize1 = (calloutState->ffiArgSpecSize); - availableRegisterSpace1 = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * 4; + availableRegisterSpace1 = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * BytesPerWord; stackPartSize1 = structSize1; if (availableRegisterSpace1 > 0) { if (structSize1 <= availableRegisterSpace1) { @@ -1402,14 +1407,8 @@ ffiArgumentSpecClassin(sqInt oop, sqInt argSpec, sqInt argClass, CalloutState *c if (atomicType2 == FFITypeSingleFloat) { /* begin ffiPushSingleFloat:in: */ if (((calloutState->floatRegisterIndex)) < NumFloatRegArgs) { - if (((calloutState->backfillFloatRegisterIndex)) > 0) { - ((calloutState->floatRegisters))[(calloutState->backfillFloatRegisterIndex)] = floatValue; - (calloutState->backfillFloatRegisterIndex = 0); - } - else { - ((calloutState->floatRegisters))[(calloutState->floatRegisterIndex)] = floatValue; - (calloutState->floatRegisterIndex = ((calloutState->floatRegisterIndex)) + 1); - } + ((calloutState->floatRegisters))[(calloutState->floatRegisterIndex)] = (((double) floatValue)); + (calloutState->floatRegisterIndex = ((calloutState->floatRegisterIndex)) + 2); } else { if ((((calloutState->currentArg)) + BytesPerWord) > ((calloutState->limit))) { @@ -1423,20 +1422,16 @@ ffiArgumentSpecClassin(sqInt oop, sqInt argSpec, sqInt argClass, CalloutState *c else { /* begin ffiPushDoubleFloat:in: */ if (((calloutState->floatRegisterIndex)) < (NumFloatRegArgs - 1)) { - if ((((calloutState->floatRegisterIndex)) & 1) == 1) { - (calloutState->backfillFloatRegisterIndex = (calloutState->floatRegisterIndex)); - (calloutState->floatRegisterIndex = ((calloutState->floatRegisterIndex)) + 1); - } (((double*) ((&(((calloutState->floatRegisters))[(calloutState->floatRegisterIndex)])))))[0] = floatValue; (calloutState->floatRegisterIndex = ((calloutState->floatRegisterIndex)) + 2); } else { - if ((((calloutState->currentArg)) + 8) > ((calloutState->limit))) { + if ((((calloutState->currentArg)) + BytesPerWord) > ((calloutState->limit))) { return FFIErrorCallFrameTooBig; } (calloutState->floatRegisterIndex = NumFloatRegArgs); storeFloatAtPointerfrom((calloutState->currentArg), floatValue); - (calloutState->currentArg = ((calloutState->currentArg)) + 8); + (calloutState->currentArg = ((calloutState->currentArg)) + BytesPerWord); } return 0; } @@ -1729,7 +1724,7 @@ ffiAtomicStructByReferenceClassin(sqInt oop, sqInt oopClass, CalloutState *callo ffiCall:WithFlags:NumArgs:Args:AndTypes: */ - /* ThreadedARMFFIPlugin>>#ffiCalloutTo:SpecOnStack:in: */ + /* ThreadedARM64FFIPlugin>>#ffiCalloutTo:SpecOnStack:in: */ static sqInt ffiCalloutToSpecOnStackin(void *procAddr, sqInt specOnStack, CalloutState *calloutState) { @@ -1787,12 +1782,12 @@ ffiCalloutToSpecOnStackin(void *procAddr, sqInt specOnStack, CalloutState *callo atomicType = ((usqInt) (typeSpec & FFIAtomicTypeMask)) >> FFIAtomicTypeShift; if ((((usqInt) atomicType) >> 1) == (((usqInt) FFITypeSingleFloat) >> 1)) { if (atomicType == FFITypeSingleFloat) { - floatRet = dispatchFunctionPointerwithwithwithwith(((float (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) procAddr), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3]); + floatRet = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((float (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) procAddr), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3], ((calloutState->integerRegisters))[4], ((calloutState->integerRegisters))[5], ((calloutState->integerRegisters))[6], ((calloutState->integerRegisters))[7]); } else { /* atomicType = FFITypeDoubleFloat */ - floatRet = dispatchFunctionPointerwithwithwithwith(((double (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) procAddr), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3]); + floatRet = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((double (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) procAddr), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3], ((calloutState->integerRegisters))[4], ((calloutState->integerRegisters))[5], ((calloutState->integerRegisters))[6], ((calloutState->integerRegisters))[7]); } if (isCalleePopsConvention((calloutState->callFlags))) { setsp((calloutState->argVector)); @@ -1802,7 +1797,7 @@ ffiCalloutToSpecOnStackin(void *procAddr, sqInt specOnStack, CalloutState *callo } /* undo any callee argument pops because it may confuse stack management with the alloca. */ - intRet = dispatchFunctionPointerwithwithwithwith(((usqIntptr_t (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) procAddr), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3]); + intRet = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((usqIntptr_t (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) procAddr), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3], ((calloutState->integerRegisters))[4], ((calloutState->integerRegisters))[5], ((calloutState->integerRegisters))[6], ((calloutState->integerRegisters))[7]); if (isCalleePopsConvention((calloutState->callFlags))) { setsp((calloutState->argVector)); } @@ -2224,12 +2219,12 @@ ffiCallArgArrayOrNilNumArgs(sqInt externalFunction, sqInt argArrayOrNil, sqInt n atomicType = ((usqInt) (typeSpec & FFIAtomicTypeMask)) >> FFIAtomicTypeShift; if ((((usqInt) atomicType) >> 1) == (((usqInt) FFITypeSingleFloat) >> 1)) { if (atomicType == FFITypeSingleFloat) { - floatRet = dispatchFunctionPointerwithwithwithwith(((float (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3]); + floatRet = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((float (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3], ((calloutState->integerRegisters))[4], ((calloutState->integerRegisters))[5], ((calloutState->integerRegisters))[6], ((calloutState->integerRegisters))[7]); } else { /* atomicType = FFITypeDoubleFloat */ - floatRet = dispatchFunctionPointerwithwithwithwith(((double (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3]); + floatRet = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((double (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3], ((calloutState->integerRegisters))[4], ((calloutState->integerRegisters))[5], ((calloutState->integerRegisters))[6], ((calloutState->integerRegisters))[7]); } if (isCalleePopsConvention((calloutState->callFlags))) { setsp((calloutState->argVector)); @@ -2240,7 +2235,7 @@ ffiCallArgArrayOrNilNumArgs(sqInt externalFunction, sqInt argArrayOrNil, sqInt n } /* undo any callee argument pops because it may confuse stack management with the alloca. */ - intRet = dispatchFunctionPointerwithwithwithwith(((usqIntptr_t (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3]); + intRet = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((usqIntptr_t (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3], ((calloutState->integerRegisters))[4], ((calloutState->integerRegisters))[5], ((calloutState->integerRegisters))[6], ((calloutState->integerRegisters))[7]); if (isCalleePopsConvention((calloutState->callFlags))) { setsp((calloutState->argVector)); } @@ -2961,12 +2956,12 @@ ffiPushSignedCharin(sqInt value, CalloutState *calloutState) return 0; } - /* ThreadedARMFFIPlugin>>#ffiPushSignedInt:in: */ + /* ThreadedARM64FFIPlugin>>#ffiPushSignedInt:in: */ static sqInt ffiPushSignedIntin(sqInt value, CalloutState *calloutState) { if (((calloutState->integerRegisterIndex)) < NumIntRegArgs) { - ((calloutState->integerRegisters))[(calloutState->integerRegisterIndex)] = value; + ((calloutState->integerRegisters))[(calloutState->integerRegisterIndex)] = (((sqLong) value)); (calloutState->integerRegisterIndex = ((calloutState->integerRegisterIndex)) + 1); } else { @@ -3005,42 +3000,34 @@ ffiPushSignedLongLongOopin(sqInt oop, CalloutState *calloutState) } } /* begin ffiPushSignedLongLong:in: */ - if (((calloutState->integerRegisterIndex)) < (NumIntRegArgs - 1)) { - (calloutState->integerRegisterIndex = (((((calloutState->integerRegisterIndex)) + 1) | 1) - 1)); - ((calloutState->integerRegisters))[(calloutState->integerRegisterIndex)] = (((usqInt) value)); - ((calloutState->integerRegisters))[((calloutState->integerRegisterIndex)) + 1] = (((usqInt) (((unsigned sqLong)value) >> 32))); - (calloutState->integerRegisterIndex = ((calloutState->integerRegisterIndex)) + 2); + if (((calloutState->integerRegisterIndex)) < NumIntRegArgs) { + ((calloutState->integerRegisters))[(calloutState->integerRegisterIndex)] = (((sqLong) value)); + (calloutState->integerRegisterIndex = ((calloutState->integerRegisterIndex)) + 1); } else { - if ((((calloutState->currentArg)) + 8) > ((calloutState->limit))) { + if ((((calloutState->currentArg)) + BytesPerWord) > ((calloutState->limit))) { return FFIErrorCallFrameTooBig; } - (calloutState->integerRegisterIndex = NumIntRegArgs); - longAtput((calloutState->currentArg), ((usqInt) value)); - longAtput(((calloutState->currentArg)) + BytesPerWord, ((usqInt) (((unsigned sqLong)value) >> 32))); - (calloutState->currentArg = ((calloutState->currentArg)) + 8); + longAtput((calloutState->currentArg), value); + (calloutState->currentArg = ((calloutState->currentArg)) + BytesPerWord); } return 0; } - /* ThreadedARMFFIPlugin>>#ffiPushSignedLongLong:in: */ + /* ThreadedARM64FFIPlugin>>#ffiPushSignedLongLong:in: */ static sqInt ffiPushSignedLongLongin(sqLong value, CalloutState *calloutState) { - if (((calloutState->integerRegisterIndex)) < (NumIntRegArgs - 1)) { - (calloutState->integerRegisterIndex = (((((calloutState->integerRegisterIndex)) + 1) | 1) - 1)); - ((calloutState->integerRegisters))[(calloutState->integerRegisterIndex)] = (((usqInt) value)); - ((calloutState->integerRegisters))[((calloutState->integerRegisterIndex)) + 1] = (((usqInt) (((unsigned sqLong)value) >> 32))); - (calloutState->integerRegisterIndex = ((calloutState->integerRegisterIndex)) + 2); + if (((calloutState->integerRegisterIndex)) < NumIntRegArgs) { + ((calloutState->integerRegisters))[(calloutState->integerRegisterIndex)] = (((sqLong) value)); + (calloutState->integerRegisterIndex = ((calloutState->integerRegisterIndex)) + 1); } else { - if ((((calloutState->currentArg)) + 8) > ((calloutState->limit))) { + if ((((calloutState->currentArg)) + BytesPerWord) > ((calloutState->limit))) { return FFIErrorCallFrameTooBig; } - (calloutState->integerRegisterIndex = NumIntRegArgs); - longAtput((calloutState->currentArg), ((usqInt) value)); - longAtput(((calloutState->currentArg)) + BytesPerWord, ((usqInt) (((unsigned sqLong)value) >> 32))); - (calloutState->currentArg = ((calloutState->currentArg)) + 8); + longAtput((calloutState->currentArg), value); + (calloutState->currentArg = ((calloutState->currentArg)) + BytesPerWord); } return 0; } @@ -3132,7 +3119,7 @@ ffiPushStructureContentsOfin(sqInt oop, CalloutState *calloutState) structSize = ((calloutState->ffiArgHeader)) & FFIStructSizeMask; argSpec = (calloutState->ffiArgSpec); argSpecSize = (calloutState->ffiArgSpecSize); - availableRegisterSpace = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * 4; + availableRegisterSpace = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * BytesPerWord; stackPartSize = structSize; if (availableRegisterSpace > 0) { if (structSize <= availableRegisterSpace) { @@ -3188,7 +3175,7 @@ ffiPushStructureContentsOfin(sqInt oop, CalloutState *calloutState) structSize1 = ((calloutState->ffiArgHeader)) & FFIStructSizeMask; argSpec1 = (calloutState->ffiArgSpec); argSpecSize1 = (calloutState->ffiArgSpecSize); - availableRegisterSpace1 = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * 4; + availableRegisterSpace1 = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * BytesPerWord; stackPartSize1 = structSize1; if (availableRegisterSpace1 > 0) { if (structSize1 <= availableRegisterSpace1) { @@ -3246,7 +3233,7 @@ ffiPushStructureContentsOfin(sqInt oop, CalloutState *calloutState) return FFIErrorBadArg; } - /* ThreadedARMFFIPlugin>>#ffiPushStructure:ofSize:typeSpec:ofLength:in: */ + /* ThreadedARM64FFIPlugin>>#ffiPushStructure:ofSize:typeSpec:ofLength:in: */ static sqInt ffiPushStructureofSizetypeSpecofLengthin(void *pointer, sqInt structSize, sqInt *argSpec, sqInt argSpecSize, CalloutState *calloutState) { @@ -3254,7 +3241,7 @@ ffiPushStructureofSizetypeSpecofLengthin(void *pointer, sqInt structSize, sqInt sqInt roundedSize; sqInt stackPartSize; - availableRegisterSpace = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * 4; + availableRegisterSpace = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * BytesPerWord; stackPartSize = structSize; if (availableRegisterSpace > 0) { if (structSize <= availableRegisterSpace) { @@ -3325,12 +3312,12 @@ ffiPushUnsignedCharin(sqInt value, CalloutState *calloutState) return 0; } - /* ThreadedARMFFIPlugin>>#ffiPushUnsignedInt:in: */ + /* ThreadedARM64FFIPlugin>>#ffiPushUnsignedInt:in: */ static sqInt ffiPushUnsignedIntin(sqInt value, CalloutState *calloutState) { if (((calloutState->integerRegisterIndex)) < NumIntRegArgs) { - ((calloutState->integerRegisters))[(calloutState->integerRegisterIndex)] = value; + ((calloutState->integerRegisters))[(calloutState->integerRegisterIndex)] = (((usqLong) value)); (calloutState->integerRegisterIndex = ((calloutState->integerRegisterIndex)) + 1); } else { @@ -3369,42 +3356,34 @@ ffiPushUnsignedLongLongOopin(sqInt oop, CalloutState *calloutState) } } /* begin ffiPushUnsignedLongLong:in: */ - if (((calloutState->integerRegisterIndex)) < (NumIntRegArgs - 1)) { - (calloutState->integerRegisterIndex = (((((calloutState->integerRegisterIndex)) + 1) | 1) - 1)); - ((calloutState->integerRegisters))[(calloutState->integerRegisterIndex)] = (((usqInt) value)); - ((calloutState->integerRegisters))[((calloutState->integerRegisterIndex)) + 1] = (((usqInt) (value >> 32))); - (calloutState->integerRegisterIndex = ((calloutState->integerRegisterIndex)) + 2); + if (((calloutState->integerRegisterIndex)) < NumIntRegArgs) { + ((calloutState->integerRegisters))[(calloutState->integerRegisterIndex)] = (((usqLong) value)); + (calloutState->integerRegisterIndex = ((calloutState->integerRegisterIndex)) + 1); } else { - if ((((calloutState->currentArg)) + 8) > ((calloutState->limit))) { + if ((((calloutState->currentArg)) + BytesPerWord) > ((calloutState->limit))) { return FFIErrorCallFrameTooBig; } - (calloutState->integerRegisterIndex = NumIntRegArgs); - longAtput((calloutState->currentArg), ((usqInt) value)); - longAtput(((calloutState->currentArg)) + BytesPerWord, ((usqInt) (value >> 32))); - (calloutState->currentArg = ((calloutState->currentArg)) + 8); + longAtput((calloutState->currentArg), value); + (calloutState->currentArg = ((calloutState->currentArg)) + BytesPerWord); } return 0; } - /* ThreadedARMFFIPlugin>>#ffiPushUnsignedLongLong:in: */ + /* ThreadedARM64FFIPlugin>>#ffiPushUnsignedLongLong:in: */ static sqInt ffiPushUnsignedLongLongin(usqLong value, CalloutState *calloutState) { - if (((calloutState->integerRegisterIndex)) < (NumIntRegArgs - 1)) { - (calloutState->integerRegisterIndex = (((((calloutState->integerRegisterIndex)) + 1) | 1) - 1)); - ((calloutState->integerRegisters))[(calloutState->integerRegisterIndex)] = (((usqInt) value)); - ((calloutState->integerRegisters))[((calloutState->integerRegisterIndex)) + 1] = (((usqInt) (value >> 32))); - (calloutState->integerRegisterIndex = ((calloutState->integerRegisterIndex)) + 2); + if (((calloutState->integerRegisterIndex)) < NumIntRegArgs) { + ((calloutState->integerRegisters))[(calloutState->integerRegisterIndex)] = (((usqLong) value)); + (calloutState->integerRegisterIndex = ((calloutState->integerRegisterIndex)) + 1); } else { - if ((((calloutState->currentArg)) + 8) > ((calloutState->limit))) { + if ((((calloutState->currentArg)) + BytesPerWord) > ((calloutState->limit))) { return FFIErrorCallFrameTooBig; } - (calloutState->integerRegisterIndex = NumIntRegArgs); - longAtput((calloutState->currentArg), ((usqInt) value)); - longAtput(((calloutState->currentArg)) + BytesPerWord, ((usqInt) (value >> 32))); - (calloutState->currentArg = ((calloutState->currentArg)) + 8); + longAtput((calloutState->currentArg), value); + (calloutState->currentArg = ((calloutState->currentArg)) + BytesPerWord); } return 0; } @@ -4081,12 +4060,12 @@ primitiveCallout(void) atomicType = ((usqInt) (typeSpec & FFIAtomicTypeMask)) >> FFIAtomicTypeShift; if ((((usqInt) atomicType) >> 1) == (((usqInt) FFITypeSingleFloat) >> 1)) { if (atomicType == FFITypeSingleFloat) { - floatRet = dispatchFunctionPointerwithwithwithwith(((float (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3]); + floatRet = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((float (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3], ((calloutState->integerRegisters))[4], ((calloutState->integerRegisters))[5], ((calloutState->integerRegisters))[6], ((calloutState->integerRegisters))[7]); } else { /* atomicType = FFITypeDoubleFloat */ - floatRet = dispatchFunctionPointerwithwithwithwith(((double (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3]); + floatRet = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((double (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3], ((calloutState->integerRegisters))[4], ((calloutState->integerRegisters))[5], ((calloutState->integerRegisters))[6], ((calloutState->integerRegisters))[7]); } if (isCalleePopsConvention((calloutState->callFlags))) { setsp((calloutState->argVector)); @@ -4097,7 +4076,7 @@ primitiveCallout(void) } /* undo any callee argument pops because it may confuse stack management with the alloca. */ - intRet = dispatchFunctionPointerwithwithwithwith(((usqIntptr_t (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3]); + intRet = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((usqIntptr_t (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3], ((calloutState->integerRegisters))[4], ((calloutState->integerRegisters))[5], ((calloutState->integerRegisters))[6], ((calloutState->integerRegisters))[7]); if (isCalleePopsConvention((calloutState->callFlags))) { setsp((calloutState->argVector)); } @@ -4484,12 +4463,12 @@ primitiveCallout(void) atomicType2 = ((usqInt) (typeSpec2 & FFIAtomicTypeMask)) >> FFIAtomicTypeShift; if ((((usqInt) atomicType2) >> 1) == (((usqInt) FFITypeSingleFloat) >> 1)) { if (atomicType2 == FFITypeSingleFloat) { - floatRet1 = dispatchFunctionPointerwithwithwithwith(((float (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address2))), ((calloutState1->integerRegisters))[0], ((calloutState1->integerRegisters))[1], ((calloutState1->integerRegisters))[2], ((calloutState1->integerRegisters))[3]); + floatRet1 = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((float (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address2))), ((calloutState1->integerRegisters))[0], ((calloutState1->integerRegisters))[1], ((calloutState1->integerRegisters))[2], ((calloutState1->integerRegisters))[3], ((calloutState1->integerRegisters))[4], ((calloutState1->integerRegisters))[5], ((calloutState1->integerRegisters))[6], ((calloutState1->integerRegisters))[7]); } else { /* atomicType = FFITypeDoubleFloat */ - floatRet1 = dispatchFunctionPointerwithwithwithwith(((double (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address2))), ((calloutState1->integerRegisters))[0], ((calloutState1->integerRegisters))[1], ((calloutState1->integerRegisters))[2], ((calloutState1->integerRegisters))[3]); + floatRet1 = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((double (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address2))), ((calloutState1->integerRegisters))[0], ((calloutState1->integerRegisters))[1], ((calloutState1->integerRegisters))[2], ((calloutState1->integerRegisters))[3], ((calloutState1->integerRegisters))[4], ((calloutState1->integerRegisters))[5], ((calloutState1->integerRegisters))[6], ((calloutState1->integerRegisters))[7]); } if (isCalleePopsConvention((calloutState1->callFlags))) { setsp((calloutState1->argVector)); @@ -4500,7 +4479,7 @@ primitiveCallout(void) } /* undo any callee argument pops because it may confuse stack management with the alloca. */ - intRet1 = dispatchFunctionPointerwithwithwithwith(((usqIntptr_t (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address2))), ((calloutState1->integerRegisters))[0], ((calloutState1->integerRegisters))[1], ((calloutState1->integerRegisters))[2], ((calloutState1->integerRegisters))[3]); + intRet1 = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((usqIntptr_t (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address2))), ((calloutState1->integerRegisters))[0], ((calloutState1->integerRegisters))[1], ((calloutState1->integerRegisters))[2], ((calloutState1->integerRegisters))[3], ((calloutState1->integerRegisters))[4], ((calloutState1->integerRegisters))[5], ((calloutState1->integerRegisters))[6], ((calloutState1->integerRegisters))[7]); if (isCalleePopsConvention((calloutState1->callFlags))) { setsp((calloutState1->argVector)); } @@ -5021,12 +5000,12 @@ primitiveCalloutWithArgs(void) atomicType = ((usqInt) (typeSpec & FFIAtomicTypeMask)) >> FFIAtomicTypeShift; if ((((usqInt) atomicType) >> 1) == (((usqInt) FFITypeSingleFloat) >> 1)) { if (atomicType == FFITypeSingleFloat) { - floatRet = dispatchFunctionPointerwithwithwithwith(((float (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3]); + floatRet = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((float (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3], ((calloutState->integerRegisters))[4], ((calloutState->integerRegisters))[5], ((calloutState->integerRegisters))[6], ((calloutState->integerRegisters))[7]); } else { /* atomicType = FFITypeDoubleFloat */ - floatRet = dispatchFunctionPointerwithwithwithwith(((double (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3]); + floatRet = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((double (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3], ((calloutState->integerRegisters))[4], ((calloutState->integerRegisters))[5], ((calloutState->integerRegisters))[6], ((calloutState->integerRegisters))[7]); } if (isCalleePopsConvention((calloutState->callFlags))) { setsp((calloutState->argVector)); @@ -5037,7 +5016,7 @@ primitiveCalloutWithArgs(void) } /* undo any callee argument pops because it may confuse stack management with the alloca. */ - intRet = dispatchFunctionPointerwithwithwithwith(((usqIntptr_t (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3]); + intRet = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((usqIntptr_t (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address))), ((calloutState->integerRegisters))[0], ((calloutState->integerRegisters))[1], ((calloutState->integerRegisters))[2], ((calloutState->integerRegisters))[3], ((calloutState->integerRegisters))[4], ((calloutState->integerRegisters))[5], ((calloutState->integerRegisters))[6], ((calloutState->integerRegisters))[7]); if (isCalleePopsConvention((calloutState->callFlags))) { setsp((calloutState->argVector)); } @@ -5430,12 +5409,12 @@ primitiveCalloutWithArgs(void) atomicType2 = ((usqInt) (typeSpec2 & FFIAtomicTypeMask)) >> FFIAtomicTypeShift; if ((((usqInt) atomicType2) >> 1) == (((usqInt) FFITypeSingleFloat) >> 1)) { if (atomicType2 == FFITypeSingleFloat) { - floatRet1 = dispatchFunctionPointerwithwithwithwith(((float (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address2))), ((calloutState1->integerRegisters))[0], ((calloutState1->integerRegisters))[1], ((calloutState1->integerRegisters))[2], ((calloutState1->integerRegisters))[3]); + floatRet1 = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((float (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address2))), ((calloutState1->integerRegisters))[0], ((calloutState1->integerRegisters))[1], ((calloutState1->integerRegisters))[2], ((calloutState1->integerRegisters))[3], ((calloutState1->integerRegisters))[4], ((calloutState1->integerRegisters))[5], ((calloutState1->integerRegisters))[6], ((calloutState1->integerRegisters))[7]); } else { /* atomicType = FFITypeDoubleFloat */ - floatRet1 = dispatchFunctionPointerwithwithwithwith(((double (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address2))), ((calloutState1->integerRegisters))[0], ((calloutState1->integerRegisters))[1], ((calloutState1->integerRegisters))[2], ((calloutState1->integerRegisters))[3]); + floatRet1 = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((double (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address2))), ((calloutState1->integerRegisters))[0], ((calloutState1->integerRegisters))[1], ((calloutState1->integerRegisters))[2], ((calloutState1->integerRegisters))[3], ((calloutState1->integerRegisters))[4], ((calloutState1->integerRegisters))[5], ((calloutState1->integerRegisters))[6], ((calloutState1->integerRegisters))[7]); } if (isCalleePopsConvention((calloutState1->callFlags))) { setsp((calloutState1->argVector)); @@ -5446,7 +5425,7 @@ primitiveCalloutWithArgs(void) } /* undo any callee argument pops because it may confuse stack management with the alloca. */ - intRet1 = dispatchFunctionPointerwithwithwithwith(((usqIntptr_t (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address2))), ((calloutState1->integerRegisters))[0], ((calloutState1->integerRegisters))[1], ((calloutState1->integerRegisters))[2], ((calloutState1->integerRegisters))[3]); + intRet1 = dispatchFunctionPointerwithwithwithwithwithwithwithwith(((usqIntptr_t (*)(sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t, sqIntptr_t)) (((void *) address2))), ((calloutState1->integerRegisters))[0], ((calloutState1->integerRegisters))[1], ((calloutState1->integerRegisters))[2], ((calloutState1->integerRegisters))[3], ((calloutState1->integerRegisters))[4], ((calloutState1->integerRegisters))[5], ((calloutState1->integerRegisters))[6], ((calloutState1->integerRegisters))[7]); if (isCalleePopsConvention((calloutState1->callFlags))) { setsp((calloutState1->argVector)); }