Internet says that replacing R by X will do the trick. And also adjust the size of the registers. But I'm not sure about the $ifdef semantics. Should this work?
Code: Select all
// First parameters in registers, then on stack
if ArgCount > 4 then
begin
{$IFDEF CPUARM} // 32-bit ARM
P := @Args + 16; // Start after first 4 args (4 * 4 bytes = 16 bytes)
Tmp := ArgCount - 4;
asm
ldr r0, Tmp
ldr r1, P
mov r3, #0
.Lmyloop:
ldr r2, [r1, r3]
str r2, [r13, r3]
add r3, r3, #4
sub r0, r0, #1
cmp r0, #0
bgt .Lmyloop
end;
{$ENDIF}
{$IFDEF CPUARM64} // 64-bit ARM
P := @Args + 64; // Start after first 8 args (8 * 8 bytes = 64 bytes)
Tmp := ArgCount - 8;
asm
ldr x0, Tmp
ldr x1, P
mov x3, #0
.Lmyloop64:
ldr x2, [x1, x3]
str x2, [sp, x3]
add x3, x3, #8
sub x0, x0, #1
cmp x0, #0
bgt .Lmyloop64
end;
{$ENDIF}
end;
{$IFDEF CPUARM} // 32-bit ARM
asm
ldr r0, Args
ldr r1, Args + 4
ldr r2, Args + 8
ldr r3, Args + 12
ldr r4, TheFunc
blx r4
str r0, RetVal
end;
{$ENDIF}
{$IFDEF CPUARM64} // 64-bit ARM
asm
ldr x0, Args
ldr x1, Args + 8
ldr x2, Args + 16
ldr x3, Args + 24
ldr x4, TheFunc
blr x4
str x0, RetVal
end;
{$ENDIF}
I'll try that tomorrow, as it is super late.
Edit:
32 bits version is compiling and running fine, so the $ifdef statements should be ok. But I get another compilation problem with the 64 bits version:
Code: Select all
ZExpressions.pas(2953,32) Error: Overloaded functions have the same parameter list
ZExpressions.pas(2265,32) Error: Found declaration: Execute(PExecutionEnvironment);
ZExpressions.pas(2953,32) Error: Function header doesn't match any method of this class "Execute(PExecutionEnvironment);"
ZExpressions.pas(2265,32) Error: Found declaration: Execute(PExecutionEnvironment);
Edit 2:
I solved this by replacing line 2764
Code: Select all
{$endif}
{$if defined(cpuaarch64)} // ARM64
by
Code: Select all
{$elseif defined(cpuaarch64)} // ARM64 (not for Android)
So Android 64 doesn't enter the main 64 code. This needs to be reviewed, as there are a lot of $ifdef in this code...
Next compilation error:
Code: Select all
ZExpressions.pas(443,16) Error: Forward declaration not solved "destructor Destroy;"
coming from
Code: Select all
{$if defined(cpux64) or defined(cpuaarch64)}
destructor Destroy; override;
{$endif}
And there, I don't understand exactly how Pascal works. I believe it's because the TExpExternalFuncCall.Destroy is now inaccessible for Android 64 due to previous modification:
Code: Select all
destructor TExpExternalFuncCall.Destroy;
begin
fpmunmap(Trampoline,512);
end;
So let's add another $ifdef to handle 64 bits computers and android
Code: Select all
{$endif}
{$if defined(cpuaarch64)} // ARM64
destructor TExpExternalFuncCall.Destroy;
begin
fpmunmap(Trampoline,512);
end;
{$endif}