Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r46536:80bde0482a01 Date: 2011-08-16 14:00 +0200 http://bitbucket.org/pypy/pypy/changeset/80bde0482a01/
Log: Simplify the handling of we_are_translated() by moving it to the flow space already. It also has the benefit that the False path is not flowed at all. diff --git a/pypy/annotation/builtin.py b/pypy/annotation/builtin.py --- a/pypy/annotation/builtin.py +++ b/pypy/annotation/builtin.py @@ -308,9 +308,6 @@ clsdef = clsdef.commonbase(cdef) return SomeInstance(clsdef) -def robjmodel_we_are_translated(): - return immutablevalue(True) - def robjmodel_r_dict(s_eqfn, s_hashfn, s_force_non_null=None): if s_force_non_null is None: force_non_null = False @@ -376,8 +373,6 @@ BUILTIN_ANALYZERS[pypy.rlib.rarithmetic.intmask] = rarith_intmask BUILTIN_ANALYZERS[pypy.rlib.objectmodel.instantiate] = robjmodel_instantiate -BUILTIN_ANALYZERS[pypy.rlib.objectmodel.we_are_translated] = ( - robjmodel_we_are_translated) BUILTIN_ANALYZERS[pypy.rlib.objectmodel.r_dict] = robjmodel_r_dict BUILTIN_ANALYZERS[pypy.rlib.objectmodel.hlinvoke] = robjmodel_hlinvoke BUILTIN_ANALYZERS[pypy.rlib.objectmodel.keepalive_until_here] = robjmodel_keepalive_until_here diff --git a/pypy/objspace/flow/specialcase.py b/pypy/objspace/flow/specialcase.py --- a/pypy/objspace/flow/specialcase.py +++ b/pypy/objspace/flow/specialcase.py @@ -4,6 +4,7 @@ from pypy.interpreter.error import OperationError from pypy.tool.cache import Cache from pypy.rlib.rarithmetic import r_uint +from pypy.rlib.objectmodel import we_are_translated import py def sc_import(space, fn, args): @@ -129,6 +130,9 @@ return Constant(r_uint(w_value.value)) return space.do_operation('simple_call', space.wrap(r_uint), w_value) +def sc_we_are_translated(space, we_are_translated, args): + return Constant(True) + def setup(space): # fn = pyframe.normalize_exception.get_function(space) # this is now routed through the objspace, directly. @@ -144,3 +148,5 @@ # (normally, the 32-bit constant is a long, and is not allowed to # show up in the flow graphs at all) space.specialcases[r_uint] = sc_r_uint + # special case we_are_translated() to return True + space.specialcases[we_are_translated] = sc_we_are_translated diff --git a/pypy/objspace/flow/test/test_objspace.py b/pypy/objspace/flow/test/test_objspace.py --- a/pypy/objspace/flow/test/test_objspace.py +++ b/pypy/objspace/flow/test/test_objspace.py @@ -501,6 +501,24 @@ assert op.args[1].value == 3 #__________________________________________________________ + + def wearetranslated(x): + from pypy.rlib.objectmodel import we_are_translated + if we_are_translated(): + return x + else: + some_name_error_here + + def test_wearetranslated(self): + x = self.codetest(self.wearetranslated) + from pypy.translator.simplify import join_blocks + join_blocks(x) + # check that 'x' is an empty graph + assert len(x.startblock.operations) == 0 + assert len(x.startblock.exits) == 1 + assert x.startblock.exits[0].target is x.returnblock + + #__________________________________________________________ def jump_target_specialization(x): if x: n = 5 diff --git a/pypy/rlib/objectmodel.py b/pypy/rlib/objectmodel.py --- a/pypy/rlib/objectmodel.py +++ b/pypy/rlib/objectmodel.py @@ -157,7 +157,7 @@ def we_are_translated(): return False -# annotation -> True +# annotation -> True (replaced by the flow objspace) def keepalive_until_here(*values): pass diff --git a/pypy/rpython/raddress.py b/pypy/rpython/raddress.py --- a/pypy/rpython/raddress.py +++ b/pypy/rpython/raddress.py @@ -7,7 +7,6 @@ from pypy.rpython.rptr import PtrRepr from pypy.rpython.lltypesystem import lltype from pypy.rlib.rarithmetic import r_uint -from pypy.rlib.objectmodel import we_are_translated class __extend__(annmodel.SomeAddress): diff --git a/pypy/rpython/rbuiltin.py b/pypy/rpython/rbuiltin.py --- a/pypy/rpython/rbuiltin.py +++ b/pypy/rpython/rbuiltin.py @@ -283,10 +283,6 @@ v_error = hop.inputarg(lltype.Signed, arg=1) r_self.setfield(v_self, 'winerror', v_error, hop.llops) -def rtype_we_are_translated(hop): - hop.exception_cannot_occur() - return hop.inputconst(lltype.Bool, True) - def rtype_hlinvoke(hop): _, s_repr = hop.r_s_popfirstarg() r_callable = s_repr.const @@ -553,7 +549,6 @@ BUILTIN_TYPER[lltype.Ptr] = rtype_const_result BUILTIN_TYPER[lltype.runtime_type_info] = rtype_runtime_type_info BUILTIN_TYPER[rarithmetic.intmask] = rtype_intmask -BUILTIN_TYPER[objectmodel.we_are_translated] = rtype_we_are_translated BUILTIN_TYPER[objectmodel.hlinvoke] = rtype_hlinvoke _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit