[M3devel] FW: NT386 jmpbuf size?
Olaf Wagner
wagner at elegosoft.com
Sun May 4 13:46:25 CEST 2008
Quoting Jay <jayk123 at hotmail.com>:
> I BELIEVE:
> It is statically knowable:
> msvcrt _setjmp uses 8 words
> msvcrt _setjmp3 uses 16
> cygwin uses I think 13 -- their header is just wrong by a factor of 4
> You can tell from a mix of disassembly and source -- disassembly
> for msvcrt, disassembly and source for cygwin.
>
> It isn't runtime variables that make the difference.
> (well, the 16 case might sometimes shrink, it appears)
>
> What is less clear is if _setjmp or _setjmp3 should be used.
> It appears that any use of setjmp in C or C++ uses _setjmp3.
>
> The difference appears to be whether or not the generally expected
> interaction with C __finally and C++ destructors and exception
> handling occurs.
> "generally expected' but also "generally unknown".
>
> One might argue that if C/C++ can afford the extra 32 bytes, then so
> can Modula-3 BUT C/C++ have MUCH more efficient exception handling
> mechanisms available and so setjmp is much less used there. They get
> by with around 3 words for a frame with exception handling on x86,
> and with zero overheard everywhere else.
>
> The C/C++ behavior might also be affected by command line options.
> I'd have to experiment more..
>
> To clarify, imagine Modula-3 gave a callback function to some C++
> and that C++ has a local with a destructor, and the Modula-3 raises
> an exception.
> Does the C++ destructor run or not?
> With _setjmp probably not, with _setjmp3 probably.
IMO it should.
> Similarly, imagine some C++ gives some Modula-3 a callback and the
> C++ raises an exception.
> Do the Modula-3 FINALLY blocks run?
Dito.
> Similar dilemna really on all platforms.
> There relatively recently an ABI for C++ exception handling that
> maybe Modula-3 should use.
I think we should start on the safe side and try to optimize later
if needed. So I'd vote for 16 bytes and use of _setjmp3.
Olaf
--
Olaf Wagner -- elego Software Solutions GmbH
Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany
phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95
http://www.elegosoft.com | Geschäftsführer: Olaf Wagner | Sitz: Berlin
Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194
More information about the M3devel
mailing list