Skip to content

Commit 0432b9a

Browse files
committed
void _Py_Specialize_BinaryOp. PyBinaryOpSpecializationDescr --> _PyBinaryOpSpecializationDescr
1 parent 68c4f34 commit 0432b9a

File tree

5 files changed

+33
-35
lines changed

5 files changed

+33
-35
lines changed

Include/internal/pycore_code.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ extern void _Py_Specialize_Call(_PyStackRef callable, _Py_CODEUNIT *instr,
346346
int nargs);
347347
extern void _Py_Specialize_CallKw(_PyStackRef callable, _Py_CODEUNIT *instr,
348348
int nargs);
349-
extern int _Py_Specialize_BinaryOp(_PyStackRef lhs, _PyStackRef rhs, _Py_CODEUNIT *instr,
350-
int oparg, _PyStackRef *locals);
349+
extern void _Py_Specialize_BinaryOp(_PyStackRef lhs, _PyStackRef rhs, _Py_CODEUNIT *instr,
350+
int oparg, _PyStackRef *locals);
351351
extern void _Py_Specialize_CompareOp(_PyStackRef lhs, _PyStackRef rhs,
352352
_Py_CODEUNIT *instr, int oparg);
353353
extern void _Py_Specialize_UnpackSequence(_PyStackRef seq, _Py_CODEUNIT *instr,
@@ -597,10 +597,10 @@ adaptive_counter_backoff(_Py_BackoffCounter counter) {
597597
typedef int (*binaryopguardfunc)(PyObject *lhs, PyObject *rhs);
598598
typedef PyObject *(*binaryopactionfunc)(PyObject *lhs, PyObject *rhs);
599599

600-
typedef struct _PyBinaryOpSpecializationDescr {
600+
typedef struct {
601601
binaryopguardfunc guard;
602602
binaryopactionfunc action;
603-
} PyBinaryOpSpecializationDescr;
603+
} _PyBinaryOpSpecializationDescr;
604604

605605
/* Comparison bit masks. */
606606

Python/bytecodes.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,8 @@ dummy_func(
747747
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
748748
assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5);
749749
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)(next_instr - INLINE_CACHE_ENTRIES_BINARY_OP);
750-
PyBinaryOpSpecializationDescr *descr =
751-
(PyBinaryOpSpecializationDescr *)read_void(cache->external_cache);
750+
_PyBinaryOpSpecializationDescr *descr =
751+
(_PyBinaryOpSpecializationDescr *)read_void(cache->external_cache);
752752
assert(descr && descr->guard);
753753
int res = descr->guard(left_o, right_o);
754754
EXIT_IF(!res);
@@ -759,8 +759,8 @@ dummy_func(
759759
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
760760
assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5);
761761
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)(next_instr - INLINE_CACHE_ENTRIES_BINARY_OP);
762-
PyBinaryOpSpecializationDescr *descr =
763-
(PyBinaryOpSpecializationDescr *)read_void(cache->external_cache);
762+
_PyBinaryOpSpecializationDescr *descr =
763+
(_PyBinaryOpSpecializationDescr *)read_void(cache->external_cache);
764764

765765
STAT_INC(BINARY_OP, hit);
766766

@@ -4768,8 +4768,7 @@ dummy_func(
47684768
#if ENABLE_SPECIALIZATION_FT
47694769
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
47704770
next_instr = this_instr;
4771-
int res = _Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, LOCALS_ARRAY);
4772-
ERROR_IF(res == -1, error);
4771+
_Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, LOCALS_ARRAY);
47734772
DISPATCH_SAME_OPARG();
47744773
}
47754774
OPCODE_DEFERRED_INC(BINARY_OP);

Python/executor_cases.c.h

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

Python/generated_cases.c.h

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

Python/specialize.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,14 +2417,14 @@ LONG_FLOAT_ACTION(compactlong_float_multiply, *)
24172417
LONG_FLOAT_ACTION(compactlong_float_true_div, /)
24182418
#undef LONG_FLOAT_ACTION
24192419

