Skip to content

Commit 1467ce7

Browse files
committed
Revert "pythongh-149570: avoid tier-2 self-link in _COLD_EXIT"
This reverts commit da37760.
1 parent da37760 commit 1467ce7

5 files changed

Lines changed: 2 additions & 73 deletions

File tree

Include/internal/pycore_ceval.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,9 @@ _PyEval_SpecialMethodCanSuggest(PyObject *self, int oparg);
351351
#define _PY_EVAL_PLEASE_STOP_BIT (1U << 5)
352352
#define _PY_EVAL_EXPLICIT_MERGE_BIT (1U << 6)
353353
#define _PY_EVAL_JIT_INVALIDATE_COLD_BIT (1U << 7)
354-
#define _PY_EVAL_JIT_FORCE_TIER1_BIT (1U << 8)
355354

356355
/* Reserve a few bits for future use */
357-
#define _PY_EVAL_EVENTS_BITS 9
356+
#define _PY_EVAL_EVENTS_BITS 8
358357
#define _PY_EVAL_EVENTS_MASK ((1 << _PY_EVAL_EVENTS_BITS)-1)
359358

360359
static inline void

Lib/test/test_capi/test_opt.py

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import contextlib
22
import itertools
3-
import subprocess
43
import sys
54
import textwrap
65
import unittest
@@ -10,7 +9,7 @@
109

1110
import _opcode
1211

13-
from test.support import (SHORT_TIMEOUT, script_helper, requires_specialization,
12+
from test.support import (script_helper, requires_specialization,
1413
import_helper, Py_GIL_DISABLED, requires_jit_enabled,
1514
reset_code)
1615

@@ -5995,51 +5994,6 @@ def __init__(self, name):
59955994
PYTHON_JIT_SIDE_EXIT_INITIAL_VALUE="1")
59965995
self.assertEqual(result[0].rc, 0, result)
59975996

5998-
def test_side_exit_to_executor_makes_progress(self):
5999-
script = textwrap.dedent("""
6000-
classes = []
6001-
6002-
def make_iter():
6003-
class It:
6004-
def __init__(self):
6005-
self.i = 0
6006-
6007-
def __iter__(self):
6008-
return self
6009-
6010-
def __next__(self):
6011-
self.i += 1
6012-
if self.i > 1000:
6013-
raise StopIteration
6014-
return self.i
6015-
6016-
classes.append(It)
6017-
return It()
6018-
6019-
def f(n):
6020-
for outer in range(n):
6021-
for x in make_iter():
6022-
pass
6023-
6024-
f(200)
6025-
""")
6026-
env = os.environ.copy()
6027-
env.update({
6028-
"PYTHON_JIT": "1",
6029-
"PYTHON_JIT_SIDE_EXIT_INITIAL_VALUE": "1",
6030-
})
6031-
try:
6032-
result = subprocess.run(
6033-
[sys.executable, "-X", "faulthandler", "-c", script],
6034-
stdout=subprocess.PIPE,
6035-
stderr=subprocess.PIPE,
6036-
env=env,
6037-
timeout=SHORT_TIMEOUT,
6038-
)
6039-
except subprocess.TimeoutExpired as exc:
6040-
self.fail(f"subprocess timed out: {exc}")
6041-
self.assertEqual(result.returncode, 0, result)
6042-
60435997
def test_for_iter_gen_cleared_frame_does_not_crash(self):
60445998
# See: https://github.com/python/cpython/issues/145197
60455999
result = script_helper.run_python_until_end('-c', textwrap.dedent("""

Python/bytecodes.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6297,16 +6297,6 @@ dummy_func(
62976297
if (target->op.code == ENTER_EXECUTOR) {
62986298
PyCodeObject *code = _PyFrame_GetCode(frame);
62996299
executor = code->co_executors->executors[target->op.arg];
6300-
_PyExecutorObject *previous_executor = _PyExecutor_FromExit(exit);
6301-
if (!exit->is_control_flow) {
6302-
int chain_depth = previous_executor->vm_data.chain_depth + 1;
6303-
if (executor == previous_executor ||
6304-
chain_depth % MAX_CHAIN_DEPTH == 0) {
6305-
/* Avoid tier-2 self-link/wrap that bypasses the eval breaker. */
6306-
_Py_set_eval_breaker_bit(tstate, _PY_EVAL_JIT_FORCE_TIER1_BIT);
6307-
GOTO_TIER_ONE(target);
6308-
}
6309-
}
63106300
Py_INCREF(executor);
63116301
assert(tstate->jit_exit == exit);
63126302
exit->executor = executor;

Python/ceval_gil.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,10 +1403,6 @@ _Py_HandlePending(PyThreadState *tstate)
14031403
}
14041404

14051405
#ifdef _Py_TIER2
1406-
if ((breaker & _PY_EVAL_JIT_FORCE_TIER1_BIT) != 0) {
1407-
_Py_unset_eval_breaker_bit(tstate, _PY_EVAL_JIT_FORCE_TIER1_BIT);
1408-
}
1409-
14101406
if ((breaker & _PY_EVAL_JIT_INVALIDATE_COLD_BIT) != 0) {
14111407
_Py_unset_eval_breaker_bit(tstate, _PY_EVAL_JIT_INVALIDATE_COLD_BIT);
14121408
_Py_Executors_InvalidateCold(tstate->interp);

Python/executor_cases.c.h

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)