<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
There's no difference. Is there?<BR>
call is "jump and link", no change to sp. Right?<BR>
No parameters are passed to the function, so no pushes (if the calling sequence even would).<BR>
Notice that if there is a difference, calling sem_post will wipe it out anyway.<BR>
 <BR>
How about an implementation that calls setjmp on all platforms, longjmp right away if there are register windows, and then uses the address of the jmpbuf as the stack pointer?<BR>
 <BR>
 - Jay<BR><BR> <BR>
<HR id=stopSpelling>
From: hosking@cs.purdue.edu<BR>Date: Wed, 25 Nov 2009 10:33:42 -0500<BR>To: jay.krell@cornell.edu<BR>CC: m3devel@elegosoft.com<BR>Subject: Re: [M3devel] sparc ta/setjmp/longjmp<BR><BR><BASE>
<DIV><BR></DIV>
<DIV>      asm("     ta      0x3   ! ST_FLUSH_WINDOWS");</DIV>
<DIV>      asm("     retl");</DIV>
<DIV>      asm("     mov     %sp,%o0");</DIV>
<DIV><BR></DIV>
<DIV><FONT class=ecxApple-style-span size=3><SPAN style="FONT-SIZE: 12px" class=ecxApple-style-span><FONT class=ecxApple-style-span color=#0000ff face="'Gill Sans'"><SPAN style="FONT-SIZE: medium" class=ecxApple-style-span>The sp returned is that for the *callee* SaveRegsInStack, which includes the space for saved registers.  Your version gives an address in the *caller* frame.</SPAN></FONT></SPAN></FONT></DIV>
<DIV><BR></DIV>
<DIV>
<DIV>On 24 Nov 2009, at 20:55, Jay K wrote:</DIV><BR class=ecxApple-interchange-newline>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage>
<DIV> > No.  The sp back from SaveRegsInStack may capture more state than ADR(xx).</DIV> <BR>How so?<BR>Esp. the 32bit version, which doesn't change the register window?<BR>I can see how maybe the 64bit one would make the current registers available since it allocates a new window.<BR></DIV></SPAN></BLOCKQUOTE>
<DIV><BR></DIV>Correct:<BR>
<DIV><BR></DIV>
<DIV>
<DIV>      asm("     save        %sp,-128,%sp");</DIV>
<DIV>      asm("     flushw");</DIV>
<DIV>      asm("     ret");</DIV>
<DIV>      asm("     restore %sp,2047+128,%o0");</DIV></DIV><BR>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage> Maybe we should just setjmp on all architectures and include the jmpbuf in the stack, by making a function call after it and taking the address of a local in the second function?<BR></DIV></SPAN></BLOCKQUOTE>
<DIV><BR></DIV>
<DIV>That could work.</DIV><BR>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage>And also longjmp on Sparc. Basically very much resemble ProcessLive, but just to set sp and not make the callbacks?<BR>And endeavor to be sure to not waste time getting the signal mask.<BR></DIV></SPAN></BLOCKQUOTE>
<DIV><BR></DIV>
<DIV>OK.</DIV><BR>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage> <BR> - Jay<BR><BR> <BR>
<HR id=ecxstopSpelling>
From:<SPAN class=ecxApple-converted-space> </SPAN><A href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</A><BR>Date: Tue, 24 Nov 2009 17:17:51 -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] sparc ta/setjmp/longjmp<BR><BR>
<DIV><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxecxApple-style-span>
<DIV style="WORD-WRAP: break-word"><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxecxApple-style-span>
<DIV><SPAN style="FONT-SIZE: medium" class=ecxecxApple-style-span>On 24 Nov 2009, at 06:05, Jay K wrote:</SPAN></DIV></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></DIV></SPAN></SPAN></DIV>
<DIV><BR class=ecxecxApple-interchange-newline>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxecxhmmessage>Tony,<BR> <BR>Does this seem correct?<BR> <BR><SPAN lang=EN>PROCEDURE SignalHandler (sig: int) =<BR>VAR<BR>...<BR>old:<BR> <BR>me.sp := SaveRegsInStack();<BR>IF me.sp = NIL THEN me.sp := ADR(xx) END;<BR>new:<BR> <BR>SaveRegsInStack(); (* no return value *)<BR>me.sp := ADR(xx); (* unconditional *)<BR></SPAN></DIV></SPAN></BLOCKQUOTE>
<DIV><BR></DIV>
<DIV>No.  The sp back from SaveRegsInStack may capture more state than ADR(xx).</DIV><BR>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxecxhmmessage> <BR> <BR> <BR><SPAN lang=EN>void ThreadPThread__SaveRegsInStack(void)<BR>{<BR>#ifdef M3_REGISTER_WINDOWS<BR>/* On "register window" architectures, setjmp/longjmp tends<BR>to flush registers to the stack in a fairly portable not<BR>too inefficient fashion, and saves us the need for<BR>gnarly assembly. (ta 3 on Sparc, flushrs on IA64)<BR>*/<BR>jmp_buf jb;<BR>if (setjmp(jb) == 0) longjmp(jb, 1);<BR>#endif<BR>}<BR></SPAN> <BR> <BR>You know -- was the stack pointer returned by SaveRegsInStack before really better/different than just ADR(xx)?<BR> <BR> <BR>Consider:<BR> <BR>#   if defined(__arch64__) || defined(__sparcv9)<BR>      asm("     save        %sp,-128,%sp");<BR>      asm("     flushw");<BR>      asm("     ret");<BR>      asm("     restore %sp,2047+128,%o0");<BR>#   else<BR>asm("     ta      0x3   ! ST_FLUSH_WINDOWS");<BR>      asm("     retl");<BR>      asm("     mov     %sp,%o0");<BR>#   endif<BR> <BR> <BR>on 32bit, it just returns the unchanged %sp of its caller.<BR>On 64bit, I suspect kind of the same thing, though I don't know what the 128 or 2047 are. 2047 is probably some "bias" builtin to the register and 128 I guess is required for flushw??<BR> <BR> <BR> - Jay<BR><BR><BR><BR></DIV></SPAN></BLOCKQUOTE></DIV><BR></DIV></SPAN><BR class=ecxApple-interchange-newline></BLOCKQUOTE></DIV><BR>                                        </body>
</html>