Sat Dec 31 14:49:10 2022: Request 145723 was acted upon.
Transaction: Correspondence added by BULKDD
       Queue: Win32-API
     Subject: Add support for Windows on ARM64
   Broken in: (no value)
    Severity: (no value)
       Owner: Nobody
  Requestors: stephenj...@gmail.com
      Status: new
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=145723 >


On Thu Dec 29 12:10:45 2022, stephenj...@gmail.com wrote:
> I'm trying to compile Win32-API from Git (
> https://github.com/bulk88/perl5-win32-api) for ARM64, but this
> platform
> isn't supported by the code yet.
> 
> I was able to port Win32::API::Call over to ARM64 via
> https://github.com/stephenjust/perl5-win32-
> api/commit/44267e3bca3627979d9625366494e2423c05f286
> but I don't really understand Win32::API::Callback and would
> appreciate
> some help with that part.
> 
> Regards,
> Stephen

Win32::API::Callback, makes 1-off executable binary machine code, C function 
pointers "on-demand/runtime", AKA as JIT, those C function pointers call back 
into Perl. No "void *" or "opaque *" needs to be passed through Alien 3rd party 
C lib, to get back to Perl VM with the correct context, the Perl context info 
is stored in an int/pointer const in the one-off binary C function. Remember 
generic "malloc" often isn't enough because of x86 DEP, etc. You probably need 
memory page protection changing like I did here. 

I would need a document/blog article on describing what Win-on-ARM ABI is.

https://github.com/stephenjust/perl5-win32-api/blob/master/Callback.pm#L285

This needs to be adjusted with an ARM template, basically copy pasted ARM 
assembly code from the template, then fill in the pointer consts, tailcall/jmp 
(remove the hand-written 1 off C function binary from C stack) to "stage 2" 
Stage2CallbackX64/PerlCallback, which is Plain C code. I would follow the 
"Stage2CallbackX64" implementation, because its simpler, and for 32-bit x86, 
"Stage2CallbackX64"'s functionality was directly embedded into the "C machine 
code in a string" factory in Callback.pm. Keeping those "machine code in a 
string" 1 off templates shorter is probably for the better, for maint reasons.

https://github.com/stephenjust/perl5-win32-api/blob/master/Callback/Callback.xs#L102

Reply via email to