Skip to content

Commit 619edb8

Browse files
authored
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.
1 parent 5f1aed1 commit 619edb8

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

Python/ceval.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ skip_to_next_entry(unsigned char *p, unsigned char *end) {
14271427

14281428
#define MAX_LINEAR_SEARCH 40
14291429

1430-
static int
1430+
static Py_NO_INLINE int
14311431
get_exception_handler(PyCodeObject *code, int index, int *level, int *handler, int *lasti)
14321432
{
14331433
unsigned char *start = (unsigned char *)PyBytes_AS_STRING(code->co_exceptiontable);

Python/instrumentation.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ call_instrumentation_vector(
12001200
return err;
12011201
}
12021202

1203-
int
1203+
Py_NO_INLINE int
12041204
_Py_call_instrumentation(
12051205
PyThreadState *tstate, int event,
12061206
_PyInterpreterFrame *frame, _Py_CODEUNIT *instr)
@@ -1209,7 +1209,7 @@ _Py_call_instrumentation(
12091209
return call_instrumentation_vector(instr, tstate, event, frame, instr, 2, args);
12101210
}
12111211

1212-
int
1212+
Py_NO_INLINE int
12131213
_Py_call_instrumentation_arg(
12141214
PyThreadState *tstate, int event,
12151215
_PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg)
@@ -1218,7 +1218,7 @@ _Py_call_instrumentation_arg(
12181218
return call_instrumentation_vector(instr, tstate, event, frame, instr, 3, args);
12191219
}
12201220

1221-
int
1221+
Py_NO_INLINE int
12221222
_Py_call_instrumentation_2args(
12231223
PyThreadState *tstate, int event,
12241224
_PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1)
@@ -1227,7 +1227,7 @@ _Py_call_instrumentation_2args(
12271227
return call_instrumentation_vector(instr, tstate, event, frame, instr, 4, args);
12281228
}
12291229

1230-
_Py_CODEUNIT *
1230+
Py_NO_INLINE _Py_CODEUNIT *
12311231
_Py_call_instrumentation_jump(
12321232
_Py_CODEUNIT *instr, PyThreadState *tstate, int event,
12331233
_PyInterpreterFrame *frame, _Py_CODEUNIT *src, _Py_CODEUNIT *dest)
@@ -1271,7 +1271,7 @@ call_instrumentation_vector_protected(
12711271
assert(_PyErr_Occurred(tstate));
12721272
}
12731273

1274-
void
1274+
Py_NO_INLINE void
12751275
_Py_call_instrumentation_exc2(
12761276
PyThreadState *tstate, int event,
12771277
_PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1)
@@ -1294,7 +1294,7 @@ _Py_Instrumentation_GetLine(PyCodeObject *code, int index)
12941294
return line;
12951295
}
12961296

1297-
int
1297+
Py_NO_INLINE int
12981298
_Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame, _Py_CODEUNIT *instr, _Py_CODEUNIT *prev)
12991299
{
13001300
PyCodeObject *code = _PyFrame_GetCode(frame);
@@ -1396,7 +1396,7 @@ _Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame,
13961396
return original_opcode;
13971397
}
13981398

1399-
int
1399+
Py_NO_INLINE int
14001400
_Py_call_instrumentation_instruction(PyThreadState *tstate, _PyInterpreterFrame* frame, _Py_CODEUNIT *instr)
14011401
{
14021402
PyCodeObject *code = _PyFrame_GetCode(frame);

Python/specialize.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ specialize_module_load_attr(
818818

819819
/* Attribute specialization */
820820

821-
void
821+
Py_NO_INLINE void
822822
_Py_Specialize_LoadSuperAttr(_PyStackRef global_super_st, _PyStackRef cls_st, _Py_CODEUNIT *instr, int load_method) {
823823
PyObject *global_super = PyStackRef_AsPyObjectBorrow(global_super_st);
824824
PyObject *cls = PyStackRef_AsPyObjectBorrow(cls_st);
@@ -1342,7 +1342,7 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
13421342
return result;
13431343
}
13441344

1345-
void
1345+
Py_NO_INLINE void
13461346
_Py_Specialize_LoadAttr(_PyStackRef owner_st, _Py_CODEUNIT *instr, PyObject *name)
13471347
{
13481348
PyObject *owner = PyStackRef_AsPyObjectBorrow(owner_st);
@@ -1373,7 +1373,7 @@ _Py_Specialize_LoadAttr(_PyStackRef owner_st, _Py_CODEUNIT *instr, PyObject *nam
13731373
}
13741374
}
13751375

1376-
void
1376+
Py_NO_INLINE void
13771377
_Py_Specialize_StoreAttr(_PyStackRef owner_st, _Py_CODEUNIT *instr, PyObject *name)
13781378
{
13791379
PyObject *owner = PyStackRef_AsPyObjectBorrow(owner_st);
@@ -1771,7 +1771,7 @@ specialize_load_global_lock_held(
17711771
unspecialize(instr);
17721772
}
17731773

1774-
void
1774+
Py_NO_INLINE void
17751775
_Py_Specialize_LoadGlobal(
17761776
PyObject *globals, PyObject *builtins,
17771777
_Py_CODEUNIT *instr, PyObject *name)
@@ -1891,7 +1891,7 @@ store_subscr_fail_kind(PyObject *container, PyObject *sub)
18911891
}
18921892
#endif
18931893

1894-
void
1894+
Py_NO_INLINE void
18951895
_Py_Specialize_StoreSubscr(_PyStackRef container_st, _PyStackRef sub_st, _Py_CODEUNIT *instr)
18961896
{
18971897
PyObject *container = PyStackRef_AsPyObjectBorrow(container_st);
@@ -2171,7 +2171,7 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs)
21712171
}
21722172
}
21732173

