[pypy-svn] pypy default: Fixes for test_ztranslation.py.

arigo commits-noreply at bitbucket.org
Wed Mar 16 11:48:27 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r42710:014b105118de
Date: 2011-03-16 06:47 -0400
http://bitbucket.org/pypy/pypy/changeset/014b105118de/

Log:	Fixes for test_ztranslation.py.

diff --git a/pypy/jit/codewriter/test/test_longlong.py b/pypy/jit/codewriter/test/test_longlong.py
--- a/pypy/jit/codewriter/test/test_longlong.py
+++ b/pypy/jit/codewriter/test/test_longlong.py
@@ -8,6 +8,7 @@
 from pypy.jit.codewriter.jtransform import Transformer, NotSupported
 from pypy.jit.codewriter.effectinfo import EffectInfo
 from pypy.jit.codewriter.test.test_jtransform import const
+from pypy.jit.codewriter import longlong
 
 
 class FakeRTyper:
@@ -28,6 +29,12 @@
         self.rtyper = FakeRTyper()
 
 
+def test_functions():
+    xll = longlong.getfloatstorage(3.5)
+    assert longlong.getrealfloat(xll) == 3.5
+    assert isinstance(longlong.gethash(xll), int)
+
+
 class TestLongLong:
     def setup_class(cls):
         if sys.maxint > 2147483647:

diff --git a/pypy/rpython/lltypesystem/opimpl.py b/pypy/rpython/lltypesystem/opimpl.py
--- a/pypy/rpython/lltypesystem/opimpl.py
+++ b/pypy/rpython/lltypesystem/opimpl.py
@@ -227,6 +227,14 @@
     assert isinstance(y, int)
     return x | y
 
+def op_int_xor(x, y):
+    # used in computing hashes
+    if isinstance(x, AddressAsInt): x = llmemory.cast_adr_to_int(x.adr)
+    if isinstance(y, AddressAsInt): y = llmemory.cast_adr_to_int(y.adr)
+    assert isinstance(x, int)
+    assert isinstance(y, int)
+    return x ^ y
+
 def op_int_mul(x, y):
     assert isinstance(x, (int, llmemory.AddressOffset))
     assert isinstance(y, (int, llmemory.AddressOffset))

diff --git a/pypy/jit/codewriter/longlong.py b/pypy/jit/codewriter/longlong.py
--- a/pypy/jit/codewriter/longlong.py
+++ b/pypy/jit/codewriter/longlong.py
@@ -38,7 +38,7 @@
 
     getfloatstorage = longlong2float.float2longlong
     getrealfloat    = longlong2float.longlong2float
-    gethash         = lambda xll: xll - (xll >> 32)
+    gethash         = lambda xll: rarithmetic.intmask(xll - (xll >> 32))
     is_longlong     = lambda TYPE: (TYPE == lltype.SignedLongLong or
                                     TYPE == lltype.UnsignedLongLong)
 


More information about the Pypy-commit mailing list