[pypy-svn] r64944 - in pypy/branch/pyjitpl5/pypy: jit/metainterp translator
arigo at codespeak.net
arigo at codespeak.net
Fri May 1 15:01:58 CEST 2009
Author: arigo
Date: Fri May 1 15:01:48 2009
New Revision: 64944
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
pypy/branch/pyjitpl5/pypy/translator/unsimplify.py
Log:
Use call_final_function() in the jit.
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py Fri May 1 15:01:48 2009
@@ -15,6 +15,7 @@
from pypy.rlib.debug import debug_print
from pypy.rpython.lltypesystem.lloperation import llop
from pypy.translator.simplify import get_funcobj, get_functype
+from pypy.translator.unsimplify import call_final_function
from pypy.jit.metainterp import support, history, pyjitpl
from pypy.jit.metainterp.pyjitpl import MetaInterpStaticData, MetaInterp
@@ -124,7 +125,7 @@
self.metainterp_sd.generate_bytecode(policy, self.ts)
self.make_enter_function()
self.rewrite_can_enter_jit()
- #self.rewrite_entry_point() XXX broken when the last block handles exceptions
+ self.add_profiler_finish()
self.metainterp_sd.num_green_args = self.num_green_args
self.metainterp_sd.state = self.state
@@ -441,24 +442,14 @@
origblock.recloseblock(Link([v_result], origportalgraph.returnblock))
checkgraph(origportalgraph)
- def rewrite_entry_point(self):
+ def add_profiler_finish(self):
def finish_profiler():
- self.metainterp_sd.profiler.finish()
+ if self.metainterp_sd.profiler.initialized:
+ self.metainterp_sd.profiler.finish()
if self.cpu.translate_support_code:
- entry_point = self.translator.graphs[0]
- _, TP = self.metainterp_sd.ts.get_FuncType([], lltype.Void)
- profiler_ptr = self.helper_func(TP, finish_profiler)
- for block in entry_point.iterblocks():
- for link in block.exits:
- if link.target is entry_point.returnblock:
- v = Variable()
- v.concretetype = lltype.Void
- newop = SpaceOperation('direct_call',
- [Constant(profiler_ptr, TP)],
- v)
- block.operations.append(newop)
- checkgraph(entry_point)
+ call_final_function(self.translator, finish_profiler,
+ annhelper = self.annhelper)
def decode_hp_hint_args(op):
# Returns (list-of-green-vars, list-of-red-vars) without Voids.
Modified: pypy/branch/pyjitpl5/pypy/translator/unsimplify.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/translator/unsimplify.py (original)
+++ pypy/branch/pyjitpl5/pypy/translator/unsimplify.py Fri May 1 15:01:48 2009
@@ -155,15 +155,18 @@
if links_to_start_block:
insert_empty_startblock(None, graph)
-def call_final_function(translator, final_func):
+def call_final_function(translator, final_func, annhelper=None):
"""When the program finishes normally, call 'final_func()'."""
from pypy.annotation import model as annmodel
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.annlowlevel import MixLevelHelperAnnotator
- annhelper = MixLevelHelperAnnotator(translator.rtyper)
+ own_annhelper = (annhelper is None)
+ if own_annhelper:
+ annhelper = MixLevelHelperAnnotator(translator.rtyper)
c_final_func = annhelper.constfunc(final_func, [], annmodel.s_None)
- annhelper.finish()
+ if own_annhelper:
+ annhelper.finish()
entry_point = translator.graphs[0]
v = copyvar(translator.annotator, entry_point.getreturnvar())
More information about the Pypy-commit
mailing list