<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi all:<br>but what pointers are you trying to diagnose, if it's a function closure then a REF to a RECORD paired with PROCEDURE is, that is, an OBJECT, but function "tagged" types, I don't think are M3language elements, that doesn't make them BRANDED by default, but structural equivalent by default just different for each type of procedure or method, if you think so, many languages have them, included C I guess, but why do we need those to build the compiler itself, perhaps object oriented environments can look for those in question, you can look for a hack B Kallsow tried to do in m3browser with RTType but I guess for structural types not branded types, so perhaps we need them both, it could be a nice work to do in static time, DEC experimented with some HW as a target for Cardelli's typeful Quest language, we could ask more about that experiment, since it
targeted Modules static info and we could add everything you want in that.<br>I need more time to do so, but looks interesting to do.<br>Thanks in advance<br><br>--- El <b>jue, 2/8/12, Jay K <i><jay.krell@cornell.edu></i></b> escribió:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>De: Jay K <jay.krell@cornell.edu><br>Asunto: Re: [M3devel] unaligned procedures closure marker check broken?<br>Para: "m3devel" <m3devel@elegosoft.com><br>Fecha: jueves, 2 de agosto, 2012 02:38<br><br><div id="yiv810074521">
<style><!--
#yiv810074521 .yiv810074521hmmessage P
{
margin:0px;padding:0px;}
#yiv810074521 body.yiv810074521hmmessage
{
font-size:10pt;font-family:Tahoma;}
--></style><div><div dir="ltr">
okok..4.5 generates:<br><br><br> ldx [%fp+2039], %g1<br> and %g1, 7, %g1<br> and %g1, 0xff, %g1<br> cmp %g1, 0<br><br><br>which is good.<br>The and 0xff is still pointless.<br>This is without optimizing.<br><br>optimized it is:<br> andcc %i0, 7, %g0<br> bne,pn %xcc, .LL2<br><br><br> - Jay<br><br><div><div id="yiv810074521SkyDrivePlaceholder"></div><hr id="yiv810074521stopSpelling">From: jay.krell@cornell.edu<br>To: m3devel@elegosoft.com<br>Date: Thu, 2 Aug 2012 07:28:40 +0000<br>Subject: [M3devel] unaligned procedures closure marker check broken?<br><br>
<style><!--
#yiv810074521 .yiv810074521ExternalClass .yiv810074521ecxhmmessage P
{padding:0px;}
#yiv810074521 .yiv810074521ExternalClass body.yiv810074521ecxhmmessage
{font-size:10pt;font-family:Tahoma;}
--></style>
<div dir="ltr">
Given:<br><br><br>MODULE RTTest; IMPORT RT0;<br><br>PROCEDURE F1 (b: RT0.Binder) = BEGIN<br>EVAL b(0);<br>END F1;<br><br>BEGIN END RTTest.<br><br><br>This tends to fail on Aligned_procedures := FALSE architectures.<br>I see this testing SPARC64_SOLARIS with gcc 4.7 backend,<br>when the procedure isn't 8-aligned -- alignment fault.<br><br><br>IL is reasonable:<br><br>...<br>(89) start_call_indirect type:addr<br>(90) load_integer type:int_64 0<br>(91) pop_param type:int_64<br>(92) load var:0x5 offset:0 src_t:addr dst_t:addr m3name:noname <br>(93) loophole type1:addr type2:int_64<br>(94) load_integer type:int_64
7<br>(95) and type:int_64<br>(96) if_true type:int_64 label:1 frequency:0X32(50)<br>(97) load var:0x5 offset:0 src_t:addr dst_t:addr m3name:noname <br>(98) load_nil<br>...<br><br><br>but the assembly is inefficient and incorrect:<br><br><br>RTTest__F1:<br>.LLFB0:<br> save %sp, -208, %sp<br>.LLCFI0:<br> stx %i0, [%fp+2175]<br> ldx [%fp+2175], %g1<br> stx %g1, [%fp+2039]<br> ldx [%fp+2039], %g1<br> and %g1, 7, %g1 <= correct<br> and %g1, 1, %g1 <=
incorrect<br> and %g1, 0xff, %g1 <= pointless, inefficient<br> cmp %g1, 0<br><br><br>current parse.c:<br><br><br>M3CG_HANDLER (IF_TRUE)<br>{<br> tree cond = m3_cast (boolean_type_node, EXPR_REF (-1));<br> EXPR_POP ();<br><br> add_stmt (build3 (COND_EXPR, t_void, cond,<br> build1 (GOTO_EXPR, t_void, label),<br> NULL_TREE));<br>}<br><br><br>static tree<br>m3_cast (tree type, tree op0)<br>{<br> return m3_build1 (NOP_EXPR, type, op0);<br>}<br><br><br>Thoughts?<br><br><br>I'm thinking, something like:<br><br><br>PROCEDURE If_closure (proc: Val; true, false: Label; freq: Frequency) =<br> VAR skip :=
Next_label (); nope := skip;<br> BEGIN<br> IF (false # No_label) THEN nope := false; END;<br> IF NOT Target.Aligned_procedures THEN<br> Push (proc);<br> Force ();<br> cg.loophole (Type.Addr, Target.Integer.cg_type);<br> Push_int (TargetMap.CG_Align_bytes[Target.Integer.cg_type] - 1);<br> cg.and (Target.Integer.cg_type);<br> <br> == insert comparisong to 0 here ==<br><br> cg.if_true (Target.Integer.cg_type, nope, Always - freq);<br> SPop (1, "If_closure-unaligned");<br> END;<br> <br><br>and possibly if_true should assert that top of stack is boolean already.<br><br><br>I'll check that this isn't
something I broke in 4.7 -- maybe boolean changed.<br><br><br>I was thinking this had something to do with tagged types, but no -- there is nothing<br>related to them in the IL. I guess function pointers can't be tagged?<br><br><br> - Jay </div></div> </div></div>
</div></blockquote></td></tr></table>