<html><head><base href="x-msg://205/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><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-align: 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: 0; "><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><span class="Apple-style-span" style="font-size: medium;">Briefly: I am fine with setjmp/longjmp instead of assembler.</span></div><div><span class="Apple-style-span" style="font-size: medium;"><br></span></div><div><span class="Apple-style-span" style="font-size: medium; ">On 22 Nov 2009, at 00:02, Jay K wrote:</span></div></span></span></span></span></span></span></span></span></div></span></span></div><div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; 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 class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">The registers are spilled..to the stack right?..by virtue of longjmp issuing ta 3.<br>Which, while I haven't thought it through, I bet must be done.<br>You can see various refererences to flushrs in IA64 setjmp/longjmp as well.<br></div></span></blockquote><div><br></div><div>I'm just concerned that setjmp/longjmp does more than we need.</div><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; 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 class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">(In college Professer Teitelbaum tricked me on a test with "implement setjmp/longjmp for sparc." I implemented them years ago for the simple 65816 but I failed to consider register windows..)<br></div></span></blockquote><div><br></div><div>Yeah, setjmp/longjmp is actually pretty simple for sparc.  The assembler routine was even simpler than setjmp/longjmp.</div><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; 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 class="hmmessage" style="font-size: 10pt; font-family: Verdana; "> ><span class="Apple-converted-space"> </span><a href="http://www.sics.se/~psm/sparcstack.html">http://www.sics.se/~psm/sparcstack.html</a><br> <br> <br>"Writing a library for multithreaded execution is an example that requires explicit flushing, as is<span class="Apple-converted-space"> </span><tt>longjmp()</tt>."<br> <br> ><span class="Apple-converted-space"> </span><a href="http://blogs.sun.com/d/entry/flush_register_windows">http://blogs.sun.com/d/entry/flush_register_windows</a><br> <br>"Note that setjmp and longjmp which are sometimes used as part of code to implement context switching already have the appropriate flushes in them. "<br> <br> <br>So I contend:<br> <br>void SaveRegsInStack(void)<br>{<br>#if defined(__sparc) || defined(__ia64__)<br>  jmpbuf j;<br>  if (!setjmp(j)) longjmp(j, 1);<br>#endif<br>}<br> <br>It might not be ideal, but given that ta 3 is expensive anyway, and in one of the users there is already a setjmp call, I think it is pretty reasonable.<br> <br> <br>Once things are working better, unless you disagree, I'll make this change in ThreadPThreadC.c and RTStackC.c.<br>ThreadPThreadC.c already has a setjmp.<br>The ProcessMe/ProcessLive interaction will change slightly.<br>ProcessMe will pass stackbase to ProcessLive.<br>stack_grows_down will be in C to be accessible to ProcessLive.<br>I had this all written but have to back up and restore general health..<br> <br> <br>I've seen code that does ta 83 instead of ta 3 on Linux.<br>But I've also seen that that isn't right.<br>This way we can sweep all these issues away fairly well, for all sparc32, sparc64, and ia64 targets.<br> <br> - Jay<br><br> <br><hr id="stopSpelling">From:<span class="Apple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>Date: Sat, 21 Nov 2009 22:19:12 -0500<br>To:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>CC:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: Re: [M3devel] SaveRegsInStack<br><br><div><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><div style="word-wrap: break-word; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><div><span class="ecxApple-style-span" style="font-size: medium; ">Are we sure that &jb is a sufficient sp?  What about other registers saved by the "ta 3"?  They don't necessarily end up in jb.</span></div><div><span class="ecxApple-style-span" style="font-size: medium; "><br></span></div><div><span class="ecxApple-style-span" style="font-size: medium; ">On 21 Nov 2009, at 20:11, Jay K wrote:</span></div></span></span></span></span></span></span></span></span></div></span></span></div><div><br class="ecxApple-interchange-newline"><blockquote><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal medium/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div class="ecxhmmessage" style="font-family: Verdana; font-size: 10pt; ">Tony,<br>Looking at the disassembly of /usr/lib/libc.so and /usr/lib/sparcv9/libc.so, both longjmps contain ta  3.<br>So how about:<br>void *RTStack__SaveRegsInStack(void)<br>{<br>  jmp_buf jb;<br>  if (setjmp(jb))<br>  {<br>    longjmp(jb, 1); /* contains ta 3 */<br>    abort(); /* unreachable */<br>  }<br>  else<br>  {<br>    return &jb;<br>  }<br>}<br> <br>Too wasteful?<br> <br> - Jay<br><br><br> <br><hr id="ecxstopSpelling">From:<span class="ecxApple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>To:<span class="ecxApple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>Date: Sun, 22 Nov 2009 00:12:44 +0000<br>CC:<span class="ecxApple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: Re: [M3devel] SaveRegsInStack<br><br>SOLsun doesn't like the current source:<br> <br>C compiler failed compiling: ../src/runtime/SOLsun/RTStackC.c<br>new source -> compiling ThreadPThreadC.c<br>"../src/thread/PTHREAD/ThreadPThreadC.c", line 310: asm statement illegal outside function<br>"../src/thread/PTHREAD/ThreadPThreadC.c", line 316: asm statement illegal outside function<br>"../src/thread/PTHREAD/ThreadPThreadC.c", line 317: asm statement illegal outside function<br>"../src/thread/PTHREAD/ThreadPThreadC.c", line 325: asm statement illegal outside function<br>"../src/thread/PTHREAD/ThreadPThreadC.c", line 326: asm statement illegal outside function<br>"../src/thread/PTHREAD/ThreadPThreadC.c", line 327: asm statement illegal outside function<br>"../src/thread/PTHREAD/ThreadPThreadC.c", line 349: cannot recover from previous<br><br> - Jay<br> <br><hr id="ecxecxstopSpelling">From:<span class="ecxApple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>To:<span class="ecxApple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>CC:<span class="ecxApple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: RE: [M3devel] SaveRegsInStack<br>Date: Sat, 21 Nov 2009 23:45:42 +0000<br><br>(or RTMachineC.c)<br> <br> - Jay<br> <br><hr id="ecxecxecxstopSpelling">From:<span class="ecxApple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>To:<span class="ecxApple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>Date: Sat, 21 Nov 2009 23:40:03 +0000<br>CC:<span class="ecxApple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: Re: [M3devel] SaveRegsInStack<br><br><div> > No, those don't have the desired effect on SPARC.</div> <br>ok. I was somewhat guessing.<br> <br> > Why wouldn't SPARC* all have stack walkers?<br> <br>Because I'm lazy and doubt anyone cares much about SPARC{32,64}_{LINUX,FREEBSD,NETBSD}, SPARC64_SOLARIS.<br>? But I can maybe try it at some point.<br> <br>I also expect the way to go is use libunwind for nearly all targets, even probably SPARC*.<br> <br> > It would be good to have it in one place for *all* SPARC targets.  Where to put it<br> <br>How about a new src/runtime/common/RTStackC.c, compiled on all platforms but with #ifdefs (the same #ifdefs as are currently used, but revisiting them at some point, the NETBSD and such seem suspicious).<br>I think I'll do that shortly.<br> <br>There is also TARGET_ARCH defined in the config files.<br>We could do<br>if exist(TARGET_ARCH/m3makefile)<br>  include_dir(TARGET_ARCH)<br>end<br> <br>(similarly there is TARGET_OS).<br> <br> - Jay<br> <br><hr id="ecxecxecxecxstopSpelling">From:<span class="ecxApple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>Date: Sat, 21 Nov 2009 17:02:23 -0500<br>To:<span class="ecxApple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>CC:<span class="ecxApple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: Re: [M3devel] SaveRegsInStack<br><br><div><span class="ecxecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><div style="word-wrap: break-word; "><span class="ecxecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><div><span class="ecxecxecxecxecxApple-style-span" style="font-size: medium; ">On 21 Nov 2009, at 15:38, Jay K wrote:</span></div></span></span></span></span></span></span></span></span></div></span></span></div><div><br class="ecxecxecxecxecxApple-interchange-newline"><blockquote><span class="ecxecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal medium/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div class="ecxecxecxecxecxhmmessage" style="font-family: Verdana; font-size: 10pt; ">Tony, it bugs me that we have three copies of this code.<br>Would it be reasonable and not very inefficient<br>and maybe somewhat portable to replace it with<br>setjmp or getcontext or alloca(1)?<br></div></span></blockquote><div><br></div><div>No, those don't have the desired effect on SPARC.</div><br><blockquote><span class="ecxecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal medium/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div class="ecxecxecxecxecxhmmessage" style="font-family: Verdana; font-size: 10pt; "> Or can we go back to having RTStack call RTMachine?<br>(Imagine if SPARC* all had stack walkers, though I<br>doubt that will happen, other than via libunwind.)<br></div></span></blockquote><div><br></div><div>Why wouldn't SPARC* all have stack walkers?  Their stack frames are trivial to unwind.</div><div>I agree that it is annoying to have multiple copies of this code.  It would be good to have it in one place for *all* SPARC targets.  Where to put it?</div><br><blockquote><span class="ecxecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal medium/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div class="ecxecxecxecxecxhmmessage" style="font-family: Verdana; font-size: 10pt; "> <br><br> - Jay<br><br></div></span></blockquote></div><br></div></span><br class="ecxApple-interchange-newline"></blockquote></div><br></div></span><br class="Apple-interchange-newline"></blockquote></div><br></body></html>