remobjects/pascalscript

Delphi MacOS64 and Linux64 support (disallows inline assembler)

Closed this issue · 13 comments

I've just tried to compile PascalScript for MacOS64. The first major issue I encountered was in uPSRuntime which uses x64.inc, but inline ASM is a disallowed feature of the Delphi LLVM compilers. Is it possible to do it without assembler or by using externally linked assembler?

Is there interest from others in this?

same story with android etc.
Unfortunately, i have not enough skills to rewrite it without asm usage.

pult commented

For modern Delphi!
I think you should use the experience "System.Rtti.pas"

function Invoke(CodeAddress: Pointer; const Args: TArray<TValue>;
  CallingConvention: TCallConv; AResultType: PTypeInfo; IsStatic: Boolean = False;
  IsConstructor: Boolean = False ): TValue;

Invoke - function hides the use of asm


procedure TVirtualMethodInterceptor.RawCallback(UserData: Pointer;
  const Args: TArray<TValue>; out Result: TValue);

TVirtualMethodInterceptor.RawCallback - it is sample to use function Invoke()

thats will be not so easy, but i will try.
BTW. method ObjectInvoke from System.ObjAuto.pas also can be useful.

I think there is a high demand for this issue, the latest versions of Delphi are supporting better and better Linux and MacOS platforms.
Maybe someone already compiled this project to the mentioned platforms and can help us to make the project compatible.
I will make also an attempt to develop what other participants suggested. Please inform each other if some progress is done.

Regards

hehe, for 32bit ver of MACos x86.inc (from Win) works nice, with minimal correction
{$IFDEF MSWINDOWS}
OleCheck(RealCall_Other(Address, @stack[Length(Stack)-3], Length(Stack) div 4, 4, nil));
{$ELSE}
RealCall_Other(Address, @stack[Length(Stack)-3], Length(Stack) div 4, 4, nil);
{$ENDIF}

atm i'm try to exec Invoke's

pult commented

or so:

{$if not declared(OleCheck)}
procedure OleCheck(Result: Longint{HResult});
begin
  if not (Result and $80000000 = 0) then
    raise Exception.CreateFmt('Safecall error %.8x', [Result]);
end;
{$endif}

function RealCall_Other(...

draft version done.
tested on win x86, win x64, macos x32. But need to test more, f.e. Variants i dont test at all.

Sure for 99% that will work good for ARM as well, but in PS there are tons of problems due to nextgen - zerobased strings, ansistrings and other - all this things i'm fix already, but still exists big problem with ARC, need to check too much of code, and next tests, tests, and again tests. At least few days will be spent for this, and later on i will report about results with PS in NEXTGEN compilers.

How to publish it - just drop here file, or make pull request? Few changes done in uPSRuntime.pas as well.

Pull request is probably best.

done - #203

i'm continue working with ARC on NEXTGEN compilation.

finished with android - works fine.

In few days will divide this huge pack of changes to set of small commits and pull then one by one.

wow! well done. looking forward to seeing the pull request. Thank you!

pull request done.

Due to huge problems in PS with ARC i'm failed to make PS fully work with NEXTGEN compiler on mobile platforms with ARC - Android and iOS (but InvokeCall works fine).

As per info from Idera latest roadmap - ARC will be removed from mobile compiler in one of next version. So, no sense to spent too much time for that, better just to wait.

If someone wants to continue play with ARC - i can make branch with latest changes for ARC.

all done, branch with new invoke calls system merged with PS rep.