[pypy-svn] r66682 - in pypy/branch/pyjitpl5/pypy/jit/backend: llgraph llvm minimal test x86
arigo at codespeak.net
arigo at codespeak.net
Wed Jul 29 22:32:19 CEST 2009
Author: arigo
Date: Wed Jul 29 22:32:18 2009
New Revision: 66682
Modified:
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
pypy/branch/pyjitpl5/pypy/jit/backend/llvm/runner.py
pypy/branch/pyjitpl5/pypy/jit/backend/minimal/runner.py
pypy/branch/pyjitpl5/pypy/jit/backend/test/runner_test.py
pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py
Log:
New detail in the backends: arraydescr.is_array_of_pointers().
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py Wed Jul 29 22:32:18 2009
@@ -46,6 +46,9 @@
def is_pointer_field(self):
return self.typeinfo == 'p'
+ def is_array_of_pointers(self):
+ return self.typeinfo == 'p'
+
def equals(self, other):
if not isinstance(other, Descr):
return False
@@ -673,6 +676,11 @@
self.setarrayitem = setarrayitem
self.getarraylength = getarraylength
self.instanceof = instanceof
+ self._is_array_of_pointers = (history.getkind(TYPE) == 'obj')
+
+ def is_array_of_pointers(self):
+ # for arrays, TYPE is the type of the array item.
+ return self._is_array_of_pointers
def __repr__(self):
return '<TypeDescr %s>' % self.TYPE._short_name()
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llvm/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llvm/runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llvm/runner.py Wed Jul 29 22:32:18 2009
@@ -706,6 +706,8 @@
self.itemsize_index = itemsize_index # index in cpu.types_by_index
self.ty_array_ptr = lltype.nullptr(llvm_rffi.LLVMTypeRef.TO)
# ^^^ set by setup_once()
+ def is_array_of_pointers(self):
+ return self.itemsize_index == LLVMCPU.SIZE_GCPTR
class CallDescr(AbstractDescr):
ty_function_ptr = lltype.nullptr(llvm_rffi.LLVMTypeRef.TO)
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/minimal/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/minimal/runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/minimal/runner.py Wed Jul 29 22:32:18 2009
@@ -415,10 +415,14 @@
x = %(input)s
p[index] = x
""" % dict).compile() in dict2
- return ArrayDescr(dict2['new'],
- dict2['length'],
- dict2['getarrayitem'],
- dict2['setarrayitem'])
+ if getkind(ARRAY.OF) == 'ptr':
+ Class = PtrArrayDescr
+ else:
+ Class = NonPtrArrayDescr
+ return Class(dict2['new'],
+ dict2['length'],
+ dict2['getarrayitem'],
+ dict2['setarrayitem'])
# ----------
@@ -607,10 +611,14 @@
x = %(input)s
a.ll_setitem_fast(index, x)
""" % dict).compile() in dict2
- return ArrayDescr(dict2['new'],
- dict2['length'],
- dict2['getarrayitem'],
- dict2['setarrayitem'])
+ if getkind(ARRAY.ITEM) == 'obj':
+ Class = PtrArrayDescr
+ else:
+ Class = NonPtrArrayDescr
+ return Class(dict2['new'],
+ dict2['length'],
+ dict2['getarrayitem'],
+ dict2['setarrayitem'])
@cached_method('_methdescrcache')
@@ -683,6 +691,14 @@
self.getarrayitem = getarrayitem
self.setarrayitem = setarrayitem
+class PtrArrayDescr(ArrayDescr):
+ def is_array_of_pointers(self):
+ return True
+
+class NonPtrArrayDescr(ArrayDescr):
+ def is_array_of_pointers(self):
+ return False
+
class CallDescr(AbstractDescr):
call = None
errbox = None
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/test/runner_test.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/test/runner_test.py Wed Jul 29 22:32:18 2009
@@ -387,6 +387,7 @@
def test_array_basic(self):
a_box, A = self.alloc_array_of(lltype.Signed, 342)
arraydescr = self.cpu.arraydescrof(A)
+ assert not arraydescr.is_array_of_pointers()
r = self.execute_operation(rop.ARRAYLEN_GC, [a_box],
'int', descr=arraydescr)
assert r.value == 342
@@ -400,6 +401,7 @@
#
a_box, A = self.alloc_array_of(lltype.Char, 11)
arraydescr = self.cpu.arraydescrof(A)
+ assert not arraydescr.is_array_of_pointers()
r = self.execute_operation(rop.ARRAYLEN_GC, [a_box],
'int', descr=arraydescr)
assert r.value == 11
@@ -422,6 +424,7 @@
A = lltype.Ptr(A)
b_box, B = self.alloc_array_of(A, 3)
arraydescr = self.cpu.arraydescrof(B)
+ assert arraydescr.is_array_of_pointers()
r = self.execute_operation(rop.ARRAYLEN_GC, [b_box],
'int', descr=arraydescr)
assert r.value == 3
@@ -436,6 +439,7 @@
# Unsigned should work the same as Signed
a_box, A = self.alloc_array_of(lltype.Unsigned, 342)
arraydescr = self.cpu.arraydescrof(A)
+ assert not arraydescr.is_array_of_pointers()
r = self.execute_operation(rop.ARRAYLEN_GC, [a_box],
'int', descr=arraydescr)
assert r.value == 342
@@ -450,6 +454,7 @@
# Bool should work the same as Char
a_box, A = self.alloc_array_of(lltype.Bool, 311)
arraydescr = self.cpu.arraydescrof(A)
+ assert not arraydescr.is_array_of_pointers()
r = self.execute_operation(rop.ARRAYLEN_GC, [a_box],
'int', descr=arraydescr)
assert r.value == 311
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py Wed Jul 29 22:32:18 2009
@@ -42,6 +42,9 @@
def is_pointer_field(self):
return self.flag2 # for fielddescrs
+ def is_array_of_pointers(self):
+ return self.flag2 # for arraydescrs
+
def equals(self, other):
if not isinstance(other, ConstDescr3):
return False
More information about the Pypy-commit
mailing list