#1 2025-07-07 13:29:13

ComingNine
Member
Registered: 2010-07-29
Posts: 304

03 - HelloSpiderMonkey52 does not work for FPC & win32

The SyNode sample "03-HelloSpiderMonkey52-cross" works for both `Delphi & win32` and `FPC & Linux64`.
However, the same sample does not work for `FPC & win32` (compiled on windows, or cross-compiled from linux).
The same synsm.dll used for `Delphi & win32` is used.
The error is access violation at `InitSelfHostedCode`.
For some compiling occasions, the error is `Invalid floating point operation` instead.
As shown by the figures, the operations for `Delphi & win32` and  `FPC & win32` seem to be identical.
I could not figure out the cause or the workaround.
Could you help to suggest what could be the cause and how to fix ? Many thanks !

jCJmDaN.png

SCtHFUg.png

Offline

#2 Yesterday 20:29:01

ComingNine
Member
Registered: 2010-07-29
Posts: 304

Re: 03 - HelloSpiderMonkey52 does not work for FPC & win32

It turns out that if I put the SetExceptionMask line

// https://forum.lazarus.freepascal.org/index.php?topic=70135.15
SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow,exPrecision]);
try
  JS_Init();
  cx := JSContext.CreateNew(8 * 1024 * 1024);
  ...

at the very beginning of "HelloSpiderMonkey52.dpr", the sample works fine for FPC & win32.

Nevertheless, it is still confusing for me because the line

TSynFPUException.ForLibraryCode

is already called at the very beginning of `JSContext.CreateNew`.

SyNode/SpiderMonkey.pas:4190:class function JSContext.CreateNew(maxbytes: uint32; maxNurseryBytes: uint32; parentContext: PJSContext): PJSContext;
SyNode/SpiderMonkey.pas-4191-begin
SyNode/SpiderMonkey.pas-4192-  with TSynFPUException.ForLibraryCode do begin
SyNode/SpiderMonkey.pas-4193-    Result := JS_NewContext(maxbytes, maxNurseryBytes, parentContext);
SyNode/SpiderMonkey.pas-4194-    InitSelfHostedCode(Result);
SyNode/SpiderMonkey.pas-4195-  end;

Could you help to suggest why would there be "Invalid floating point operation" at "JSContext.CreateNew" when "TSynFPUException.ForLibraryCode" is already called at "JSContext.CreateNew" ? Many thanks !

Last edited by ComingNine (Yesterday 20:31:14)

Offline

Board footer

Powered by FluxBB