New codegen failing test-cases

Edward Z. Yang ezyang at MIT.EDU
Wed Jan 12 23:10:11 CET 2011


I appear to have tracked down the bug for ffi021:  the new
code generator doesn't appear to clear the tag bit for the
pointer to heap before:

        // outOfLine should follow:
        (_sR1::I32,) = foreign "ccall"
          _sQR::I32((I32[_sRi::I32 + 7], `signed'),
                    (I32[_sRi::I32 + 11], PtrHint),
                    (I32[_sRi::I32 + 15],))[_unsafe_call_];
        // emitReturn: Sequel: Assign
        ;

(gdb) disas
Dump of assembler code for function sRi_info:
=> 0x0804aa6c <+0>:     mov    %esi,%eax
   0x0804aa6e <+2>:     lea    0x0(%ebp),%ecx
   0x0804aa71 <+5>:     cmp    0x54(%ebx),%ecx
   0x0804aa74 <+8>:     jb     0x804aab3 <sRi_info+71>
   0x0804aa76 <+10>:    add    $0x4,%ebp
   0x0804aa79 <+13>:    add    $0x8,%edi
   0x0804aa7c <+16>:    cmp    0x5c(%ebx),%edi
   0x0804aa7f <+19>:    ja     0x804aaa4 <sRi_info+56>
   0x0804aa81 <+21>:    pushl  0xf(%eax)
   0x0804aa84 <+24>:    pushl  0xb(%eax)
   0x0804aa87 <+27>:    pushl  0x7(%eax)
   0x0804aa8a <+30>:    call   *%eax

The pushes to the stack properly untag eax, but then we just
call the tagged pointer, which seems pretty wrong to me. Here is
the old C--:

        (_sR1::I32,) = foreign "ccall"
          I32[R1 + 3]((_cSc::I32, `signed'), (_cSe::I32, PtrHint),
                      (_cSg::I32,))[_unsafe_call_];

Unfortunately, I can't figure out where this +3 is supposed to
be happening, so I don't have a patch. Some guidance here would
be appreciated.

Cheers,
Edward



More information about the Glasgow-haskell-users mailing list