gh-132336: Mark a few "slow path" functions used by the interpreter loop as noinline (#132337)

Mark a few functions used by the interpreter loop as noinline

These are all the slow path and should not be inlined into the interpreter
loop. Unfortunately, they end up being inlined with LTO and the current PGO
task.
This commit is contained in:
mpage 2025-04-10 01:41:15 -07:00 committed by GitHub
parent 5f1aed1c7e
commit 619edb802e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 22 deletions

View file

@ -1427,7 +1427,7 @@ skip_to_next_entry(unsigned char *p, unsigned char *end) {
#define MAX_LINEAR_SEARCH 40 #define MAX_LINEAR_SEARCH 40
static int static Py_NO_INLINE int
get_exception_handler(PyCodeObject *code, int index, int *level, int *handler, int *lasti) get_exception_handler(PyCodeObject *code, int index, int *level, int *handler, int *lasti)
{ {
unsigned char *start = (unsigned char *)PyBytes_AS_STRING(code->co_exceptiontable); unsigned char *start = (unsigned char *)PyBytes_AS_STRING(code->co_exceptiontable);

View file

@ -1200,7 +1200,7 @@ call_instrumentation_vector(
return err; return err;
} }
int Py_NO_INLINE int
_Py_call_instrumentation( _Py_call_instrumentation(
PyThreadState *tstate, int event, PyThreadState *tstate, int event,
_PyInterpreterFrame *frame, _Py_CODEUNIT *instr) _PyInterpreterFrame *frame, _Py_CODEUNIT *instr)
@ -1209,7 +1209,7 @@ _Py_call_instrumentation(
return call_instrumentation_vector(instr, tstate, event, frame, instr, 2, args); return call_instrumentation_vector(instr, tstate, event, frame, instr, 2, args);
} }
int Py_NO_INLINE int
_Py_call_instrumentation_arg( _Py_call_instrumentation_arg(
PyThreadState *tstate, int event, PyThreadState *tstate, int event,
_PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg) _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg)
@ -1218,7 +1218,7 @@ _Py_call_instrumentation_arg(
return call_instrumentation_vector(instr, tstate, event, frame, instr, 3, args); return call_instrumentation_vector(instr, tstate, event, frame, instr, 3, args);
} }
int Py_NO_INLINE int
_Py_call_instrumentation_2args( _Py_call_instrumentation_2args(
PyThreadState *tstate, int event, PyThreadState *tstate, int event,
_PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1) _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1)
@ -1227,7 +1227,7 @@ _Py_call_instrumentation_2args(
return call_instrumentation_vector(instr, tstate, event, frame, instr, 4, args); return call_instrumentation_vector(instr, tstate, event, frame, instr, 4, args);
} }
_Py_CODEUNIT * Py_NO_INLINE _Py_CODEUNIT *
_Py_call_instrumentation_jump( _Py_call_instrumentation_jump(
_Py_CODEUNIT *instr, PyThreadState *tstate, int event, _Py_CODEUNIT *instr, PyThreadState *tstate, int event,
_PyInterpreterFrame *frame, _Py_CODEUNIT *src, _Py_CODEUNIT *dest) _PyInterpreterFrame *frame, _Py_CODEUNIT *src, _Py_CODEUNIT *dest)
@ -1271,7 +1271,7 @@ call_instrumentation_vector_protected(
assert(_PyErr_Occurred(tstate)); assert(_PyErr_Occurred(tstate));
} }
void Py_NO_INLINE void
_Py_call_instrumentation_exc2( _Py_call_instrumentation_exc2(
PyThreadState *tstate, int event, PyThreadState *tstate, int event,
_PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1) _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1)
@ -1294,7 +1294,7 @@ _Py_Instrumentation_GetLine(PyCodeObject *code, int index)
return line; return line;
} }
int Py_NO_INLINE int
_Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame, _Py_CODEUNIT *instr, _Py_CODEUNIT *prev) _Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame, _Py_CODEUNIT *instr, _Py_CODEUNIT *prev)
{ {
PyCodeObject *code = _PyFrame_GetCode(frame); PyCodeObject *code = _PyFrame_GetCode(frame);
@ -1396,7 +1396,7 @@ done:
return original_opcode; return original_opcode;
} }
int Py_NO_INLINE int
_Py_call_instrumentation_instruction(PyThreadState *tstate, _PyInterpreterFrame* frame, _Py_CODEUNIT *instr) _Py_call_instrumentation_instruction(PyThreadState *tstate, _PyInterpreterFrame* frame, _Py_CODEUNIT *instr)
{ {
PyCodeObject *code = _PyFrame_GetCode(frame); PyCodeObject *code = _PyFrame_GetCode(frame);

View file

@ -818,7 +818,7 @@ specialize_module_load_attr(
/* Attribute specialization */ /* Attribute specialization */
void Py_NO_INLINE void
_Py_Specialize_LoadSuperAttr(_PyStackRef global_super_st, _PyStackRef cls_st, _Py_CODEUNIT *instr, int load_method) { _Py_Specialize_LoadSuperAttr(_PyStackRef global_super_st, _PyStackRef cls_st, _Py_CODEUNIT *instr, int load_method) {
PyObject *global_super = PyStackRef_AsPyObjectBorrow(global_super_st); PyObject *global_super = PyStackRef_AsPyObjectBorrow(global_super_st);
PyObject *cls = PyStackRef_AsPyObjectBorrow(cls_st); PyObject *cls = PyStackRef_AsPyObjectBorrow(cls_st);
@ -1342,7 +1342,7 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
return result; return result;
} }
void Py_NO_INLINE void
_Py_Specialize_LoadAttr(_PyStackRef owner_st, _Py_CODEUNIT *instr, PyObject *name) _Py_Specialize_LoadAttr(_PyStackRef owner_st, _Py_CODEUNIT *instr, PyObject *name)
{ {
PyObject *owner = PyStackRef_AsPyObjectBorrow(owner_st); PyObject *owner = PyStackRef_AsPyObjectBorrow(owner_st);
@ -1373,7 +1373,7 @@ _Py_Specialize_LoadAttr(_PyStackRef owner_st, _Py_CODEUNIT *instr, PyObject *nam
} }
} }
void Py_NO_INLINE void
_Py_Specialize_StoreAttr(_PyStackRef owner_st, _Py_CODEUNIT *instr, PyObject *name) _Py_Specialize_StoreAttr(_PyStackRef owner_st, _Py_CODEUNIT *instr, PyObject *name)
{ {
PyObject *owner = PyStackRef_AsPyObjectBorrow(owner_st); PyObject *owner = PyStackRef_AsPyObjectBorrow(owner_st);
@ -1771,7 +1771,7 @@ fail:
unspecialize(instr); unspecialize(instr);
} }
void Py_NO_INLINE void
_Py_Specialize_LoadGlobal( _Py_Specialize_LoadGlobal(
PyObject *globals, PyObject *builtins, PyObject *globals, PyObject *builtins,
_Py_CODEUNIT *instr, PyObject *name) _Py_CODEUNIT *instr, PyObject *name)
@ -1891,7 +1891,7 @@ store_subscr_fail_kind(PyObject *container, PyObject *sub)
} }
#endif #endif
void Py_NO_INLINE void
_Py_Specialize_StoreSubscr(_PyStackRef container_st, _PyStackRef sub_st, _Py_CODEUNIT *instr) _Py_Specialize_StoreSubscr(_PyStackRef container_st, _PyStackRef sub_st, _Py_CODEUNIT *instr)
{ {
PyObject *container = PyStackRef_AsPyObjectBorrow(container_st); PyObject *container = PyStackRef_AsPyObjectBorrow(container_st);
@ -2171,7 +2171,7 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs)
} }
} }
void Py_NO_INLINE void
_Py_Specialize_Call(_PyStackRef callable_st, _Py_CODEUNIT *instr, int nargs) _Py_Specialize_Call(_PyStackRef callable_st, _Py_CODEUNIT *instr, int nargs)
{ {
PyObject *callable = PyStackRef_AsPyObjectBorrow(callable_st); PyObject *callable = PyStackRef_AsPyObjectBorrow(callable_st);
@ -2211,7 +2211,7 @@ _Py_Specialize_Call(_PyStackRef callable_st, _Py_CODEUNIT *instr, int nargs)
} }
} }
void Py_NO_INLINE void
_Py_Specialize_CallKw(_PyStackRef callable_st, _Py_CODEUNIT *instr, int nargs) _Py_Specialize_CallKw(_PyStackRef callable_st, _Py_CODEUNIT *instr, int nargs)
{ {
PyObject *callable = PyStackRef_AsPyObjectBorrow(callable_st); PyObject *callable = PyStackRef_AsPyObjectBorrow(callable_st);
@ -2566,7 +2566,7 @@ binary_op_extended_specialization(PyObject *lhs, PyObject *rhs, int oparg,
return 0; return 0;
} }
void Py_NO_INLINE void
_Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *instr, _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *instr,
int oparg, _PyStackRef *locals) int oparg, _PyStackRef *locals)
{ {
@ -2724,7 +2724,7 @@ compare_op_fail_kind(PyObject *lhs, PyObject *rhs)
} }
#endif // Py_STATS #endif // Py_STATS
void Py_NO_INLINE void
_Py_Specialize_CompareOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *instr, _Py_Specialize_CompareOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *instr,
int oparg) int oparg)
{ {
@ -2787,7 +2787,7 @@ unpack_sequence_fail_kind(PyObject *seq)
} }
#endif // Py_STATS #endif // Py_STATS
void Py_NO_INLINE void
_Py_Specialize_UnpackSequence(_PyStackRef seq_st, _Py_CODEUNIT *instr, int oparg) _Py_Specialize_UnpackSequence(_PyStackRef seq_st, _Py_CODEUNIT *instr, int oparg)
{ {
PyObject *seq = PyStackRef_AsPyObjectBorrow(seq_st); PyObject *seq = PyStackRef_AsPyObjectBorrow(seq_st);
@ -2894,7 +2894,7 @@ int
} }
#endif // Py_STATS #endif // Py_STATS
void Py_NO_INLINE void
_Py_Specialize_ForIter(_PyStackRef iter, _Py_CODEUNIT *instr, int oparg) _Py_Specialize_ForIter(_PyStackRef iter, _Py_CODEUNIT *instr, int oparg)
{ {
assert(ENABLE_SPECIALIZATION_FT); assert(ENABLE_SPECIALIZATION_FT);
@ -2949,7 +2949,7 @@ failure:
unspecialize(instr); unspecialize(instr);
} }
void Py_NO_INLINE void
_Py_Specialize_Send(_PyStackRef receiver_st, _Py_CODEUNIT *instr) _Py_Specialize_Send(_PyStackRef receiver_st, _Py_CODEUNIT *instr)
{ {
PyObject *receiver = PyStackRef_AsPyObjectBorrow(receiver_st); PyObject *receiver = PyStackRef_AsPyObjectBorrow(receiver_st);
@ -3019,7 +3019,7 @@ check_type_always_true(PyTypeObject *ty)
return 0; return 0;
} }
void Py_NO_INLINE void
_Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr) _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
{ {
assert(ENABLE_SPECIALIZATION_FT); assert(ENABLE_SPECIALIZATION_FT);
@ -3093,7 +3093,7 @@ containsop_fail_kind(PyObject *value) {
} }
#endif #endif
void Py_NO_INLINE void
_Py_Specialize_ContainsOp(_PyStackRef value_st, _Py_CODEUNIT *instr) _Py_Specialize_ContainsOp(_PyStackRef value_st, _Py_CODEUNIT *instr)
{ {
PyObject *value = PyStackRef_AsPyObjectBorrow(value_st); PyObject *value = PyStackRef_AsPyObjectBorrow(value_st);