PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/pypy/module/pypyjit/policy.py

https://bitbucket.org/pypy/pypy/
Python | 39 lines | 37 code | 2 blank | 0 comment | 4 complexity | 40f6ebfe41a60359daa791120627328c MD5 | raw file
Possible License(s): AGPL-3.0, BSD-3-Clause, Apache-2.0
  1. from rpython.jit.codewriter.policy import JitPolicy
  2. class PyPyJitPolicy(JitPolicy):
  3. def look_inside_pypy_module(self, modname):
  4. if (modname == '__builtin__.operation' or
  5. modname == '__builtin__.abstractinst' or
  6. modname == '__builtin__.interp_classobj' or
  7. modname == '__builtin__.functional' or
  8. modname == '__builtin__.descriptor' or
  9. modname == 'thread.os_local' or
  10. modname == 'thread.os_thread' or
  11. modname.startswith('_rawffi.alt')):
  12. return True
  13. if '.' in modname:
  14. modname, rest = modname.split('.', 1)
  15. if modname in ['unicodedata', 'gc', '_minimal_curses', 'cpyext']:
  16. return False
  17. else:
  18. rest = ''
  19. if modname == 'pypyjit' and 'interp_resop' in rest:
  20. return False
  21. return True
  22. def look_inside_function(self, func):
  23. mod = func.__module__ or '?'
  24. if mod == 'rpython.rlib.rlocale' or mod == 'rpython.rlib.rsocket':
  25. return False
  26. if mod.startswith('pypy.interpreter.astcompiler.'):
  27. return False
  28. if mod.startswith('pypy.interpreter.pyparser.'):
  29. return False
  30. if mod.startswith('pypy.module.'):
  31. modname = mod[len('pypy.module.'):]
  32. if not self.look_inside_pypy_module(modname):
  33. return False
  34. return True