[pypy-svn] r78397 - in pypy/trunk/pypy/jit/codewriter: . test
arigo at codespeak.net
arigo at codespeak.net
Thu Oct 28 13:32:07 CEST 2010
Author: arigo
Date: Thu Oct 28 13:32:06 2010
New Revision: 78397
Modified:
pypy/trunk/pypy/jit/codewriter/format.py
pypy/trunk/pypy/jit/codewriter/jtransform.py
pypy/trunk/pypy/jit/codewriter/test/test_list.py
Log:
Minimal support for void lists: remove the operations that are no-ops.
Modified: pypy/trunk/pypy/jit/codewriter/format.py
==============================================================================
--- pypy/trunk/pypy/jit/codewriter/format.py (original)
+++ pypy/trunk/pypy/jit/codewriter/format.py Thu Oct 28 13:32:06 2010
@@ -80,7 +80,8 @@
def assert_format(ssarepr, expected):
asm = format_assembler(ssarepr)
- expected = str(py.code.Source(expected)).strip() + '\n'
+ if expected != '':
+ expected = str(py.code.Source(expected)).strip() + '\n'
asmlines = asm.split("\n")
explines = expected.split("\n")
for asm, exp in zip(asmlines, explines):
Modified: pypy/trunk/pypy/jit/codewriter/jtransform.py
==============================================================================
--- pypy/trunk/pypy/jit/codewriter/jtransform.py (original)
+++ pypy/trunk/pypy/jit/codewriter/jtransform.py Thu Oct 28 13:32:06 2010
@@ -894,17 +894,21 @@
prefix = 'do_resizable_'
ARRAY = LIST.items.TO
if self._array_of_voids(ARRAY):
- raise NotSupported("resizable lists of voids")
- descrs = (self.cpu.arraydescrof(ARRAY),
- self.cpu.fielddescrof(LIST, 'length'),
- self.cpu.fielddescrof(LIST, 'items'),
- self.cpu.sizeof(LIST))
+ prefix += 'void_'
+ descrs = ()
+ else:
+ descrs = (self.cpu.arraydescrof(ARRAY),
+ self.cpu.fielddescrof(LIST, 'length'),
+ self.cpu.fielddescrof(LIST, 'items'),
+ self.cpu.sizeof(LIST))
else:
prefix = 'do_fixed_'
if self._array_of_voids(LIST):
- raise NotSupported("fixed lists of voids")
- arraydescr = self.cpu.arraydescrof(LIST)
- descrs = (arraydescr,)
+ prefix += 'void_'
+ descrs = ()
+ else:
+ arraydescr = self.cpu.arraydescrof(LIST)
+ descrs = (arraydescr,)
#
try:
meth = getattr(self, prefix + oopspec_name.replace('.', '_'))
@@ -943,6 +947,11 @@
descr, args[1]], v_posindex)
return v_posindex, [op0, op1]
+ def _prepare_void_list_getset(self, op):
+ non_negative, can_raise = self._get_list_nonneg_canraise_flags(op)
+ if can_raise:
+ raise NotSupported("list operation can raise")
+
def _get_initial_newlist_length(self, op, args):
# normalize number of arguments to the 'newlist' function
if len(args) > 1:
@@ -1014,6 +1023,12 @@
def do_fixed_list_ll_arraycopy(self, op, args, arraydescr):
return self._handle_oopspec_call(op, args, EffectInfo.OS_ARRAYCOPY)
+ def do_fixed_void_list_getitem(self, op, args):
+ self._prepare_void_list_getset(op)
+ return []
+ do_fixed_void_list_getitem_foldable = do_fixed_void_list_getitem
+ do_fixed_void_list_setitem = do_fixed_void_list_getitem
+
# ---------- resizable lists ----------
def do_resizable_newlist(self, op, args, arraydescr, lengthdescr,
@@ -1049,6 +1064,12 @@
return SpaceOperation('getfield_gc_i',
[args[0], lengthdescr], op.result)
+ def do_resizable_void_list_getitem(self, op, args):
+ self._prepare_void_list_getset(op)
+ return []
+ do_resizable_void_list_getitem_foldable = do_resizable_void_list_getitem
+ do_resizable_void_list_setitem = do_resizable_void_list_getitem
+
# ----------
# Strings and Unicodes.
Modified: pypy/trunk/pypy/jit/codewriter/test/test_list.py
==============================================================================
--- pypy/trunk/pypy/jit/codewriter/test/test_list.py (original)
+++ pypy/trunk/pypy/jit/codewriter/test/test_list.py Thu Oct 28 13:32:06 2010
@@ -19,6 +19,7 @@
class FakeCPU:
class arraydescrof(AbstractDescr):
def __init__(self, ARRAY):
+ assert ARRAY.OF != lltype.Void
self.ARRAY = ARRAY
def __repr__(self):
return '<ArrayDescr>'
More information about the Pypy-commit
mailing list