Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-93516: Speedup line number checks when tracing.#93763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Merge branch 'main' into speedup-line-checks-v3
  • Loading branch information
@markshannon
markshannon committedJun 13, 2022
commit47cb2edf0d472fd42e54666f47f74d23f61523d7
17 changes: 13 additions & 4 deletionsObjects/codeobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -731,8 +731,10 @@ _PyCode_CreateLineArray(PyCodeObject *co)
if (!_PyLineTable_NextAddressRange(&bounds)) {
break;
}
int index = bounds.ar_start;
while (index < bounds.ar_end && index < Py_SIZE(co)) {
int addr = bounds.ar_start;
while (addr < bounds.ar_end) {
assert(addr < (int)(Py_SIZE(co) * sizeof(_Py_CODEUNIT)));
int index = addr / sizeof(_Py_CODEUNIT);
if (size == 2) {
assert(((int16_t)bounds.ar_line) == bounds.ar_line);
((int16_t *)co->_co_linearray)[index] = bounds.ar_line;
Expand All@@ -741,7 +743,7 @@ _PyCode_CreateLineArray(PyCodeObject *co)
assert(size == 4);
((int32_t *)co->_co_linearray)[index] = bounds.ar_line;
}
index++;
addr += sizeof(_Py_CODEUNIT);
}
}
return 0;
Expand All@@ -753,10 +755,10 @@ PyCode_Addr2Line(PyCodeObject *co, int addrq)
if (addrq < 0) {
return co->co_firstlineno;
}
assert(addrq >= 0 && addrq < _PyCode_NBYTES(co));
if (co->_co_linearray) {
return _PyCode_LineNumberFromArray(co, addrq / sizeof(_Py_CODEUNIT));
}
assert(addrq >= 0 && addrq < _PyCode_NBYTES(co));
PyCodeAddressRange bounds;
_PyCode_InitAddressRange(co, &bounds);
return _PyCode_CheckLineNumber(addrq, &bounds);
Expand DownExpand Up@@ -1596,6 +1598,9 @@ code_dealloc(PyCodeObject *co)
if (co->co_weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject*)co);
}
if (co->_co_linearray) {
PyMem_Free(co->_co_linearray);
}
if (co->co_warmup == 0) {
_Py_QuickenedCount--;
}
Expand DownExpand Up@@ -2153,6 +2158,10 @@ _PyStaticCode_Dealloc(PyCodeObject *co)
PyObject_ClearWeakRefs((PyObject *)co);
co->co_weakreflist = NULL;
}
if (co->_co_linearray) {
PyMem_Free(co->_co_linearray);
co->_co_linearray = NULL;
}
}

int
Expand Down
You are viewing a condensed version of this merge commit. You can view thefull changes here.

[8]ページ先頭

©2009-2025 Movatter.jp