diff options
| author | Mark Shannon <mark@hotpy.org> | 2022-06-22 15:32:02 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-22 15:32:02 (GMT) |
| commit | 3ece6e6feb44b334cd759ead970e877bbd126892 (patch) | |
| tree | 96846029de1a3123d7fd01f67df0e5597171955a /Python | |
| parent | 8c2af4907133d4a235cce73231fab723653d6429 (diff) | |
| download | cpython-3ece6e6feb44b334cd759ead970e877bbd126892.zip cpython-3ece6e6feb44b334cd759ead970e877bbd126892.tar.gz cpython-3ece6e6feb44b334cd759ead970e877bbd126892.tar.bz2 | |
[3.11] GH-93516: Backport GH-93769: Speedup line number checks when tracing (GH-94127)
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/ceval.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 03c7489..763187a 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -6853,9 +6853,10 @@ call_trace(Py_tracefunc func, PyObject *obj, tstate->tracing_what = what; PyThreadState_EnterTracing(tstate); assert(_PyInterpreterFrame_LASTI(frame) >= 0); - initialize_trace_info(&tstate->trace_info, frame); - int addr = _PyInterpreterFrame_LASTI(frame) * sizeof(_Py_CODEUNIT); - f->f_lineno = _PyCode_CheckLineNumber(addr, &tstate->trace_info.bounds); + if (_PyCode_InitLineArray(frame->f_code)) { + return -1; + } + f->f_lineno = _PyCode_LineNumberFromArray(frame->f_code, _PyInterpreterFrame_LASTI(frame)); result = func(obj, f, what, arg); f->f_lineno = 0; PyThreadState_LeaveTracing(tstate); @@ -6892,7 +6893,9 @@ maybe_call_line_trace(Py_tracefunc func, PyObject *obj, represents a jump backwards, update the frame's line number and then call the trace function if we're tracing source lines. */ - initialize_trace_info(&tstate->trace_info, frame); + if (_PyCode_InitLineArray(frame->f_code)) { + return -1; + } int entry_point = 0; _Py_CODEUNIT *code = _PyCode_CODE(frame->f_code); while (_PyOpcode_Deopt[_Py_OPCODE(code[entry_point])] != RESUME) { @@ -6903,10 +6906,9 @@ maybe_call_line_trace(Py_tracefunc func, PyObject *obj, lastline = -1; } else { - lastline = _PyCode_CheckLineNumber(instr_prev*sizeof(_Py_CODEUNIT), &tstate->trace_info.bounds); + lastline = _PyCode_LineNumberFromArray(frame->f_code, instr_prev); } - int addr = _PyInterpreterFrame_LASTI(frame) * sizeof(_Py_CODEUNIT); - int line = _PyCode_CheckLineNumber(addr, &tstate->trace_info.bounds); + int line = _PyCode_LineNumberFromArray(frame->f_code, _PyInterpreterFrame_LASTI(frame)); PyFrameObject *f = _PyFrame_GetFrameObject(frame); if (f == NULL) { return -1; |
