mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
gh-115999: Add free-threaded specialization for `TO_BOOL
` (gh-126616)
This commit is contained in:
parent
09c240f20c
commit
78a530a578
7 changed files with 168 additions and 69 deletions
|
@ -391,7 +391,7 @@ dummy_func(
|
|||
};
|
||||
|
||||
specializing op(_SPECIALIZE_TO_BOOL, (counter/1, value -- value)) {
|
||||
#if ENABLE_SPECIALIZATION
|
||||
#if ENABLE_SPECIALIZATION_FT
|
||||
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
|
||||
next_instr = this_instr;
|
||||
_Py_Specialize_ToBool(value, next_instr);
|
||||
|
@ -399,7 +399,7 @@ dummy_func(
|
|||
}
|
||||
OPCODE_DEFERRED_INC(TO_BOOL);
|
||||
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
|
||||
#endif /* ENABLE_SPECIALIZATION */
|
||||
#endif /* ENABLE_SPECIALIZATION_FT */
|
||||
}
|
||||
|
||||
op(_TO_BOOL, (value -- res)) {
|
||||
|
@ -435,7 +435,7 @@ dummy_func(
|
|||
PyObject *value_o = PyStackRef_AsPyObjectBorrow(value);
|
||||
EXIT_IF(!PyList_CheckExact(value_o));
|
||||
STAT_INC(TO_BOOL, hit);
|
||||
res = Py_SIZE(value_o) ? PyStackRef_True : PyStackRef_False;
|
||||
res = PyList_GET_SIZE(value_o) ? PyStackRef_True : PyStackRef_False;
|
||||
DECREF_INPUTS();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue