mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
gh-126513: Use helpers for _Py_Specialize_ConstainsOp (#126517)
* Use helpers for _Py_Specialize_ConstainsOp * Remove unnecessary variable
This commit is contained in:
parent
8fa4dc4ba8
commit
6e03ff2419
1 changed files with 7 additions and 17 deletions
|
|
@ -2760,8 +2760,8 @@ success:
|
||||||
cache->counter = adaptive_counter_cooldown();
|
cache->counter = adaptive_counter_cooldown();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_STATS
|
static int
|
||||||
static int containsop_fail_kind(PyObject *value) {
|
containsop_fail_kind(PyObject *value) {
|
||||||
if (PyUnicode_CheckExact(value)) {
|
if (PyUnicode_CheckExact(value)) {
|
||||||
return SPEC_FAIL_CONTAINS_OP_STR;
|
return SPEC_FAIL_CONTAINS_OP_STR;
|
||||||
}
|
}
|
||||||
|
|
@ -2776,7 +2776,6 @@ static int containsop_fail_kind(PyObject *value) {
|
||||||
}
|
}
|
||||||
return SPEC_FAIL_OTHER;
|
return SPEC_FAIL_OTHER;
|
||||||
}
|
}
|
||||||
#endif // Py_STATS
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_Py_Specialize_ContainsOp(_PyStackRef value_st, _Py_CODEUNIT *instr)
|
_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(ENABLE_SPECIALIZATION_FT);
|
||||||
assert(_PyOpcode_Caches[CONTAINS_OP] == INLINE_CACHE_ENTRIES_COMPARE_OP);
|
assert(_PyOpcode_Caches[CONTAINS_OP] == INLINE_CACHE_ENTRIES_COMPARE_OP);
|
||||||
uint8_t specialized_op;
|
|
||||||
_PyContainsOpCache *cache = (_PyContainsOpCache *)(instr + 1);
|
|
||||||
if (PyDict_CheckExact(value)) {
|
if (PyDict_CheckExact(value)) {
|
||||||
specialized_op = CONTAINS_OP_DICT;
|
specialize(instr, CONTAINS_OP_DICT);
|
||||||
goto success;
|
return;
|
||||||
}
|
}
|
||||||
if (PySet_CheckExact(value) || PyFrozenSet_CheckExact(value)) {
|
if (PySet_CheckExact(value) || PyFrozenSet_CheckExact(value)) {
|
||||||
specialized_op = CONTAINS_OP_SET;
|
specialize(instr, CONTAINS_OP_SET);
|
||||||
goto success;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPECIALIZATION_FAIL(CONTAINS_OP, containsop_fail_kind(value));
|
unspecialize(instr, containsop_fail_kind(value));
|
||||||
STAT_INC(CONTAINS_OP, failure);
|
|
||||||
SET_OPCODE_OR_RETURN(instr, CONTAINS_OP);
|
|
||||||
cache->counter = adaptive_counter_backoff(cache->counter);
|
|
||||||
return;
|
return;
|
||||||
success:
|
|
||||||
STAT_INC(CONTAINS_OP, success);
|
|
||||||
SET_OPCODE_OR_RETURN(instr, specialized_op);
|
|
||||||
cache->counter = adaptive_counter_cooldown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Code init cleanup.
|
/* Code init cleanup.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue