Skip to content

Commit d097c86

Browse files
committed
Feedback from code review
1 parent 1cd663f commit d097c86

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Python/optimizer_symbols.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,21 @@ _Py_uop_sym_set_const(JitOptContext *ctx, JitOptSymbol *sym, PyObject *const_val
275275
}
276276
return;
277277
case JIT_SYM_TUPLE_TAG:
278-
if (Py_TYPE(const_val) != &PyTuple_Type) {
279-
sym_set_bottom(ctx, sym);
280-
return;
278+
// TODO: We should do something smarter here. It's not as simple
279+
// as sym_set_const, though, since we need to sym_set_bottom if
280+
// the length doesn't match, or one of the symbolic types within
281+
// the tuple contradicts its constant counterpart:
282+
if (PyTuple_CheckExact(const_val)) {
283+
Py_ssize_t len = PyTuple_GET_SIZE(const_val);
284+
if (len == sym->tuple.length) {
285+
for (Py_ssize_t i = 0; i < len; i++) {
286+
JitOptSymbol *item = allocation_base(ctx) + sym->tuple.items[i];
287+
PyObject *item_const = PyTuple_GET_ITEM(const_val, i);
288+
_Py_uop_sym_set_const(ctx, item, item_const);
289+
}
290+
}
281291
}
282-
make_const(sym, const_val);
292+
sym_set_bottom(ctx, sym);
283293
return;
284294
case JIT_SYM_TYPE_VERSION_TAG:
285295
if (sym->version.version != Py_TYPE(const_val)->tp_version_tag) {

0 commit comments

Comments
 (0)