Skip to content

Commit ac7e343

Browse files
Address review
1 parent c2f8e22 commit ac7e343

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

Include/internal/pycore_stackref.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ PyStackRef_FromPyObjectBorrow(PyObject *obj)
374374
}
375375
#define PyStackRef_FromPyObjectBorrow(obj) PyStackRef_FromPyObjectBorrow(_PyObject_CAST(obj))
376376

377-
378377
#define PyStackRef_CLOSE(REF) \
379378
do { \
380379
_PyStackRef _close_tmp = (REF); \

Python/optimizer_cases.c.h

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

Python/optimizer_symbols.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,10 @@ _Py_uop_sym_is_safe_const(JitOptContext *ctx, JitOptSymbol *sym)
170170
}
171171
PyTypeObject *typ = Py_TYPE(const_val);
172172
return (typ == &PyLong_Type) ||
173-
(typ == &PyUnicode_Type) ||
174-
(typ == &PyFloat_Type) ||
175-
(typ == &PyDict_Type) ||
176-
(typ == &PyTuple_Type) ||
177-
(typ == &PyList_Type);
173+
(typ == &PyUnicode_Type) ||
174+
(typ == &PyFloat_Type) ||
175+
(typ == &PyDict_Type) ||
176+
(typ == &PyTuple_Type);
178177
}
179178

180179
void
@@ -438,6 +437,10 @@ _Py_uop_sym_new_const_steal(JitOptContext *ctx, PyObject *const_val)
438437
{
439438
assert(const_val != NULL);
440439
JitOptSymbol *res = _Py_uop_sym_new_const(ctx, const_val);
440+
// Decref once because sym_new_const increfs it.
441+
Py_DECREF(const_val);
442+
// Decref it another time, because we are a steal operation.
443+
// (Ownership now belongs to the symbol).
441444
Py_DECREF(const_val);
442445
return res;
443446
}

Tools/cases_generator/optimizer_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def write_uop_pure_evaluation_region_header(
217217
# All new stackrefs are created from new references.
218218
# That's how the stackref contract works.
219219
if not outp.peek:
220-
emitter.emit(f"{outp.name} = sym_new_const_steal(ctx, PyStackRef_AsPyObjectBorrow({outp.name}_stackref));\n")
220+
emitter.emit(f"{outp.name} = sym_new_const_steal(ctx, PyStackRef_AsPyObjectSteal({outp.name}_stackref));\n")
221221
else:
222222
emitter.emit(f"{outp.name} = sym_new_const(ctx, PyStackRef_AsPyObjectBorrow({outp.name}_stackref));\n")
223223
storage.flush(out)

0 commit comments

Comments
 (0)