Skip to content

Commit

Permalink
Regenerate source for Threaded FFI plugin from VMMaker.oscog-nice.2693
Browse files Browse the repository at this point in the history
Let X64 SysV FFI handle passing/returning union

This can be tricky because we can have union in struct, struct in union etc...
So we must correctly peel the union.
  • Loading branch information
nicolas-cellier-aka-nice committed Feb 1, 2020
1 parent ad4bb0b commit c855035
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 109 deletions.
42 changes: 37 additions & 5 deletions src/plugins/SqueakFFIPrims/ARM32FFIPlugin.c
@@ -1,9 +1,9 @@
/* Automatically generated by
VMPluginCodeGenerator VMMaker.oscog-eem.2692 uuid: 63be09a4-63a7-465c-8f34-48d50ba631f8
VMPluginCodeGenerator VMMaker.oscog-nice.2693 uuid: 645642cf-46fa-4505-85fb-019e1f91c68e
from
ThreadedARM32FFIPlugin VMMaker.oscog-eem.2692 uuid: 63be09a4-63a7-465c-8f34-48d50ba631f8
ThreadedARM32FFIPlugin VMMaker.oscog-nice.2693 uuid: 645642cf-46fa-4505-85fb-019e1f91c68e
*/
static char __buildInfo[] = "ThreadedARM32FFIPlugin VMMaker.oscog-eem.2692 uuid: 63be09a4-63a7-465c-8f34-48d50ba631f8 " __DATE__ ;
static char __buildInfo[] = "ThreadedARM32FFIPlugin VMMaker.oscog-nice.2693 uuid: 645642cf-46fa-4505-85fb-019e1f91c68e " __DATE__ ;



Expand Down Expand Up @@ -241,6 +241,7 @@ static sqInt alignmentOfStructSpecOfLengthStartingAt(unsigned int *specs, sqInt
static sqInt atomicTypeOf(sqInt typeSpec);
static sqInt canReturnInRegistersStructOfSize(sqInt returnStructSize);
static sqInt checkAlignmentOfStructSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize, sqInt startIndex);
static sqInt checkAlignmentOfUnionSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize, sqInt startIndex);
static void cleanupCalloutState(CalloutState *calloutState);
static sqInt encodeStructReturnTypeIn(CalloutState *calloutState);
static sqInt externalFunctionHasStackSizeSlot(void);
Expand Down Expand Up @@ -536,7 +537,7 @@ extern sqInt trueObject(void);
extern
#endif
struct VirtualMachine* interpreterProxy;
static const char *moduleName = "ARM32FFIPlugin VMMaker.oscog-eem.2692 " INT_EXT;
static const char *moduleName = "ARM32FFIPlugin VMMaker.oscog-nice.2693 " INT_EXT;


/*** Macros ***/
Expand Down Expand Up @@ -629,7 +630,7 @@ checkAlignmentOfStructSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize
spec = specs[index];
assert((spec & ((FFIFlagPointer + FFIFlagAtomic) + FFIFlagStructure)) == FFIFlagStructure);
if (isUnionSpecOfLengthStartingAt(specs, specSize, index)) {
return 1;
return checkAlignmentOfUnionSpecOfLengthStartingAt(specs, specSize, startIndex);
}
declaredSize = spec & FFIStructSizeMask;
computedSize = 0;
Expand Down Expand Up @@ -665,6 +666,37 @@ checkAlignmentOfStructSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize
}


/* Check the alignment of a union and return true if correctly aligned.
Union are correctly aligned, but a sub-structure might not. */

/* ThreadedFFIPlugin>>#checkAlignmentOfUnionSpec:OfLength:StartingAt: */
static sqInt
checkAlignmentOfUnionSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize, sqInt startIndex)
{
sqInt index;
unsigned int spec;

index = startIndex;
spec = specs[index];
while (1) {
index += 1;
if (!(index < specSize)) break;
spec = specs[index];
if (spec == FFIFlagStructure) {
return 1;
}
if (!(spec & FFIFlagPointer)) {
if (spec & FFIFlagStructure) {
if (!(checkAlignmentOfStructSpecOfLengthStartingAt(specs, specSize, index))) {
return 0;
}
}
}
}
return 1;
}


