diff --git a/Python/bytecodes.c b/Python/bytecodes.c index b650613650cf36..1a81c51ac1e116 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -262,12 +262,13 @@ dummy_func( ); ERROR_IF(1, error); } - value = PyStackRef_DUP(value_s); + // value = PyStackRef_DUP(value_s); + value = PyStackRef_DupDeferred(value_s); } replicate(8) pure inst(LOAD_FAST, (-- value)) { assert(!PyStackRef_IsNull(GETLOCAL(oparg))); - value = PyStackRef_DUP(GETLOCAL(oparg)); + value = PyStackRef_DupDeferred(GETLOCAL(oparg)); } inst(LOAD_FAST_AND_CLEAR, (-- value)) { @@ -278,8 +279,8 @@ dummy_func( inst(LOAD_FAST_LOAD_FAST, ( -- value1, value2)) { uint32_t oparg1 = oparg >> 4; uint32_t oparg2 = oparg & 15; - value1 = PyStackRef_DUP(GETLOCAL(oparg1)); - value2 = PyStackRef_DUP(GETLOCAL(oparg2)); + value1 = PyStackRef_DupDeferred(GETLOCAL(oparg1)); + value2 = PyStackRef_DupDeferred(GETLOCAL(oparg2)); } family(LOAD_CONST, 0) = { diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 22d11059fcadb8..692d0f8ea4053d 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -87,7 +87,8 @@ stack_pointer = _PyFrame_GetStackPointer(frame); JUMP_TO_ERROR(); } - value = PyStackRef_DUP(value_s); + // value = PyStackRef_DUP(value_s); + value = PyStackRef_DupDeferred(value_s); stack_pointer[0] = value; stack_pointer += 1; assert(WITHIN_STACK_BOUNDS()); @@ -99,7 +100,7 @@ oparg = 0; assert(oparg == CURRENT_OPARG()); assert(!PyStackRef_IsNull(GETLOCAL(oparg))); - value = PyStackRef_DUP(GETLOCAL(oparg)); + value = PyStackRef_DupDeferred(GETLOCAL(oparg)); stack_pointer[0] = value; stack_pointer += 1; assert(WITHIN_STACK_BOUNDS()); @@ -111,7 +112,7 @@ oparg = 1; assert(oparg == CURRENT_OPARG()); assert(!PyStackRef_IsNull(GETLOCAL(oparg))); - value = PyStackRef_DUP(GETLOCAL(oparg)); + value = PyStackRef_DupDeferred(GETLOCAL(oparg)); stack_pointer[0] = value; stack_pointer += 1; assert(WITHIN_STACK_BOUNDS()); @@ -123,7 +124,7 @@ oparg = 2; assert(oparg == CURRENT_OPARG()); assert(!PyStackRef_IsNull(GETLOCAL(oparg))); - value = PyStackRef_DUP(GETLOCAL(oparg)); + value = PyStackRef_DupDeferred(GETLOCAL(oparg)); stack_pointer[0] = value; stack_pointer += 1; assert(WITHIN_STACK_BOUNDS()); @@ -135,7 +136,7 @@ oparg = 3; assert(oparg == CURRENT_OPARG()); assert(!PyStackRef_IsNull(GETLOCAL(oparg))); - value = PyStackRef_DUP(GETLOCAL(oparg)); + value = PyStackRef_DupDeferred(GETLOCAL(oparg)); stack_pointer[0] = value; stack_pointer += 1; assert(WITHIN_STACK_BOUNDS()); @@ -147,7 +148,7 @@ oparg = 4; assert(oparg == CURRENT_OPARG()); assert(!PyStackRef_IsNull(GETLOCAL(oparg))); - value = PyStackRef_DUP(GETLOCAL(oparg)); + value = PyStackRef_DupDeferred(GETLOCAL(oparg)); stack_pointer[0] = value; stack_pointer += 1; assert(WITHIN_STACK_BOUNDS()); @@ -159,7 +160,7 @@ oparg = 5; assert(oparg == CURRENT_OPARG()); assert(!PyStackRef_IsNull(GETLOCAL(oparg))); - value = PyStackRef_DUP(GETLOCAL(oparg)); + value = PyStackRef_DupDeferred(GETLOCAL(oparg)); stack_pointer[0] = value; stack_pointer += 1; assert(WITHIN_STACK_BOUNDS()); @@ -171,7 +172,7 @@ oparg = 6; assert(oparg == CURRENT_OPARG()); assert(!PyStackRef_IsNull(GETLOCAL(oparg))); - value = PyStackRef_DUP(GETLOCAL(oparg)); + value = PyStackRef_DupDeferred(GETLOCAL(oparg)); stack_pointer[0] = value; stack_pointer += 1; assert(WITHIN_STACK_BOUNDS()); @@ -183,7 +184,7 @@ oparg = 7; assert(oparg == CURRENT_OPARG()); assert(!PyStackRef_IsNull(GETLOCAL(oparg))); - value = PyStackRef_DUP(GETLOCAL(oparg)); + value = PyStackRef_DupDeferred(GETLOCAL(oparg)); stack_pointer[0] = value; stack_pointer += 1; assert(WITHIN_STACK_BOUNDS()); @@ -194,7 +195,7 @@ _PyStackRef value; oparg = CURRENT_OPARG(); assert(!PyStackRef_IsNull(GETLOCAL(oparg))); - value = PyStackRef_DUP(GETLOCAL(oparg)); + value = PyStackRef_DupDeferred(GETLOCAL(oparg)); stack_pointer[0] = value; stack_pointer += 1; assert(WITHIN_STACK_BOUNDS()); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 5820147ff712a9..e2dda00fee550b 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -6863,7 +6863,7 @@ INSTRUCTION_STATS(LOAD_FAST); _PyStackRef value; assert(!PyStackRef_IsNull(GETLOCAL(oparg))); - value = PyStackRef_DUP(GETLOCAL(oparg)); + value = PyStackRef_DupDeferred(GETLOCAL(oparg)); stack_pointer[0] = value; stack_pointer += 1; assert(WITHIN_STACK_BOUNDS()); @@ -6898,7 +6898,8 @@ stack_pointer = _PyFrame_GetStackPointer(frame); goto error; } - value = PyStackRef_DUP(value_s); + // value = PyStackRef_DUP(value_s); + value = PyStackRef_DupDeferred(value_s); stack_pointer[0] = value; stack_pointer += 1; assert(WITHIN_STACK_BOUNDS()); @@ -6913,8 +6914,8 @@ _PyStackRef value2; uint32_t oparg1 = oparg >> 4; uint32_t oparg2 = oparg & 15; - value1 = PyStackRef_DUP(GETLOCAL(oparg1)); - value2 = PyStackRef_DUP(GETLOCAL(oparg2)); + value1 = PyStackRef_DupDeferred(GETLOCAL(oparg1)); + value2 = PyStackRef_DupDeferred(GETLOCAL(oparg2)); stack_pointer[0] = value1; stack_pointer[1] = value2; stack_pointer += 2; diff --git a/Tools/cases_generator/analyzer.py b/Tools/cases_generator/analyzer.py index 11a559bca474b0..7bd4d7c0253dad 100644 --- a/Tools/cases_generator/analyzer.py +++ b/Tools/cases_generator/analyzer.py @@ -587,6 +587,7 @@ def has_error_without_pop(op: parser.CodeDef) -> bool: "PyStackRef_CLEAR", "PyStackRef_CLOSE_SPECIALIZED", "PyStackRef_DUP", + "PyStackRef_DupDeferred", "PyStackRef_False", "PyStackRef_FromPyObjectImmortal", "PyStackRef_FromPyObjectNew",