[pypy-svn] r62191 - pypy/branch/pyjitpl5/pypy/jit/metainterp
arigo at codespeak.net
arigo at codespeak.net
Thu Feb 26 16:18:30 CET 2009
Author: arigo
Date: Thu Feb 26 16:18:30 2009
New Revision: 62191
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py
Log:
Add caching to avoid repeated construction of
the MixLevelHelperAnnotator.
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py Thu Feb 26 16:18:30 2009
@@ -191,6 +191,11 @@
raise ValueError(op.opname)
def builtin_func_for_spec(rtyper, oopspec_name, ll_args, ll_res):
+ key = (oopspec_name, tuple(ll_args), ll_res)
+ try:
+ return rtyper._builtin_func_for_spec_cache[key]
+ except (KeyError, AttributeError):
+ pass
args_s = [annmodel.lltype_to_annotation(v) for v in ll_args]
if '.' not in oopspec_name: # 'newxxx' operations
LIST_OR_DICT = ll_res
@@ -206,4 +211,8 @@
c_func = mixlevelann.constfunc(impl, args_s, s_result)
mixlevelann.finish()
#
+ if not hasattr(rtyper, '_builtin_func_for_spec_cache'):
+ rtyper._builtin_func_for_spec_cache = {}
+ rtyper._builtin_func_for_spec_cache[key] = (c_func, LIST_OR_DICT)
+ #
return c_func, LIST_OR_DICT
More information about the Pypy-commit
mailing list