[M3devel] updating exception handling implementation and backend interface??
Jay K
jay.krell at cornell.edu
Wed Feb 6 10:28:14 CET 2013
The jmpbuf/alloca fix?
For reference, here is most of the undo:http://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-sys/m3front/src/misc/Marker.m3.diff?r1=1.9;r2=1.10;f=uor http://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-sys/m3front/src/misc/Marker.m3.diff?r1=1.9;r2=1.10
I had generated code like:
old:char buf[sizeof(jmpbuf)]; // frontend knows sizeof(jmpbuf) -- the portability problem to be solved TRY => setjmp(buf);
new:jmpbuf* buf;extern const size_t Csetjmp__Jumpbuf_size/* = sizeof(jmp_buf)*/; *)TRY => buf = m3_alloca(sizeof(Csetjmp__Jumpbuf_size)); setjmp(buf);=> alloca for every TRY, even if TRY in a loop, not good
Understanding that is a further de-optimization, how about I just do:jmpbuf* buf;TRY => buf = buf ? buf : alloca(sizeof(jmpbuf)); setjmp(buf);
?
It seems easy enough?
furthermore, let's think ahead to the C and maybe C++ backends?
The portable slightly optimizing C backend will go back to jmpbuf, no alloca.The optimizing C++ backend will try to use native C++ exception handling.And/or the optimizing C-for-NT backend will use __try/__except/__finally.
Should I start/end "buf" with some distinguished name?So some backends will remove it, in favor of whatever they do better?Should "m3_alloca" be named something more specific like "m3_alloca_for_try"?Again, so it is easier to backends to recognize and remove?i.e. one of the first optimizations the C backend should make isto #include <setjmp.h> and change these to jmpbuf.
Should we invent a higher level interface?Should we do "both", make low level and high level calls to the backend?It will chose to ignore one set?But the low level calls need to be altered at least a little bit.Like the locals and the calls will have a flag or a boolean indicatingthey are "exception handling related"?
Am I making sense?
Thanks, - Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20130206/62396389/attachment-0001.html>
More information about the M3devel
mailing list