Skip to content

Commit fbedeb3

Browse files
eendebakptclaude
andcommitted
Revert unrelated bytecodes.c comment/whitespace changes
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c8f860f commit fbedeb3

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

Python/bytecodes.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -785,12 +785,13 @@ dummy_func(
785785
macro(BINARY_OP_SUBTRACT_FLOAT) =
786786
_GUARD_TOS_FLOAT + _GUARD_NOS_FLOAT + unused/5 + _BINARY_OP_SUBTRACT_FLOAT + _POP_TOP_FLOAT + _POP_TOP_FLOAT;
787787

788-
// Inplace float ops: mutate the uniquely-referenced operand
788+
// Inplace float ops: mutate the uniquely-referenced left operand
789789
// instead of allocating a new float. Tier 2 only.
790+
// The optimizer sets l to null so the following _POP_TOP_FLOAT
791+
// becomes _POP_TOP_NOP.
790792
// Note: read into a local double and write back to avoid compound
791793
// assignment (+=) on ob_fval, which generates problematic JIT
792794
// stencils on i686-pc-windows-msvc.
793-
794795
tier2 op(_BINARY_OP_ADD_FLOAT_INPLACE, (left, right -- res, l, r)) {
795796
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
796797
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
@@ -800,10 +801,12 @@ dummy_func(
800801
STAT_INC(BINARY_OP, hit);
801802
double dres = ((PyFloatObject *)left_o)->ob_fval + ((PyFloatObject *)right_o)->ob_fval;
802803
((PyFloatObject *)left_o)->ob_fval = dres;
804+
// Transfer ownership of left to res.
805+
// Original left is now dead.
803806
res = left;
804-
INPUTS_DEAD();
805807
l = PyStackRef_NULL;
806808
r = right;
809+
INPUTS_DEAD();
807810
}
808811

809812
tier2 op(_BINARY_OP_SUBTRACT_FLOAT_INPLACE, (left, right -- res, l, r)) {
@@ -816,9 +819,9 @@ dummy_func(
816819
double dres = ((PyFloatObject *)left_o)->ob_fval - ((PyFloatObject *)right_o)->ob_fval;
817820
((PyFloatObject *)left_o)->ob_fval = dres;
818821
res = left;
819-
INPUTS_DEAD();
820822
l = PyStackRef_NULL;
821823
r = right;
824+
INPUTS_DEAD();
822825
}
823826

824827
tier2 op(_BINARY_OP_MULTIPLY_FLOAT_INPLACE, (left, right -- res, l, r)) {
@@ -831,11 +834,12 @@ dummy_func(
831834
double dres = ((PyFloatObject *)left_o)->ob_fval * ((PyFloatObject *)right_o)->ob_fval;
832835
((PyFloatObject *)left_o)->ob_fval = dres;
833836
res = left;
834-
INPUTS_DEAD();
835837
l = PyStackRef_NULL;
836838
r = right;
839+
INPUTS_DEAD();
837840
}
838841

842+
// Inplace RIGHT variants: mutate the uniquely-referenced right operand.
839843
tier2 op(_BINARY_OP_ADD_FLOAT_INPLACE_RIGHT, (left, right -- res, l, r)) {
840844
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
841845
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
@@ -846,39 +850,39 @@ dummy_func(
846850
double dres = ((PyFloatObject *)left_o)->ob_fval + ((PyFloatObject *)right_o)->ob_fval;
847851
((PyFloatObject *)right_o)->ob_fval = dres;
848852
res = right;
849-
INPUTS_DEAD();
850853
l = left;
851854
r = PyStackRef_NULL;
855+
INPUTS_DEAD();
852856
}
853857

854-
tier2 op(_BINARY_OP_SUBTRACT_FLOAT_INPLACE_RIGHT, (left, right -- res, l, r)) {
858+
tier2 op(_BINARY_OP_MULTIPLY_FLOAT_INPLACE_RIGHT, (left, right -- res, l, r)) {
855859
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
856860
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
857861
assert(PyFloat_CheckExact(left_o));
858862
assert(PyFloat_CheckExact(right_o));
859863
assert(_PyObject_IsUniquelyReferenced(right_o));
860864
STAT_INC(BINARY_OP, hit);
861-
double dres = ((PyFloatObject *)left_o)->ob_fval - ((PyFloatObject *)right_o)->ob_fval;
865+
double dres = ((PyFloatObject *)left_o)->ob_fval * ((PyFloatObject *)right_o)->ob_fval;
862866
((PyFloatObject *)right_o)->ob_fval = dres;
863867
res = right;
864-
INPUTS_DEAD();
865868
l = left;
866869
r = PyStackRef_NULL;
870+
INPUTS_DEAD();
867871
}
868872

869-
tier2 op(_BINARY_OP_MULTIPLY_FLOAT_INPLACE_RIGHT, (left, right -- res, l, r)) {
873+
tier2 op(_BINARY_OP_SUBTRACT_FLOAT_INPLACE_RIGHT, (left, right -- res, l, r)) {
870874
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
871875
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
872876
assert(PyFloat_CheckExact(left_o));
873877
assert(PyFloat_CheckExact(right_o));
874878
assert(_PyObject_IsUniquelyReferenced(right_o));
875879
STAT_INC(BINARY_OP, hit);
876-
double dres = ((PyFloatObject *)left_o)->ob_fval * ((PyFloatObject *)right_o)->ob_fval;
880+
double dres = ((PyFloatObject *)left_o)->ob_fval - ((PyFloatObject *)right_o)->ob_fval;
877881
((PyFloatObject *)right_o)->ob_fval = dres;
878882
res = right;
879-
INPUTS_DEAD();
880883
l = left;
881884
r = PyStackRef_NULL;
885+
INPUTS_DEAD();
882886
}
883887

884888
pure op(_BINARY_OP_ADD_UNICODE, (left, right -- res, l, r)) {

Python/executor_cases.c.h

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)