Greetings,
Made the mistake of running the FFI unit tests in Cuis, which directly led me down the rabbit hole.
Think I have made some progress in understanding, but don't yet see how to teach VMMaker to get code from register.
Here is crux of one of my investigations: ==============================
===== C source ======sqFFITestFuncs.c
/* test passing and returning doubles */ EXPORT(double) ffiTestDoubles(double d1, double d2) { printf("The two floats are %f and %f\n", (float)d1, (float)d2); return d1+d2; }
===== ASM === from objectdump -d 0000000000000ac0 <ffiTestDoubles>: ac0: a9be7bfd stp x29, x30, [sp, #-32]! ac4: 90000000 adrp x0, 0 <ffiTestChars> ac8: 91000000 add x0, x0, #0x0 acc: 910003fd mov x29, sp ad0: 6d0127e8 stp d8, d9, [sp, #16] ad4: 1e604009 fmov d9, d0 ad8: 1e604028 fmov d8, d1 adc: 1e624000 fcvt s0, d0 ae0: 1e624021 fcvt s1, d1 ae4: 1e22c000 fcvt d0, s0 ae8: 1e22c021 fcvt d1, s1 aec: 94000000 bl 0 <printf> af0: 1e682920 fadd d0, d9, d8 af4: 6d4127e8 ldp d8, d9, [sp, #16] af8: a8c27bfd ldp x29, x30, [sp], #32 afc: d65f03c0 ret // result returned in d0 (NB: _not_ x0) =================Cuis Workspace (after FFI unit test)=========== FFITestLibrary ffiTestDoubles: 30.0 with: 65.0. "--> 00.00558872584952 -- should be 95.0" =================Terminal Output=================================== The two floats are 30.000000 and 65.000000 =================================================================== FFIPlugin>>ffiCreateReturnOop: retVal ...
^interpreterProxy floatObjectOf: (self ffiReturnFloatValue). ==================================================================== My theory: return value taken from x0, not d0.==============================================Is this a sensible interpretation?Any hints from Heloise? Thanks much,-KenDPS: Merry Christmas! (I would use Xmas, but who knows what is lurking under the X? 8^)
Hi Ken,
I have a suggestion. Instead of initializing WordSize from Smalltalk wordSize I would create two subclasses with a wordSize method, hardcoded as ^4 and ^8 respectively. We want to be able to simulate any of the processors on any platform, hence we can simulate x64 on the 32-bit version and x86 on the 64-bit version as well as 32-bit processors on 32-bit versions and 64-bit processors on 64-bit versions. So structuring the ARM FFI as an abstract subclass with a subclass responsibility for wordSize, along with two subclasses for 64 & 32 bits will give us that flexibility.
Where a wordSize define would make sense would be in platforms/Cross/plugins/IA32ABI/*ARM*, although you might want to review the code first and see if #ifdef or splitting the files into 32 and 64-bit versions is cleaner.
On Sun, Dec 23, 2018 at 8:06 AM ken.dickey@whidbey.com wrote:
Rats!
Can't even use this webmail thingie...
[the _other_ changes file]
Cheers, -KenD
Sorry.
See, if you don't give me VMMaker write access, you won't get a certain class of dumb mistakes!
Thanks, -KenD
----- Original Message -----
From: "Eliot Miranda" eliot.miranda@gmail.com
To:"Ken.Dickey" ken.dickey@whidbey.com
Cc:vm-beginners@lists.squeakfoundation.org
Sent:Sun, 23 Dec 2018 11:20:16 -0800
Subject:Re: Steps toward aarch64 Cog [FFI]
Hi Ken,
I have a suggestion. Instead of initializing WordSize from Smalltalk wordSize I would create two subclasses with a wordSize method, hardcoded as ^4 and ^8 respectively. We want to be able to simulate any of the processors on any platform, hence we can simulate x64 on the 32-bit version and x86 on the 64-bit version as well as 32-bit processors on 32-bit versions and 64-bit processors on 64-bit versions. So structuring the ARM FFI as an abstract subclass with a subclass responsibility for wordSize, along with two subclasses for 64 & 32 bits will give us that flexibility.
Where a wordSize define would make sense would be in platforms/Cross/plugins/IA32ABI/*ARM*, although you might want to review the code first and see if #ifdef or splitting the files into 32 and 64-bit versions is cleaner.
On Sun, Dec 23, 2018 at 8:06 AM ken.dickey@whidbey.com wrote:
Rats!
Can't even use this webmail thingie...
[the _other_ changes file]
Cheers, -KenD
Updated..
----- Original Message -----
From: "Eliot Miranda" eliot.miranda@gmail.com
To:"Ken.Dickey" ken.dickey@whidbey.com
Cc:vm-beginners@lists.squeakfoundation.org
Sent:Sun, 23 Dec 2018 11:20:16 -0800
Subject:Re: Steps toward aarch64 Cog [FFI]
Hi Ken,
I have a suggestion. Instead of initializing WordSize from Smalltalk wordSize I would create two subclasses with a wordSize method, hardcoded as ^4 and ^8 respectively. We want to be able to simulate any of the processors on any platform, hence we can simulate x64 on the 32-bit version and x86 on the 64-bit version as well as 32-bit processors on 32-bit versions and 64-bit processors on 64-bit versions. So structuring the ARM FFI as an abstract subclass with a subclass responsibility for wordSize, along with two subclasses for 64 & 32 bits will give us that flexibility.
Where a wordSize define would make sense would be in platforms/Cross/plugins/IA32ABI/*ARM*, although you might want to review the code first and see if #ifdef or splitting the files into 32 and 64-bit versions is cleaner.
On Sun, Dec 23, 2018 at 8:06 AM ken.dickey@whidbey.com wrote:
Rats!
Can't even use this webmail thingie...
[the _other_ changes file]
Cheers, -KenD
Ah! Doscovered CCodeGenerator. Don't know where it was hiding.
From the rabbit hole down into the mine shaft.
Gee, sure is dark down here. Hope it's shallow! ;^)
-KenD
vm-beginners@lists.squeakfoundation.org