[pypy-svn] r77482 - in pypy/branch/jitffi/pypy/jit/metainterp: optimizeopt test
antocuni at codespeak.net
antocuni at codespeak.net
Thu Sep 30 10:06:54 CEST 2010
Author: antocuni
Date: Thu Sep 30 10:06:52 2010
New Revision: 77482
Modified:
pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py
pypy/branch/jitffi/pypy/jit/metainterp/test/test_optimizeopt.py
Log:
attach the dynamic calldescr to the new emitted CALL operation
Modified: pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py
==============================================================================
--- pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py (original)
+++ pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py Thu Sep 30 10:06:52 2010
@@ -5,17 +5,18 @@
from pypy.jit.metainterp.optimizeutil import _findall
from pypy.jit.metainterp.optimizeopt.optimizer import Optimization
-class FuncDescription(object):
+class FuncInfo(object):
def __init__(self, cpu, func):
self.func = func
- self.args = []
+ self.opargs = []
+ self.descr = cpu.calldescrof_dynamic(func.argtypes, func.restype)
class OptFfiCall(Optimization):
def __init__(self):
- self.funcs = {}
+ self.func_infos = {}
def get_oopspec(self, funcval):
# XXX: not RPython at all, just a hack while waiting to have an
@@ -60,25 +61,25 @@
def do_prepare_call(self, op):
func = self._get_func(op)
- assert func not in self.funcs # XXX: do something nice etc. etc.
- self.funcs[func] = FuncDescription(self.optimizer.cpu, func)
+ assert func not in self.func_infos # XXX: do something nice etc. etc.
+ self.func_infos[func] = FuncInfo(self.optimizer.cpu, func)
def do_push_arg(self, op):
# we store the op in funcs because we might want to emit it later,
# in case we give up with the optimization
func = self._get_func(op)
- self.funcs[func].args.append(op)
+ self.func_infos[func].opargs.append(op)
def do_call(self, op):
func = self._get_func(op)
funcsymval = self.getvalue(op.getarg(2))
arglist = [funcsymval.force_box()]
- for push_op in self.funcs[func].args:
+ info = self.func_infos[func]
+ for push_op in info.opargs:
argval = self.getvalue(push_op.getarg(2))
arglist.append(argval.force_box())
- # XXX: add the descr
- newop = ResOperation(rop.CALL, arglist, op.result, None)
- del self.funcs[func]
+ newop = ResOperation(rop.CALL, arglist, op.result, descr=info.descr)
+ del self.func_infos[func]
return newop
def propagate_forward(self, op):
Modified: pypy/branch/jitffi/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/branch/jitffi/pypy/jit/metainterp/test/test_optimizeopt.py (original)
+++ pypy/branch/jitffi/pypy/jit/metainterp/test/test_optimizeopt.py Thu Sep 30 10:06:52 2010
@@ -3900,7 +3900,24 @@
# ------------------------------------------------
from pypy.rpython.lltypesystem import llmemory
-from pypy.rlib.libffi import Func
+from pypy.rlib.libffi import Func, ffi_type_sint, ffi_type_double
+from pypy.jit.metainterp.history import AbstractDescr
+
+class MyCallDescr(AbstractDescr):
+ """
+ Fake calldescr to be used inside the tests.
+
+ The particularity is that it provides an __eq__ method, so that it
+ comparses by value by comparing the arg_types and typeinfo fields, so you
+ can check that the signature of a call is really what you want.
+ """
+
+ def __init__(self, arg_types, typeinfo):
+ self.arg_types = arg_types
+ self.typeinfo = typeinfo # return type
+
+ def __eq__(self, other):
+ return self.arg_types == other.arg_types and self.typeinfo == other.typeinfo
class FakeLLObject(object):
@@ -3916,8 +3933,11 @@
class namespace:
cpu = LLtypeMixin.cpu
plaincalldescr = LLtypeMixin.plaincalldescr
+ int_float__int = MyCallDescr('if', 'i')
funcptr = FakeLLObject()
- func = FakeLLObject(_fake_class=Func)
+ func = FakeLLObject(_fake_class=Func,
+ argtypes=[ffi_type_sint, ffi_type_double],
+ restype=ffi_type_sint)
namespace = namespace.__dict__
@@ -3933,7 +3953,7 @@
"""
expected = """
[i0, f1]
- i3 = call(1, i0, f1)
+ i3 = call(1, i0, f1, descr=int_float__int)
jump(i3, f1)
"""
loop = self.optimize_loop(ops, 'Not, Not', expected)
More information about the Pypy-commit
mailing list