<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><base href="x-msg://569/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I haven’t looked at what the front-end does with exception handlers in a long time. I’ll try to look soon. Let me know what you find out.<div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><font class="Apple-style-span" color="#0000FF"><font class="Apple-style-span" face="Gill Sans"><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; "><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; ">Antony Hosking</span></span></font></font><font class="Apple-style-span" face="Gill Sans"><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-converted-space"> </span>|<span class="Apple-converted-space"> </span></span></span><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-style-span" style="font-family: 'Gill Sans'; ">Associate Professor</span></span><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-style-span" style="font-family: 'Gill Sans'; "> | Computer Science | Purdue University</span></span></font></div><div><font class="Apple-style-span" face="GillSans-Light"><span class="Apple-style-span" style="font-family: GillSans-Light; ">305 N. University Street | West Lafayette | IN 47907 | USA</span></font></div><div><font class="Apple-style-span" color="#0000FF" face="Gill Sans"><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; "><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; ">Mobile</span></span></font><font class="Apple-style-span" face="GillSans-Light"><span class="Apple-style-span" style="font-family: GillSans-Light; "><span class="Apple-style-span" style="font-family: GillSans-Light; "><span class="Apple-converted-space"> </span>+1 765 427 5484</span></span></font></div><div><font class="Apple-style-span" face="GillSans-Light"><br class="khtml-block-placeholder"></font></div></span></span></span></span></span></span></span><br class="Apple-interchange-newline"></span></div></span></div></span><br class="Apple-interchange-newline"></span><br class="Apple-interchange-newline">
</div>
<br><div><div>On Sep 20, 2012, at 4:37 PM, Jay K <<a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="hmmessage" style="font-size: 12pt; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div dir="ltr">Eh. Better yet, I'll just pass an extra parameter to direct calls to exception handlers.<div>It is a gross special case. The backend shouldn't know anything about these functions.</div><div><br></div><div><br></div><div><div> (* workaround frontend bug? *)</div><div> IF<span class="Apple-converted-space"> </span><a href="http://proc.is">proc.is</a>_exception_handler THEN</div><div> push(u, Type.Addr, "0");</div><div> pop_parameter_helper(u, "0");</div><div> END;</div></div><div><br></div><div><br></div><div>Again though, I need to see what happens with the other backends.</div><div><br></div><div><br></div><div>The other backends pass the static_link in a special way (do all calling</div><div>conventions really have an extra, special register?), so that is part of their out.</div><div>Plus that you can pass more parameters than are used.</div><div>So they pass a static link in a special register, and one or zero parameters for the activation.</div><div>The lingering question is what happens in finally blocks that access the activation but there isn't one.</div><div>In my case it will be nil, with the above hack.</div><div>For the other backends I think it is arbitrary garbage.</div><div><br></div><div><br></div><div> - Jay<br><br><br><div><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling">From: <a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>To: <a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>Date: Thu, 20 Sep 2012 20:10:03 +0000<br>CC: <a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: Re: [M3devel] Areas that may need attention in the frontend?<br><br><div dir="ltr">This is still bugging me. My current plan is that for exception handlers (functions that end _M3_LINE_number or I3), I will generate the "usual" function Foo, and the function FooDirect. I will set a field in my Proc variable pointing to "direct". Whenever I make a direct call, I'll call the direct function. When I take the address, e.g. for an indirect call, I'll call the "regular" one.<div>The indirect version will take two parameters -- activation and static link, static link list, the direct one will take one, static link.</div><div><br></div><div><br></div><div>I kind of think this a bug in the frontend.</div><div><br></div><div><br></div><div>It might even be a bug with other backends.</div><div>It is rare for a finally block to look at the exception that was raised.</div><div><br></div><div><br></div><div>This only affects finally blocks.</div><div><br></div><div><br></div><div>It doesn't affect except blocks.</div><div>They aren't ever "separate little functions", but rather chunks of code entered/exited via goto.</div><div><br></div><div><br></div><div><br></div><div>I do need to investigate more though.</div><div><br></div><div><br></div><div>Perhaps the frontend notices if a finally block calls Compiler.ThisException() and does something different?</div><div><br></div><div><br></div><div>Inside a finally block, can I call a function, that itself calls Compiler.ThisException()? That would make it impossible for the frontend to fix up. Unless maybe it was pessimistic and observed any function call in a finally block as a sign to do things differently.</div><div><br></div><div><br></div><div>Compiler.ThisException() is available in finally<span style="font-size: 12pt; "> blocks, right?</span></div><div>Otherwise the parameter would ever be passed (i.e. in RTExFrame.m3)</div><div><br></div><div><br></div><div>The analog in Microsoft "SEH" isn't complete.</div><div>A finally block can call BOOL AbnormalTermination() to find out if you "fell off the end" of the __try or called __leave, or raised an exception or returned. (return is kind of unfortunately "abnormal" -- and incurs runtime cost).</div><div>But access to "the exception" is only available in __except filters and maybe __except blocks.</div><div>Not __finally blocks.</div><div><br></div><div><br></div><div>"All these Digital systems" and "all these exception handling systems" seem to have commom threads running through them, similar features, similar syntax, and similar implementation strategies. That's why I bring it up. </div><div><br></div><div><br></div><div> - Jay<br><br><br><div><div id="ecxSkyDrivePlaceholder"></div><hr id="ecxstopSpelling">Subject: Re: [M3devel] Areas that may need attention in the frontend?<br>From: <a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>Date: Thu, 20 Sep 2012 08:16:59 -0400<br>CC: <a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>To: <a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br><br><br><br><div><div>On Sep 20, 2012, at 7:37 AM, Jay K <<a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a>> wrote:</div><br class="ecxApple-interchange-newline"><blockquote><div class="ecxhmmessage" style="font-size: 12pt; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; "><div dir="ltr">I think this isn't right. I understand the static link is implied by level > 0. But the activation/exception parameter should be always passed or never passed. Or there should be two functions -- one that takes an exception, one that doesn't, and one calls the other. Or pass it as null if there isn't an exception.<div><br></div><div>I should really not have to resort to K&R and passing varying numbers of parameters.</div><div><br></div><div>I still have to look at a few test cases to see when each parameter is used.</div><div>Maybe I'm confused.</div><div><br></div><div>The other thing, you want the code to stay?</div></div></div></blockquote><div><br></div><div>For now, yes.</div><br><blockquote><div class="ecxhmmessage" style="font-size: 12pt; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; "><div dir="ltr"><div><br></div><div> - Jay<br><br><br><div><div id="ecxSkyDrivePlaceholder"></div><hr id="ecxstopSpelling">CC:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a>;<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>From:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>Subject: Re: [M3devel] Areas that may need attention in the frontend?<br>Date: Wed, 19 Sep 2012 21:33:43 -0700<br>To:<span class="Apple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br><br><div>Clarification: the "questioning comment" is not mine, it is there in the code. I suspect it is a good question & that the code isn't what it should be.<br><br> - Jay (briefly/pocket-sized-computer-aka-phone)</div><div><br>On Sep 19, 2012, at 7:39 PM, Antony Hosking <<a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a>> wrote:<br><br></div><div></div><blockquote><div>On Sep 19, 2012, at 9:31 PM, Jay K <<a href="mailto:jay.krell@cornell.edu"></a><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a>> wrote:</div><br class="ecxApple-interchange-newline"><blockquote><div class="ecxhmmessage" style="font-size: 12pt; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; "><div dir="ltr"><div><font face="Calibri, sans-serif">Areas that may need attention in the frontend?</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">TryFinStmt.m3:</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> CG.Start_call_direct (p.handler.cg_proc, p.handler.level, CG.Type.Void);</font></div><div><font face="Calibri, sans-serif"> (* Shouldn't we pass the activation parameter here?</font></div><div><font face="Calibri, sans-serif"> What value do we pass? *)</font></div><div><font face="Calibri, sans-serif"> CG.Call_direct (p.handler.cg_proc, CG.Type.Void);</font></div></div></div></blockquote><div><br></div><div>The level let’s you compute that.</div><br><blockquote><div class="ecxhmmessage" style="font-size: 12pt; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; "><div dir="ltr"><div><span style="font-family: Calibri, sans-serif; font-size: 12pt; ">I'm wondering this too...like..what is the interface</span></div><div><font face="Calibri, sans-serif">to except/finally blocks?</font></div></div></div></blockquote><div><br></div><div>?</div><br><blockquote><div class="ecxhmmessage" style="font-size: 12pt; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; "><div dir="ltr"><div><span style="font-family: Calibri, sans-serif; font-size: 12pt; ">It appears they take two, or one, or zero parameters,</span></div><div><span style="font-family: Calibri, sans-serif; ">depending on intepretation and context.</span></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">two parameters:</font></div><div><font face="Calibri, sans-serif"> _static_link</font></div><div><font face="Calibri, sans-serif"> exception stuff</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> </font></div><div><font face="Calibri, sans-serif">one parameter:</font></div><div><font face="Calibri, sans-serif"> _static_link</font></div><div><font face="Calibri, sans-serif"> </font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">zero parameters:</font></div><div><font face="Calibri, sans-serif"> the above</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">I think the right implmentation (assuming no significant</font></div><div><font face="Calibri, sans-serif">change to nested functions, which Tony is thinking about:) )</font></div><div><font face="Calibri, sans-serif">is one parameter:</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> exception stuff</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">and the implied/popped static_link, always.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">For now, I think I'll not prototype these and use K&R definitions, yuck!</font></div></div></div></blockquote><div><br></div><div>That works.</div><br><blockquote><div class="ecxhmmessage" style="font-size: 12pt; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; "><div dir="ltr"><div><span style="font-family: Calibri, sans-serif; font-size: 12pt; ">Maybe generating C++ with overloads is a good idea??</span></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">values/Procedure.m3:</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> ELSIF (cur.token = TK.tSEMI) THEN</font></div><div><font face="Calibri, sans-serif"> t.body := NEW (Body, self := t);</font></div><div><font face="Calibri, sans-serif"> ProcBody.Push (t.body);</font></div><div><font face="Calibri, sans-serif"> (* try accepting the Modula-2 syntax *)</font></div><div><font face="Calibri, sans-serif"> Error.ID (id, "expecting \'=\' before procedure body");</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> </font></div><div><font face="Calibri, sans-serif">Probably everything after the error should be removed?</font></div><div><font face="Calibri, sans-serif">Or this is an example trying to recover from parse errors</font></div><div><font face="Calibri, sans-serif">and doing best effort?</font></div></div></div></blockquote><div><br></div><div>Yes.</div><br><blockquote><div class="ecxhmmessage" style="font-size: 12pt; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; "><div dir="ltr"><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> - Jay</font></div></div></div></blockquote></blockquote></div></div></div></div></blockquote></div></div></div></div></div></div></div></div></blockquote></div><br></div></body></html>