diff options
author | Mark Shannon <mark@hotpy.org> | 2024-01-05 09:45:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-05 09:45:22 (GMT) |
commit | 0ae60b66dea5140382190463a676bafe706608f5 (patch) | |
tree | f3cb44d3f9b90ec14d6cddde5687f72ca4e776f3 /Python | |
parent | ed6ea3ea79fac68b127c7eb457c7ecb996461010 (diff) | |
download | cpython-0ae60b66dea5140382190463a676bafe706608f5.zip cpython-0ae60b66dea5140382190463a676bafe706608f5.tar.gz cpython-0ae60b66dea5140382190463a676bafe706608f5.tar.bz2 |
GH-113486: Do not emit spurious PY_UNWIND events for optimized calls to classes. (GH-113680)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 3 | ||||
-rw-r--r-- | Python/instrumentation.c | 6 | ||||
-rw-r--r-- | Python/specialize.c | 2 |
3 files changed, 6 insertions, 5 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 1fea974..b3b542f 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2111,6 +2111,9 @@ do_monitor_exc(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, int event) { assert(event < _PY_MONITORING_UNGROUPED_EVENTS); + if (_PyFrame_GetCode(frame)->co_flags & CO_NO_MONITORING_EVENTS) { + return 0; + } PyObject *exc = PyErr_GetRaisedException(); assert(exc != NULL); int err = _Py_call_instrumentation_arg(tstate, event, frame, instr, exc); diff --git a/Python/instrumentation.c b/Python/instrumentation.c index 35b0e7a..533aece 100644 --- a/Python/instrumentation.c +++ b/Python/instrumentation.c @@ -1576,13 +1576,11 @@ _Py_Instrument(PyCodeObject *code, PyInterpreterState *interp) } _Py_Executors_InvalidateDependency(interp, code); int code_len = (int)Py_SIZE(code); - /* code->_co_firsttraceable >= code_len indicates - * that no instrumentation can be inserted. - * Exit early to avoid creating instrumentation + /* Exit early to avoid creating instrumentation * data for potential statically allocated code * objects. * See https://github.com/python/cpython/issues/108390 */ - if (code->_co_firsttraceable >= code_len) { + if (code->co_flags & CO_NO_MONITORING_EVENTS) { return 0; } if (update_instrumentation_data(code, interp)) { diff --git a/Python/specialize.c b/Python/specialize.c index 369b962..7b63393 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -2534,7 +2534,7 @@ const struct _PyCode_DEF(8) _Py_InitCleanup = { .co_consts = (PyObject *)&_Py_SINGLETON(tuple_empty), .co_names = (PyObject *)&_Py_SINGLETON(tuple_empty), .co_exceptiontable = (PyObject *)&_Py_SINGLETON(bytes_empty), - .co_flags = CO_OPTIMIZED, + .co_flags = CO_OPTIMIZED | CO_NO_MONITORING_EVENTS, .co_localsplusnames = (PyObject *)&_Py_SINGLETON(tuple_empty), .co_localspluskinds = (PyObject *)&_Py_SINGLETON(bytes_empty), .co_filename = &_Py_ID(__init__), |