Skip to content

Commit 2be4c37

Browse files
authored
Move predispatch logic from DISPATCH macro to juts before switch. Reduces size of each opocde in interpreter. (GH-28475)
1 parent 02fdd73 commit 2be4c37

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Python/ceval.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,21 +1297,20 @@ eval_frame_handle_pending(PyThreadState *tstate)
12971297

12981298
#if USE_COMPUTED_GOTOS
12991299
#define TARGET(op) op: TARGET_##op
1300-
#define DISPATCH_GOTO() goto *opcode_targets[opcode]
1301-
#else
1302-
#define TARGET(op) op
1303-
#define DISPATCH_GOTO() goto dispatch_opcode
1304-
#endif
1305-
13061300
#define DISPATCH() \
13071301
{ \
13081302
if (trace_info.cframe.use_tracing OR_DTRACE_LINE OR_LLTRACE) { \
13091303
goto tracing_dispatch; \
13101304
} \
13111305
f->f_lasti = INSTR_OFFSET(); \
13121306
NEXTOPARG(); \
1313-
DISPATCH_GOTO(); \
1307+
goto *opcode_targets[opcode]; \
13141308
}
1309+
#else
1310+
#define TARGET(op) op
1311+
#define DISPATCH() goto predispatch;
1312+
#endif
1313+
13151314

13161315
#define CHECK_EVAL_BREAKER() \
13171316
if (_Py_atomic_load_relaxed(eval_breaker)) { \
@@ -1827,7 +1826,16 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
18271826
}
18281827
}
18291828
#endif
1829+
#if USE_COMPUTED_GOTOS == 0
1830+
goto dispatch_opcode;
18301831

1832+
predispatch:
1833+
if (trace_info.cframe.use_tracing OR_DTRACE_LINE OR_LLTRACE) {
1834+
goto tracing_dispatch;
1835+
}
1836+
f->f_lasti = INSTR_OFFSET();
1837+
NEXTOPARG();
1838+
#endif
18311839
dispatch_opcode:
18321840
#ifdef DYNAMIC_EXECUTION_PROFILE
18331841
#ifdef DXPAIRS

0 commit comments

Comments
 (0)