[M3commit] CVS Update: cm3

Rodney M. Bates rodney.bates at wichita.edu
Fri Apr 11 21:45:21 CEST 2008



Rodney M. Bates wrote:
> 
> 
> Tony Hosking wrote:
> 
>> I am tracking down this bug right now (trying to get a 64-bit  
>> AMD64_DARWIN port) up and running.  If you have something as a  
>> testcase that will demonstrate the problem I would appreciate it.
> 
> 
> Attached.  It doesn't write any output.  I just used m3gdb to go in and
> print variables at various times.  Line 16 is enough to show the problem.
> I also used m3cgcat, where the problem also shows.
> 
> Where things go wrong is in TInt.ToInt, line 65:

Thinking about this while eating lunch, I realized this analysis couldn't
be right.  I just checked in a different fix (to TInt.CheckSign) and backed
out my previous hack.  This one is much better.  It gives a system than can
bootstrap itself twice, build the whole distribution, and makes my test case
work right.

This reminded my of my late father, a Chemical Engineer.  He once had an
article roasting Chemical Engineers that said "Chemical Engineers have a
lot of equations they believe are true because they can integrate them twice."


> 
> 
> PROCEDURE ToInt (READONLY r: Int;  VAR x: INTEGER): BOOLEAN =
>   VAR sign := CheckSign (r, BITSIZE (INTEGER) DIV BITSIZE (IByte)); (* 
> <=== line 65, HERE. *)
>   BEGIN
>     (* ensure the result has the right sign extension *)
>     CASE sign OF
>     | Sign.Bad => RETURN FALSE;
>     | Sign.Pos => x := 0;
>     | Sign.Neg => x := Word.Not (0);
>     END;
> 
>     (* finally, pack the bits *)
>     FOR i := r.n-1 TO 0 BY -1  DO
>       x := Word.Or (LShift (x, BITSIZE (IByte)), r.x[i]);
>     END;
> 
>     RETURN TRUE;
>   END ToInt;
> 
> The value gets through all the stages OK to here, with r.n=8, but the 2nd
> actual parameter to CheckSign is 4, and CheckSign thinks the value is
> negative and within the range of INTEGER.  I think just passing r.n to
> CheckSign would be right, but there are lots of calls on ToInt that I
> haven't looked at, so for a quick fix, I did the hack at the relevant call
> site in M3CG_BinWr.
> 
>
-- 
-------------------------------------------------------------
Rodney M. Bates, retired assistant professor
Dept. of Computer Science, Wichita State University
Wichita, KS 67260-0083
316-978-3922
rodney.bates at wichita.edu



More information about the M3commit mailing list