<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>declare_local<span class="Apple-tab-span" style="white-space:pre"> </span> noArgs 0 8 Struct -1522787086 T F 50 v.318</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">and here is some relevant M3x86 code:</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> IF u.in_proc THEN</font></div><div><font face="Calibri, sans-serif"> v := get_temp_var (u, type, s, a, n);</font></div><div><font face="Calibri, sans-serif"> ELSE</font></div><div><font face="Calibri, sans-serif"> v := create_temp_var (u, type, s, a, n);</font></div><div><font face="Calibri, sans-serif"> END;</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">PROCEDURE get_temp_var (u: U; type: Type; s: ByteSize; a: Alignment;</font></div><div><font face="Calibri, sans-serif"> n: Name := M3ID.NoID): x86Var =</font></div><div><font face="Calibri, sans-serif"> BEGIN</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> (* round size and alignment up to 4 *)</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> IF s < 4 THEN</font></div><div><font face="Calibri, sans-serif"> s := 4;</font></div><div><font face="Calibri, sans-serif"> END;</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> IF a < 4 THEN</font></div><div><font face="Calibri, sans-serif"> a := 4;</font></div><div><font face="Calibri, sans-serif"> END;</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">PROCEDURE create_temp_var (u: U; type: Type; s: ByteSize; a: Alignment;</font></div><div><font face="Calibri, sans-serif"> n: Name): x86Var =</font></div><div><font face="Calibri, sans-serif"> VAR v := NewVar(u, type, 0, s, a, n);</font></div><div><font face="Calibri, sans-serif"> BEGIN</font></div><div><font face="Calibri, sans-serif"> v.loc := VLoc.temp;</font></div><div><font face="Calibri, sans-serif"> v.parent := u.current_proc;</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> u.current_proc.framesize := Word.And(u.current_proc.framesize + a - 1,</font></div><div><font face="Calibri, sans-serif"> Alignmask[a]);</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> INC(u.current_proc.framesize, s);</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> v.offset := -u.current_proc.framesize;</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> RETURN v;</font></div><div><font face="Calibri, sans-serif"> END create_temp_var;</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">which isn't clear by inspection...it actually looks like</font></div><div><font face="Calibri, sans-serif">zero size is allowed through commonly...in_proc is rare,</font></div><div><font face="Calibri, sans-serif">so create is common...assuming the frame is already aligned,</font></div><div><font face="Calibri, sans-serif">the size remains unchanged...</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">Relevant aside: I have been ignoring alignment.</font></div><div><font face="Calibri, sans-serif">I'm inclined to go with something like:</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><* ASSERT (size MOD alignment) = 0 *></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">If that ever fails, then I will change it to:</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">FUNCTION RoundUp(a, b: INTEGER): INTEGER =</font></div><div><font face="Calibri, sans-serif">BEGIN</font></div><div><font face="Calibri, sans-serif"> WITH c = a MOD b DO</font></div><div><font face="Calibri, sans-serif"> IF c # 0 THEN</font></div><div><font face="Calibri, sans-serif"> RETURN a + b - c;</font></div><div><font face="Calibri, sans-serif"> END;</font></div><div><font face="Calibri, sans-serif"> END;</font></div><div><font face="Calibri, sans-serif"> RETURN a;</font></div><div><font face="Calibri, sans-serif">END;</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">size := RoundUp(size, alignment);</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">and then, more to the point, I'll go with:</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">IF size = 0 THEN</font></div><div><font face="Calibri, sans-serif"> size = 1;</font></div><div><font face="Calibri, sans-serif">END;</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 haven't dug into what the gcc backend would do here, too much</font></div><div><font face="Calibri, sans-serif">to dig through. :)</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">Thoughts?</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 guess I should try both m3x86 and m3cc, and print the address</font></div><div><font face="Calibri, sans-serif">of these things????</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"> - Jay</font></div><br><br><br><div style="font-family: Calibri, sans-serif; font-size: 12pt; "><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling">From: jay.krell@cornell.edu<br>To: m3devel@elegosoft.com<br>Date: Thu, 4 Oct 2012 06:13:28 +0000<br>Subject: [M3devel] zero sized structs?<br><br>
<style><!--
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:12pt;font-family:Calibri;}
--></style>
<div dir="ltr"><div><font face="Calibri, sans-serif">Building obliqrt I get:</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">***</font></div><div><font face="Calibri, sans-serif">*** runtime error:</font></div><div><font face="Calibri, sans-serif">*** <*ASSERT*> failed.</font></div><div><font face="Calibri, sans-serif">*** file "../src/M3C.m3", line 1768</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"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">PROCEDURE GetStructSizes_Declare(self: GetStructSizes_t; type: Type; byte_size: ByteSize): M3CG.Var =</font></div><div><font face="Calibri, sans-serif">BEGIN</font></div><div><font face="Calibri, sans-serif"> IF type = Type.Struct THEN</font></div><div><font face="Calibri, sans-serif"> <* ASSERT byte_size > 0 *></font></div><div><font face="Calibri, sans-serif"> self.sizes[self.count] := byte_size;</font></div><div><font face="Calibri, sans-serif"> INC(self.count);</font></div><div><font face="Calibri, sans-serif"> END;</font></div><div><font face="Calibri, sans-serif"> RETURN NIL;</font></div><div><font face="Calibri, sans-serif">END GetStructSizes_Declare;</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">due to presumably:</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">PROCEDURE ApplyThreadClosure (self: ObliqThreadClosure): REFANY =</font></div><div><font face="Calibri, sans-serif"> VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val;</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">...</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">PROCEDURE HandleWork (self: ObliqWork) =</font></div><div><font face="Calibri, sans-serif"> VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val;</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">PROCEDURE EvalThread ( self : PackageThread;</font></div><div><font face="Calibri, sans-serif">...</font></div><div><font face="Calibri, sans-serif">noArgs : ARRAY [0 .. -1] OF ObValue.Val;</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">What is the meaning of this?</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"> - Jay</font></div><br><br> </div></div> </div></body>
</html>