Skip to content

Commit 064de0e

Browse files
authored
GH-104610: Remove the use of PREDICT macros. (GH-104651)
1 parent d63a7c3 commit 064de0e

File tree

3 files changed

+507
-551
lines changed

3 files changed

+507
-551
lines changed

Python/bytecodes.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#define DEOPT_IF(cond, instname) ((void)0)
4545
#define ERROR_IF(cond, labelname) ((void)0)
4646
#define GO_TO_INSTRUCTION(instname) ((void)0)
47-
#define PREDICT(opname) ((void)0)
4847

4948
#define inst(name, ...) case name:
5049
#define op(name, ...) /* NAME is ignored */
@@ -562,14 +561,12 @@ dummy_func(
562561

563562
inst(LIST_APPEND, (list, unused[oparg-1], v -- list, unused[oparg-1])) {
564563
ERROR_IF(_PyList_AppendTakeRef((PyListObject *)list, v) < 0, error);
565-
PREDICT(JUMP_BACKWARD);
566564
}
567565

568566
inst(SET_ADD, (set, unused[oparg-1], v -- set, unused[oparg-1])) {
569567
int err = PySet_Add(set, v);
570568
DECREF_INPUTS();
571569
ERROR_IF(err, error);
572-
PREDICT(JUMP_BACKWARD);
573570
}
574571

575572
family(store_subscr, INLINE_CACHE_ENTRIES_STORE_SUBSCR) = {
@@ -824,8 +821,6 @@ dummy_func(
824821
Py_DECREF(next_iter);
825822
}
826823
}
827-
828-
PREDICT(LOAD_CONST);
829824
}
830825

831826
inst(GET_AWAITABLE, (iterable -- iter)) {
@@ -852,8 +847,6 @@ dummy_func(
852847
}
853848

854849
ERROR_IF(iter == NULL, error);
855-
856-
PREDICT(LOAD_CONST);
857850
}
858851

859852
family(send, INLINE_CACHE_ENTRIES_SEND) = {
@@ -1611,7 +1604,6 @@ dummy_func(
16111604
ERROR_IF(true, error);
16121605
}
16131606
DECREF_INPUTS();
1614-
PREDICT(CALL_FUNCTION_EX);
16151607
}
16161608

16171609
inst(MAP_ADD, (key, value --)) {
@@ -1620,7 +1612,6 @@ dummy_func(
16201612
/* dict[key] = value */
16211613
// Do not DECREF INPUTS because the function steals the references
16221614
ERROR_IF(_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0, error);
1623-
PREDICT(JUMP_BACKWARD);
16241615
}
16251616

16261617
inst(INSTRUMENTED_LOAD_SUPER_ATTR, (unused/9, unused, unused, unused -- unused if (oparg & 1), unused)) {
@@ -2248,13 +2239,11 @@ dummy_func(
22482239
inst(MATCH_MAPPING, (subject -- subject, res)) {
22492240
int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING;
22502241
res = match ? Py_True : Py_False;
2251-
PREDICT(POP_JUMP_IF_FALSE);
22522242
}
22532243

22542244
inst(MATCH_SEQUENCE, (subject -- subject, res)) {
22552245
int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE;
22562246
res = match ? Py_True : Py_False;
2257-
PREDICT(POP_JUMP_IF_FALSE);
22582247
}
22592248

22602249
inst(MATCH_KEYS, (subject, keys -- subject, keys, values_or_none)) {
@@ -2295,7 +2284,6 @@ dummy_func(
22952284
}
22962285
DECREF_INPUTS();
22972286
}
2298-
PREDICT(LOAD_CONST);
22992287
}
23002288

23012289
// Most members of this family are "secretly" super-instructions.
@@ -2485,7 +2473,6 @@ dummy_func(
24852473
Py_DECREF(exit);
24862474
ERROR_IF(true, error);
24872475
}
2488-
PREDICT(GET_AWAITABLE);
24892476
}
24902477

24912478
inst(BEFORE_WITH, (mgr -- exit, res)) {

Python/ceval_macros.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,6 @@ GETITEM(PyObject *v, Py_ssize_t i) {
174174
*/
175175

176176
#define PREDICT_ID(op) PRED_##op
177-
178-
#if USE_COMPUTED_GOTOS
179-
#define PREDICT(op) if (0) goto PREDICT_ID(op)
180-
#else
181-
#define PREDICT(next_op) \
182-
do { \
183-
_Py_CODEUNIT word = *next_instr; \
184-
opcode = word.op.code; \
185-
if (opcode == next_op) { \
186-
oparg = word.op.arg; \
187-
INSTRUCTION_START(next_op); \
188-
goto PREDICT_ID(next_op); \
189-
} \
190-
} while(0)
191-
#endif
192177
#define PREDICTED(op) PREDICT_ID(op):
193178

194179

0 commit comments

Comments
 (0)