[pypy-commit] pypy win64_gborg: merge

ctismer noreply at buildbot.pypy.org
Wed Nov 9 14:38:06 CET 2011


Author: Christian Tismer <tismer at stackless.com>
Branch: win64_gborg
Changeset: r49011:5353e7a1dade
Date: 2011-11-09 14:37 +0100
http://bitbucket.org/pypy/pypy/changeset/5353e7a1dade/

Log:	merge

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,4 +1,4 @@
-from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift, LONG_BIT
+from pypy.rlib.rarithmetic import ovfcheck, LONG_BIT
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.jit.metainterp.resoperation import rop, ResOperation
 from pypy.jit.metainterp.history import BoxInt, ConstInt
@@ -174,10 +174,10 @@
            other.known_ge(IntBound(0, 0)) and \
            other.known_lt(IntBound(LONG_BIT, LONG_BIT)):
             try:
-                vals = (ovfcheck_lshift(self.upper, other.upper),
-                        ovfcheck_lshift(self.upper, other.lower),
-                        ovfcheck_lshift(self.lower, other.upper),
-                        ovfcheck_lshift(self.lower, other.lower))
+                vals = (ovfcheck(self.upper << other.upper),
+                        ovfcheck(self.upper << other.lower),
+                        ovfcheck(self.lower << other.upper),
+                        ovfcheck(self.lower << other.lower))
                 return IntBound(min4(vals), max4(vals))
             except (OverflowError, ValueError):
                 return IntUnbounded()
diff --git a/pypy/objspace/flow/operation.py b/pypy/objspace/flow/operation.py
--- a/pypy/objspace/flow/operation.py
+++ b/pypy/objspace/flow/operation.py
@@ -11,7 +11,7 @@
 from pypy.interpreter.baseobjspace import ObjSpace
 from pypy.interpreter.error import OperationError
 from pypy.tool.sourcetools import compile2
-from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift
+from pypy.rlib.rarithmetic import ovfcheck
 from pypy.objspace.flow import model
 
 
@@ -144,7 +144,7 @@
     return ovfcheck(x % y)
 
 def lshift_ovf(x, y):
-    return ovfcheck_lshift(x, y)
+    return ovfcheck(x << y)
 
 # slicing: operator.{get,set,del}slice() don't support b=None or c=None
 def do_getslice(a, b, c):
diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -6,7 +6,7 @@
 from pypy.objspace.std.noneobject import W_NoneObject
 from pypy.objspace.std.register_all import register_all
 from pypy.rlib import jit
