[pypy-svn] r76631 - in pypy/branch/micronumpy/pypy/jit/backend: llsupport test
arigo at codespeak.net
arigo at codespeak.net
Mon Aug 16 14:47:05 CEST 2010
Author: arigo
Date: Mon Aug 16 14:47:03 2010
New Revision: 76631
Modified:
pypy/branch/micronumpy/pypy/jit/backend/llsupport/descr.py
pypy/branch/micronumpy/pypy/jit/backend/test/runner_test.py
Log:
Add a passing test. Check that we don't get plain lltype.Arrays.
Modified: pypy/branch/micronumpy/pypy/jit/backend/llsupport/descr.py
==============================================================================
--- pypy/branch/micronumpy/pypy/jit/backend/llsupport/descr.py (original)
+++ pypy/branch/micronumpy/pypy/jit/backend/llsupport/descr.py Mon Aug 16 14:47:03 2010
@@ -195,9 +195,13 @@
try:
return cache[ARRAY]
except KeyError:
+ # we only support Arrays that are either GcArrays, or raw no-length
+ # non-gc Arrays.
if ARRAY._hints.get('nolength', False):
+ assert not isinstance(ARRAY, lltype.GcArray)
arraydescr = getArrayNoLengthDescrClass(ARRAY)()
else:
+ assert isinstance(ARRAY, lltype.GcArray)
arraydescr = getArrayDescrClass(ARRAY)()
# verify basic assumption that all arrays' basesize and ofslength
# are equal
Modified: pypy/branch/micronumpy/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/micronumpy/pypy/jit/backend/test/runner_test.py (original)
+++ pypy/branch/micronumpy/pypy/jit/backend/test/runner_test.py Mon Aug 16 14:47:03 2010
@@ -1832,6 +1832,31 @@
assert self.cpu.get_latest_value_float(0) == 13.5
assert called
+ def test_raw_malloced_getarrayitem(self):
+ ARRAY = rffi.CArray(lltype.Signed)
+ descr = self.cpu.arraydescrof(ARRAY)
+ a = lltype.malloc(ARRAY, 10, flavor='raw')
+ a[7] = -4242
+ addr = llmemory.cast_ptr_to_adr(a)
+ abox = BoxInt(heaptracker.adr2int(addr))
+ r1 = self.execute_operation(rop.GETARRAYITEM_RAW, [abox, BoxInt(7)],
+ 'int', descr=descr)
+ assert r1.getint() == -4242
+ lltype.free(a, flavor='raw')
+
+ def test_raw_malloced_setarrayitem(self):
+ ARRAY = rffi.CArray(lltype.Signed)
+ descr = self.cpu.arraydescrof(ARRAY)
+ a = lltype.malloc(ARRAY, 10, flavor='raw')
+ addr = llmemory.cast_ptr_to_adr(a)
+ abox = BoxInt(heaptracker.adr2int(addr))
+ self.execute_operation(rop.SETARRAYITEM_RAW, [abox, BoxInt(5),
+ BoxInt(12345)],
+ 'int', descr=descr)
+ assert a[5] == 12345
+ lltype.free(a, flavor='raw')
+
+
class OOtypeBackendTest(BaseBackendTest):
type_system = 'ootype'
More information about the Pypy-commit
mailing list