summaryrefslogtreecommitdiffstats
path: root/Python/specialize.c
diff options
context:
space:
mode:
authorKirill Podoprigora <kirill.bast9@mail.ru>2024-11-06 21:52:15 (GMT)
committerGitHub <noreply@github.com>2024-11-06 21:52:15 (GMT)
commit6e03ff2419a7faf514ad833dc513175c4f7e9bc7 (patch)
treeb9e5db80238ac6f9059d78a795ea522aec608213 /Python/specialize.c
parent8fa4dc4ba8646c59f945f2451c53e2919f066065 (diff)
downloadcpython-6e03ff2419a7faf514ad833dc513175c4f7e9bc7.zip
cpython-6e03ff2419a7faf514ad833dc513175c4f7e9bc7.tar.gz
cpython-6e03ff2419a7faf514ad833dc513175c4f7e9bc7.tar.bz2
gh-126513: Use helpers for `_Py_Specialize_ConstainsOp` (#126517)
* Use helpers for _Py_Specialize_ConstainsOp * Remove unnecessary variable
Diffstat (limited to 'Python/specialize.c')
-rw-r--r--Python/specialize.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/Python/specialize.c b/Python/specialize.c
index 2673e16..0699e7b 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -2760,8 +2760,8 @@ success:
cache->counter = adaptive_counter_cooldown();
}
-#ifdef Py_STATS
-static int containsop_fail_kind(PyObject *value) {
+static int
+containsop_fail_kind(PyObject *value) {
if (PyUnicode_CheckExact(value)) {
return SPEC_FAIL_CONTAINS_OP_STR;
}
@@ -2776,7 +2776,6 @@ static int containsop_fail_kind(PyObject *value) {
}
return SPEC_FAIL_OTHER;
}
-#endif // Py_STATS
void
_Py_Specialize_ContainsOp(_PyStackRef value_st, _Py_CODEUNIT *instr)
@@ -2785,26 +2784,17 @@ _Py_Specialize_ContainsOp(_PyStackRef value_st, _Py_CODEUNIT *instr)
assert(ENABLE_SPECIALIZATION_FT);
assert(_PyOpcode_Caches[CONTAINS_OP] == INLINE_CACHE_ENTRIES_COMPARE_OP);
- uint8_t specialized_op;
- _PyContainsOpCache *cache = (_PyContainsOpCache *)(instr + 1);
if (PyDict_CheckExact(value)) {
- specialized_op = CONTAINS_OP_DICT;
- goto success;
+ specialize(instr, CONTAINS_OP_DICT);
+ return;
}
if (PySet_CheckExact(value) || PyFrozenSet_CheckExact(value)) {
- specialized_op = CONTAINS_OP_SET;
- goto success;
+ specialize(instr, CONTAINS_OP_SET);
+ return;
}
- SPECIALIZATION_FAIL(CONTAINS_OP, containsop_fail_kind(value));
- STAT_INC(CONTAINS_OP, failure);
- SET_OPCODE_OR_RETURN(instr, CONTAINS_OP);
- cache->counter = adaptive_counter_backoff(cache->counter);
+ unspecialize(instr, containsop_fail_kind(value));
return;
-success:
- STAT_INC(CONTAINS_OP, success);
- SET_OPCODE_OR_RETURN(instr, specialized_op);
- cache->counter = adaptive_counter_cooldown();
}
/* Code init cleanup.