[pypy-commit] pypy default: make the dynamic interiorfield optimization work correctly with unsigned values

alex_gaynor noreply at buildbot.pypy.org
Thu Dec 8 11:42:22 CET 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r50293:617e1464542c
Date: 2011-12-08 05:41 -0500
http://bitbucket.org/pypy/pypy/changeset/617e1464542c/

Log:	make the dynamic interiorfield optimization work correctly with
	unsigned values

diff --git a/pypy/jit/metainterp/optimizeopt/fficall.py b/pypy/jit/metainterp/optimizeopt/fficall.py
--- a/pypy/jit/metainterp/optimizeopt/fficall.py
+++ b/pypy/jit/metainterp/optimizeopt/fficall.py
@@ -234,6 +234,9 @@
             # longlongs are treated as floats, see
             # e.g. llsupport/descr.py:getDescrClass
             is_float = True
+        elif kind == 'u':
+            # they're all False
+            pass
         else:
             assert False, "unsupported ffitype or kind"
         #
diff --git a/pypy/jit/metainterp/test/test_fficall.py b/pypy/jit/metainterp/test/test_fficall.py
--- a/pypy/jit/metainterp/test/test_fficall.py
+++ b/pypy/jit/metainterp/test/test_fficall.py
@@ -147,6 +147,29 @@
         self.check_resops({'jump': 2, 'int_lt': 2, 'setinteriorfield_raw': 4,
                            'getinteriorfield_raw': 8, 'int_add': 6, 'guard_true': 2})
 
+    def test_array_getitem_uint8(self):
+        myjitdriver = JitDriver(
+            greens = [],
+            reds = ["n", "i", "s", "data"],
+        )
+        def f(data, n):
+            i = s = 0
+            while i < n:
+                myjitdriver.jit_merge_point(n=n, i=i, s=s, data=data)
+                s += rffi.cast(lltype.Signed, array_getitem(types.uchar, 1, data, 0, 0))
+                i += 1
+            return s
+
+        def main(n):
+            with lltype.scoped_alloc(rffi.CArray(rffi.UCHAR), 1) as data:
+                data[0] = rffi.cast(rffi.UCHAR, 200)
+                return f(data, n)
+
+        assert self.meta_interp(main, [10]) == 2000
+        self.check_resops({'jump': 2, 'int_lt': 2, 'getinteriorfield_raw': 2,
+                           'guard_true': 2, 'int_add': 4})
+
+
 class TestFfiCall(FfiCallTests, LLJitMixin):
     supports_all = False
 


More information about the pypy-commit mailing list