2420-
static PyBinaryOpSpecializationDescr float_compactlong_specs[NB_OPARG_LAST+1] = {
2420+
static _PyBinaryOpSpecializationDescr float_compactlong_specs[NB_OPARG_LAST+1] = {
24212421
[NB_ADD] = {float_compactlong_guard, float_compactlong_add},
24222422
[NB_SUBTRACT] = {float_compactlong_guard, float_compactlong_subtract},
24232423
[NB_TRUE_DIVIDE] = {float_compactlong_guard, float_compactlong_true_div},
24242424
[NB_MULTIPLY] = {float_compactlong_guard, float_compactlong_multiply},
24252425
};
24262426

2427-
static PyBinaryOpSpecializationDescr compactlong_float_specs[NB_OPARG_LAST+1] = {
2427+
static _PyBinaryOpSpecializationDescr compactlong_float_specs[NB_OPARG_LAST+1] = {
24282428
[NB_ADD] = {compactlong_float_guard, compactlong_float_add},
24292429
[NB_SUBTRACT] = {compactlong_float_guard, compactlong_float_subtract},
24302430
[NB_TRUE_DIVIDE] = {compactlong_float_guard, compactlong_float_true_div},
@@ -2433,7 +2433,7 @@ static PyBinaryOpSpecializationDescr compactlong_float_specs[NB_OPARG_LAST+1] =
24332433

24342434
static int
24352435
binary_op_extended_specialization(PyObject *lhs, PyObject *rhs, int oparg,
2436-
PyBinaryOpSpecializationDescr **descr)
2436+
_PyBinaryOpSpecializationDescr **descr)
24372437
{
24382438
#define LOOKUP_SPEC(TABLE, OPARG) \
24392439
if ((TABLE)[(OPARG)].action) { \
@@ -2449,7 +2449,7 @@ binary_op_extended_specialization(PyObject *lhs, PyObject *rhs, int oparg,
24492449
return 0;
24502450
}
24512451

2452-
int
2452+
void
24532453
_Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *instr,
24542454
int oparg, _PyStackRef *locals)
24552455
{
@@ -2474,18 +2474,18 @@ _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *in
24742474
bool to_store = (next.op.code == STORE_FAST);
24752475
if (to_store && PyStackRef_AsPyObjectBorrow(locals[next.op.arg]) == lhs) {
24762476
specialize(instr, BINARY_OP_INPLACE_ADD_UNICODE);
2477-
return 0;
2477+
return;
24782478
}
24792479
specialize(instr, BINARY_OP_ADD_UNICODE);
2480-
return 0;
2480+
return;
24812481
}
24822482
if (PyLong_CheckExact(lhs)) {
24832483
specialize(instr, BINARY_OP_ADD_INT);
2484-
return 0;
2484+
return;
24852485
}
24862486
if (PyFloat_CheckExact(lhs)) {
24872487
specialize(instr, BINARY_OP_ADD_FLOAT);
2488-
return 0;
2488+
return;
24892489
}
24902490
break;
24912491
case NB_MULTIPLY:
@@ -2495,11 +2495,11 @@ _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *in
24952495
}
24962496
if (PyLong_CheckExact(lhs)) {
24972497
specialize(instr, BINARY_OP_MULTIPLY_INT);
2498-
return 0;
2498+
return;
24992499
}
25002500
if (PyFloat_CheckExact(lhs)) {
25012501
specialize(instr, BINARY_OP_MULTIPLY_FLOAT);
2502-
return 0;
2502+
return;
25032503
}
25042504
break;
25052505
case NB_SUBTRACT:
@@ -2509,25 +2509,25 @@ _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *in
25092509
}
25102510
if (PyLong_CheckExact(lhs)) {
25112511
specialize(instr, BINARY_OP_SUBTRACT_INT);
2512-
return 0;
2512+
return;
25132513
}
25142514
if (PyFloat_CheckExact(lhs)) {
25152515
specialize(instr, BINARY_OP_SUBTRACT_FLOAT);
2516-
return 0;
2516+
return;
25172517
}
25182518
break;
25192519
}
25202520

2521-
PyBinaryOpSpecializationDescr *descr;
2521+
_PyBinaryOpSpecializationDescr *descr;
25222522
if (binary_op_extended_specialization(lhs, rhs, oparg, &descr)) {
25232523
specialize(instr, BINARY_OP_EXTEND);
25242524
write_void(cache->external_cache, (void*)descr);
2525-
return 0;
2525+
return;
25262526
}
25272527

25282528
SPECIALIZATION_FAIL(BINARY_OP, binary_op_fail_kind(oparg, lhs, rhs));
25292529
unspecialize(instr);
2530-
return 0;
2530+
return;
25312531
}
25322532

25332533

0 commit comments

Comments
 (0)