[MLton] Re: Bug? print statement makes program terminate / run-forever

Wesley W. Terpstra wesley at terpstra.ca
Wed Jun 24 12:16:24 PDT 2009


On Wed, Jun 24, 2009 at 9:06 PM, Vesa Karvonen <vesa.a.j.k at gmail.com> wrote:

> > MLton 20061107 works. So does 20070826.
>

Strange that this didn't used to happen.


> Did you try this on a x86 platform?
>

This was only on x86, yes.


> If so, did you try with -ieee-fp true?
>

With this flag it terminates.


> Here is my theory.  On x86, the
> print in the loop has the effect of forcing the y' value out of FP
> registers.  This allows the loop to terminate.  Otherwise, with the
> 80-bit registers of the x86, and the 80-bit value of y' in a register
> at the time of the comparison, the loop will never terminate as the
> 64-bit value of y and the 80-bit value of y' will never be equal.


Actually it seems the two 80-bit values never become equal:
 loop_12:
        fldL (globalReal64+0x8)
        fldL 0x30(%ebp)
        fdivr %st, %st(1)
        fadd %st, %st(1)
        fxch %st(1)
        fdivL (globalReal64+0x0)
        fxch %st(1)
        fucomp %st(1)
        fnstsw %ax
        andw $0x4500,%ax
        cmpw $0x4000,%ax
        je L_1331
L_151:
        fstpL 0x30(%ebp)
        jmp loop_12

The comparison is indeed happening in a floating point register, which means
it might behave differently than when truncated in/out of memory for the C
call.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mlton.org/pipermail/mlton/attachments/20090624/8eba5668/attachment.html


More information about the MLton mailing list