Author: Carl Friedrich Bolz-Tereick <cfb...@gmx.de> Branch: jit-hooks-can-be-disabled Changeset: r94163:f85a77753cf9 Date: 2018-03-28 14:20 +0200 http://bitbucket.org/pypy/pypy/changeset/f85a77753cf9/
Log: if no JitHookInterface is given, disable hooks completely diff --git a/rpython/jit/codewriter/policy.py b/rpython/jit/codewriter/policy.py --- a/rpython/jit/codewriter/policy.py +++ b/rpython/jit/codewriter/policy.py @@ -11,9 +11,6 @@ self.supports_floats = False self.supports_longlong = False self.supports_singlefloats = False - if jithookiface is None: - from rpython.rlib.jit import JitHookInterface - jithookiface = JitHookInterface() self.jithookiface = jithookiface def set_supports_floats(self, flag): diff --git a/rpython/jit/metainterp/compile.py b/rpython/jit/metainterp/compile.py --- a/rpython/jit/metainterp/compile.py +++ b/rpython/jit/metainterp/compile.py @@ -554,6 +554,8 @@ original_jitcell_token, loop.operations, type, greenkey) hooks.before_compile(debug_info) + else: + hooks = None operations = get_deep_immutable_oplist(loop.operations) metainterp_sd.profiler.start_backend() debug_start("jit-backend") @@ -606,6 +608,8 @@ original_loop_token, operations, 'bridge', fail_descr=faildescr) hooks.before_compile_bridge(debug_info) + else: + hooks = None operations = get_deep_immutable_oplist(operations) metainterp_sd.profiler.start_backend() debug_start("jit-backend") diff --git a/rpython/jit/metainterp/warmspot.py b/rpython/jit/metainterp/warmspot.py --- a/rpython/jit/metainterp/warmspot.py +++ b/rpython/jit/metainterp/warmspot.py @@ -220,6 +220,15 @@ stats.check_consistency() # ____________________________________________________________ +# always disabled hooks interface + +from rpython.rlib.jit import JitHookInterface + +class NoHooksInterface(JitHookInterface): + def are_hooks_enabled(self): + return False + +# ____________________________________________________________ class WarmRunnerDesc(object): @@ -259,7 +268,7 @@ else: self.jitcounter = counter.DeterministicJitCounter() # - self.hooks = policy.jithookiface + self.make_hooks(policy.jithookiface) self.make_virtualizable_infos() self.make_driverhook_graphs() self.make_enter_functions() @@ -498,6 +507,12 @@ self.metainterp_sd.opencoder_model = Model self.stats.metainterp_sd = self.metainterp_sd + def make_hooks(self, hooks): + if hooks is None: + # interface not overridden, use a special one that is never enabled + hooks = NoHooksInterface() + self.hooks = hooks + def make_virtualizable_infos(self): vinfos = {} for jd in self.jitdrivers_sd: diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py --- a/rpython/rlib/jit.py +++ b/rpython/rlib/jit.py @@ -1084,7 +1084,8 @@ """ This is the main connector between the JIT and the interpreter. Several methods on this class will be invoked at various stages of JIT running like JIT loops compiled, aborts etc. - An instance of this class will be available as policy.jithookiface. + An instance of this class has to be passed into the JitPolicy constructor + (and will then be available as policy.jithookiface). """ # WARNING: You should make a single prebuilt instance of a subclass # of this class. You can, before translation, initialize some _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit