8000 GH-131798: Narrow types more aggressively in the JIT by brandtbucher · Pull Request #134373 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-131798: Narrow types more aggressively in the JIT #134373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 20, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Feedback from code review
  • Loading branch information
brandtbucher committed May 20, 2025
commit d097c860adec35ecbbfe6e329a4f325b22e17aad
18 changes: 14 additions & 4 deletions Python/optimizer_symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,21 @@ _Py_uop_sym_set_const(JitOptContext *ctx, JitOptSymbol *sym, PyObject *const_val
}
return;
case JIT_SYM_TUPLE_TAG:
if (Py_TYPE(const_val) != &PyTuple_Type) {
sym_set_bottom(ctx, sym);
return;
// TODO: We should do something smarter here. It's not as simple
// as sym_set_const, though, since we need to sym_set_bottom if
// the length doesn't match, or one of the symbolic types within
// the tuple contradicts its constant counterpart:
if (PyTuple_CheckExact(const_val)) {
Py_ssize_t len = PyTuple_GET_SIZE(const_val);
if (len == sym->tuple.length) {
for (Py_ssize_t i = 0; i < len; i++) {
JitOptSymbol *item = allocation_base(ctx) + sym->tuple.items[i];
PyObject *item_const = PyTuple_GET_ITEM(const_val, i);
_Py_uop_sym_set_const(ctx, item, item_const);
}
}
}
make_const(sym, const_val);
sym_set_bottom(ctx, sym);
return;
case JIT_SYM_TYPE_VERSION_TAG:
if (sym->version.version != Py_TYPE(const_val)->tp_version_tag) {
Expand Down
Loading
0