Skip to content

Commit f2cb39d

Browse files
committed
Steal reference instead of increfing
1 parent 7d90844 commit f2cb39d

File tree

6 files changed

+88
-59
lines changed

6 files changed

+88
-59
lines changed

Include/internal/pycore_uop_ids.h

Lines changed: 59 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4989,6 +4989,10 @@ dummy_func(
49894989
value = PyStackRef_FromPyObjectNew(ptr);
49904990
}
49914991

4992+
tier2 pure op(_LOAD_CONST_INLINE_STEAL, (ptr/4 -- value)) {
4993+
value = PyStackRef_FromPyObjectSteal(ptr);
4994+
}
4995+
49924996
tier2 pure op(_LOAD_CONST_INLINE_BORROW, (ptr/4 -- value)) {
49934997
value = PyStackRef_FromPyObjectImmortal(ptr);
49944998
}

Python/executor_cases.c.h

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,14 +1379,15 @@ counter_optimize(
13791379
_Py_CODEUNIT *target = instr + 1 + _PyOpcode_Caches[JUMP_BACKWARD] - oparg;
13801380
_PyUOpInstruction buffer[4] = {
13811381
{ .opcode = _START_EXECUTOR, .jump_target = 3, .format=UOP_FORMAT_JUMP },
1382-
{ .opcode = _LOAD_CONST_INLINE, .operand0 = (uintptr_t)self },
1382+
{ .opcode = _LOAD_CONST_INLINE_STEAL, .operand0 = (uintptr_t)self },
13831383
{ .opcode = _INTERNAL_INCREMENT_OPT_COUNTER },
13841384
{ .opcode = _EXIT_TRACE, .target = (uint32_t)(target - _PyCode_CODE(code)), .format=UOP_FORMAT_TARGET }
13851385
};
13861386
_PyExecutorObject *executor = make_executor_from_uops(buffer, 4, &EMPTY_FILTER);
13871387
if (executor == NULL) {
13881388
return -1;
13891389
}
1390+
Py_INCREF(self);
13901391
Py_SET_TYPE(executor, &_PyCounterExecutor_Type);
13911392
*exec_ptr = executor;
13921393
return 1;

Python/optimizer_cases.c.h

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)