GH-102300: Reuse objects with refcount == 1 in float specialized binary ops. (GH-102301)

This commit is contained in:
Mark Shannon 2023-03-13 10:34:54 +00:00 committed by GitHub
parent 78e4e6c3d7
commit 233e32f936
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 24 deletions

View file

@ -263,10 +263,7 @@
STAT_INC(BINARY_OP, hit);
double dprod = ((PyFloatObject *)left)->ob_fval *
((PyFloatObject *)right)->ob_fval;
prod = PyFloat_FromDouble(dprod);
_Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc);
_Py_DECREF_SPECIALIZED(left, _PyFloat_ExactDealloc);
if (prod == NULL) goto pop_2_error;
DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dprod, prod);
STACK_SHRINK(1);
stack_pointer[-1] = prod;
next_instr += 1;
@ -300,10 +297,7 @@
DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP);
STAT_INC(BINARY_OP, hit);
double dsub = ((PyFloatObject *)left)->ob_fval - ((PyFloatObject *)right)->ob_fval;
sub = PyFloat_FromDouble(dsub);
_Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc);
_Py_DECREF_SPECIALIZED(left, _PyFloat_ExactDealloc);
if (sub == NULL) goto pop_2_error;
DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dsub, sub);
STACK_SHRINK(1);
stack_pointer[-1] = sub;
next_instr += 1;
@ -372,10 +366,7 @@
STAT_INC(BINARY_OP, hit);
double dsum = ((PyFloatObject *)left)->ob_fval +
((PyFloatObject *)right)->ob_fval;
sum = PyFloat_FromDouble(dsum);
_Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc);
_Py_DECREF_SPECIALIZED(left, _PyFloat_ExactDealloc);
if (sum == NULL) goto pop_2_error;
DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dsum, sum);
STACK_SHRINK(1);
stack_pointer[-1] = sum;
next_instr += 1;