mirror of
https://github.com/python/cpython.git
synced 2026-04-14 15:50:50 +00:00
gh-144540: Add _MAKE_HEAP_SAFE uop to eliminate unnecessary refcount operations in RETURN_VALUE and YIELD_VALUE (GH-144414)
This commit is contained in:
parent
77d6d5d8fc
commit
f062014d38
10 changed files with 1288 additions and 1072 deletions
|
|
@ -88,6 +88,14 @@ dummy_func(void) {
|
|||
|
||||
// BEGIN BYTECODES //
|
||||
|
||||
op(_MAKE_HEAP_SAFE, (value -- value)) {
|
||||
// eliminate _MAKE_HEAP_SAFE when we *know* the value is immortal
|
||||
if (sym_is_immortal(PyJitRef_Unwrap(value))) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
value = PyJitRef_StripReferenceInfo(value);
|
||||
}
|
||||
|
||||
op(_LOAD_FAST_CHECK, (-- value)) {
|
||||
value = GETLOCAL(oparg);
|
||||
// We guarantee this will error - just bail and don't optimize it.
|
||||
|
|
@ -944,8 +952,7 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_RETURN_VALUE, (retval -- res)) {
|
||||
// Mimics PyStackRef_MakeHeapSafe in the interpreter.
|
||||
JitOptRef temp = PyJitRef_StripReferenceInfo(retval);
|
||||
JitOptRef temp = retval;
|
||||
DEAD(retval);
|
||||
SAVE_STACK();
|
||||
ctx->frame->stack_pointer = stack_pointer;
|
||||
|
|
@ -983,8 +990,7 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_YIELD_VALUE, (retval -- value)) {
|
||||
// Mimics PyStackRef_MakeHeapSafe in the interpreter.
|
||||
JitOptRef temp = PyJitRef_StripReferenceInfo(retval);
|
||||
JitOptRef temp = retval;
|
||||
DEAD(retval);
|
||||
SAVE_STACK();
|
||||
ctx->frame->stack_pointer = stack_pointer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue