<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
<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>
 <BR>
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>
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>
 <BR>
 - Jay<BR><BR> <BR>
<HR id=stopSpelling>
From: hosking@cs.purdue.edu<BR>Date: Tue, 24 Nov 2009 17:17:51 -0500<BR>To: jay.krell@cornell.edu<BR>CC: m3devel@elegosoft.com<BR>Subject: Re: [M3devel] sparc ta/setjmp/longjmp<BR><BR><BASE>
<DIV><SPAN class=ecxApple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=ecxApple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate">
<DIV style="WORD-WRAP: break-word"><SPAN class=ecxApple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=ecxApple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=ecxApple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=ecxApple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=ecxApple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=ecxApple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=ecxApple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=ecxApple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate">
<DIV><SPAN class=ecxApple-style-span style="FONT-SIZE: medium">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=ecxApple-interchange-newline>
<BLOCKQUOTE><SPAN class=ecxApple-style-span style="WORD-SPACING: 0px; FONT: medium Helvetica; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate">
<DIV class=ecxhmmessage style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">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 class=ecxApple-style-span style="WORD-SPACING: 0px; FONT: medium Helvetica; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate">
<DIV class=ecxhmmessage style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"> <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>                                          </body>
</html>