16
16
from pypy .jit .metainterp .optimizeopt import ALL_OPTS_DICT
17
17
from pypy .jit .metainterp .test .support import LLJitMixin , OOJitMixin
18
18
19
- class BasicTests :
19
+ class BasicTests :
20
20
21
21
def test_basic (self ):
22
22
def f (x , y ):
@@ -36,7 +36,7 @@ def f(n):
36
36
37
37
def test_uint_floordiv (self ):
38
38
from pypy .rlib .rarithmetic import r_uint
39
-
39
+
40
40
def f (a , b ):
41
41
a = r_uint (a )
42
42
b = r_uint (b )
@@ -251,7 +251,7 @@ def track_init(self, name):
251
251
res = self .meta_interp (f , [6 , 15 ], no_stats = True )
252
252
finally :
253
253
history .TreeLoop .__init__ = old_init
254
-
254
+
255
255
assert res == f (6 , 15 )
256
256
gc .collect ()
257
257
@@ -839,7 +839,7 @@ def f(n):
839
839
840
840
def test_bridge_from_interpreter_4 (self ):
841
841
jitdriver = JitDriver (reds = ['n' , 'k' ], greens = [])
842
-
842
+
843
843
def f (n , k ):
844
844
while n > 0 :
845
845
jitdriver .can_enter_jit (n = n , k = k )
@@ -852,7 +852,7 @@ def f(n, k):
852
852
853
853
from pypy .rpython .test .test_llinterp import get_interpreter , clear_tcache
854
854
from pypy .jit .metainterp .warmspot import WarmRunnerDesc
855
-
855
+
856
856
interp , graph = get_interpreter (f , [0 , 0 ], backendopt = False ,
857
857
inline_threshold = 0 , type_system = self .type_system )
858
858
clear_tcache ()
@@ -1207,14 +1207,22 @@ def f(n):
1207
1207
def test_residual_external_call (self ):
1208
1208
import math
1209
1209
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
+
1210
1218
def f (x , y ):
1211
1219
x = float (x )
1212
1220
res = 0.0
1213
1221
while y > 0 :
1214
1222
myjitdriver .can_enter_jit (x = x , y = y , res = res )
1215
1223
myjitdriver .jit_merge_point (x = x , y = y , res = res )
1216
1224
# this is an external call that the default policy ignores
1217
- rpart , ipart = math . modf (x )
1225
+ rpart , ipart = modf (x )
1218
1226
res += ipart
1219
1227
y -= 1
1220
1228
return res
@@ -1248,7 +1256,7 @@ def f(x):
1248
1256
return x
1249
1257
res = self .meta_interp (f , [299 ], listops = True )
1250
1258
assert res == f (299 )
1251
- self .check_loops (guard_class = 0 , guard_value = 2 )
1259
+ self .check_loops (guard_class = 0 , guard_value = 2 )
1252
1260
self .check_loops (guard_class = 0 , guard_value = 5 , everywhere = True )
1253
1261
1254
1262
def test_merge_guardnonnull_guardclass (self ):
@@ -1542,9 +1550,9 @@ def f(x, y):
1542
1550
1543
1551
def test_raw_malloc_and_access (self ):
1544
1552
from pypy .rpython .lltypesystem import rffi
1545
-
1553
+
1546
1554
TP = rffi .CArray (lltype .Signed )
1547
-
1555
+
1548
1556
def f (n ):
1549
1557
a = lltype .malloc (TP , n , flavor = 'raw' )
1550
1558
a [0 ] = n
@@ -1557,9 +1565,9 @@ def f(n):
1557
1565
1558
1566
def test_raw_malloc_and_access_float (self ):
1559
1567
from pypy .rpython .lltypesystem import rffi
1560
-
1568
+
1561
1569
TP = rffi .CArray (lltype .Float )
1562
-
1570
+
1563
1571
def f (n , f ):
1564
1572
a = lltype .malloc (TP , n , flavor = 'raw' )
1565
1573
a [0 ] = f
@@ -1862,7 +1870,7 @@ def g(x, y):
1862
1870
1863
1871
def test_dont_trace_every_iteration (self ):
1864
1872
myjitdriver = JitDriver (greens = [], reds = ['a' , 'b' , 'i' , 'sa' ])
1865
-
1873
+
1866
1874
def main (a , b ):
1867
1875
i = sa = 0
1868
1876
#while i < 200:
@@ -1958,7 +1966,7 @@ def f(x):
1958
1966
return n
1959
1967
res = self .meta_interp (f , [sys .maxint >> 10 ])
1960
1968
assert res == 11
1961
- self .check_tree_loop_count (2 )
1969
+ self .check_tree_loop_count (2 )
1962
1970
1963
1971
def test_wrap_around_sub (self ):
1964
1972
myjitdriver = JitDriver (greens = [], reds = ['x' , 'n' ])
@@ -1974,7 +1982,7 @@ def f(x):
1974
1982
return n
1975
1983
res = self .meta_interp (f , [10 - sys .maxint ])
1976
1984
assert res == 12
1977
- self .check_tree_loop_count (2 )
1985
+ self .check_tree_loop_count (2 )
1978
1986
1979
1987
1980
1988
@@ -2052,7 +2060,7 @@ def f(flag, n):
2052
2060
policy = StopAtXPolicy (getcls ),
2053
2061
enable_opts = '' )
2054
2062
assert not res
2055
-
2063
+
2056
2064
res = self .meta_interp (f , [0 , 100 ],
2057
2065
policy = StopAtXPolicy (getcls ),
2058
2066
enable_opts = '' )
@@ -2072,7 +2080,7 @@ def f():
2072
2080
2073
2081
def test_oops_on_nongc (self ):
2074
2082
from pypy .rpython .lltypesystem import lltype
2075
-
2083
+
2076
2084
TP = lltype .Struct ('x' )
2077
2085
def f (i1 , i2 ):
2078
2086
p1 = prebuilt [i1 ]
@@ -2144,7 +2152,7 @@ def __init__(self, i):
2144
2152
2145
2153
def f ():
2146
2154
a = A (0 )
2147
-
2155
+
2148
2156
while a .i < 10 :
2149
2157
jitdriver .jit_merge_point (a = a )
2150
2158
jitdriver .can_enter_jit (a = a )
0 commit comments