Skip to content

Commit f2b4400

Browse files
committed
make sure we also close callable
1 parent 6c04f67 commit f2b4400

File tree

6 files changed

+62
-36
lines changed

6 files changed

+62
-36
lines changed

Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4349,7 +4349,7 @@ dummy_func(
43494349
DEOPT_IF(callable_o != interp->callable_cache.isinstance);
43504350
}
43514351

4352-
op(_CALL_ISINSTANCE, (callable, null, instance, cls -- res, i, c)) {
4352+
op(_CALL_ISINSTANCE, (callable, null, instance, cls -- res, c1, i, c2)) {
43534353
/* isinstance(o, o2) */
43544354
STAT_INC(CALL, hit);
43554355
PyObject *inst_o = PyStackRef_AsPyObjectBorrow(instance);
@@ -4359,8 +4359,9 @@ dummy_func(
43594359
ERROR_NO_POP();
43604360
}
43614361
INPUTS_DEAD();
4362+
c1 = callable;
43624363
i = instance;
4363-
c = cls;
4364+
c2 = cls;
43644365
res = retval ? PyStackRef_True : PyStackRef_False;
43654366
assert((!PyStackRef_IsNull(res)) ^ (_PyErr_Occurred(tstate) != NULL));
43664367
}
@@ -4372,6 +4373,7 @@ dummy_func(
43724373
_GUARD_CALLABLE_ISINSTANCE +
43734374
_CALL_ISINSTANCE +
43744375
POP_TOP +
4376+
POP_TOP +
43754377
POP_TOP;
43764378

43774379
macro(CALL_LIST_APPEND) =
@@ -5360,17 +5362,17 @@ dummy_func(
53605362
value = PyStackRef_FromPyObjectBorrow(ptr);
53615363
}
53625364

5363-
tier2 op(_SWAP_CALL_TWO_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, instance, cls -- value, i, c)) {
5365+
tier2 op(_SWAP_CALL_TWO_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, instance, cls -- value, c1, i, c2)) {
53645366
PyStackRef_CLOSE(cls);
53655367
PyStackRef_CLOSE(instance);
53665368
(void)null; // Silence compiler warnings about unused variables
5367-
(void)callable;
53685369
DEAD(null);
5369-
DEAD(callable);
5370+
PyStackRef_CLOSE(callable);
53705371
assert(_Py_IsImmortal(PyStackRef_AsPyObjectBorrow(callable)));
53715372
value = PyStackRef_FromPyObjectBorrow(ptr);
5373+
c1 = callable;
53725374
i = instance;
5373-
c = cls;
5375+
c2 = cls;
53745376
}
53755377

53765378
tier2 op(_LOAD_CONST_UNDER_INLINE, (ptr/4, old -- value, new)) {

Python/executor_cases.c.h

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

Python/generated_cases.c.h

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

Python/optimizer_bytecodes.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,11 @@ dummy_func(void) {
567567
value = PyJitRef_Borrow(sym_new_const(ctx, ptr));
568568
}
569569

570-
op(_SWAP_CALL_TWO_LOAD_CONST_INLINE_BORROW, (ptr/4, unused, unused, instance, cls -- value, i, c)) {
570+
op(_SWAP_CALL_TWO_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, instance, cls -- value, c1, i, c2)) {
571571
value = PyJitRef_Borrow(sym_new_const(ctx, ptr));
572+
c1 = callable;
572573
i = instance;
573-
c = cls;
574+
c2 = cls;
574575
}
575576

576577
op(_POP_TOP, (value -- )) {
@@ -1003,7 +1004,7 @@ dummy_func(void) {
10031004
}
10041005
}
10051006

1006-
op(_CALL_ISINSTANCE, (unused, unused, instance, cls -- res, unused, unused)) {
1007+
op(_CALL_ISINSTANCE, (unused, unused, instance, cls -- res, unused, unused, unused)) {
10071008
// the result is always a bool, but sometimes we can
10081009
// narrow it down to True or False
10091010
res = sym_new_type(ctx, &PyBool_Type);

Python/optimizer_cases.c.h

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

0 commit comments

Comments
 (0)