/* Free any temporary arg strings. */

/* ThreadedFFIPlugin>>#cleanupCalloutState: */
Expand Down
42 changes: 37 additions & 5 deletions src/plugins/SqueakFFIPrims/ARM64FFIPlugin.c
@@ -1,9 +1,9 @@
/* Automatically generated by
VMPluginCodeGenerator VMMaker.oscog-eem.2692 uuid: 63be09a4-63a7-465c-8f34-48d50ba631f8
VMPluginCodeGenerator VMMaker.oscog-nice.2693 uuid: 645642cf-46fa-4505-85fb-019e1f91c68e
from
ThreadedARM64FFIPlugin VMMaker.oscog-eem.2692 uuid: 63be09a4-63a7-465c-8f34-48d50ba631f8
ThreadedARM64FFIPlugin VMMaker.oscog-nice.2693 uuid: 645642cf-46fa-4505-85fb-019e1f91c68e
*/
static char __buildInfo[] = "ThreadedARM64FFIPlugin VMMaker.oscog-eem.2692 uuid: 63be09a4-63a7-465c-8f34-48d50ba631f8 " __DATE__ ;
static char __buildInfo[] = "ThreadedARM64FFIPlugin VMMaker.oscog-nice.2693 uuid: 645642cf-46fa-4505-85fb-019e1f91c68e " __DATE__ ;



Expand Down Expand Up @@ -240,6 +240,7 @@ static sqInt alignmentOfStructSpecOfLengthStartingAt(unsigned int *specs, sqInt
static sqInt atomicTypeOf(sqInt typeSpec);
static sqInt canReturnInRegistersStructOfSize(sqInt returnStructSize);
static sqInt checkAlignmentOfStructSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize, sqInt startIndex);
static sqInt checkAlignmentOfUnionSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize, sqInt startIndex);
static void cleanupCalloutState(CalloutState *calloutState);
static sqInt encodeStructReturnTypeIn(CalloutState *calloutState);
static sqInt externalFunctionHasStackSizeSlot(void);
Expand Down Expand Up @@ -538,7 +539,7 @@ extern sqInt trueObject(void);
extern
#endif
struct VirtualMachine* interpreterProxy;
static const char *moduleName = "ARM64FFIPlugin VMMaker.oscog-eem.2692 " INT_EXT;
static const char *moduleName = "ARM64FFIPlugin VMMaker.oscog-nice.2693 " INT_EXT;


/*** Macros ***/
Expand Down Expand Up @@ -634,7 +635,7 @@ checkAlignmentOfStructSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize
spec = specs[index];
assert((spec & ((FFIFlagPointer + FFIFlagAtomic) + FFIFlagStructure)) == FFIFlagStructure);
if (isUnionSpecOfLengthStartingAt(specs, specSize, index)) {
return 1;
return checkAlignmentOfUnionSpecOfLengthStartingAt(specs, specSize, startIndex);
}
declaredSize = spec & FFIStructSizeMask;
computedSize = 0;
Expand Down Expand Up @@ -670,6 +671,37 @@ checkAlignmentOfStructSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize
}


/* Check the alignment of a union and return true if correctly aligned.
Union are correctly aligned, but a sub-structure might not. */

/* ThreadedFFIPlugin>>#checkAlignmentOfUnionSpec:OfLength:StartingAt: */
static sqInt
checkAlignmentOfUnionSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize, sqInt startIndex)
{
sqInt index;
unsigned int spec;

index = startIndex;
spec = specs[index];
while (1) {
index += 1;
if (!(index < specSize)) break;
spec = specs[index];
if (spec == FFIFlagStructure) {
return 1;
}
if (!(spec & FFIFlagPointer)) {
if (spec & FFIFlagStructure) {
if (!(checkAlignmentOfStructSpecOfLengthStartingAt(specs, specSize, index))) {
return 0;
}
}
}
}
return 1;
}


/* Free any temporary arg strings. */

