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
|
I think this might be a problem because in creation functions such as cpython/Python/optimizer_symbols.c Lines 690 to 709 in fb8d8d9 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 via PyJitRef_Borrow() are “known to be borrowed.”
|
|
Mark also reminded me in the last PR: #144414 (review). |
|
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. |
I also don’t think it’s necessary to maintain the performance of legacy systems |
|
I guess I'll mark this PR as draft for now until that is in? |
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...