Author: Christian Tismer <[email protected]>
Branch: win64-stage1
Changeset: r49749:df362a54e674
Date: 2011-11-24 19:50 +0100
http://bitbucket.org/pypy/pypy/changeset/df362a54e674/

Log:    Starting stage2 a bit by defining maxint in rarithmetic

diff --git a/pypy/jit/metainterp/optimizeopt/intutils.py 
b/pypy/jit/metainterp/optimizeopt/intutils.py
--- a/pypy/jit/metainterp/optimizeopt/intutils.py
+++ b/pypy/jit/metainterp/optimizeopt/intutils.py
@@ -1,10 +1,9 @@
-from pypy.rlib.rarithmetic import ovfcheck, LONG_BIT
+from pypy.rlib.rarithmetic import ovfcheck, LONG_BIT, maxint, is_valid_int
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.jit.metainterp.resoperation import rop, ResOperation
 from pypy.jit.metainterp.history import BoxInt, ConstInt
-import sys
-MAXINT = sys.maxint
-MININT = -sys.maxint - 1
+MAXINT = maxint
+MININT = -maxint - 1
 
 class IntBound(object):
     _attrs_ = ('has_upper', 'has_lower', 'upper', 'lower')
@@ -16,8 +15,8 @@
         self.lower = lower
         # check for unexpected overflows:
         if not we_are_translated():
-            assert type(upper) is not long
-            assert type(lower) is not long
+            assert is_valid_int(upper)
+            assert is_valid_int(lower)
 
     # Returns True if the bound was updated
     def make_le(self, other):
diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -92,7 +92,7 @@
 We therefore can no longer use the int type as it is, but need
 to use long everywhere.
 """
-    
+
 def intmask(n):
     if isinstance(n, objectmodel.Symbolic):
         return n        # assume Symbolics don't overflow
@@ -133,8 +133,11 @@
         r_class.BITS == LONG_BIT and r_class.SIGNED)
 _should_widen_type._annspecialcase_ = 'specialize:memo'
 
+# the replacement for sys.maxint
+maxint = int(LONG_TEST - 1)
+
 def is_valid_int(r):
-    return -sys.maxint - 1 <= r <= sys.maxint
+    return -maxint - 1 <= r <= maxint
 
 def ovfcheck(r):
     "NOT_RPYTHON"
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to