[M3commit] CVS Update: cm3

Jay K jay.krell at cornell.edu
Wed Feb 10 17:37:23 CET 2010


Please look for "word." in the historical m3back, anything from a week or so ago, the release branch, any other release, etc.

I know I get runtime errors for large shift counts, I haven't used insert/extract as much, but if they are broken, then they have probably been broken a long time, probably forever.

 

 - Jay

 


From: jay.krell at cornell.edu
To: hosking at cs.purdue.edu; jkrell at elego.de
Date: Wed, 10 Feb 2010 16:31:28 +0000
CC: m3commit at elegosoft.com
Subject: Re: [M3commit] CVS Update: cm3



I don't really allow Add/Subtract to overflow.
  In fact I didn't make that change. I removed the overflow in the test case.
  My work is actually finding code that depends on silent overflow.
 
My usage follows historical usage.
Even the change I did have, not sure it is still there, returned the correct "false".
  But after possible garbage produced (or the wraparound value))
 
 
Realize that all my tint/tword code used to use word. There were no checks.
 
 
Ok, some overflow I'm allowing is like here, so I must have kept a change in ToInt:
 
    IF (NOT TInt.ToInt(imm, ins.imm)) AND (NOT TWord.LE(imm, Target.Word32.max)) THEN
      t.Err("immOp1: unable to convert immediate to INTEGER:" & Target.TargetIntToDiagnosticText(imm));
    END;

    IF (NOT TInt.ToInt(imm, ins.imm)) AND (NOT TWord.LE(imm, Target.Word32.max)) THEN
      t.Err("movImmT: unable to convert immediate to INTEGER:" & Target.TargetIntToDiagnosticText(imm));
    END;

        IF (NOT TInt.ToInt(src.imm, ins.imm)) AND (NOT TWord.LE(src.imm, Target.Word32.max)) THEN
          t.Err("pushOp: unable to convert immediate to INTEGER:" & Target.TargetIntToDiagnosticText(src.imm));
        END;

It really is around some type ambiguity.
Is the value signed or unsigned?
Maybe we need TWord.ToWord(Word.T)?
I think that is the simple answer really. Overflow checking good, no need to proceed with an answer, as long as we have a variant for conversion to 0..2^n. For now TInt.ToInt is what I use, a bit off.
 
 - Jay

 


From: hosking at cs.purdue.edu
Date: Wed, 10 Feb 2010 10:18:24 -0500
To: jkrell at elego.de
CC: m3commit at elegosoft.com
Subject: Re: [M3commit] CVS Update: cm3

Jay,  I think your usage of TInt and TWord is strongly at odds with its intended use.  Certainly, allowing TInt.Add/Subtract to overflow will break large swaths of the front-end.  There is a deep contract there that requires that TInt arithmetic not provide bogus results. 






Antony Hosking | Associate Professor | Computer Science | Purdue University
305 N. University Street | West Lafayette | IN 47907 | USA
Office +1 765 494 6001 | Mobile +1 765 427 5484



On 10 Feb 2010, at 12:58, Jay Krell wrote:

CVSROOT: /usr/cvs
Changes by: jkrell at birch. 10/02/10 12:58:11

Modified files:
cm3/m3-sys/m3back/src/: Stackx86.m3 

Log message:
allow negating FIRST(INTEGER) even though it overflows
allows this test case to compile:
C:\dev2\cm3.2\m3-sys\m3tests\src\p1\p137>cm3
--- building in NT386 ---

new source -> compiling Main.m3
"..\Main.m3", line 35: doneg: Negate overflowed
1 error encountered
compilation failed => not building program "pgm.exe"
Fatal Error: package build failed

tempting to make TInt.Add/Subtract return the value
even if overflow, but for now, no.
This fix assumes two's complement, that is,
it assumes FIRST(INTEGER) = -FIRST(INTEGER)

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3commit/attachments/20100210/8ad86807/attachment-0002.html>


More information about the M3commit mailing list