[pypy-commit] pypy better-jit-hooks: added support for float getinteriorfield_raws
alex_gaynor
noreply at buildbot.pypy.org
Sun Jan 8 19:54:32 CET 2012
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: better-jit-hooks
Changeset: r51141:e44952da636d
Date: 2012-01-08 12:53 -0600
http://bitbucket.org/pypy/pypy/changeset/e44952da636d/
Log: added support for float getinteriorfield_raws
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,11 +234,11 @@
# longlongs are treated as floats, see
# e.g. llsupport/descr.py:getDescrClass
is_float = True
- elif kind == 'u':
+ elif kind == 'u' or kind == 's':
# they're all False
pass
else:
- assert False, "unsupported ffitype or kind"
+ raise NotImplementedError("unsupported ffitype or kind: %s" % kind)
#
fieldsize = rffi.getintfield(ffitype, 'c_size')
return self.optimizer.cpu.interiorfielddescrof_dynamic(
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
@@ -148,28 +148,38 @@
self.check_resops({'jump': 1, 'int_lt': 2, 'setinteriorfield_raw': 4,
'getinteriorfield_raw': 8, 'int_add': 6, 'guard_true': 2})
- def test_array_getitem_uint8(self):
+ def _test_getitem_type(self, TYPE, ffitype, COMPUTE_TYPE):
+ reds = ["n", "i", "s", "data"]
+ if COMPUTE_TYPE is lltype.Float:
+ # Move the float var to the back.
+ reds.remove("s")
+ reds.append("s")
myjitdriver = JitDriver(
greens = [],
- reds = ["n", "i", "s", "data"],
+ reds = reds,
)
def f(data, n):
- i = s = 0
+ i = 0
+ s = rffi.cast(COMPUTE_TYPE, 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))
+ s += rffi.cast(COMPUTE_TYPE, array_getitem(ffitype, rffi.sizeof(TYPE), data, 0, 0))
i += 1
return s
+ def main(n):
+ with lltype.scoped_alloc(rffi.CArray(TYPE), 1) as data:
+ data[0] = rffi.cast(TYPE, 200)
+ return f(data, n)
+ assert self.meta_interp(main, [10]) == 2000
- 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
+ def test_array_getitem_uint8(self):
+ self._test_getitem_type(rffi.UCHAR, types.uchar, lltype.Signed)
self.check_resops({'jump': 1, 'int_lt': 2, 'getinteriorfield_raw': 2,
'guard_true': 2, 'int_add': 4})
+ def test_array_getitem_float(self):
+ self._test_getitem_type(rffi.FLOAT, types.float, lltype.Float)
+
class TestFfiCall(FfiCallTests, LLJitMixin):
supports_all = False
More information about the pypy-commit
mailing list