/* ThreadedFFIPlugin>>#cleanupCalloutState: */
Expand Down
42 changes: 37 additions & 5 deletions src/plugins/SqueakFFIPrims/IA32FFIPlugin.c
@@ -1,9 +1,9 @@
/* Automatically generated by
VMPluginCodeGenerator VMMaker.oscog-eem.2692 uuid: 63be09a4-63a7-465c-8f34-48d50ba631f8
VMPluginCodeGenerator VMMaker.oscog-nice.2693 uuid: 645642cf-46fa-4505-85fb-019e1f91c68e
from
ThreadedIA32FFIPlugin VMMaker.oscog-eem.2692 uuid: 63be09a4-63a7-465c-8f34-48d50ba631f8
ThreadedIA32FFIPlugin VMMaker.oscog-nice.2693 uuid: 645642cf-46fa-4505-85fb-019e1f91c68e
*/
static char __buildInfo[] = "ThreadedIA32FFIPlugin VMMaker.oscog-eem.2692 uuid: 63be09a4-63a7-465c-8f34-48d50ba631f8 " __DATE__ ;
static char __buildInfo[] = "ThreadedIA32FFIPlugin VMMaker.oscog-nice.2693 uuid: 645642cf-46fa-4505-85fb-019e1f91c68e " __DATE__ ;



Expand Down Expand Up @@ -232,6 +232,7 @@ typedef struct {
static sqInt alignmentOfStructSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize, unsigned int *indexPtr);
static sqInt atomicTypeOf(sqInt typeSpec);
static sqInt checkAlignmentOfStructSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize, sqInt startIndex);
static sqInt checkAlignmentOfUnionSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize, sqInt startIndex);
static void cleanupCalloutState(CalloutState *calloutState);
static sqInt encodeStructReturnTypeIn(CalloutState *calloutState);
static sqInt externalFunctionHasStackSizeSlot(void);
Expand Down Expand Up @@ -527,7 +528,7 @@ extern sqInt trueObject(void);
extern
#endif
struct VirtualMachine* interpreterProxy;
static const char *moduleName = "IA32FFIPlugin VMMaker.oscog-eem.2692 " INT_EXT;
static const char *moduleName = "IA32FFIPlugin VMMaker.oscog-nice.2693 " INT_EXT;


/*** Macros ***/
Expand Down Expand Up @@ -611,7 +612,7 @@ checkAlignmentOfStructSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize
spec = specs[index];
assert((spec & ((FFIFlagPointer + FFIFlagAtomic) + FFIFlagStructure)) == FFIFlagStructure);
if (isUnionSpecOfLengthStartingAt(specs, specSize, index)) {
return 1;
return checkAlignmentOfUnionSpecOfLengthStartingAt(specs, specSize, startIndex);
}
declaredSize = spec & FFIStructSizeMask;
computedSize = 0;
Expand Down Expand Up @@ -647,6 +648,37 @@ checkAlignmentOfStructSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize
}


/* Check the alignment of a union and return true if correctly aligned.
Union are correctly aligned, but a sub-structure might not. */

/* ThreadedFFIPlugin>>#checkAlignmentOfUnionSpec:OfLength:StartingAt: */
static sqInt
checkAlignmentOfUnionSpecOfLengthStartingAt(unsigned int *specs, sqInt specSize, sqInt startIndex)
{
sqInt index;
unsigned int spec;

index = startIndex;
spec = specs[index];
while (1) {
index += 1;
if (!(index < specSize)) break;
spec = specs[index];
if (spec == FFIFlagStructure) {
return 1;
}
if (!(spec & FFIFlagPointer)) {
if (spec & FFIFlagStructure) {
if (!(checkAlignmentOfStructSpecOfLengthStartingAt(specs, specSize, index))) {
return 0;
}
}
}
}
return 1;
}


/* Free any temporary arg strings. */

/* ThreadedFFIPlugin>>#cleanupCalloutState: */
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/SqueakFFIPrims/SqueakFFIPrims.c
@@ -1,5 +1,5 @@
/* Automatically generated by
ThreadedFFIPlugin VMMaker.oscog-eem.2535 uuid: e4217d2b-77f4-4947-ad0a-eabe9fa6b911
ThreadedFFIPlugin VMMaker.oscog-nice.2693 uuid: 645642cf-46fa-4505-85fb-019e1f91c68e
*/

#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7__) || defined(__arm32__) || defined(ARM32) || defined(_M_ARM)
Expand Down

0 comments on commit c855035

Please sign in to comment.