From 77c059e6837b524617b44122de0f56febbe48e35 Mon Sep 17 00:00:00 2001 From: sweeneyde Date: Mon, 28 Mar 2022 04:13:33 -0400 Subject: [PATCH 1/4] Add more FOR_ITER stats --- Python/specialize.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/Python/specialize.c b/Python/specialize.c index 720bc7f241586b..575bb99b149860 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -452,6 +452,11 @@ initial_counter_value(void) { #define SPEC_FAIL_COMPARE_OP_EXTENDED_ARG 24 /* FOR_ITER */ +#define SPEC_FAIL_FOR_ITER_SQLITE 5 +#define SPEC_FAIL_FOR_ITER_IO 6 +#define SPEC_FAIL_FOR_ITER_CALLABLE 7 +#define SPEC_FAIL_FOR_ITER_FILTER 8 +#define SPEC_FAIL_FOR_ITER_ELEMENTTREE 9 #define SPEC_FAIL_FOR_ITER_GENERATOR 10 #define SPEC_FAIL_FOR_ITER_COROUTINE 11 #define SPEC_FAIL_FOR_ITER_ASYNC_GENERATOR 12 @@ -466,6 +471,11 @@ initial_counter_value(void) { #define SPEC_FAIL_FOR_ITER_DICT_ITEMS 21 #define SPEC_FAIL_FOR_ITER_DICT_VALUES 22 #define SPEC_FAIL_FOR_ITER_ENUMERATE 23 +#define SPEC_FAIL_FOR_ITER_MAP 24 +#define SPEC_FAIL_FOR_ITER_ZIP 25 +#define SPEC_FAIL_FOR_ITER_SEQ_ITER 26 +#define SPEC_FAIL_FOR_ITER_LIST_REVERSED 27 +#define SPEC_FAIL_FOR_ITER_BYTEARRAY 28 // UNPACK_SEQUENCE @@ -2033,10 +2043,40 @@ int if (t == &PyEnum_Type) { return SPEC_FAIL_FOR_ITER_ENUMERATE; } - - if (strncmp(t->tp_name, "itertools", 8) == 0) { + if (t == &PyMap_Type) { + return SPEC_FAIL_FOR_ITER_MAP; + } + if (t == &PyZip_Type) { + return SPEC_FAIL_FOR_ITER_ZIP; + } + if (t == &PySeqIter_Type) { + return SPEC_FAIL_FOR_ITER_SEQ_ITER; + } + if (t == &PyListRevIter_Type) { + return SPEC_FAIL_FOR_ITER_LIST_REVERSED; + } + if (t == &PyByteArrayIter_Type) { + return SPEC_FAIL_FOR_ITER_BYTEARRAY; + } + if (t == &PyFilter_Type) { + return SPEC_FAIL_FOR_ITER_FILTER; + } + const char *name = t->tp_name; + if (strncmp(name, "_elementtree", 12) == 0) { + return SPEC_FAIL_FOR_ITER_ELEMENTTREE; + } + if (strncmp(name, "itertools", 9) == 0) { return SPEC_FAIL_FOR_ITER_ITERTOOLS; } + if (strncmp(name, "_io.", 4) == 0) { + return SPEC_FAIL_FOR_ITER_IO; + } + if (strncmp(name, "callable_iterator", 17) == 0) { + return SPEC_FAIL_FOR_ITER_CALLABLE; + } + if (strncmp(name, "sqlite3.", 8) == 0) { + return SPEC_FAIL_FOR_ITER_SQLITE; + } return SPEC_FAIL_OTHER; } From 64f77dfc3018e6efd52055daf303e559e498d35a Mon Sep 17 00:00:00 2001 From: sweeneyde Date: Mon, 28 Mar 2022 04:26:18 -0400 Subject: [PATCH 2/4] Check for PyReversed_Type --- Python/specialize.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Python/specialize.c b/Python/specialize.c index 575bb99b149860..76947390a9bcfb 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -452,6 +452,7 @@ initial_counter_value(void) { #define SPEC_FAIL_COMPARE_OP_EXTENDED_ARG 24 /* FOR_ITER */ +#define SPEC_FAIL_FOR_ITER_REVERSED 4 #define SPEC_FAIL_FOR_ITER_SQLITE 5 #define SPEC_FAIL_FOR_ITER_IO 6 #define SPEC_FAIL_FOR_ITER_CALLABLE 7 @@ -2061,6 +2062,9 @@ int if (t == &PyFilter_Type) { return SPEC_FAIL_FOR_ITER_FILTER; } + if (t == &PyReversed_Type) { + return SPEC_FAIL_FOR_ITER_REVERSED; + } const char *name = t->tp_name; if (strncmp(name, "_elementtree", 12) == 0) { return SPEC_FAIL_FOR_ITER_ELEMENTTREE; From dfc25f9a7dde78da1c25b7809833f29d6a1c0bc7 Mon Sep 17 00:00:00 2001 From: sweeneyde Date: Wed, 30 Mar 2022 08:13:32 -0400 Subject: [PATCH 3/4] remove a few failure kinds --- Python/specialize.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/Python/specialize.c b/Python/specialize.c index 38d04070dfb39b..b6dfcbdad0145d 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -452,12 +452,6 @@ initial_counter_value(void) { #define SPEC_FAIL_COMPARE_OP_EXTENDED_ARG 24 /* FOR_ITER */ -#define SPEC_FAIL_FOR_ITER_REVERSED 4 -#define SPEC_FAIL_FOR_ITER_SQLITE 5 -#define SPEC_FAIL_FOR_ITER_IO 6 -#define SPEC_FAIL_FOR_ITER_CALLABLE 7 -#define SPEC_FAIL_FOR_ITER_FILTER 8 -#define SPEC_FAIL_FOR_ITER_ELEMENTTREE 9 #define SPEC_FAIL_FOR_ITER_GENERATOR 10 #define SPEC_FAIL_FOR_ITER_COROUTINE 11 #define SPEC_FAIL_FOR_ITER_ASYNC_GENERATOR 12 @@ -475,8 +469,8 @@ initial_counter_value(void) { #define SPEC_FAIL_FOR_ITER_MAP 24 #define SPEC_FAIL_FOR_ITER_ZIP 25 #define SPEC_FAIL_FOR_ITER_SEQ_ITER 26 -#define SPEC_FAIL_FOR_ITER_LIST_REVERSED 27 -#define SPEC_FAIL_FOR_ITER_BYTEARRAY 28 +#define SPEC_FAIL_FOR_ITER_REVERSED_LIST 27 +#define SPEC_FAIL_FOR_ITER_CALLABLE 28 // UNPACK_SEQUENCE @@ -2058,33 +2052,15 @@ int return SPEC_FAIL_FOR_ITER_SEQ_ITER; } if (t == &PyListRevIter_Type) { - return SPEC_FAIL_FOR_ITER_LIST_REVERSED; - } - if (t == &PyByteArrayIter_Type) { - return SPEC_FAIL_FOR_ITER_BYTEARRAY; - } - if (t == &PyFilter_Type) { - return SPEC_FAIL_FOR_ITER_FILTER; - } - if (t == &PyReversed_Type) { - return SPEC_FAIL_FOR_ITER_REVERSED; + return SPEC_FAIL_FOR_ITER_REVERSED_LIST; } const char *name = t->tp_name; - if (strncmp(name, "_elementtree", 12) == 0) { - return SPEC_FAIL_FOR_ITER_ELEMENTTREE; - } if (strncmp(name, "itertools", 9) == 0) { return SPEC_FAIL_FOR_ITER_ITERTOOLS; } - if (strncmp(name, "_io.", 4) == 0) { - return SPEC_FAIL_FOR_ITER_IO; - } if (strncmp(name, "callable_iterator", 17) == 0) { return SPEC_FAIL_FOR_ITER_CALLABLE; } - if (strncmp(name, "sqlite3.", 8) == 0) { - return SPEC_FAIL_FOR_ITER_SQLITE; - } return SPEC_FAIL_OTHER; } From 3083f3dfdb0f77119eb4f4937e7cb066ed8c59e9 Mon Sep 17 00:00:00 2001 From: sweeneyde Date: Sat, 11 Jun 2022 03:24:08 -0400 Subject: [PATCH 4/4] check for ascii string iterator --- Python/specialize.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Python/specialize.c b/Python/specialize.c index acbf42e1e07622..b1877841cdf730 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -482,6 +482,7 @@ miss_counter_start(void) { #define SPEC_FAIL_FOR_ITER_SEQ_ITER 26 #define SPEC_FAIL_FOR_ITER_REVERSED_LIST 27 #define SPEC_FAIL_FOR_ITER_CALLABLE 28 +#define SPEC_FAIL_FOR_ITER_ASCII_STRING 29 // UNPACK_SEQUENCE @@ -2068,6 +2069,9 @@ int if (t == &PyListRevIter_Type) { return SPEC_FAIL_FOR_ITER_REVERSED_LIST; } + if (t == &_PyUnicodeASCIIIter_Type) { + return SPEC_FAIL_FOR_ITER_ASCII_STRING; + } const char *name = t->tp_name; if (strncmp(name, "itertools", 9) == 0) { return SPEC_FAIL_FOR_ITER_ITERTOOLS;