mirror of
https://github.com/python/cpython.git
synced 2025-08-25 11:15:02 +00:00
GH-98686: Get rid of BINARY_OP_GENERIC and COMPARE_OP_GENERIC (GH-99399)
This commit is contained in:
parent
6f8b0e781c
commit
8555dee5ae
8 changed files with 161 additions and 206 deletions
|
@ -196,7 +196,6 @@ dummy_func(
|
|||
BINARY_OP_ADD_FLOAT,
|
||||
BINARY_OP_ADD_INT,
|
||||
BINARY_OP_ADD_UNICODE,
|
||||
BINARY_OP_GENERIC,
|
||||
// BINARY_OP_INPLACE_ADD_UNICODE, // This is an odd duck.
|
||||
BINARY_OP_MULTIPLY_FLOAT,
|
||||
BINARY_OP_MULTIPLY_INT,
|
||||
|
@ -2074,21 +2073,6 @@ dummy_func(
|
|||
JUMPBY(INLINE_CACHE_ENTRIES_STORE_ATTR);
|
||||
}
|
||||
|
||||
// stack effect: (__0 -- )
|
||||
inst(COMPARE_OP_GENERIC) {
|
||||
assert(oparg <= Py_GE);
|
||||
PyObject *right = POP();
|
||||
PyObject *left = TOP();
|
||||
PyObject *res = PyObject_RichCompare(left, right, oparg);
|
||||
SET_TOP(res);
|
||||
Py_DECREF(left);
|
||||
Py_DECREF(right);
|
||||
if (res == NULL) {
|
||||
goto error;
|
||||
}
|
||||
JUMPBY(INLINE_CACHE_ENTRIES_COMPARE_OP);
|
||||
}
|
||||
|
||||
// stack effect: (__0 -- )
|
||||
inst(COMPARE_OP) {
|
||||
_PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr;
|
||||
|
@ -2102,7 +2086,17 @@ dummy_func(
|
|||
}
|
||||
STAT_INC(COMPARE_OP, deferred);
|
||||
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
|
||||
GO_TO_INSTRUCTION(COMPARE_OP_GENERIC);
|
||||
assert(oparg <= Py_GE);
|
||||
PyObject *right = POP();
|
||||
PyObject *left = TOP();
|
||||
PyObject *res = PyObject_RichCompare(left, right, oparg);
|
||||
SET_TOP(res);
|
||||
Py_DECREF(left);
|
||||
Py_DECREF(right);
|
||||
if (res == NULL) {
|
||||
goto error;
|
||||
}
|
||||
JUMPBY(INLINE_CACHE_ENTRIES_COMPARE_OP);
|
||||
}
|
||||
|
||||
// stack effect: (__0 -- )
|
||||
|
@ -3662,18 +3656,7 @@ dummy_func(
|
|||
PUSH(Py_NewRef(peek));
|
||||
}
|
||||
|
||||
inst(BINARY_OP_GENERIC, (lhs, rhs, unused/1 -- res)) {
|
||||
assert(0 <= oparg);
|
||||
assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops));
|
||||
assert(binary_ops[oparg]);
|
||||
res = binary_ops[oparg](lhs, rhs);
|
||||
Py_DECREF(lhs);
|
||||
Py_DECREF(rhs);
|
||||
ERROR_IF(res == NULL, error);
|
||||
}
|
||||
|
||||
// This always dispatches, so the result is unused.
|
||||
inst(BINARY_OP, (lhs, rhs, unused/1 -- unused)) {
|
||||
inst(BINARY_OP, (lhs, rhs, unused/1 -- res)) {
|
||||
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
|
||||
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
|
@ -3683,7 +3666,13 @@ dummy_func(
|
|||
}
|
||||
STAT_INC(BINARY_OP, deferred);
|
||||
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
|
||||
GO_TO_INSTRUCTION(BINARY_OP_GENERIC);
|
||||
assert(0 <= oparg);
|
||||
assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops));
|
||||
assert(binary_ops[oparg]);
|
||||
res = binary_ops[oparg](lhs, rhs);
|
||||
Py_DECREF(lhs);
|
||||
Py_DECREF(rhs);
|
||||
ERROR_IF(res == NULL, error);
|
||||
}
|
||||
|
||||
// stack effect: ( -- )
|
||||
|
@ -3737,7 +3726,7 @@ family(call) = {
|
|||
CALL_NO_KW_METHOD_DESCRIPTOR_O, CALL_NO_KW_STR_1, CALL_NO_KW_TUPLE_1,
|
||||
CALL_NO_KW_TYPE_1 };
|
||||
family(compare_op) = {
|
||||
COMPARE_OP, COMPARE_OP_FLOAT_JUMP, COMPARE_OP_GENERIC,
|
||||
COMPARE_OP, COMPARE_OP_FLOAT_JUMP,
|
||||
COMPARE_OP_INT_JUMP, COMPARE_OP_STR_JUMP };
|
||||
family(for_iter) = {
|
||||
FOR_ITER, FOR_ITER_LIST,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue