1
from pypy.jit.hintannotator.annotator import HintAnnotatorPolicy
2
from pypy.jit.timeshifter.test.test_timeshift import TimeshiftingTests
3
from pypy.rlib.objectmodel import hint
5
P_OOPSPEC = HintAnnotatorPolicy(novirtualcontainer=True, oopspec=True)
8
class TestVList(TimeshiftingTests):
15
res = self.timeshift(ll_function, [], [], policy=P_OOPSPEC)
19
def test_enter_block(self):
20
def ll_function(flag):
28
res = self.timeshift(ll_function, [6], [], policy=P_OOPSPEC)
30
self.check_insns({'int_is_true': 1})
31
res = self.timeshift(ll_function, [0], [], policy=P_OOPSPEC)
33
self.check_insns({'int_is_true': 1})
36
def ll_function(flag):
43
res = self.timeshift(ll_function, [6], [], policy=P_OOPSPEC)
45
self.check_insns({'int_is_true': 1})
46
res = self.timeshift(ll_function, [0], [], policy=P_OOPSPEC)
48
self.check_insns({'int_is_true': 1})
50
def test_replace(self):
51
def ll_function(flag):
58
res = self.timeshift(ll_function, [6], [], policy=P_OOPSPEC)
60
self.check_insns({'int_is_true': 1})
61
res = self.timeshift(ll_function, [0], [], policy=P_OOPSPEC)
63
self.check_insns({'int_is_true': 1})
72
res = self.timeshift(ll_function, [6], [], policy=P_OOPSPEC)
74
res = self.timeshift(ll_function, [0], [], policy=P_OOPSPEC)
77
def test_oop_vlist(self):
80
five = lst.pop() # [3]
81
lst.append(len(lst)) # [3, 1]
83
three = lst.pop(0) # [1]
84
lst.insert(0, 8) # [8, 1]
85
lst.insert(2, 7) # [8, 1, 7]
86
lst.append(not lst) # [8, 1, 7, 0]
87
lst.reverse() # [0, 7, 1, 8]
88
lst3 = lst2 + lst # [3, 1, 0, 7, 1, 8]
89
del lst3[1] # [3, 0, 7, 1, 8]
90
seven = lst3.pop(2) # [3, 0, 1, 8]
91
lst3[0] = 9 # [9, 0, 1, 8]
92
nine = lst3.pop(-4) # [0, 1, 8]
93
return (len(lst3) * 10000000 +
101
assert ll_function() == 30185379
102
res = self.timeshift(ll_function, [], [], policy=P_OOPSPEC)
103
assert res == 30185379
106
def test_alloc_and_set(self):
110
res = self.timeshift(ll_function, [], [], policy=P_OOPSPEC)
114
def test_lists_deepfreeze(self):
122
def ll_function(n, i):
124
l = hint(l, deepfreeze=True)
126
res = hint(res, variable=True)
129
res = self.timeshift(ll_function, [3, 4], [0, 1], policy=P_OOPSPEC)
133
def test_frozen_list(self):
136
mylist = hint(lst, deepfreeze=True)
138
hint(z, concrete=True)
141
res = self.timeshift(ll_function, [1], policy=P_OOPSPEC)
145
def test_frozen_list_indexerror(self):
148
mylist = hint(lst, deepfreeze=True)
153
hint(z, concrete=True)
156
res = self.timeshift(ll_function, [4], policy=P_OOPSPEC)
160
def test_bogus_index_while_compiling(self):
165
lst = hint(lst, deepfreeze=True)
176
if i == 1: return lst1
177
elif i == 2: return lst2
186
res = self.timeshift(f, [2], [0], policy=P_OOPSPEC)