GH-104610: Remove the use of PREDICT macros. (GH-104651)

This commit is contained in:
Mark Shannon 2023-06-07 17:04:53 +01:00 committed by GitHub
parent d63a7c3694
commit 064de0e3fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 507 additions and 551 deletions

View file

@ -44,7 +44,6 @@
#define DEOPT_IF(cond, instname) ((void)0)
#define ERROR_IF(cond, labelname) ((void)0)
#define GO_TO_INSTRUCTION(instname) ((void)0)
#define PREDICT(opname) ((void)0)
#define inst(name, ...) case name:
#define op(name, ...) /* NAME is ignored */
@ -562,14 +561,12 @@ dummy_func(
inst(LIST_APPEND, (list, unused[oparg-1], v -- list, unused[oparg-1])) {
ERROR_IF(_PyList_AppendTakeRef((PyListObject *)list, v) < 0, error);
PREDICT(JUMP_BACKWARD);
}
inst(SET_ADD, (set, unused[oparg-1], v -- set, unused[oparg-1])) {
int err = PySet_Add(set, v);
DECREF_INPUTS();
ERROR_IF(err, error);
PREDICT(JUMP_BACKWARD);
}
family(store_subscr, INLINE_CACHE_ENTRIES_STORE_SUBSCR) = {
@ -824,8 +821,6 @@ dummy_func(
Py_DECREF(next_iter);
}
}
PREDICT(LOAD_CONST);
}
inst(GET_AWAITABLE, (iterable -- iter)) {
@ -852,8 +847,6 @@ dummy_func(
}
ERROR_IF(iter == NULL, error);
PREDICT(LOAD_CONST);
}
family(send, INLINE_CACHE_ENTRIES_SEND) = {
@ -1611,7 +1604,6 @@ dummy_func(
ERROR_IF(true, error);
}
DECREF_INPUTS();
PREDICT(CALL_FUNCTION_EX);
}
inst(MAP_ADD, (key, value --)) {
@ -1620,7 +1612,6 @@ dummy_func(
/* dict[key] = value */
// Do not DECREF INPUTS because the function steals the references
ERROR_IF(_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0, error);
PREDICT(JUMP_BACKWARD);
}
inst(INSTRUMENTED_LOAD_SUPER_ATTR, (unused/9, unused, unused, unused -- unused if (oparg & 1), unused)) {
@ -2248,13 +2239,11 @@ dummy_func(
inst(MATCH_MAPPING, (subject -- subject, res)) {
int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING;
res = match ? Py_True : Py_False;
PREDICT(POP_JUMP_IF_FALSE);
}
inst(MATCH_SEQUENCE, (subject -- subject, res)) {
int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE;
res = match ? Py_True : Py_False;
PREDICT(POP_JUMP_IF_FALSE);
}
inst(MATCH_KEYS, (subject, keys -- subject, keys, values_or_none)) {
@ -2295,7 +2284,6 @@ dummy_func(
}
DECREF_INPUTS();
}
PREDICT(LOAD_CONST);
}
// Most members of this family are "secretly" super-instructions.
@ -2485,7 +2473,6 @@ dummy_func(
Py_DECREF(exit);
ERROR_IF(true, error);
}
PREDICT(GET_AWAITABLE);
}
inst(BEFORE_WITH, (mgr -- exit, res)) {

View file

@ -174,21 +174,6 @@ GETITEM(PyObject *v, Py_ssize_t i) {
*/
#define PREDICT_ID(op) PRED_##op
#if USE_COMPUTED_GOTOS
#define PREDICT(op) if (0) goto PREDICT_ID(op)
#else
#define PREDICT(next_op) \
do { \
_Py_CODEUNIT word = *next_instr; \
opcode = word.op.code; \
if (opcode == next_op) { \
oparg = word.op.arg; \
INSTRUCTION_START(next_op); \
goto PREDICT_ID(next_op); \
} \
} while(0)
#endif
#define PREDICTED(op) PREDICT_ID(op):

File diff suppressed because it is too large Load diff