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 2f8dad97bcb08627eb24c16017dc3e07dec53833
17 changes: 8 additions & 9 deletions Python/optimizer_symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ _Py_uop_sym_set_type_version(JitOptContext *ctx, JitOptSymbol *sym, unsigned int
}
case JIT_SYM_KNOWN_VALUE_TAG:
if (Py_TYPE(sym->value.value)->tp_version_tag != version) {
Py_CLEAR(sym->value.value);
sym_set_bottom(ctx, sym);
return false;
};
Expand Down Expand Up @@ -275,18 +276,16 @@ _Py_uop_sym_set_const(JitOptContext *ctx, JitOptSymbol *sym, PyObject *const_val
}
return;
case JIT_SYM_TUPLE_TAG:
// 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) {
Py_ssize_t len = _Py_uop_sym_tuple_length(sym);
if (len == PyTuple_GET_SIZE(const_val)) {
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);
JitOptSymbol *sym_item = _Py_uop_sym_tuple_getitem(ctx, sym, i);
PyObject *item = PyTuple_GET_ITEM(const_val, i);
_Py_uop_sym_set_const(ctx, sym_item, item);
}
_Py_uop_sym_set_const(ctx, sym, const_val);
return;
}
}
sym_set_bottom(ctx, sym);
Expand Down
Loading
0