mirror of
https://github.com/python/cpython.git
synced 2026-04-17 09:20:43 +00:00
gh-GH-131798: optimize jit attribute loads on immutable types (#146449)
This commit is contained in:
parent
b5a27bdcf0
commit
fc1f6b176e
2 changed files with 7 additions and 4 deletions
|
|
@ -367,7 +367,11 @@ lookup_attr(JitOptContext *ctx, _PyBloomFilter *dependencies, _PyUOpInstruction
|
|||
if (type && PyType_Check(type)) {
|
||||
PyObject *lookup = _PyType_Lookup(type, name);
|
||||
if (lookup) {
|
||||
int opcode = _Py_IsImmortal(lookup) ? immortal : mortal;
|
||||
int opcode = mortal;
|
||||
// if the object is immortal or the type is immutable, borrowing is safe
|
||||
if (_Py_IsImmortal(lookup) || (type->tp_flags & Py_TPFLAGS_IMMUTABLETYPE)) {
|
||||
opcode = immortal;
|
||||
}
|
||||
ADD_OP(opcode, 0, (uintptr_t)lookup);
|
||||
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type);
|
||||
_Py_BloomFilter_Add(dependencies, type);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue