mirror of
https://github.com/python/cpython.git
synced 2025-08-22 01:35:16 +00:00
[3.11] GH-93516: Backport GH-93769: Speedup line number checks when tracing (GH-94127)
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
This commit is contained in:
parent
8c2af49071
commit
3ece6e6feb
7 changed files with 409 additions and 298 deletions
|
@ -475,6 +475,35 @@ write_location_entry_start(uint8_t *ptr, int code, int length)
|
|||
}
|
||||
|
||||
|
||||
/* Line array cache for tracing */
|
||||
|
||||
extern int _PyCode_CreateLineArray(PyCodeObject *co);
|
||||
|
||||
static inline int
|
||||
_PyCode_InitLineArray(PyCodeObject *co)
|
||||
{
|
||||
if (co->_co_linearray) {
|
||||
return 0;
|
||||
}
|
||||
return _PyCode_CreateLineArray(co);
|
||||
}
|
||||
|
||||
static inline int
|
||||
_PyCode_LineNumberFromArray(PyCodeObject *co, int index)
|
||||
{
|
||||
assert(co->_co_linearray != NULL);
|
||||
assert(index >= 0);
|
||||
assert(index < Py_SIZE(co));
|
||||
if (co->_co_linearray_entry_size == 2) {
|
||||
return ((int16_t *)co->_co_linearray)[index];
|
||||
}
|
||||
else {
|
||||
assert(co->_co_linearray_entry_size == 4);
|
||||
return ((int32_t *)co->_co_linearray)[index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue