29.11.2017 15:12, J. Gareth Moreton wrote:
Thanks Christo.

Apologies for 4 messages coming in at once.  I think there were a few technical 
glitches with the mailing
list.  Either way, I have submitted an updated patch to the bug report in 
question that corrects the stack
unwinding for Windows.  Any testing would be greatly appreciated (I'm not in a 
position to rigorously test
the code for Linux).

Yeah, I got a little emotional with Thaddy's response (which has since been 
deleted), partly because he
mocked me a bit for even attempting to use assembly language for optimisation. 
Granted, I tend to do more
low-level and mathematical programming than higher-level components, where 
assembler optimisation can really
pay dividends. Plus in a perverted way, I actually enjoy trying to squeeze 
another microsecond out of
running time!

Gareth aka. Kit.


I should have read and answered earlier, but better late than never.

The x86-64 target (actually, all targets except i386 and m68k) use concept of fixed stack. This means: all changes to the stack pointer are done at the beginning and at the end of procedure. Pushing something in the middle is illegal. The stack pointer itself needs to be aligned only at the point of calling another procedure. As a consequence, simple procedures that don't call other procedures and don't use nonvolatile registers can have the stack pointer misaligned by 8 bytes as it naturally is at the first instruction (such procedures don't need any SEH annotations at all, which is a way to simplify things). Now, several first instructions where is stack pointer is changed and nonvolatile registers are saved is called prologue. It is delimited by .seh_endprologue directive and can be at most 255 bytes in size. The advice given at forum to insert .seh_endprologue at the very beginning is plain wrong. .seh_endprologue must be the last SEH directive in procedure. Compiler probably needs to do more checks and reject SEH directives coming after .seh_endprologue.

Regards,
Sergei

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to