Author: Armin Rigo <ar...@tunes.org>
Branch: heapcache-refactor
Changeset: r83134:5f85929ae2ee
Date: 2016-03-18 18:00 +0100
http://bitbucket.org/pypy/pypy/changeset/5f85929ae2ee/

Log:    Test and fix

diff --git a/rpython/jit/metainterp/history.py 
b/rpython/jit/metainterp/history.py
--- a/rpython/jit/metainterp/history.py
+++ b/rpython/jit/metainterp/history.py
@@ -651,10 +651,15 @@
     _attrs_ = ('position_and_flags',)
 
     def __init__(self, pos):
-        self.position_and_flags = r_uint(pos << FO_POSITION_SHIFT)
+        # p is the 32-bit position shifted left by one (might be negative,
+        # but casted to the 32-bit UINT type)
+        p = rffi.cast(rffi.UINT, pos << FO_POSITION_SHIFT)
+        self.position_and_flags = r_uint(p)    # zero-extended to a full word
 
     def get_position(self):
-        return intmask(r_uint32(self.position_and_flags)) >> FO_POSITION_SHIFT
+        # p is the signed 32-bit position, from self.position_and_flags
+        p = rffi.cast(rffi.INT, self.position_and_flags)
+        return intmask(p) >> FO_POSITION_SHIFT
 
     def is_replaced_with_const(self):
         return bool(self.position_and_flags & FO_REPLACED_WITH_CONST)
diff --git a/rpython/jit/metainterp/test/test_history.py 
b/rpython/jit/metainterp/test/test_history.py
--- a/rpython/jit/metainterp/test/test_history.py
+++ b/rpython/jit/metainterp/test/test_history.py
@@ -62,6 +62,12 @@
     assert c5.nonnull()
     assert c6.nonnull()
 
+def test_frontendop():
+    f = FrontendOp(42)
+    assert f.get_position() == 42
+    f = FrontendOp(-56)
+    assert f.get_position() == -56
+
 class TestZTranslated(StandaloneTests):
     def test_ztranslated_same_constant_float(self):
         def fn(args):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to