[MLton-devel] cvs commit: Const.SmallIntInf and IntInf.rep
Stephen Weeks
sweeks@users.sourceforge.net
Wed, 02 Jul 2003 08:08:16 -0700
sweeks 03/07/02 08:08:16
Modified: mlton/atoms const.fun const.sig prim.fun
Log:
Fixed bug that Henry saw (and Matthew found) with small negative
IntInf constants. The problem was int Const.SmallIntInf.t, which
treated the word corresponding to a small IntInf inconsistently.
SmallIntInf.toWord shifted and added the tag bit, whit
SmallIntInf.fromWord assumed the tag bit wasn't there. As a
consequence, the SSA simplifier treated small negative IntInf's as
large ones, i.e. as word vectors, and they got propagated to the x86
codegen which tried to treat an constant integer as a base address.
Unfortunately, it's not a good fix to use MLton.IntInf.rep, for two
reasons. First, MLton still needs work when compiled using
mlton-stubs, so this just shifts the duplicated code from
Const.SmallIntInf to the stubs. Second, even worse,
MLton.IntInf.Small w leaves the word untagged instead of tagged. So
there wasn't much to be gained by moving the code to the stubs, since
we still need a slightly different treatment. It might be worth
moving to the stubs if we change the meaning of MLton.IntInf.rep.
Anyone have any thoughts one way or the other on that? I prefer
leaving it as is for two reasons. One, that's the way it is now and I
assume at least PolySpace is using it. Two, the shift and tag is
really part of the low level implementation and it's not clear it
should be exposed.
Hmmm. It occurs to me that the right thing to do is to change rep
from:
datatype rep =
Small of word
| Big of word vector
to:
datatype rep =
Small of int
| Big of word vector
That has nothing to do with the bug at hand, but it does clarify the
issue with the tag, since it makes clear that we're dealing with an
int and not some low level representation. It also solves the problem
with legacy code, since it will cause type errors for those who use
it.
Revision Changes Path
1.9 +2 -4 mlton/mlton/atoms/const.fun
Index: const.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/atoms/const.fun,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- const.fun 23 Jun 2003 04:58:55 -0000 1.8
+++ const.fun 2 Jul 2003 15:08:16 -0000 1.9
@@ -53,10 +53,8 @@
0w1)))
else NONE
- fun fromWord (w: word): IntInf.t option =
- if w < 0wx80000000
- then SOME (IntInf.fromInt (Word.toIntX (Word.~>> (w, 0w1))))
- else NONE
+ fun fromWord (w: word): IntInf.t =
+ IntInf.fromInt (Word.toIntX (Word.~>> (w, 0w1)))
end
datatype t =
1.8 +1 -1 mlton/mlton/atoms/const.sig
Index: const.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/atoms/const.sig,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- const.sig 23 Jun 2003 04:58:55 -0000 1.7
+++ const.sig 2 Jul 2003 15:08:16 -0000 1.8
@@ -22,9 +22,9 @@
structure SmallIntInf:
sig
+ val fromWord: word -> IntInf.t
val isSmall: IntInf.t -> bool
val toWord: IntInf.t -> word option
- val fromWord: word -> IntInf.t option
end
datatype t =
1.54 +1 -3 mlton/mlton/atoms/prim.fun
Index: prim.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/atoms/prim.fun,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- prim.fun 25 Jun 2003 23:15:31 -0000 1.53
+++ prim.fun 2 Jul 2003 15:08:16 -0000 1.54
@@ -929,9 +929,7 @@
| (Word_toInt (_, s), [Word w]) =>
int (IntX.make (WordX.toIntInf w, s))
| (Word_toIntInf, [Word w]) =>
- (case SmallIntInf.fromWord (WordX.toWord w) of
- NONE => ApplyResult.Unknown
- | SOME i => intInf i)
+ intInf (SmallIntInf.fromWord (WordX.toWord w))
| (Word_toIntX (_, s), [Word w]) =>
int (IntX.make (WordX.toIntInfX w, s))
| (Word_toWord (_, s), [Word w]) => word (WordX.resize (w, s))
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel