| 1 | from pypy.module.pypyjit import policy |
| 2 | |
| 3 | pypypolicy = policy.PyPyJitPolicy() |
| 4 | |
| 5 | def test_id_any(): |
| 6 | from pypy.objspace.std.intobject import W_IntObject |
| 7 | assert pypypolicy.look_inside_function(W_IntObject.descr_add) |
| 8 | |
| 9 | def test_rlocale(): |
| 10 | from rpython.rlib.rlocale import setlocale |
| 11 | assert not pypypolicy.look_inside_function(setlocale) |
| 12 | |
| 13 | def test_astcompiler(): |
| 14 | from pypy.interpreter.astcompiler import ast |
| 15 | assert not pypypolicy.look_inside_function(ast.AST.walkabout) |
| 16 | |
| 17 | def test_pyparser(): |
| 18 | from pypy.interpreter.pyparser import parser |
| 19 | assert not pypypolicy.look_inside_function(parser.Token.__init__.im_func) |
| 20 | |
| 21 | def test_property(): |
| 22 | from pypy.module.__builtin__.descriptor import W_Property |
| 23 | assert pypypolicy.look_inside_function(W_Property.get.im_func) |
| 24 | |
| 25 | def test_thread_local(): |
| 26 | from pypy.module.thread.os_local import Local |
| 27 | from pypy.module.thread.os_thread import get_ident |
| 28 | assert pypypolicy.look_inside_function(Local.getdict.im_func) |
| 29 | assert pypypolicy.look_inside_function(get_ident) |
| 30 | |
| 31 | def test_time(): |
| 32 | from pypy.module.time.interp_time import time_time |
| 33 | assert pypypolicy.look_inside_function(time_time) |
| 34 | |
| 35 | def test_io(): |
| 36 | from pypy.module._io.interp_bytesio import W_BytesIO |
| 37 | assert pypypolicy.look_inside_function(W_BytesIO.seek_w.im_func) |
| 38 | |
| 39 | def test_thread(): |
| 40 | from pypy.module.thread.os_lock import Lock |
| 41 | assert pypypolicy.look_inside_function(Lock.descr_lock_acquire.im_func) |
| 42 | |
| 43 | def test_select(): |
| 44 | from pypy.module.select.interp_select import poll |
| 45 | assert pypypolicy.look_inside_function(poll) |
| 46 | |
| 47 | def test_pypy_module(): |
| 48 | from pypy.module._collections.interp_deque import W_Deque |
| 49 | from pypy.module._random.interp_random import W_Random |
| 50 | assert pypypolicy.look_inside_function(W_Random.random) |
| 51 | assert pypypolicy.look_inside_function(W_Deque.length) |
| 52 | assert pypypolicy.look_inside_pypy_module('__builtin__.operation') |
| 53 | assert pypypolicy.look_inside_pypy_module('__builtin__.abstractinst') |
| 54 | assert pypypolicy.look_inside_pypy_module('__builtin__.functional') |
| 55 | assert pypypolicy.look_inside_pypy_module('__builtin__.descriptor') |
| 56 | assert pypypolicy.look_inside_pypy_module('exceptions.interp_exceptions') |
| 57 | for modname in 'pypyjit', 'signal', 'micronumpy', 'math', 'imp': |
| 58 | assert pypypolicy.look_inside_pypy_module(modname) |
| 59 | assert pypypolicy.look_inside_pypy_module(modname + '.foo') |
| 60 | assert not pypypolicy.look_inside_pypy_module('pypyjit.interp_resop') |
| 61 | |
| 62 | def test_see_jit_module(): |
| 63 | assert pypypolicy.look_inside_pypy_module('pypyjit.interp_jit') |