PageRenderTime 0ms CodeModel.GetById 30ms app.highlight 4ms RepoModel.GetById 16ms app.codeStats 0ms

/pypy/module/pypyjit/policy.py

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