Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.3k
gh-144540: Eliminate_MAKE_HEAP_FUNCTION for owned references#146320
gh-144540: Eliminate_MAKE_HEAP_FUNCTION for owned references#146320Sacul0457 wants to merge 1 commit intopython:mainfrom
_MAKE_HEAP_FUNCTION for owned references#146320Conversation
cocolato commentedMar 23, 2026
I think this might be a problem because in creation functions such as cpython/Python/optimizer_symbols.c Lines 690 to 709 infb8d8d9
PyJitRef_Wrap produces a ref with tag = 0.This means that tag = 0 is the default state, indicating “we have no specific information about borrowing/ownership,” rather than “definitely owned.” Only those explicitly marked with tag = 1 viaPyJitRef_Borrow() are “known to be borrowed.” |
cocolato commentedMar 23, 2026
Mark also reminded me in the last PR:#144414 (review). |
Fidget-Spinner commentedMar 23, 2026
Hmm Mark is indeed right. However, currently the only place that can generate borrowed references are LOAD_FAST_BORROW. I suspect we need to create a new tag bit for this to work. We only support good perf on 64 bit systems right now. I propose we drop the 32 bit Windows support so that we have 3 tag bits to use and can support "unknown" references. |
cocolato commentedMar 23, 2026
I also don’t think it’s necessary to maintain the performance of legacy systems |
Sacul0457 commentedMar 23, 2026
I guess I'll mark this PR as draft for now until that is in? |
Uh oh!
There was an error while loading.Please reload this page.
If the reference of the returned object is not borrowed, we remove the
_MAKE_HEAP_FUNCTION. Hence I ended up changing thetest_make_heap_safe_optimized_ownedtest to test that_MAKE_HEAP_FUNCTIONis no longer in the trace as the value returned is not a borrowed reference.Also, for a "return of a return", given the inner function returns a borrowed reference, the double
_MAKE_HEAP_FUNCTIONis reduced to just 1 :)I hope I didn't misunderstand the issue...