-from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift, LONG_BIT, r_uint
+from pypy.rlib.rarithmetic import ovfcheck, LONG_BIT, r_uint
 from pypy.rlib.rbigint import rbigint
 
 """
@@ -245,7 +245,7 @@
     b = w_int2.intval
     if r_uint(b) < LONG_BIT: # 0 <= b < LONG_BIT
         try:
-            c = ovfcheck_lshift(a, b)
+            c = ovfcheck(a << b)
         except OverflowError:
             raise FailedToImplementArgs(space.w_OverflowError,
                                     space.wrap("integer left shift"))
diff --git a/pypy/rlib/listsort.py b/pypy/rlib/listsort.py
--- a/pypy/rlib/listsort.py
+++ b/pypy/rlib/listsort.py
@@ -1,4 +1,4 @@
-from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift
+from pypy.rlib.rarithmetic import ovfcheck
 
 
 ## ------------------------------------------------------------------------
@@ -136,7 +136,7 @@
                     if lower(a.list[p + ofs], key):
                         lastofs = ofs
                         try:
-                            ofs = ovfcheck_lshift(ofs, 1)
+                            ofs = ovfcheck(ofs << 1)
                         except OverflowError:
                             ofs = maxofs
                         else:
@@ -161,7 +161,7 @@
                         # key <= a[hint - ofs]
                         lastofs = ofs
                         try:
-                            ofs = ovfcheck_lshift(ofs, 1)
+                            ofs = ovfcheck(ofs << 1)
                         except OverflowError:
                             ofs = maxofs
                         else:
diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -12,9 +12,6 @@
          back to a signed int value
 ovfcheck check on CPython whether the result of a signed
          integer operation did overflow
-ovfcheck_lshift
-         << with oveflow checking
-         catering to 2.3/2.4 differences about <<
 ovfcheck_float_to_int
          convert to an integer or raise OverflowError
 r_longlong
@@ -152,19 +149,6 @@
         raise OverflowError, "signed integer expression did overflow"
     return r
 
-def _local_ovfcheck(r):
-    # a copy of the above, because we cannot call ovfcheck
-    # in a context where no primitiveoperator is involved.
-    assert not isinstance(r, r_uint), "unexpected ovf check on unsigned"
-    # if isinstance(r, long):
-    if abs(r) > sys.maxint:
-        raise OverflowError, "signed integer expression did overflow"
-    return r
-
-def ovfcheck_lshift(a, b):
-    "NOT_RPYTHON"
-    return _local_ovfcheck(int(long(a) << b))
-
 # Strange things happening for float to int on 64 bit:
 # int(float(i)) != i  because of rounding issues.
 # These are the minimum and maximum float value that can
diff --git a/pypy/rpython/llinterp.py b/pypy/rpython/llinterp.py
--- a/pypy/rpython/llinterp.py
+++ b/pypy/rpython/llinterp.py
@@ -1,6 +1,6 @@
 from pypy.objspace.flow.model import FunctionGraph, Constant, Variable, c_last_exception
 from pypy.rlib.rarithmetic import intmask, r_uint, ovfcheck, r_longlong
-from pypy.rlib.rarithmetic import r_ulonglong, ovfcheck_lshift
+from pypy.rlib.rarithmetic import r_ulonglong
 from pypy.rpython.lltypesystem import lltype, llmemory, lloperation, llheap
 from pypy.rpython.lltypesystem import rclass
 from pypy.rpython.ootypesystem import ootype
@@ -1038,7 +1038,7 @@
         assert isinstance(x, (int, long))
         assert isinstance(y, (int, long))
         try:
-            return ovfcheck_lshift(x, y)
+            return ovfcheck(x << y)
         except OverflowError:
             self.make_llexception()
 
diff --git a/pypy/translator/cli/test/test_snippet.py b/pypy/translator/cli/test/test_snippet.py
--- a/pypy/translator/cli/test/test_snippet.py
+++ b/pypy/translator/cli/test/test_snippet.py
@@ -28,14 +28,14 @@
         res = self.interpret(fn, [], backendopt=False)
         
     def test_link_vars_overlapping(self):
-        from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift
+        from pypy.rlib.rarithmetic import ovfcheck
         def fn(maxofs):
             lastofs = 0
             ofs = 1
             while ofs < maxofs:
                 lastofs = ofs
                 try:
-                    ofs = ovfcheck_lshift(ofs, 1)
+                    ofs = ovfcheck(ofs << 1)
                 except OverflowError:
                     ofs = maxofs
                 else:
diff --git a/pypy/translator/simplify.py b/pypy/translator/simplify.py
--- a/pypy/translator/simplify.py
+++ b/pypy/translator/simplify.py
@@ -111,16 +111,13 @@
                 # the while loop above will simplify recursively the new link
 
 def transform_ovfcheck(graph):
-    """The special function calls ovfcheck and ovfcheck_lshift need to
+    """The special function calls ovfcheck needs to
     be translated into primitive operations. ovfcheck is called directly
     after an operation that should be turned into an overflow-checked
     version. It is considered a syntax error if the resulting <op>_ovf
     is not defined in objspace/flow/objspace.py.
-    ovfcheck_lshift is special because there is no preceding operation.
-    Instead, it will be replaced by an OP_LSHIFT_OVF operation.
     """
     covf = Constant(rarithmetic.ovfcheck)
-    covfls = Constant(rarithmetic.ovfcheck_lshift)
 
     def check_syntax(opname):
         exlis = operation.implicit_exceptions.get("%s_ovf" % (opname,), [])
@@ -154,9 +151,6 @@
                 op1.opname += '_ovf'
                 del block.operations[i]
                 block.renamevariables({op.result: op1.result})
-            elif op.args[0] == covfls:
-                op.opname = 'lshift_ovf'
-                del op.args[0]
 
 def simplify_exceptions(graph):
     """The exception handling caused by non-implicit exceptions
diff --git a/pypy/translator/test/snippet.py b/pypy/translator/test/snippet.py
--- a/pypy/translator/test/snippet.py
+++ b/pypy/translator/test/snippet.py
@@ -1210,7 +1210,7 @@
     return istk.top(), sstk.top()
 
 
-from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift
+from pypy.rlib.rarithmetic import ovfcheck
 
 def add_func(i=numtype):
     try:
@@ -1253,7 +1253,7 @@
 def lshift_func(i=numtype):
     try:
         hugo(2, 3, 5)
-        return ovfcheck_lshift((-maxint-1), i)
+        return ovfcheck((-maxint-1) << i)
     except (hugelmugel, OverflowError, StandardError, ValueError):
         raise
 


More information about the pypy-commit mailing list