FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-GH-131798: optimize jit attribute loads on immutable types by kumaraditya303 · Pull Request #146449 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .py  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 2 additions & 3 deletions Lib/test/test_capi/test_opt.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2792,9 +2792,6 @@ def testfunc(n):
self.assertEqual(res, sum(range(TIER2_THRESHOLD)))
uops = get_opnames(ex)
self.assertIn("_CALL_LIST_APPEND", uops)
# We should remove these in the future
self.assertIn("_GUARD_NOS_LIST", uops)
self.assertIn("_GUARD_CALLABLE_LIST_APPEND", uops)

def test_call_list_append_pop_top(self):
def testfunc(n):
Expand Down Expand Up @@ -3030,6 +3027,8 @@ def f(n):
self.assertEqual(res, TIER2_THRESHOLD)
uops = get_opnames(ex)
self.assertNotIn("_LOAD_ATTR_METHOD_NO_DICT", uops)
self.assertNotIn("_LOAD_CONST_UNDER_INLINE", uops)
self.assertIn("_LOAD_CONST_UNDER_INLINE_BORROW", uops)

def test_store_fast_refcount_elimination(self):
def foo(x):
Expand Down
6 changes: 5 additions & 1 deletion Python/optimizer_analysis.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

Back | FazBrowse Home | New Git URL