[pypy-svn] r54256 - in pypy/branch/oo-jit/pypy: jit/rainbow jit/rainbow/test jit/timeshifter rpython/ootypesystem
antocuni at codespeak.net
antocuni at codespeak.net
Wed Apr 30 10:56:21 CEST 2008
Author: antocuni
Date: Wed Apr 30 10:56:19 2008
New Revision: 54256
Modified:
pypy/branch/oo-jit/pypy/jit/rainbow/codewriter.py
pypy/branch/oo-jit/pypy/jit/rainbow/test/test_vlist.py
pypy/branch/oo-jit/pypy/jit/timeshifter/oop.py
pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py
Log:
- make vlist working also with ootype.Array
- test_bogus_index_while_compiling passes these days
Modified: pypy/branch/oo-jit/pypy/jit/rainbow/codewriter.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/codewriter.py (original)
+++ pypy/branch/oo-jit/pypy/jit/rainbow/codewriter.py Wed Apr 30 10:56:19 2008
@@ -1702,7 +1702,8 @@
if TYPE.oopspec_name is not None:
oopspecdescindex = self.oopspecdesc_position('new', TYPE, False)
oopspecdesc = self.oopspecdescs[oopspecdescindex]
- args, args_v = self.serialize_argtuple([], oopspecdesc.argtuple)
+ opargs = op.args[1:] # it's != [] if TYPE is an Array
+ args, args_v = self.serialize_argtuple(opargs, oopspecdesc.argtuple)
deepfrozen = False
self.emit('red_oopspec_call_%s' % len(args))
self.emit(oopspecdescindex)
@@ -1715,6 +1716,8 @@
self.emit("red_new", index)
self.register_redvar(op.result)
+ serialize_op_oonewarray = serialize_op_new
+
def serialize_op_oosend(self, op):
assert not self.hannotator.policy.hotpath, 'TODO'
kind, withexc = self.guess_call_kind(op)
Modified: pypy/branch/oo-jit/pypy/jit/rainbow/test/test_vlist.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/test/test_vlist.py (original)
+++ pypy/branch/oo-jit/pypy/jit/rainbow/test/test_vlist.py Wed Apr 30 10:56:19 2008
@@ -18,6 +18,18 @@
assert res == 12
self.check_insns({})
+ def test_fixed_vlist(self):
+ def ll_function(flag):
+ lst = [0, 0, 0]
+ if flag:
+ lst[0] = 42
+ else:
+ lst[0] = 1
+ return lst[0]
+ res = self.interpret(ll_function, [True], [], policy=P_OOPSPEC)
+ assert res == 42
+ self.check_insns({})
+
def test_enter_block(self):
def ll_function(flag):
lst = []
@@ -160,7 +172,6 @@
self.check_insns({})
def test_bogus_index_while_compiling(self):
- py.test.skip("implement me")
class Y:
pass
Modified: pypy/branch/oo-jit/pypy/jit/timeshifter/oop.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/timeshifter/oop.py (original)
+++ pypy/branch/oo-jit/pypy/jit/timeshifter/oop.py Wed Apr 30 10:56:19 2008
@@ -250,13 +250,20 @@
self.typename = TYPE.oopspec_name
self.method = 'oop_new%s' % self.typename
self.is_method = False
- opname, argtuple = parse_oopspec(TYPE.oopspec_new, [])
+ opname, argtuple = parse_oopspec(TYPE.oopspec_new,
+ TYPE.oopspec_new_argnames)
assert opname == 'new'
self.argtuple = argtuple
- def allocate():
- return ootype.new(TYPE)
- self.fnptr = self.rtyper.annotate_helper_fn(allocate, [])
+ if isinstance(TYPE, ootype.Array):
+ def allocate(length):
+ return ootype.oonewarray(TYPE, length)
+ self.fnptr = self.rtyper.annotate_helper_fn(allocate,
+ [ootype.Signed])
+ else:
+ def allocate():
+ return ootype.new(TYPE)
+ self.fnptr = self.rtyper.annotate_helper_fn(allocate, [])
class NewOopSpecDesc_list(NewOopSpecDesc):
pass
Modified: pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py (original)
+++ pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py Wed Apr 30 10:56:19 2008
@@ -490,6 +490,7 @@
ITEMTYPE_T = object()
oopspec_name = 'list'
oopspec_new = 'new(0)'
+ oopspec_new_argnames = ()
def __init__(self, ITEMTYPE=None):
self.ITEM = ITEMTYPE
@@ -582,6 +583,9 @@
SELFTYPE_T = object()
ITEMTYPE_T = object()
+ oopspec_name = 'list'
+ oopspec_new = 'new(length)'
+ oopspec_new_argnames = ('length',)
def __init__(self, ITEMTYPE=None):
self.ITEM = ITEMTYPE
@@ -662,6 +666,7 @@
VALUETYPE_T = object()
oopspec_name = 'dict'
oopspec_new = 'new()'
+ oopspec_new_argnames = ()
def __init__(self, KEYTYPE=None, VALUETYPE=None):
self._KEYTYPE = KEYTYPE
More information about the Pypy-commit
mailing list