2174-
void
2174+
Py_NO_INLINE void
21752175
_Py_Specialize_Call(_PyStackRef callable_st, _Py_CODEUNIT *instr, int nargs)
21762176
{
21772177
PyObject *callable = PyStackRef_AsPyObjectBorrow(callable_st);
@@ -2211,7 +2211,7 @@ _Py_Specialize_Call(_PyStackRef callable_st, _Py_CODEUNIT *instr, int nargs)
22112211
}
22122212
}
22132213

2214-
void
2214+
Py_NO_INLINE void
22152215
_Py_Specialize_CallKw(_PyStackRef callable_st, _Py_CODEUNIT *instr, int nargs)
22162216
{
22172217
PyObject *callable = PyStackRef_AsPyObjectBorrow(callable_st);
@@ -2566,7 +2566,7 @@ binary_op_extended_specialization(PyObject *lhs, PyObject *rhs, int oparg,
25662566
return 0;
25672567
}
25682568

2569-
void
2569+
Py_NO_INLINE void
25702570
_Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *instr,
25712571
int oparg, _PyStackRef *locals)
25722572
{
@@ -2724,7 +2724,7 @@ compare_op_fail_kind(PyObject *lhs, PyObject *rhs)
27242724
}
27252725
#endif // Py_STATS
27262726

2727-
void
2727+
Py_NO_INLINE void
27282728
_Py_Specialize_CompareOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *instr,
27292729
int oparg)
27302730
{
@@ -2787,7 +2787,7 @@ unpack_sequence_fail_kind(PyObject *seq)
27872787
}
27882788
#endif // Py_STATS
27892789

2790-
void
2790+
Py_NO_INLINE void
27912791
_Py_Specialize_UnpackSequence(_PyStackRef seq_st, _Py_CODEUNIT *instr, int oparg)
27922792
{
27932793
PyObject *seq = PyStackRef_AsPyObjectBorrow(seq_st);
@@ -2894,7 +2894,7 @@ int
28942894
}
28952895
#endif // Py_STATS
28962896

2897-
void
2897+
Py_NO_INLINE void
28982898
_Py_Specialize_ForIter(_PyStackRef iter, _Py_CODEUNIT *instr, int oparg)
28992899
{
29002900
assert(ENABLE_SPECIALIZATION_FT);
@@ -2949,7 +2949,7 @@ _Py_Specialize_ForIter(_PyStackRef iter, _Py_CODEUNIT *instr, int oparg)
29492949
unspecialize(instr);
29502950
}
29512951

2952-
void
2952+
Py_NO_INLINE void
29532953
_Py_Specialize_Send(_PyStackRef receiver_st, _Py_CODEUNIT *instr)
29542954
{
29552955
PyObject *receiver = PyStackRef_AsPyObjectBorrow(receiver_st);
@@ -3019,7 +3019,7 @@ check_type_always_true(PyTypeObject *ty)
30193019
return 0;
30203020
}
30213021

3022-
void
3022+
Py_NO_INLINE void
30233023
_Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
30243024
{
30253025
assert(ENABLE_SPECIALIZATION_FT);
@@ -3093,7 +3093,7 @@ containsop_fail_kind(PyObject *value) {
30933093
}
30943094
#endif
30953095

3096-
void
3096+
Py_NO_INLINE void
30973097
_Py_Specialize_ContainsOp(_PyStackRef value_st, _Py_CODEUNIT *instr)
30983098
{
30993099
PyObject *value = PyStackRef_AsPyObjectBorrow(value_st);

0 commit comments

Comments
 (0)