mirror of
https://github.com/python/cpython.git
synced 2025-11-26 21:33:10 +00:00
GH-90043: Handle NaNs in COMPARE_OP_FLOAT_JUMP (GH-100278)
This commit is contained in:
parent
d4052d835b
commit
9076455d1b
4 changed files with 23 additions and 24 deletions
|
|
@ -2024,13 +2024,11 @@ dummy_func(
|
|||
// Combined: COMPARE_OP (float ? float) + POP_JUMP_IF_(true/false)
|
||||
DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP);
|
||||
DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP);
|
||||
STAT_INC(COMPARE_OP, hit);
|
||||
double dleft = PyFloat_AS_DOUBLE(left);
|
||||
double dright = PyFloat_AS_DOUBLE(right);
|
||||
// 1 if <, 2 if ==, 4 if >; this matches when _to_jump_mask
|
||||
int sign_ish = 2*(dleft > dright) + 2 - (dleft < dright);
|
||||
DEOPT_IF(isnan(dleft), COMPARE_OP);
|
||||
DEOPT_IF(isnan(dright), COMPARE_OP);
|
||||
STAT_INC(COMPARE_OP, hit);
|
||||
// 1 if NaN, 2 if <, 4 if >, 8 if ==; this matches when_to_jump_mask
|
||||
int sign_ish = 1 << (2 * (dleft >= dright) + (dleft <= dright));
|
||||
_Py_DECREF_SPECIALIZED(left, _PyFloat_ExactDealloc);
|
||||
_Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc);
|
||||
jump = sign_ish & when_to_jump_mask;
|
||||
|
|
@ -2057,8 +2055,8 @@ dummy_func(
|
|||
assert(Py_ABS(Py_SIZE(left)) <= 1 && Py_ABS(Py_SIZE(right)) <= 1);
|
||||
Py_ssize_t ileft = Py_SIZE(left) * ((PyLongObject *)left)->ob_digit[0];
|
||||
Py_ssize_t iright = Py_SIZE(right) * ((PyLongObject *)right)->ob_digit[0];
|
||||
// 1 if <, 2 if ==, 4 if >; this matches when _to_jump_mask
|
||||
int sign_ish = 2*(ileft > iright) + 2 - (ileft < iright);
|
||||
// 2 if <, 4 if >, 8 if ==; this matches when_to_jump_mask
|
||||
int sign_ish = 1 << (2 * (ileft >= iright) + (ileft <= iright));
|
||||
_Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||
jump = sign_ish & when_to_jump_mask;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue