Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
39 changes: 21 additions & 18 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Lib/test/test_capi/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2712,7 +2712,7 @@ def testfunc(n):
# for i, (opname, oparg) in enumerate(ex):
# print(f"{i:4d}: {opname:<20s} {oparg:3d}")
uops = {opname for opname, _, _ in ex}
self.assertIn("_IS_ITER_EXHAUSTED_RANGE", uops)
self.assertIn("_GUARD_NOT_EXHAUSTED_RANGE", uops)
# Verification that the jump goes past END_FOR
# is done by manual inspection of the output

Expand All @@ -2734,7 +2734,7 @@ def testfunc(a):
# for i, (opname, oparg) in enumerate(ex):
# print(f"{i:4d}: {opname:<20s} {oparg:3d}")
uops = {opname for opname, _, _ in ex}
self.assertIn("_IS_ITER_EXHAUSTED_LIST", uops)
self.assertIn("_GUARD_NOT_EXHAUSTED_LIST", uops)
# Verification that the jump goes past END_FOR
# is done by manual inspection of the output

Expand All @@ -2756,7 +2756,7 @@ def testfunc(a):
# for i, (opname, oparg) in enumerate(ex):
# print(f"{i:4d}: {opname:<20s} {oparg:3d}")
uops = {opname for opname, _, _ in ex}
self.assertIn("_IS_ITER_EXHAUSTED_TUPLE", uops)
self.assertIn("_GUARD_NOT_EXHAUSTED_TUPLE", uops)
# Verification that the jump goes past END_FOR
# is done by manual inspection of the output

Expand Down
12 changes: 3 additions & 9 deletions Python/abstract_interp_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 11 additions & 29 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2580,7 +2580,7 @@ dummy_func(
DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type);
}

op(_ITER_JUMP_LIST, (iter -- iter)) {
replaced op(_ITER_JUMP_LIST, (iter -- iter)) {
_PyListIterObject *it = (_PyListIterObject *)iter;
assert(Py_TYPE(iter) == &PyListIter_Type);
STAT_INC(FOR_ITER, hit);
Expand All @@ -2599,21 +2599,12 @@ dummy_func(
}

// Only used by Tier 2
op(_IS_ITER_EXHAUSTED_LIST, (iter -- iter, exhausted)) {
op(_GUARD_NOT_EXHAUSTED_LIST, (iter -- iter)) {
_PyListIterObject *it = (_PyListIterObject *)iter;
assert(Py_TYPE(iter) == &PyListIter_Type);
PyListObject *seq = it->it_seq;
if (seq == NULL) {
exhausted = Py_True;
}
else if (it->it_index >= PyList_GET_SIZE(seq)) {
Py_DECREF(seq);
it->it_seq = NULL;
exhausted = Py_True;
}
else {
exhausted = Py_False;
}
DEOPT_IF(seq == NULL);
DEOPT_IF(it->it_index >= PyList_GET_SIZE(seq));
}

op(_ITER_NEXT_LIST, (iter -- iter, next)) {
Expand All @@ -2635,7 +2626,7 @@ dummy_func(
DEOPT_IF(Py_TYPE(iter) != &PyTupleIter_Type);
}

op(_ITER_JUMP_TUPLE, (iter -- iter)) {
replaced op(_ITER_JUMP_TUPLE, (iter -- iter)) {
_PyTupleIterObject *it = (_PyTupleIterObject *)iter;
assert(Py_TYPE(iter) == &PyTupleIter_Type);
STAT_INC(FOR_ITER, hit);
Expand All @@ -2654,21 +2645,12 @@ dummy_func(
}

// Only used by Tier 2
op(_IS_ITER_EXHAUSTED_TUPLE, (iter -- iter, exhausted)) {
op(_GUARD_NOT_EXHAUSTED_TUPLE, (iter -- iter)) {
_PyTupleIterObject *it = (_PyTupleIterObject *)iter;
assert(Py_TYPE(iter) == &PyTupleIter_Type);
PyTupleObject *seq = it->it_seq;
if (seq == NULL) {
exhausted = Py_True;
}
else if (it->it_index >= PyTuple_GET_SIZE(seq)) {
Py_DECREF(seq);
it->it_seq = NULL;
exhausted = Py_True;
}
else {
exhausted = Py_False;
}
DEOPT_IF(seq == NULL);
DEOPT_IF(it->it_index >= PyTuple_GET_SIZE(seq));
}

op(_ITER_NEXT_TUPLE, (iter -- iter, next)) {
Expand All @@ -2691,7 +2673,7 @@ dummy_func(
DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type);
}

op(_ITER_JUMP_RANGE, (iter -- iter)) {
replaced op(_ITER_JUMP_RANGE, (iter -- iter)) {
_PyRangeIterObject *r = (_PyRangeIterObject *)iter;
assert(Py_TYPE(r) == &PyRangeIter_Type);
STAT_INC(FOR_ITER, hit);
Expand All @@ -2705,10 +2687,10 @@ dummy_func(
}

// Only used by Tier 2
op(_IS_ITER_EXHAUSTED_RANGE, (iter -- iter, exhausted)) {
op(_GUARD_NOT_EXHAUSTED_RANGE, (iter -- iter)) {
_PyRangeIterObject *r = (_PyRangeIterObject *)iter;
assert(Py_TYPE(r) == &PyRangeIter_Type);
exhausted = r->len <= 0 ? Py_True : Py_False;
DEOPT_IF(r->len <= 0);
}

op(_ITER_NEXT_RANGE, (iter -- iter, next)) {
Expand Down
43 changes: 8 additions & 35 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading