[pypy-svn] r77947 - pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt
antocuni at codespeak.net
antocuni at codespeak.net
Thu Oct 14 17:39:06 CEST 2010
Author: antocuni
Date: Thu Oct 14 17:39:04 2010
New Revision: 77947
Modified:
pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py
Log:
simplify the logic, it's much more readable now
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 Oct 14 17:39:04 2010
@@ -59,9 +59,6 @@
return f.inst_argtypes, f.inst_restype
-class NonConstantFuncVal(Exception):
- pass
-
class OptFfiCall(Optimization):
def __init__(self):
@@ -88,18 +85,14 @@
def optimize_CALL(self, op):
oopspec = self._get_oopspec(op)
- try:
- if oopspec == EffectInfo.OS_LIBFFI_PREPARE:
- self.do_prepare_call(op)
- elif oopspec == EffectInfo.OS_LIBFFI_PUSH_ARG:
- self.do_push_arg(op)
- elif oopspec == EffectInfo.OS_LIBFFI_CALL:
- op = self.do_call(op)
- self.emit_operation(op)
- else:
- raise NonConstantFuncVal # it's not a libffi call
- except NonConstantFuncVal:
- # normal case
+ if oopspec == EffectInfo.OS_LIBFFI_PREPARE:
+ op = self.do_prepare_call(op)
+ elif oopspec == EffectInfo.OS_LIBFFI_PUSH_ARG:
+ op = self.do_push_arg(op)
+ elif oopspec == EffectInfo.OS_LIBFFI_CALL:
+ op = self.do_call(op)
+ #
+ if op:
self.emit_operation(op)
optimize_CALL_MAY_FORCE = optimize_CALL
@@ -109,21 +102,20 @@
if self.funcval:
assert self.funcval is funcval # XXX do something nice
if not funcval.is_constant():
- raise NonConstantFuncVal
+ return None
return funcval
def do_prepare_call(self, op):
funcval = self._get_funcval(op)
+ if not funcval:
+ return op
assert self.funcval is None # XXX: do something nice etc. etc.
self.funcval = funcval
self.funcinfo = FuncInfo(funcval, self.optimizer.cpu, op)
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
if self.funcval is None:
- self.emit_operation(op)
- return
+ return op
funcval = self._get_funcval(op)
self.funcinfo.opargs.append(op)
More information about the Pypy-commit
mailing list