[pypy-svn] r67326 - in pypy/branch/pyjitpl5-llmodel/pypy/jit: backend/test backend/x86 backend/x86/test metainterp
arigo at codespeak.net
arigo at codespeak.net
Sat Aug 29 18:23:36 CEST 2009
Author: arigo
Date: Sat Aug 29 18:23:36 2009
New Revision: 67326
Modified:
pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/test/runner_test.py
pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/x86/regalloc.py
pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/x86/test/test_symbolic.py
pypy/branch/pyjitpl5-llmodel/pypy/jit/metainterp/executor.py
Log:
In-progress, more tests pass.
Modified: pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/test/runner_test.py (original)
+++ pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/test/runner_test.py Sat Aug 29 18:23:36 2009
@@ -400,6 +400,13 @@
a_box, A = self.alloc_array_of(lltype.Signed, 342)
arraydescr = self.cpu.arraydescrof(A)
assert not arraydescr.is_array_of_pointers()
+ #
+ r = self.cpu.do_arraylen_gc([a_box], arraydescr)
+ assert r.value == 342
+ self.cpu.do_setarrayitem_gc([a_box, BoxInt(311), BoxInt(170)], arraydescr)
+ r = self.cpu.do_getarrayitem_gc([a_box, BoxInt(311)], arraydescr)
+ assert r.value == 170
+ #
r = self.execute_operation(rop.ARRAYLEN_GC, [a_box],
'int', descr=arraydescr)
assert r.value == 342
@@ -410,11 +417,6 @@
r = self.execute_operation(rop.GETARRAYITEM_GC, [a_box, BoxInt(310)],
'int', descr=arraydescr)
assert r.value == 7441
- r = self.cpu.do_getarrayitem_gc([a_box, BoxInt(310)], arraydescr)
- assert r.value == 7441
- self.cpu.do_setarrayitem_gc([a_box, BoxInt(3), BoxInt(170)], arraydescr)
- r = self.cpu.do_getarrayitem_gc([a_box, BoxInt(3)], arraydescr)
- assert r.value == 170
#
a_box, A = self.alloc_array_of(lltype.Char, 11)
arraydescr = self.cpu.arraydescrof(A)
@@ -513,6 +515,11 @@
assert r.value == 153
def test_unicode_basic(self):
+ u_box = self.cpu.do_newunicode([ConstInt(5)])
+ self.cpu.do_unicodesetitem([u_box, BoxInt(4), BoxInt(123)])
+ r = self.cpu.do_unicodegetitem([u_box, BoxInt(4)])
+ assert r.value == 123
+ #
u_box = self.alloc_unicode(u"hello\u1234")
r = self.execute_operation(rop.UNICODELEN, [u_box], 'int')
assert r.value == 6
@@ -528,10 +535,6 @@
r = self.execute_operation(rop.UNICODEGETITEM, [u_box, BoxInt(4)],
'int')
assert r.value == 31313
- u_box = self.cpu.do_newunicode([ConstInt(5)])
- self.cpu.do_unicodesetitem([u_box, BoxInt(4), BoxInt(123)])
- r = self.cpu.do_unicodegetitem([u_box, BoxInt(4)])
- assert r.value == 123
def test_same_as(self):
r = self.execute_operation(rop.SAME_AS, [ConstInt(5)], 'int')
Modified: pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/x86/regalloc.py (original)
+++ pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/x86/regalloc.py Sat Aug 29 18:23:36 2009
@@ -12,7 +12,7 @@
from pypy.jit.backend.llsupport import symbolic
from pypy.jit.backend.x86.jump import remap_stack_layout
from pypy.jit.metainterp.resoperation import rop
-from pypy.jit.backend.llsupport.descr import BaseFieldDescr
+from pypy.jit.backend.llsupport.descr import BaseFieldDescr, BaseArrayDescr
from pypy.jit.backend.llsupport.descr import BaseCallDescr
REGS = [eax, ecx, edx, ebx, esi, edi]
@@ -768,14 +768,14 @@
else:
assert False, itemsize
- def _malloc_varsize(self, ofs_items, ofs_length, size, v, res_v):
+ def _malloc_varsize(self, ofs_items, ofs_length, scale, v, res_v):
# XXX kill this function at some point
if isinstance(v, Box):
loc = self.make_sure_var_in_reg(v, [v])
other_loc = self.force_allocate_reg(TempBox(), [v])
- self.assembler.load_effective_addr(loc, ofs_items, size, other_loc)
+ self.assembler.load_effective_addr(loc, ofs_items,scale, other_loc)
else:
- other_loc = imm(ofs_items + (v.getint() << size))
+ other_loc = imm(ofs_items + (v.getint() << scale))
self._call(ResOperation(rop.NEW, [v], res_v),
[other_loc], [v])
loc = self.make_sure_var_in_reg(v, [res_v])
@@ -794,13 +794,20 @@
arglocs.append(self.loc(op.args[0]))
return self._call(op, arglocs)
# boehm GC (XXX kill the following code at some point)
- size_of_field, basesize, _ = self._unpack_arraydescr(op.descr)
- return self._malloc_varsize(basesize, 0, size_of_field, op.args[0],
+ scale_of_field, basesize, _ = self._unpack_arraydescr(op.descr)
+ return self._malloc_varsize(basesize, 0, scale_of_field, op.args[0],
op.result)
def _unpack_arraydescr(self, arraydescr):
- xxx
- return CPU386.unpack_arraydescr(arraydescr)
+ assert isinstance(arraydescr, BaseArrayDescr)
+ ofs = arraydescr.get_base_size(self.translate_support_code)
+ size = arraydescr.get_item_size(self.translate_support_code)
+ ptr = arraydescr.is_array_of_pointers()
+ scale = 0
+ while (1 << scale) < size:
+ scale += 1
+ assert (1 << scale) == size
+ return scale, ofs, ptr
def _unpack_fielddescr(self, fielddescr):
assert isinstance(fielddescr, BaseFieldDescr)
Modified: pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/x86/test/test_symbolic.py
==============================================================================
--- pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/x86/test/test_symbolic.py (original)
+++ pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/x86/test/test_symbolic.py Sat Aug 29 18:23:36 2009
@@ -1,8 +1,10 @@
import py
-from pypy.jit.backend.x86.symbolic import *
-from pypy.jit.backend.x86.runner import CPU386
+from pypy.jit.backend.llsupport.symbolic import *
from pypy.rpython.lltypesystem import lltype, rffi
+# This test file is here and not in llsupport/test/ because it checks
+# that we get correct numbers for a 32-bit machine.
+
class FakeStats(object):
pass
@@ -44,15 +46,6 @@
assert itemsize == 4
assert ofs_length == basesize - 4
-def test_array_token_2():
- cpu = CPU386(None, None)
- A = lltype.GcArray(lltype.Ptr(lltype.Array(lltype.Signed)))
- descr = cpu.arraydescrof(A)
- assert not descr.flag2
- A = lltype.GcArray(lltype.Ptr(lltype.GcArray(lltype.Signed)))
- descr = cpu.arraydescrof(A)
- assert descr.flag2
-
def test_varsized_struct_size():
S1 = lltype.GcStruct('S1', ('parent', S),
('extra', lltype.Signed),
@@ -66,16 +59,6 @@
assert basesize == ofs_length + 4
assert itemsize == 1
-def test_methods_of_cpu():
- py.test.skip("A bit pointless")
- cpu = CPU386(rtyper=None, stats=FakeStats())
- assert cpu.sizeof(S) == get_size(S, False)
- assert cpu.fielddescrof(S, 'y') & 0xffff == get_field_token(S, 'y')[0]
- assert cpu.fielddescrof(S, 'y') >> 16 == get_field_token(S, 'y')[1]
- A = lltype.GcArray(lltype.Char)
- #assert cpu.itemoffsetof(A) == get_array_token(A)[0]
- #assert cpu.arraylengthoffset(A) == get_array_token(A)[2]
-
def test_string():
STR = lltype.GcStruct('String', ('hash', lltype.Signed),
('chars', lltype.Array(lltype.Char)))
Modified: pypy/branch/pyjitpl5-llmodel/pypy/jit/metainterp/executor.py
==============================================================================
--- pypy/branch/pyjitpl5-llmodel/pypy/jit/metainterp/executor.py (original)
+++ pypy/branch/pyjitpl5-llmodel/pypy/jit/metainterp/executor.py Sat Aug 29 18:23:36 2009
@@ -234,6 +234,18 @@
def make_execute_list(cpuclass):
from pypy.jit.backend.model import AbstractCPU
+ if 0: # enable this to trace calls to do_xxx
+ def wrap(fn):
+ def myfn(*args):
+ print '<<<', fn.__name__
+ try:
+ return fn(*args)
+ finally:
+ print fn.__name__, '>>>'
+ return myfn
+ else:
+ def wrap(fn):
+ return fn
execute = [None] * (rop._LAST+1)
for key, value in rop.__dict__.items():
if not key.startswith('_'):
@@ -246,9 +258,9 @@
key = key[:-5]
name = 'do_' + key.lower()
if hasattr(cpuclass, name):
- execute[value] = getattr(cpuclass, name)
+ execute[value] = wrap(getattr(cpuclass, name))
elif name in globals():
- execute[value] = globals()[name]
+ execute[value] = wrap(globals()[name])
else:
assert hasattr(AbstractCPU, name), name
cpuclass._execute_list = execute
More information about the Pypy-commit
mailing list