<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I think I see the problem in the compiler.<div>There is some strangeness in how true=CG.No_label is dealt with.</div><div><br><div><div>On 16 Jun 2009, at 05:59, Jay wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; 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: 0px; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">Here is the code in the compiler, not being familiar..it seems reasonable..<br> <br> <br>    ELSIF RefType.Is (t) THEN<br>      Expr.Compile (ce.args[0]);<br>      tagged := CG.Next_label ();<br>      false := CG.Next_label ();<br>      true := CG.Next_label ();<br>      ptr := CG.Pop ();<br>      Value.Load (Bool.True);<br>      CG.Force (); (* we need a temp *)<br>      ce.tmp := CG.Pop_temp ();<br>      CG.Push (ptr);<br>      CG.Load_nil ();<br>      CG.If_compare (CG.Type.Addr, CG.Cmp.EQ, true, CG.Maybe);<br>      CG.Push (ptr);<br>      CG.Loophole (CG.Type.Addr, Target.Integer.cg_type);<br>      CG.Load_integer (Target.Integer.cg_type, TInt.One);<br>      CG.And (Target.Integer.cg_type);<br>      CG.If_true (tagged, CG.Maybe);<br>      CG.Push (ptr);<br>      CG.Ref_to_info (M3RT.RH_typecode_offset, M3RT.RH_typecode_size);<br>      Type.LoadInfo (t, M3RT.TC_typecode);<br> <br>; This is the comparison of the desired and actual typecode<br>; If it equal, we will jump to the label "true"<br>      CG.If_compare (Target.Integer.cg_type, CG.Cmp.EQ, true, CG.Always);<br><br> ; otherwise, we already decided it isn't tagged, so jump<br> ; around that to the label false<span class="Apple-converted-space"> </span><br> ;<br> ; This is what is missing in the IL.<br> ;<br>      CG.Jump (false);<br>      <br>      CG.Set_label (tagged);<br>      CG.Load_intt (M3RT.REFANY_typecode);<br>      Type.LoadInfo (t, M3RT.TC_typecode);<br>      CG.If_compare (Target.Integer.cg_type, CG.Cmp.EQ, true, CG.Always);<br>      CG.Set_label (false);<br>      Value.Load (Bool.False);<br>      CG.Store_temp (ce.tmp);<br>      CG.Set_label (true);<br>      CG.Free (ptr);<br><br><br><br>Let's look for jumps in the IL, there are only two:<br> <br>(172) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(173) load_indirect<br>  load address offset 0xffffffffffffffc0 src_t 0x7 dst_t 0x7<br>(174) extract_mn<br>(175) load<br>  m3cg_load (MM_Main): offset 0x9c0, convert 0x7 -> 0x7<br>(176) if_eq<br> label 6<br>(177) jump   <== here<span class="Apple-converted-space"> </span><br> label 5<br>(178) set_label<br> label 4<br>(179) load_integer<br>  integer 0x3  <== notice this<span class="Apple-converted-space"> </span><br>(180) load<br>  m3cg_load (MM_Main): offset 0x9c0, convert 0x7 -> 0x7<br>(181) if_eq<br> label 6<br>(182) set_label<br> label 5<br>(183) load_integer<br>  integer 0x0<br>(184) store<br>  store (noname) offset 0x0 src_t 0x7 dst_t 0x7<br>(185) set_label<br> label 6<br>(186) import_procedure<br>  procedure Fmt__Bool nparams 0x1 rettype 0xb<br>(187) declare_param<br> <br> <br>That is the call to Fmt_Bool.<br>You can see the signature value "3", that the jump goes around.<br> <br>and the other one:<br> <br>(265) pop_param<br>  pop param type 0xb<br>(266) call_direct<br>  call procedure Main__PutLn, type 0xd<br>(267) jump<br> label 7<br> <br>not interesting -- you can't tell here, but it is after all the interesting stuff.<br>It is for the if to skip the else.<br> <br>So that leaves me wondering -- what happened to the jump in the IsType?<br>I think it should be there and it missing messes this up.<br>We don't expect to take that jump, we expect the comparison to be equal, but I think the code gets it reversed and makes corresponding changes so this missing jump is the problem...<br> <br> <br> - Jay<br><br><br> <br><hr id="stopSpelling">From:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>To:<span class="Apple-converted-space"> </span><a href="mailto:mika@async.caltech.edu">mika@async.caltech.edu</a><br>CC:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: RE: [M3devel] Strange behavior in recent CM3-compiled code...<br>Date: Tue, 16 Jun 2009 09:16:39 +0000<br><br>I haven't figured it out, but:<br><br>Here is the code for the Fmt.Bool:<br> <br>.L6:<br> ; assume the parameter to Fmt.Bool is TRUE, by<br> ; storing 1 in the parameter place<br><br>        movq    $1, 16(%rsp)<br> <br> ; do a bunch of stuff, no need to understand..<br><br>        movq    32(%rsp), %rax<br>        testq   %rax, %rax<br>        je      .L7<br>        movq    32(%rsp), %rax<br>        testb   $1, %al<br>        jne     .L8<br>        movq    32(%rsp), %rax<br>        movq    312+MM_Main(%rip), %rdx<br>        movq    -8(%rax), %rax<br>        salq    $43, %rax<br>        shrq    $44, %rax<br> <br> ; at this point, between $rdx and $rax, one is<br> ; typecode of the object, one is the typecode of the type<br> ; they compare equal<br><br>        cmpq    %rdx, %rax<br> <br>  ; This is not taken.<br><br>        jne     .L9<br> <br>  ; This is taken.<br><br>        jmp     .L7<br><br>.L8:<br>  ; This does not run.<br>        movq    312+MM_Main(%rip), %rax<br>        cmpq    $3, %rax<br>        je      .L7<br>.L9:<br> ; Had the expression resolved to FALSE, this would be<br> ; where FALSE is passed to Fmt.Bool<br>        movq    $0, 16(%rsp)<br>.L7:<br>        movq    16(%rsp), %rdi<br>        call   <span class="Apple-converted-space"> </span><a href="mailto:Fmt__Bool@PLT">Fmt__Bool@PLT</a><br><br> <br>And here is the code for the IF:<br><br>.L11:<br> ; just gloss over this part..<br><br>        movq    40(%rsp), %rax<br>        testq   %rax, %rax<br>        je      .L12<br>        movq    40(%rsp), %rax<br>        testb   $1, %al<br>        jne     .L13<br>        movq    40(%rsp), %rax<br>        movq    312+MM_Main(%rip), %rdx<br>        movq    -8(%rax), %rax<br>        salq    $43, %rax<br>        shrq    $44, %rax<br> <br> ; again at this point, we have the typecodes, and they compare equal<br> <br>        cmpq    %rdx, %rax<br> <br> ; This is not taken.<br><br>        jne     .L14<br><br>.L13:<br> <br> ; At this point things have gone wrong.<br> ; The Fmt.Bool path did not compare the typecode to 3.<br> ; after the jne, there should have been a jmp to I guess .L12.<br> <br>        movq    312+MM_Main(%rip), %rax<br>        cmpq    $3, %rax<br>        jne     .L14<br><br>.L12:<br>        .stabn  68,0,19,.LM9-.LFBB2<br>.LM9:<br>        leaq    128+L_1(%rip), %rdi<br>        call   <span class="Apple-converted-space"> </span><a href="mailto:Main__PutLn@PLT">Main__PutLn@PLT</a><br>        jmp     .L15<br>        .p2align 4,,10<br>        .p2align 3<br>.L14:<br>        .stabn  68,0,21,.LM10-.LFBB2<br>.LM10:<br>        leaq    168+L_1(%rip), %rdi<br>        call   <span class="Apple-converted-space"> </span><a href="mailto:Main__PutLn@PLT">Main__PutLn@PLT</a><br><br> <br>Thanks for the small test case!<br><br> - Jay<br><br><br> <br><hr id="EC_stopSpelling">From:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>To:<span class="Apple-converted-space"> </span><a href="mailto:mika@async.caltech.edu">mika@async.caltech.edu</a><br>Date: Tue, 16 Jun 2009 08:50:02 +0000<br>CC:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: Re: [M3devel] Strange behavior in recent CM3-compiled code...<br><br>Well, the number 3 is REFANY_typecode.<br>I need to compare the if code to the printing code though..<br> <br> - Jay<br> <br><hr id="EC_EC_stopSpelling">From:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>To:<span class="Apple-converted-space"> </span><a href="mailto:mika@async.caltech.edu">mika@async.caltech.edu</a><br>CC:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: RE: [M3devel] Strange behavior in recent CM3-compiled code...<br>Date: Tue, 16 Jun 2009 08:44:21 +0000<br><br>Cool.<br>Here is a smaller repro, on birch AMD64_LINUX.<br> <br>The problem is not the AND, the problem is the IF.<br> <br><br>MODULE Main;<br>IMPORT IO, Fmt;<br>PROCEDURE PutLn(what : TEXT) =<br>BEGIN IO.Put(what & "\n") END PutLn;<br><br>TYPE<br>Pair = REF RECORD<br>rest : REFANY;<br>END;<br>VAR<br>t := NEW(Pair, rest := NEW(Pair, rest := NIL));<br>BEGIN<br>PutLn("ISTYPE(t.rest,Pair)? " & Fmt.Bool(ISTYPE(t.rest,Pair)));<br>IF ISTYPE(t.rest,Pair) THEN<br>PutLn("in IF clause...")<br>ELSE<br>PutLn("in ELSE clause...")<br>END<br>END Main.<br><br>Tony this is presumably your type tagging changes??<br><br>The problem in the code I think is the compare to the number 3.<br><br>.L13:<br>        movq    312+MM_Main(%rip), %rax<br>        cmpq    $3, %rax            <====<br>        jne     .L14<br>.L12:<br>        .stabn  68,0,19,.LM9-.LFBB2<br>.LM9:<br>        leaq    128+L_1(%rip), %rdi<br>        call   <span class="Apple-converted-space"> </span><a href="mailto:Main__PutLn@PLT">Main__PutLn@PLT</a><br>        jmp     .L15<br>        .p2align 4,,10<br>        .p2align 3<br>.L14:<br>        .stabn  68,0,21,.LM10-.LFBB2<br>.LM10:<br>        leaq    168+L_1(%rip), %rdi<br>        call   <span class="Apple-converted-space"> </span><a href="mailto:Main__PutLn@PLT">Main__PutLn@PLT</a><br> <br><br>What is that for?<br> <br><br>It comes right from the IL:<br><br>(118) set_source_line<br>  source line   17<br>(119) import_procedure<br>  procedure RTHooks__CheckLoadTracedRef nparams 0x1 rettype 0xd<br>(120) declare_param<br>  param M3_Af40ku_ref type 0xb typeid 0x1c1c45e6 bytesize 0x40 alignment 0x40 in<br>_memory 0x0 up_level 0x0<br>  mode 0x11 (DImode)<br>(121) set_runtime_proc<br>(122) load<br>  m3cg_load (MM_Main): offset 0x640, convert 0xb -> 0xb<br>(123) store<br>  store (noname) offset 0x0 src_t 0xb dst_t 0xb<br>(124) load_nil<br>(125) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(126) if_eq<br>(127) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(128) loophole<br>(129) load_integer<br>  integer 0x1<br>(130) and<br>(131) if_true<br>(132) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(133) load_indirect<br>  load address offset 0xffffffffffffffc0 src_t 0x7 dst_t 0x7<br>(134) extract_mn<br>(135) if_false<br>(136) start_call_direct<br>  start call procedure RTHooks__CheckLoadTracedRef, level 0x0, type 0xd<br>(137) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(138) pop_param<br>  pop param type 0xb<br>(139) call_direct<br>  call procedure RTHooks__CheckLoadTracedRef, type 0xd<br>(140) set_label<br>(141) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(142) load_indirect<br>  load address offset 0x0 src_t 0xb dst_t 0xb<br>(143) store<br>  store (noname) offset 0x0 src_t 0xb dst_t 0xb<br>(144) load_nil<br>(145) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(146) if_eq<br>(147) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(148) loophole<br>(149) load_integer<br>  integer 0x1<br>(150) and<br>(151) if_true<br>(152) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(153) load_indirect<br>  load address offset 0xffffffffffffffc0 src_t 0x7 dst_t 0x7<br>(154) extract_mn<br>(155) if_false<br>(156) start_call_direct<br>  start call procedure RTHooks__CheckLoadTracedRef, level 0x0, type 0xd<br>(157) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(158) pop_param<br>  pop param type 0xb<br>(159) call_direct<br>  call procedure RTHooks__CheckLoadTracedRef, type 0xd<br>(160) set_label<br>(161) load_integer<br>  integer 0x1<br>(162) declare_temp<br>  temp var type 0x7 size 0x40 alignment 0x40<br>(163) store<br>  store (noname) offset 0x0 src_t 0x7 dst_t 0x7<br>(164) load_nil<br>(165) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(166) if_eq<br>(167) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(168) loophole<br>(169) load_integer<br>  integer 0x1<br>(170) and<br>(171) if_true<br>(172) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(173) load_indirect<br>  load address offset 0xffffffffffffffc0 src_t 0x7 dst_t 0x7<br>(174) extract_mn<br>(175) load<br>  m3cg_load (MM_Main): offset 0x9c0, convert 0x7 -> 0x7<br>(176) if_eq<br>(177) jump<br>(178) set_label<br>(179) load_integer<br>  integer 0x3<br>(180) load<br>  m3cg_load (MM_Main): offset 0x9c0, convert 0x7 -> 0x7<br>(181) if_eq<br>(182) set_label<br>(183) load_integer<br>  integer 0x0<br>(184) store<br>  store (noname) offset 0x0 src_t 0x7 dst_t 0x7<br>(185) set_label<br>(186) import_procedure<br>  procedure Fmt__Bool nparams 0x1 rettype 0xb<br>(187) declare_param<br>  param M3_AicXUJ_b type 0x0 typeid 0x1e59237d bytesize 0x8 alignment 0x8 in_mem<br>ory 0x0 up_level 0x0<br>  mode 0xe ()<br>(188) start_call_direct<br>  start call procedure Fmt__Bool, level 0x0, type 0xb<br>(189) load<br>  m3cg_load (noname): offset 0x0, convert 0x7 -> 0x7<br>(190) pop_param<br>  pop param type 0x0<br>(191) call_direct<br>  call procedure Fmt__Bool, type 0xb<br>(192) store<br>  store (noname) offset 0x0 src_t 0xb dst_t 0xb<br>(193) start_call_direct<br>  start call procedure RTHooks__Concat, level 0x0, type 0xb<br>(194) load_address<br>  load address (L_1) offset 0x280<br>(195) pop_param<br>  pop param type 0xb<br>(196) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(197) pop_param<br>  pop param type 0xb<br>(198) call_direct<br>  call procedure RTHooks__Concat, type 0xb<br>(199) store<br>  store (noname) offset 0x0 src_t 0xb dst_t 0xb<br>(200) start_call_direct<br>  start call procedure Main__PutLn, level 0x0, type 0xd<br>(201) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(202) pop_param<br>  pop param type 0xb<br>(203) call_direct<br>  call procedure Main__PutLn, type 0xd<br>(204) set_source_line<br>  source line   18<br>(205) load<br>  m3cg_load (MM_Main): offset 0x640, convert 0xb -> 0xb<br>(206) store<br>  store (noname) offset 0x0 src_t 0xb dst_t 0xb<br>(207) load_nil<br>(208) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(209) if_eq<br>(210) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(211) loophole<br>(212) load_integer<br>  integer 0x1<br>(213) and<br>(214) if_true<br>(215) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(216) load_indirect<br>  load address offset 0xffffffffffffffc0 src_t 0x7 dst_t 0x7<br>(217) extract_mn<br>(218) if_false<br>(219) start_call_direct<br>  start call procedure RTHooks__CheckLoadTracedRef, level 0x0, type 0xd<br>(220) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(221) pop_param<br>  pop param type 0xb<br>(222) call_direct<br>  call procedure RTHooks__CheckLoadTracedRef, type 0xd<br>(223) set_label<br>(224) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(225) load_indirect<br>  load address offset 0x0 src_t 0xb dst_t 0xb<br>(226) store<br>  store (noname) offset 0x0 src_t 0xb dst_t 0xb<br>(227) load_nil<br>(228) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(229) if_eq<br>(230) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(231) loophole<br>(232) load_integer<br>  integer 0x1<br>(233) and<br>(234) if_true<br>(235) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(236) load_indirect<br>  load address offset 0xffffffffffffffc0 src_t 0x7 dst_t 0x7<br>(237) extract_mn<br>(238) if_false<br>(239) start_call_direct<br>  start call procedure RTHooks__CheckLoadTracedRef, level 0x0, type 0xd<br>(240) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(241) pop_param<br>  pop param type 0xb<br>(242) call_direct<br>  call procedure RTHooks__CheckLoadTracedRef, type 0xd<br>(243) set_label<br>(244) load_nil<br>(245) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(246) if_eq<br>(247) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(248) loophole<br>(249) load_integer<br>  integer 0x1<br>(250) and<br>(251) if_true<br>(252) load<br>  m3cg_load (noname): offset 0x0, convert 0xb -> 0xb<br>(253) load_indirect<br>  load address offset 0xffffffffffffffc0 src_t 0x7 dst_t 0x7<br>(254) extract_mn<br>(255) load<br>  m3cg_load (MM_Main): offset 0x9c0, convert 0x7 -> 0x7<br>(256) if_ne<br>(257) set_label<br>(258) load_integer<br>  integer 0x3               <=====<span class="Apple-converted-space"> </span><br>(259) load<br>  m3cg_load (MM_Main): offset 0x9c0, convert 0x7 -> 0x7<br>(260) if_ne<br>(261) set_label<br>(262) set_source_line<br>  source line   19<br>(263) start_call_direct<br>  start call procedure Main__PutLn, level 0x0, type 0xd<br>(264) load_address<br>  load address (L_1) offset 0x400<br>(265) pop_param<br>  pop param type 0xb<br>(266) call_direct<br>  call procedure Main__PutLn, type 0xd<br>(267) jump<br>(268) set_label<br>(269) set_source_line<br>  source line   21<br>(270) start_call_direct<br>  start call procedure Main__PutLn, level 0x0, type 0xd<br>(271) load_address<br>  load address (L_1) offset 0x540<br>(272) pop_param<br>  pop param type 0xb<br>(273) call_direct<br>  call procedure Main__PutLn, type 0xd<br>(274) set_label<br>(275) set_label<br>(276) load_address<br>  load address (MM_Main) offset 0x0<br>(277) exit_proc<br>(278) free_temp<br>(279) free_temp<br>(280) free_temp<br>(281) free_temp<br>(282) free_temp<br>(283) end_procedure<br>  procedure Main_M3<br>(284) comment<br>  comment: `global constant type descriptor'<br>(285) declare_record<br>  record id 0xffffffff, fields 0x0, size 0x940<br>(286) comment<br>  comment: `global data type descriptor'<br> <br> <br>I'll dig a bit more.<br> <br><br> - Jay<br><br><br><br><br><br><br> <br>> To:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>> Date: Tue, 16 Jun 2009 00:59:10 -0700<br>> From:<span class="Apple-converted-space"> </span><a href="mailto:mika@async.caltech.edu">mika@async.caltech.edu</a><br>> CC:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>> Subject: Re: [M3devel] Strange behavior in recent CM3-compiled code...<br>><span class="Apple-converted-space"> </span><br>> This small example exhibits it!<br>><span class="Apple-converted-space"> </span><br>> MODULE Main;<br>> IMPORT IO, Fmt;<br>><span class="Apple-converted-space"> </span><br>> PROCEDURE PutLn(what : TEXT) =<br>> BEGIN IO.Put(what & "\n") END PutLn;<br>><span class="Apple-converted-space"> </span><br>><span class="Apple-converted-space"> </span><br>> TYPE<span class="Apple-converted-space"> </span><br>> Pair = BRANDED "Pair" REF RECORD<br>> first, rest : REFANY;<br>> END;<br>><span class="Apple-converted-space"> </span><br>> PROCEDURE Rest(p : Pair) : REFANY =<span class="Apple-converted-space"> </span><br>> BEGIN<br>> IF p = NIL THEN RETURN NIL ELSE RETURN p.rest END<br>> END Rest;<br>><span class="Apple-converted-space"> </span><br>> VAR<span class="Apple-converted-space"> </span><br>> t := NEW(Pair, first := "first",<span class="Apple-converted-space"> </span><br>> rest := NEW(Pair, first := "second",<span class="Apple-converted-space"> </span><br>> rest := NIL));<br>><span class="Apple-converted-space"> </span><br>> BEGIN<br>> PutLn("t.rest # NIL? " & Fmt.Bool(t.rest#NIL));<br>> PutLn("ISTYPE(t.rest,Pair)? " & Fmt.Bool(ISTYPE(t.rest,Pair)));<br>> PutLn("Rest(t.rest) = NIL? " & Fmt.Bool(Rest(t.rest)=NIL));<br>> PutLn("conjunction? " & Fmt.Bool(<br>> (t.rest # NIL) AND (ISTYPE(t.rest,Pair)) AND (Rest(t.rest) = NIL) ));<br>> IF (t.rest # NIL) AND (ISTYPE(t.rest,Pair)) AND (Rest(t.rest) = NIL) THEN<br>> PutLn("in IF clause...")<br>> ELSE<br>> PutLn("in ELSE clause...")<br>> END<br>> END Main.<br>><span class="Apple-converted-space"> </span><br>> Output:<br>><span class="Apple-converted-space"> </span><br>> (133)rover:~/testcm3/src>m3build -O<br>> --- building in ../FreeBSD4 ---<br>> m3build: missing ../src/m3overrides<br>> new source -> compiling ../src/Main.m3<br>> -> linking prog<br>> (134)rover:~/testcm3/src>../FreeBSD4/prog<br>> t.rest # NIL? TRUE<br>> ISTYPE(t.rest,Pair)? TRUE<br>> Rest(t.rest) = NIL? TRUE<br>> conjunction? TRUE<br>> in IF clause...<br>> (135)rover:~/testcm3/src>cm3 -clean<br>> --- cleaning ../FreeBSD4 ---<br>><span class="Apple-converted-space"> </span><br>> (136)rover:~/testcm3/src>cm3<br>> --- building in ../FreeBSD4 ---<br>><span class="Apple-converted-space"> </span><br>> new source -> compiling Main.m3<br>> -> linking prog<br>> (137)rover:~/testcm3/src>../FreeBSD4/prog<span class="Apple-converted-space"> </span><br>> t.rest # NIL? TRUE<br>> ISTYPE(t.rest,Pair)? TRUE<br>> Rest(t.rest) = NIL? TRUE<br>> conjunction? FALSE<br>> in ELSE clause...<br>> (138)rover:~/testcm3/src><br>><span class="Apple-converted-space"> </span><br>> Jay writes:<br>> >--_55f6c801-7d57-4602-a131-dda139b64dfd_<br>> >Content-Type: text/plain; charset="iso-8859-1"<br>> >Content-Transfer-Encoding: quoted-printable<br>> ><br>> ><br>> >Kneejerk generic response:<br>> ><br>> >=20<br>> ><br>> >I don't know the operator precedence. Can you put in parens?<br>> ><br>> >Have you looked at the code?<br>> ><br>> >Can you mail us a small self contained repro?<br>> ><br>> >Can you test it on birch?<br>> ><br>> > (That way -- all your files are there and easily gotten/investigated by o=<br>> >thers.)<br>> ><br>> >Optimization enabled? Works without? I know=2C I shouldn't even ask this so=<br>> >rt of thing without evidence.<br>> ><br>> >=20<br>> ><br>> > - Jay<br>> >=20<br>> >> To:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>> >> Date: Tue=2C 16 Jun 2009 00:01:18 -0700<br>> >> From:<span class="Apple-converted-space"> </span><a href="mailto:mika@async.caltech.edu">mika@async.caltech.edu</a><br>> >> CC:<span class="Apple-converted-space"> </span><a href="mailto:mika@camembert.async.caltech.edu">mika@camembert.async.caltech.edu</a><br>> >> Subject: [M3devel] Strange behavior in recent CM3-compiled code...<br>> >>=20<br>> >>=20<br>> >> Hello everyone=2C<br>> >>=20<br>> >> I'm trying to update to the latest CM3 again=2C so that I can get my<br>> >> Mac working=2C and push my project of migrating a largish codebase<br>> >> from PM3 to CM3 a little further.<br>> >>=20<br>> >> I updated CM3 today from CVS=2C on both my Mac and on a FreeBSD system=2C<br>> >> and ... my Scheme interpreter broke. Here's what the code looks like=2C<br>> >> with annotations:<br>> >>=20<br>> >> 49 Debug.Out("t.rest =3D NIL? " & Fmt.Bool(t.rest=3DNIL))=3B<br>> >> 50 Debug.Out("ISTYPE(t.rest=2CT)? " & Fmt.Bool(ISTYPE(t.rest=2CT)))=3B<br>> >> 51 Debug.Out("Rest(t.rest) =3D NIL? " & Fmt.Bool(Rest(t.rest)=3DNIL))=3B<br>> >> 52<br>> >> 53 IF t.rest # NIL AND ISTYPE(t.rest=2CT) AND Rest(t.rest) =3D NIL THEN<br>> >> 54 Debug.Out("in IF clause...")=3B<br>> >> 55<br>> >> 56 IF SymEq(t.first=2C "quote") THEN special :=3D "'"<br>> >> 57 ELSIF SymEq(t.first=2C "quasiquote") THEN special :=3D "`"<br>> >> 58 ELSIF SymEq(t.first=2C "unquote") THEN special :=3D "=2C"<br>> >> 59 ELSIF SymEq(t.first=2C "unquote-splicing") THEN special :=3D "=2C@"<br>> >> 60 END<br>> >> 61 ELSE<br>> >> 62 Debug.Out("in ELSE clause...")<br>> >> 63 END=3B<br>> >>=20<br>> >> all you need to know is that Debug.Out prints out debugging information<br>> >> to the terminal. What I see is...<br>> >>=20<br>> >> t.rest =3D NIL? FALSE<br>> >> ISTYPE(t.rest=2CT)? TRUE<br>> >> Rest(t.rest) =3D NIL? TRUE<br>> >> in ELSE clause...<br>> >>=20<br>> >> What gives!?<br>> >>=20<br>> >> Note this behavior occurs on both the Mac and on FreeBSD4 with a<br>> > compiler and runtime bootstrapped today from some previous CM3.<br>> >> My old CM3 compiler was timestamped... April 30=2C I believe=2C and the<br>> >> code behaved properly under that one.<br>> >>=20<br>> >> I believe I have also tried it both with and without compiler<br>> >> optimizations.<br>> >>=20<br>> >> I find it baffling that so much stuff (mentor!) can work if "AND" isn't<br>> >> working right. This is the only if statement in many=2C many source files<br>> >> that seems to be working wrong.<br>> >>=20<br>> >> Is it possible I'm missing something?? No I don't think so... here's a mo=<br>> >re<br>> >> explicit version:<br>> >>=20<br>> >> Debug.Out("t.rest # NIL? " & Fmt.Bool(t.rest#NIL))=3B<br>> >> Debug.Out("ISTYPE(t.rest=2CT)? " & Fmt.Bool(ISTYPE(t.rest=2CT)))=3B<br>> >> Debug.Out("Rest(t.rest) =3D NIL? " & Fmt.Bool(Rest(t.rest)=3DNIL))=3B<br>> >> Debug.Out("conjunction? " & Fmt.Bool(<br>> >> t.rest # NIL AND ISTYPE(t.rest=2CT) AND Rest(t.rest) =3D NIL ))=3B<br>> >> IF t.rest # NIL AND ISTYPE(t.rest=2CT) AND Rest(t.rest) =3D NIL THEN<br>> >> ...<br>> >>=20<br>> >> output is:<br>> >>=20<br>> >> t.rest # NIL? TRUE<br>> >> ISTYPE(t.rest=2CT)? TRUE<br>> >> Rest(t.rest) =3D NIL? TRUE<br>> >> conjunction? FALSE<br>> >> in ELSE clause...<br>> >>=20<br>> >> TRUE AND TRUE AND TRUE is FALSE??<br>> >>=20<br>> >> Note that:=20<br>> >>=20<br>> >> VAR q=2C w=2C e :=3D TRUE=3B<br>> >>=20<br>> >> Debug.Out("conjunction? " & Fmt.Bool(<br>> >> q AND w AND e))=3B<br>> >>=20<br>> >> results in TRUE (as it should).<br>> >>=20<br>> >>=20<br>> >> Mika<br>> >>=20<br>> ><br>> >--_55f6c801-7d57-4602-a131-dda139b64dfd_<br>> >Content-Type: text/html; charset="iso-8859-1"<br>> >Content-Transfer-Encoding: quoted-printable<br>> ><br>> ><html><br>> ><head><br>> ><style><br>> >.hmmessage P<br>> >{<br>> >margin:0px=3B<br>> >padding:0px<br>> >}<br>> >body.hmmessage<br>> >{<br>> >font-size: 10pt=3B<br>> >font-family:Verdana<br>> >}<br>> ></style><br>> ></head><br>> ><body class=3D'hmmessage'><br>> >Kneejerk generic response:<BR><br>> >&nbsp=3B<BR><br>> >I don't know the operator precedence. Can you put in parens?<BR><br>> >Have you looked at the code?<BR><br>> >Can you mail us a small self contained repro?<BR><br>> >Can you test it on birch?<BR><br>> >&nbsp=3B (That way -- all your files are there and easily gotten/investigat=<br>> >ed by others.)<BR><br>> >Optimization enabled? Works without? I know=2C I shouldn't even ask this so=<br>> >rt of thing without evidence.<BR><br>> >&nbsp=3B<BR><br>> >&nbsp=3B- Jay<BR>&nbsp=3B<BR>&gt=3B To:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><BR>&gt=3B Dat=<br>> >e: Tue=2C 16 Jun 2009 00:01:18 -0700<BR>&gt=3B From:<span class="Apple-converted-space"> </span><a href="mailto:mika@async.caltech.edu">mika@async.caltech.edu</a>=<br>> ><BR>&gt=3B CC:<span class="Apple-converted-space"> </span><a href="mailto:mika@camembert.async.caltech.edu">mika@camembert.async.caltech.edu</a><BR>&gt=3B Subject: [M3devel=<br>> >] Strange behavior in recent CM3-compiled code...<BR>&gt=3B <BR>&gt=3B <BR>=<br>> >&gt=3B Hello everyone=2C<BR>&gt=3B <BR>&gt=3B I'm trying to update to the l=<br>> >atest CM3 again=2C so that I can get my<BR>&gt=3B Mac working=2C and push m=<br>> >y project of migrating a largish codebase<BR>&gt=3B from PM3 to CM3 a littl=<br>> >e further.<BR>&gt=3B <BR>&gt=3B I updated CM3 today from CVS=2C on both my =<br>> >Mac and on a FreeBSD system=2C<BR>&gt=3B and ... my Scheme interpreter brok=<br>> >e. Here's what the code looks like=2C<BR>&gt=3B with annotations:<BR>&gt=3B=<br>> > <BR>&gt=3B 49 Debug.Out("t.rest =3D NIL? " &amp=3B Fmt.Bool(t.rest=3DNIL))=<br>> >=3B<BR>&gt=3B 50 Debug.Out("ISTYPE(t.rest=2CT)? " &amp=3B Fmt.Bool(ISTYPE(t=<br>> >.rest=2CT)))=3B<BR>&gt=3B 51 Debug.Out("Rest(t.rest) =3D NIL? " &amp=3B Fmt=<br>> >.Bool(Rest(t.rest)=3DNIL))=3B<BR>&gt=3B 52<BR>&gt=3B 53 IF t.rest # NIL AND=<br>> > ISTYPE(t.rest=2CT) AND Rest(t.rest) =3D NIL THEN<BR>&gt=3B 54 Debug.Out("i=<br>> >n IF clause...")=3B<BR>&gt=3B 55<BR>&gt=3B 56 IF SymEq(t.first=2C "quote") =<br>> >THEN special :=3D "'"<BR>&gt=3B 57 ELSIF SymEq(t.first=2C "quasiquote") THE=<br>> >N special :=3D "`"<BR>&gt=3B 58 ELSIF SymEq(t.first=2C "unquote") THEN spec=<br>> >ial :=3D "=2C"<BR>&gt=3B 59 ELSIF SymEq(t.first=2C "unquote-splicing") THEN=<br>> > special :=3D "=2C@"<BR>&gt=3B 60 END<BR>&gt=3B 61 ELSE<BR>&gt=3B 62 Debug.=<br>> >Out("in ELSE clause...")<BR>&gt=3B 63 END=3B<BR>&gt=3B <BR>&gt=3B all you n=<br>> >eed to know is that Debug.Out prints out debugging information<BR>&gt=3B to=<br>> > the terminal. What I see is...<BR>&gt=3B <BR>&gt=3B t.rest =3D NIL? FALSE<=<br>> >BR>&gt=3B ISTYPE(t.rest=2CT)? TRUE<BR>&gt=3B Rest(t.rest) =3D NIL? TRUE<BR>=<br>> >&gt=3B in ELSE clause...<BR>&gt=3B <BR>&gt=3B What gives!?<BR>&gt=3B <BR>&g=<br>> >t=3B Note this behavior occurs on both the Mac and on FreeBSD4 with a<BR>&g=<br>> >t=3B compiler and runtime bootstrapped today from some previous CM3.<BR>&gt=<br>> >=3B My old CM3 compiler was timestamped... April 30=2C I believe=2C and the=<br>> ><BR>&gt=3B code behaved properly under that one.<BR>&gt=3B <BR>&gt=3B I bel=<br>> >ieve I have also tried it both with and without compiler<BR>&gt=3B optimiza=<br>> >tions.<BR>&gt=3B <BR>&gt=3B I find it baffling that so much stuff (mentor!)=<br>> > can work if "AND" isn't<BR>&gt=3B working right. This is the only if state=<br>> >ment in many=2C many source files<BR>&gt=3B that seems to be working wrong.=<br>> ><BR>&gt=3B <BR>&gt=3B Is it possible I'm missing something?? No I don't thi=<br>> >nk so... here's a more<BR>&gt=3B explicit version:<BR>&gt=3B <BR>&gt=3B Deb=<br>> >ug.Out("t.rest # NIL? " &amp=3B Fmt.Bool(t.rest#NIL))=3B<BR>&gt=3B Debug.Ou=<br>> >t("ISTYPE(t.rest=2CT)? " &amp=3B Fmt.Bool(ISTYPE(t.rest=2CT)))=3B<BR>&gt=3B=<br>> > Debug.Out("Rest(t.rest) =3D NIL? " &amp=3B Fmt.Bool(Rest(t.rest)=3DNIL))=<br>> >=3B<BR>&gt=3B Debug.Out("conjunction? " &amp=3B Fmt.Bool(<BR>&gt=3B t.rest =<br>> ># NIL AND ISTYPE(t.rest=2CT) AND Rest(t.rest) =3D NIL ))=3B<BR>&gt=3B IF t.=<br>> >rest # NIL AND ISTYPE(t.rest=2CT) AND Rest(t.rest) =3D NIL THEN<BR>&gt=3B .=<br>> >..<BR>&gt=3B <BR>&gt=3B output is:<BR>&gt=3B <BR>&gt=3B t.rest # NIL? TRUE<=<br>> >BR>&gt=3B ISTYPE(t.rest=2CT)? TRUE<BR>&gt=3B Rest(t.rest) =3D NIL? TRUE<BR>=<br>> >&gt=3B conjunction? FALSE<BR>&gt=3B in ELSE clause...<BR>&gt=3B <BR>&gt=3B =<br>> >TRUE AND TRUE AND TRUE is FALSE??<BR>&gt=3B <BR>&gt=3B Note that: <BR>&gt=<br>> >=3B <BR>&gt=3B VAR q=2C w=2C e :=3D TRUE=3B<BR>&gt=3B <BR>&gt=3B Debug.Out(=<br>> >"conjunction? " &amp=3B Fmt.Bool(<BR>&gt=3B q AND w AND e))=3B<BR>&gt=3B <B=<br>> >R>&gt=3B results in TRUE (as it should).<BR>&gt=3B <BR>&gt=3B <BR>&gt=3B Mi=<br>> >ka<BR>&gt=3B <BR></body><br>> ></html>=<br>> ><br>> >--_55f6c801-7d57-4602-a131-dda139b64dfd_--<br></div></span></blockquote></div><br></div></body></html>