-
-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
GH-118095: Unify the behavior of tier 2 FOR_ITER
branch micro-ops
#118420
Conversation
FOR_ITER
branch micro-opsFOR_ITER
branch micro-ops
…prepare for execution step.
…and fix off by one error)
25a889a
to
bb7efd4
Compare
The stats are a bit confusing. The number of traces executed goes up, but the number of uops executed goes down, as we would expect. Looking at the number of instructions executed for the various tier 1 and tier 2 Specialized
Unspecialized
Specialization is being improved: we are executing more specialized T1 and T2 variants and much fewer unspecialized |
The test hangs for tier two seem to be in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seem to be some unrelated cleanups -- maybe minimize those or extract them to another PR? Otherwise LGTM.
Python/optimizer.c
Outdated
@@ -23,6 +23,18 @@ | |||
|
|||
#define MAX_EXECUTORS_SIZE 256 | |||
|
|||
#ifdef Py_DEBUG | |||
static int base_opcode(PyCodeObject *code, int offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static int base_opcode(PyCodeObject *code, int offset) | |
static int | |
base_opcode(PyCodeObject *code, int offset) |
if (_Py_uop_sym_is_not_null(sym)) { | ||
sym_set_bottom(sym); | ||
return false; | ||
} | ||
sym_set_flag(sym, IS_NULL); | ||
return !_Py_uop_sym_is_bottom(sym); | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this refactoring matter? If so, why not do the same for set_non_null below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not a refactoring.
Calling _Py_uop_sym_set_null
on a non-NULL symbol would fail an assertion in _Py_uop_sym_is_bottom
And yes, it should be applied to set_non_null
as well.
Python/optimizer.c
Outdated
#ifdef Py_DEBUG | ||
uint32_t next_inst = target + 1 + INLINE_CACHE_ENTRIES_FOR_ITER + (oparg > 255); | ||
uint32_t jump_target = next_inst + oparg; | ||
assert(base_opcode(code, jump_target) == END_FOR || | ||
base_opcode(code, jump_target) == INSTRUMENTED_END_FOR); | ||
assert(base_opcode(code, jump_target+1) == POP_TOP); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably best to include the case also in { ... }
to limit the scope of the two variables declared in debug mode.
…ps (pythonGH-118420) * Target _FOR_ITER_TIER_TWO at POP_TOP following the matching END_FOR * Modify _GUARD_NOT_EXHAUSTED_RANGE, _GUARD_NOT_EXHAUSTED_LIST and _GUARD_NOT_EXHAUSTED_TUPLE so that they also target the POP_TOP following the matching END_FOR
Simplifies and unifies the behavior of
_GUARD_NOT_EXHAUSTED_RANGE
_GUARD_NOT_EXHAUSTED_LIST
_GUARD_NOT_EXHAUSTED_TUPLE
_FOR_ITER_TIER_TWO
Such that all leave just the iterator on the stack and they exit to the
POP_TOP
immediately after the associatedEND_FOR
.This fixes a bug in the tier 2 handling of
_FOR_ITER_TIER_TWO
where errors were treated as occurring at the jump target, not an the original instructions.