[pypy-svn] r62571 - in pypy/branch/pyjitpl5/pypy/jit: backend/llgraph metainterp metainterp/test
arigo at codespeak.net
arigo at codespeak.net
Thu Mar 5 11:28:34 CET 2009
Author: arigo
Date: Thu Mar 5 11:28:31 2009
New Revision: 62571
Modified:
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_send.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_slist.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtual.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vlist.py
Log:
Rewrite operations CALL_# to CALL and CALL_PURE.
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py Thu Mar 5 11:28:31 2009
@@ -98,9 +98,8 @@
'getarrayitem_gc' : (('ptr', 'int', 'int'), 'intorptr'),
'getarrayitem_gc_pure' : (('ptr', 'int', 'int'), 'intorptr'),
'arraylen_gc' : (('ptr', 'int'), 'int'),
- 'call_ptr' : (('ptr', 'varargs'), 'ptr'),
- 'call__4' : (('ptr', 'varargs'), 'int'),
- 'call_void' : (('ptr', 'varargs'), None),
+ 'call' : (('ptr', 'int', 'varargs'), 'intorptr'),
+ 'call_pure' : (('ptr', 'int', 'varargs'), 'intorptr'),
'guard_true' : (('bool',), None),
'guard_false' : (('bool',), None),
'guard_value' : (('int', 'int'), None),
@@ -823,7 +822,7 @@
assert self.last_exception_handled
self.last_exception = None
- def do_call(self, f, *args):
+ def op_call(self, f, calldescr, *args):
ptr = cast_int_to_adr(self.memocast, f).ptr
FUNC = lltype.typeOf(ptr).TO
ARGS = FUNC.ARGS
@@ -843,9 +842,7 @@
self.clear_exception()
return x
- op_call__4 = do_call
- op_call_ptr = do_call
- op_call_void = do_call
+ op_call_pure = op_call
def op_listop_return(self, ll_func, *args):
return self.do_call(ll_func, *args)
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 Thu Mar 5 11:28:31 2009
@@ -274,7 +274,19 @@
return size*2 + bit
@staticmethod
+ def calldescrof(ARGS, RESULT):
+ if RESULT is lltype.Void:
+ return -1
+ token = history.getkind(RESULT)
+ if token == 'ptr':
+ return 1
+ else:
+ return 0
+
+ @staticmethod
def typefor(fielddesc):
+ if fielddesc == -1:
+ return 'void'
if fielddesc % 2:
return 'ptr'
return 'int'
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py Thu Mar 5 11:28:31 2009
@@ -5,7 +5,7 @@
from pypy.rlib import objectmodel
from pypy.rlib.objectmodel import we_are_translated
from pypy.rlib.jit import _we_are_jitted
-from pypy.jit.metainterp.history import Const, getkind, getkind_num
+from pypy.jit.metainterp.history import Const, getkind
from pypy.jit.metainterp import heaptracker, support, history
import py
@@ -662,18 +662,23 @@
def handle_residual_call(self, op):
self.minimize_variables()
- self.emit('residual_call_%s' % getkind_num(self.cpu,
- op.result.concretetype))
- self.emit_varargs([x for x in op.args
- if x.concretetype is not lltype.Void])
+ args = [x for x in op.args[1:] if x.concretetype is not lltype.Void]
+ argtypes = [v.concretetype for v in args]
+ resulttype = op.result.concretetype
+ calldescr = self.cpu.calldescrof(argtypes, resulttype)
+ self.emit('residual_call')
+ self.emit(self.var_position(op.args[0]))
+ self.emit(self.const_position(calldescr))
+ self.emit_varargs(args)
self.register_var(op.result)
def handle_builtin_call(self, op):
oopspec_name, args = support.decode_builtin_call(op)
- ll_args = [v.concretetype for v in args]
+ argtypes = [v.concretetype for v in args]
+ resulttype = op.result.concretetype
c_func, TP = support.builtin_func_for_spec(self.codewriter.rtyper,
- oopspec_name, ll_args,
- op.result.concretetype)
+ oopspec_name, argtypes,
+ resulttype)
if self.codewriter.metainterp.options.listops:
if self.handle_list_call(op, oopspec_name, args, TP):
return
@@ -704,11 +709,14 @@
## self._eventualy_builtin(op.result, False)
## return
if oopspec_name.endswith('_foldable'):
- opname = 'green_call_%s'
+ opname = 'residual_call_pure'
else:
- opname = 'residual_call_%s'
- self.emit(opname % getkind_num(self.cpu, op.result.concretetype))
- self.emit_varargs([c_func] + args)
+ opname = 'residual_call'
+ calldescr = self.cpu.calldescrof(argtypes, resulttype)
+ self.emit(opname)
+ self.emit(self.var_position(c_func))
+ self.emit(self.const_position(calldescr))
+ self.emit_varargs(args)
self.register_var(op.result)
def handle_list_call(self, op, oopspec_name, args, TP):
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py Thu Mar 5 11:28:31 2009
@@ -404,44 +404,17 @@
f.setup_call(varargs)
return True
- @arguments("varargs")
- def opimpl_green_call__1(self, varargs):
- return self.execute_with_exc(rop.CALL__1, varargs, 'int', True)
- @arguments("varargs")
- def opimpl_green_call__2(self, varargs):
- return self.execute_with_exc(rop.CALL__2, varargs, 'int', True)
- @arguments("varargs")
- def opimpl_green_call__4(self, varargs):
- return self.execute_with_exc(rop.CALL__4, varargs, 'int', True)
- @arguments("varargs")
- def opimpl_green_call__8(self, varargs):
- return self.execute_with_exc(rop.CALL__8, varargs, 'int', True)
-
- @arguments("varargs")
- def opimpl_green_call_ptr(self, varargs):
- return self.execute_with_exc(rop.CALL_PTR, varargs, 'ptr', True)
-
- @arguments("varargs")
- def opimpl_residual_call__1(self, varargs):
- return self.execute_with_exc(rop.CALL__1, varargs, 'int')
- @arguments("varargs")
- def opimpl_residual_call__2(self, varargs):
- return self.execute_with_exc(rop.CALL__2, varargs, 'int')
- @arguments("varargs")
- def opimpl_residual_call__4(self, varargs):
- return self.execute_with_exc(rop.CALL__4, varargs, 'int')
- @arguments("varargs")
- def opimpl_residual_call__8(self, varargs):
- return self.execute_with_exc(rop.CALL__8, varargs, 'int')
-
- @arguments("varargs")
- def opimpl_residual_call_ptr(self, varargs):
- return self.execute_with_exc(rop.CALL_PTR, varargs, 'ptr')
-
- @arguments("varargs")
- def opimpl_residual_call_void(self, varargs):
- return self.execute_with_exc(rop.CALL_VOID, varargs, 'void')
-
+ @arguments("box", "constbox", "varargs")
+ def opimpl_residual_call(self, funcbox, calldescr, varargs):
+ tp = self.metainterp.cpu.typefor(calldescr.getint())
+ args = [funcbox, calldescr] + varargs
+ return self.execute_with_exc(rop.CALL, args, tp)
+
+ @arguments("box", "constbox", "varargs")
+ def opimpl_residual_call_pure(self, funcbox, calldescr, varargs):
+ tp = self.metainterp.cpu.typefor(calldescr.getint())
+ args = [funcbox, calldescr] + varargs
+ return self.execute_with_exc(rop.CALL_PURE, args, tp, True)
## @arguments("fixedlist", "box", "box")
## def opimpl_list_getitem(self, descr, listbox, indexbox):
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py Thu Mar 5 11:28:31 2009
@@ -65,17 +65,6 @@
# ____________________________________________________________
-class typ(object):
- INT = 0 # a register-sized, non-GC-aware value (int or addr)
- PTR = 1 # a pointer to a GC object
- VOID = 2 # a void
-
- INT1 = 3 # when we need more precision about the size of the int,
- INT2 = 4 # use these instead of INT
- INT4 = 5 # (e.g. for reading or writing fields)
- INT8 = 6
-
-
class rop(object):
"""The possible names of the ResOperations."""
@@ -94,8 +83,10 @@
GUARD_EXCEPTION = 16
_GUARD_LAST = 19 # ----- end of guard operations -----
- _NOSIDEEFFECT_FIRST = 30 # ----- start of no_side_effect operations -----
- _ALWAYS_PURE_FIRST = 30 # ----- start of always_pure operations -----
+ _NOSIDEEFFECT_FIRST = 20 # ----- start of no_side_effect operations -----
+ _ALWAYS_PURE_FIRST = 20 # ----- start of always_pure operations -----
+ CALL_PURE = 20
+ #
INT_ADD = 30
INT_SUB = 31
INT_MUL = 32
@@ -158,13 +149,7 @@
STRSETITEM = 97
_CANRAISE_FIRST = 100 # ----- start of can_raise operations -----
- _CALL = 100
- CALL__1 = _CALL + typ.INT1
- CALL__2 = _CALL + typ.INT2
- CALL__4 = _CALL + typ.INT4
- CALL__8 = _CALL + typ.INT8
- CALL_PTR = _CALL + typ.PTR
- CALL_VOID = _CALL + typ.VOID
+ CALL = 100
#
_OVF_FIRST = 110
INT_ADD_OVF = 110
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py Thu Mar 5 11:28:31 2009
@@ -166,7 +166,7 @@
return externfn(n, n+1)
res = self.interp_operations(f, [6], policy=StopAtXPolicy(externfn))
assert res == 42
- self.check_history_(int_add=1, int_mul=0, call__4=1)
+ self.check_history_(int_add=1, int_mul=0, call=1)
def test_constant_across_mp(self):
myjitdriver = JitDriver(greens = [], reds = ['n'])
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_send.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_send.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_send.py Thu Mar 5 11:28:31 2009
@@ -44,11 +44,11 @@
res = self.meta_interp(f, [1], policy=StopAtXPolicy(externfn))
assert res == 2
if self.type_system == 'ootype':
- self.check_loops(call_ptr=1, builtin=1) # 'len' remains
+ self.check_loops(call=1, builtin=1) # 'len' remains
else:
# 'len' becomes a getfield('num_items') for now in lltype,
# which is itself encoded as a 'getfield_gc'
- self.check_loops(call_ptr=1, getfield_gc=1)
+ self.check_loops(call=1, getfield_gc=1)
def test_send_to_single_target_method(self):
myjitdriver = JitDriver(greens = [], reds = ['i', 'counter'])
@@ -72,7 +72,7 @@
res = self.meta_interp(f, [1], policy=StopAtXPolicy(externfn),
backendopt=True)
assert res == 43
- self.check_loops({'call_ptr': 1, 'guard_no_exception': 1,
+ self.check_loops({'call': 1, 'guard_no_exception': 1,
'getfield_gc': 1,
'int_add': 1, 'merge_point' : 1,
'jump': 1, 'int_gt' : 1, 'guard_true' : 1,
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_slist.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_slist.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_slist.py Thu Mar 5 11:28:31 2009
@@ -49,7 +49,7 @@
assert res == 42
# no more list operations in the loop
py.test.skip("not a ModifiedList yet")
- self.check_loops(call_void=0, call__4=0)
+ self.check_loops(call=0)
def test_lazy_getitem_2(self):
py.test.skip("BUG!")
@@ -68,7 +68,7 @@
res = self.meta_interp(f, [50], policy=StopAtXPolicy(g))
assert res == f(50)
# the list operations stay in the loop
- self.check_loops(call_void=1, call__4=2)
+ self.check_loops(call=3)
def test_lazy_getitem_3(self):
py.test.skip("in-progress")
@@ -81,7 +81,7 @@
res = self.meta_interp(f, [21])
assert res == 42
# two levels of list operations removed from the loop
- self.check_loops(call_void=0, call__4=0)
+ self.check_loops(call=0)
def test_lazy_getitem_4(self):
myjitdriver = JitDriver(greens = [], reds = ['n', 'lst'])
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtual.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtual.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtual.py Thu Mar 5 11:28:31 2009
@@ -125,7 +125,7 @@
assert res == f(10)
self.check_loop_count(2)
self.check_loops(**{self._new_op: 1})
- self.check_loops(int_mul=0, call__4=1)
+ self.check_loops(int_mul=0, call=1)
def test_two_virtuals(self):
myjitdriver = JitDriver(greens = [], reds = ['n', 'prev'])
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py Thu Mar 5 11:28:31 2009
@@ -413,7 +413,7 @@
res = self.meta_interp(f, [53], exceptions=False)
assert res == -6
- self.check_loops(getfield_gc=0, setfield_gc=0, call__4=0)
+ self.check_loops(getfield_gc=0, setfield_gc=0, call=0)
def test_single_list_implicit(self):
py.test.skip("in-progress")
@@ -430,7 +430,7 @@
res = self.meta_interp(f, [53], exceptions=False)
assert res == -17
- self.check_loops(getfield_gc=0, setfield_gc=0, call__4=0)
+ self.check_loops(getfield_gc=0, setfield_gc=0, call=0)
##class TestOOtype(ExplicitVirtualizableTests,
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vlist.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vlist.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vlist.py Thu Mar 5 11:28:31 2009
@@ -58,7 +58,7 @@
res = self.meta_interp(f, [10], listops=True)
assert res == f(10)
# one setitem should be gone by now
- self.check_loops(call_ptr=1, setarrayitem_gc=1, getarrayitem_gc=1)
+ self.check_loops(call=1, setarrayitem_gc=1, getarrayitem_gc=1)
def test_ll_fixed_setitem_fast(self):
jitdriver = JitDriver(greens = [], reds = ['n', 'l'])
@@ -76,7 +76,7 @@
res = self.meta_interp(f, [10], listops=True)
assert res == 1
py.test.skip("Constant propagation of length missing")
- self.check_loops(setarrayitem_gc=0, call_ptr=0, call__4=0)
+ self.check_loops(setarrayitem_gc=0, call=0)
def test_vlist_with_default_read(self):
py.test.skip("for now, more support in codewriter needed")
More information about the Pypy-commit
mailing list