mirror of
https://github.com/python/cpython.git
synced 2026-06-05 01:10:53 +00:00
gh-143732: add specialization for FOR_ITER (GH-148745)
This commit is contained in:
parent
952784af47
commit
9846407eaf
12 changed files with 1569 additions and 1176 deletions
|
|
@ -1452,6 +1452,28 @@ dummy_func(void) {
|
|||
}
|
||||
}
|
||||
|
||||
op(_FOR_ITER_TIER_TWO, (iter, null_or_index -- iter, null_or_index, next)) {
|
||||
bool definite = true;
|
||||
PyTypeObject *type = sym_get_type(iter);
|
||||
if (type == NULL) {
|
||||
type = sym_get_probable_type(iter);
|
||||
definite = false;
|
||||
}
|
||||
if (type != NULL && type != &PyGen_Type && type->tp_iternext != NULL) {
|
||||
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type);
|
||||
_Py_BloomFilter_Add(dependencies, type);
|
||||
if (!definite) {
|
||||
sym_set_type(iter, type);
|
||||
assert((this_instr - 1)->opcode == _RECORD_NOS_TYPE);
|
||||
int32_t orig_target = (this_instr - 1)->target;
|
||||
ADD_OP(_GUARD_TYPE_ITER, 0, (uintptr_t)type);
|
||||
uop_buffer_last(&ctx->out_buffer)->target = orig_target;
|
||||
}
|
||||
ADD_OP(_ITER_NEXT_INLINE, 0, (uintptr_t)type->tp_iternext);
|
||||
}
|
||||
next = sym_new_not_null(ctx);
|
||||
}
|
||||
|
||||
op(_GUARD_ITERATOR, (iterable -- iterable)) {
|
||||
bool definite = true;
|
||||
PyTypeObject *tp = sym_get_type(iterable);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue