1616from pypy .jit .metainterp .optimizeopt import ALL_OPTS_DICT
1717from pypy .jit .metainterp .test .support import LLJitMixin , OOJitMixin
1818
19- class BasicTests :
19+ class BasicTests :
2020
2121 def test_basic (self ):
2222 def f (x , y ):
@@ -36,7 +36,7 @@ def f(n):
3636
3737 def test_uint_floordiv (self ):
3838 from pypy .rlib .rarithmetic import r_uint
39-
39+
4040 def f (a , b ):
4141 a = r_uint (a )
4242 b = r_uint (b )
@@ -251,7 +251,7 @@ def track_init(self, name):
251251 res = self .meta_interp (f , [6 , 15 ], no_stats = True )
252252 finally :
253253 history .TreeLoop .__init__ = old_init
254-
254+
255255 assert res == f (6 , 15 )
256256 gc .collect ()
257257
@@ -839,7 +839,7 @@ def f(n):
839839
840840 def test_bridge_from_interpreter_4 (self ):
841841 jitdriver = JitDriver (reds = ['n' , 'k' ], greens = [])
842-
842+
843843 def f (n , k ):
844844 while n > 0 :
845845 jitdriver .can_enter_jit (n = n , k = k )
@@ -852,7 +852,7 @@ def f(n, k):
852852
853853 from pypy .rpython .test .test_llinterp import get_interpreter , clear_tcache
854854 from pypy .jit .metainterp .warmspot import WarmRunnerDesc
855-
855+
856856 interp , graph = get_interpreter (f , [0 , 0 ], backendopt = False ,
857857 inline_threshold = 0 , type_system = self .type_system )
858858 clear_tcache ()
@@ -1207,14 +1207,22 @@ def f(n):
12071207 def test_residual_external_call (self ):
12081208 import math
12091209 myjitdriver = JitDriver (greens = [], reds = ['y' , 'x' , 'res' ])
1210+
1211+ # When this test was written ll_math couldn't be inlined, now it can,
1212+ # instead of rewriting this test, just ensure that an external call is
1213+ # still generated by wrapping the function.
1214+ @dont_look_inside
1215+ def modf (x ):
1216+ return math .modf (x )
1217+
12101218 def f (x , y ):
12111219 x = float (x )
12121220 res = 0.0
12131221 while y > 0 :
12141222 myjitdriver .can_enter_jit (x = x , y = y , res = res )
12151223 myjitdriver .jit_merge_point (x = x , y = y , res = res )
12161224 # this is an external call that the default policy ignores
1217- rpart , ipart = math . modf (x )
1225+ rpart , ipart = modf (x )
12181226 res += ipart
12191227 y -= 1
12201228 return res
@@ -1248,7 +1256,7 @@ def f(x):
12481256 return x
12491257 res = self .meta_interp (f , [299 ], listops = True )
12501258 assert res == f (299 )
1251- self .check_loops (guard_class = 0 , guard_value = 2 )
1259+ self .check_loops (guard_class = 0 , guard_value = 2 )
12521260 self .check_loops (guard_class = 0 , guard_value = 5 , everywhere = True )
12531261
12541262 def test_merge_guardnonnull_guardclass (self ):
@@ -1542,9 +1550,9 @@ def f(x, y):
15421550
15431551 def test_raw_malloc_and_access (self ):
15441552 from pypy .rpython .lltypesystem import rffi
1545-
1553+
15461554 TP = rffi .CArray (lltype .Signed )
1547-
1555+
15481556 def f (n ):
15491557 a = lltype .malloc (TP , n , flavor = 'raw' )
15501558 a [0 ] = n
@@ -1557,9 +1565,9 @@ def f(n):
15571565
15581566 def test_raw_malloc_and_access_float (self ):
15591567 from pypy .rpython .lltypesystem import rffi
1560-
1568+
15611569 TP = rffi .CArray (lltype .Float )
1562-
1570+
15631571 def f (n , f ):
15641572 a = lltype .malloc (TP , n , flavor = 'raw' )
15651573 a [0 ] = f
@@ -1862,7 +1870,7 @@ def g(x, y):
18621870
18631871 def test_dont_trace_every_iteration (self ):
18641872 myjitdriver = JitDriver (greens = [], reds = ['a' , 'b' , 'i' , 'sa' ])
1865-
1873+
18661874 def main (a , b ):
18671875 i = sa = 0
18681876 #while i < 200:
@@ -1958,7 +1966,7 @@ def f(x):
19581966 return n
19591967 res = self .meta_interp (f , [sys .maxint >> 10 ])
19601968 assert res == 11
1961- self .check_tree_loop_count (2 )
1969+ self .check_tree_loop_count (2 )
19621970
19631971 def test_wrap_around_sub (self ):
19641972 myjitdriver = JitDriver (greens = [], reds = ['x' , 'n' ])
@@ -1974,7 +1982,7 @@ def f(x):
19741982 return n
19751983 res = self .meta_interp (f , [10 - sys .maxint ])
19761984 assert res == 12
1977- self .check_tree_loop_count (2 )
1985+ self .check_tree_loop_count (2 )
19781986
19791987
19801988
@@ -2052,7 +2060,7 @@ def f(flag, n):
20522060 policy = StopAtXPolicy (getcls ),
20532061 enable_opts = '' )
20542062 assert not res
2055-
2063+
20562064 res = self .meta_interp (f , [0 , 100 ],
20572065 policy = StopAtXPolicy (getcls ),
20582066 enable_opts = '' )
@@ -2072,7 +2080,7 @@ def f():
20722080
20732081 def test_oops_on_nongc (self ):
20742082 from pypy .rpython .lltypesystem import lltype
2075-
2083+
20762084 TP = lltype .Struct ('x' )
20772085 def f (i1 , i2 ):
20782086 p1 = prebuilt [i1 ]
@@ -2144,7 +2152,7 @@ def __init__(self, i):
21442152
21452153 def f ():
21462154 a = A (0 )
2147-
2155+
21482156 while a .i < 10 :
21492157 jitdriver .jit_merge_point (a = a )
21502158 jitdriver .can_enter_jit (a = a )
0 commit comments