Skip to content

Commit 8472a93

Browse files
fix test_dis
1 parent bfb7d47 commit 8472a93

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

Lib/test/test_dis.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -880,9 +880,7 @@ def foo(x):
880880
RETURN_GENERATOR
881881
POP_TOP
882882
L1: RESUME 0
883-
LOAD_FAST 0 (.0)
884-
GET_ITER
885-
L2: FOR_ITER 16 (to L3)
883+
L2: FOR_ITER 15 (to L3)
886884
STORE_FAST 1 (z)
887885
LOAD_DEREF 2 (x)
888886
LOAD_FAST_BORROW 1 (z)
@@ -911,7 +909,7 @@ def load_test(x, y=0):
911909
return a, b
912910

913911
dis_load_test_quickened_code = """\
914-
%3d RESUME{: <6} 0
912+
%3d RESUME_CHECK{: <6} 0
915913
916914
%3d LOAD_FAST_LOAD_FAST 1 (x, y)
917915
STORE_FAST_STORE_FAST 50 (b, a)
@@ -928,7 +926,7 @@ def loop_test():
928926
load_test(i)
929927

930928
dis_loop_test_quickened_code = """\
931-
%3d RESUME{: <6} 0
929+
%3d RESUME_CHECK{: <6} 0
932930
933931
%3d BUILD_LIST 0
934932
LOAD_CONST 2 ((1, 2, 3))
@@ -1326,14 +1324,14 @@ def test_super_instructions(self):
13261324
self.code_quicken(lambda: load_test(0, 0))
13271325
got = self.get_disassembly(load_test, adaptive=True)
13281326
jit = sys._jit.is_enabled()
1329-
expected = dis_load_test_quickened_code.format("" if jit else "_CHECK")
1327+
expected = dis_load_test_quickened_code.format("_JIT" if jit else "")
13301328
self.do_disassembly_compare(got, expected)
13311329

13321330
@cpython_only
13331331
@requires_specialization
13341332
def test_load_attr_specialize(self):
13351333
load_attr_quicken = """\
1336-
0 RESUME{: <6} 0
1334+
0 RESUME_CHECK{: <6} 0
13371335
13381336
1 LOAD_CONST 0 ('a')
13391337
LOAD_ATTR_SLOT 0 (__class__)
@@ -1343,14 +1341,14 @@ def test_load_attr_specialize(self):
13431341
self.code_quicken(lambda: exec(co, {}, {}))
13441342
got = self.get_disassembly(co, adaptive=True)
13451343
jit = sys._jit.is_enabled()
1346-
expected = load_attr_quicken.format("" if jit else "_CHECK")
1344+
expected = load_attr_quicken.format("_JIT" if jit else "")
13471345
self.do_disassembly_compare(got, expected)
13481346

13491347
@cpython_only
13501348
@requires_specialization
13511349
def test_call_specialize(self):
13521350
call_quicken = """\
1353-
0 RESUME{: <6} 0
1351+
0 RESUME_CHECK{: <6} 0
13541352
13551353
1 LOAD_NAME 0 (str)
13561354
PUSH_NULL
@@ -1362,7 +1360,7 @@ def test_call_specialize(self):
13621360
self.code_quicken(lambda: exec(co, {}, {}))
13631361
got = self.get_disassembly(co, adaptive=True)
13641362
jit = sys._jit.is_enabled()
1365-
expected = call_quicken.format("" if jit else "_CHECK")
1363+
expected = call_quicken.format("_JIT" if jit else "")
13661364
self.do_disassembly_compare(got, expected)
13671365

13681366
@cpython_only
@@ -1372,7 +1370,7 @@ def test_loop_quicken(self):
13721370
self.code_quicken(loop_test)
13731371
got = self.get_disassembly(loop_test, adaptive=True)
13741372
jit = sys._jit.is_enabled()
1375-
resume_str = "" if jit else "_CHECK"
1373+
resume_str = "_JIT" if jit else ""
13761374
jit_str = "_JIT" if jit else "NO_JIT"
13771375
expected = dis_loop_test_quickened_code.format(resume_str, jit_str)
13781376
self.do_disassembly_compare(got, expected)

Modules/_testinternalcapi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3023,9 +3023,10 @@ module_exec(PyObject *module)
30233023
return 1;
30243024
}
30253025

3026+
long resume_threshold = interp->opt_config.resume_initial_value + 1;
30263027
if (PyModule_Add(module, "TIER2_RESUME_THRESHOLD",
30273028
// + 1 more due to one loop spent on tracing.
3028-
PyLong_FromLong(RESUME_INITIAL_VALUE + 2)) < 0) {
3029+
PyLong_FromLong(resume_threshold)) < 0) {
30293030
return 1;
30303031
}
30313032

Python/specialize.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,9 @@ _PyCode_Quicken(_Py_CODEUNIT *instructions, Py_ssize_t size, int enable_counters
7373
case JUMP_BACKWARD:
7474
instructions[i + 1].counter = jump_counter;
7575
break;
76-
#ifdef _Py_TIER2
7776
case RESUME:
7877
instructions[i + 1].counter = resume_counter;
7978
break;
80-
#endif
8179
case POP_JUMP_IF_FALSE:
8280
case POP_JUMP_IF_TRUE:
8381
case POP_JUMP_IF_NONE:

0 commit comments

Comments
 (0)