cpython/Python/record_functions.c.h
Mark Shannon b53fc7caa6
GH-144179: Use recorded values to make optimizer more robust (GH-144437)
* Add three new symbol kinds
* Do not smuggle code object in _PUSH_FRAME operand
* Fix small bug in predicate analysis
2026-02-05 08:58:41 +00:00

120 lines
5.3 KiB
C
Generated

// This file is generated by Tools/cases_generator/record_function_generator.py
// from:
// Python/bytecodes.c
// Do not edit!
#ifdef TIER_ONE
#error "This file is for Tier 2 only"
#endif
void _PyOpcode_RecordFunction_TOS(_PyInterpreterFrame *frame, _PyStackRef *stack_pointer, int oparg, PyObject **recorded_value) {
_PyStackRef tos;
tos = stack_pointer[-1];
*recorded_value = (PyObject *)PyStackRef_AsPyObjectBorrow(tos);
Py_INCREF(*recorded_value);
}
void _PyOpcode_RecordFunction_TOS_TYPE(_PyInterpreterFrame *frame, _PyStackRef *stack_pointer, int oparg, PyObject **recorded_value) {
_PyStackRef tos;
tos = stack_pointer[-1];
*recorded_value = (PyObject *)Py_TYPE(PyStackRef_AsPyObjectBorrow(tos));
Py_INCREF(*recorded_value);
}
void _PyOpcode_RecordFunction_NOS(_PyInterpreterFrame *frame, _PyStackRef *stack_pointer, int oparg, PyObject **recorded_value) {
_PyStackRef nos;
nos = stack_pointer[-2];
*recorded_value = (PyObject *)PyStackRef_AsPyObjectBorrow(nos);
Py_INCREF(*recorded_value);
}
void _PyOpcode_RecordFunction_NOS_GEN_FUNC(_PyInterpreterFrame *frame, _PyStackRef *stack_pointer, int oparg, PyObject **recorded_value) {
_PyStackRef nos;
nos = stack_pointer[-2];
PyObject *obj = PyStackRef_AsPyObjectBorrow(nos);
if (PyGen_Check(obj)) {
_PyFrame_SetStackPointer(frame, stack_pointer);
PyObject *func = (PyObject *)_PyFrame_GetFunction(&((PyGenObject *)obj)->gi_iframe);
stack_pointer = _PyFrame_GetStackPointer(frame);
*recorded_value = (PyObject *)func;
Py_INCREF(*recorded_value);
}
}
void _PyOpcode_RecordFunction_4OS(_PyInterpreterFrame *frame, _PyStackRef *stack_pointer, int oparg, PyObject **recorded_value) {
_PyStackRef value;
value = stack_pointer[-4];
*recorded_value = (PyObject *)PyStackRef_AsPyObjectBorrow(value);
Py_INCREF(*recorded_value);
}
void _PyOpcode_RecordFunction_CALLABLE(_PyInterpreterFrame *frame, _PyStackRef *stack_pointer, int oparg, PyObject **recorded_value) {
_PyStackRef func;
func = stack_pointer[-2 - oparg];
*recorded_value = (PyObject *)PyStackRef_AsPyObjectBorrow(func);
Py_INCREF(*recorded_value);
}
void _PyOpcode_RecordFunction_BOUND_METHOD(_PyInterpreterFrame *frame, _PyStackRef *stack_pointer, int oparg, PyObject **recorded_value) {
_PyStackRef callable;
callable = stack_pointer[-2 - oparg];
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
if (Py_TYPE(callable_o) == &PyMethod_Type) {
PyObject *func = ((PyMethodObject *)callable_o)->im_func;
*recorded_value = (PyObject *)func;
Py_INCREF(*recorded_value);
}
}
void _PyOpcode_RecordFunction_CODE(_PyInterpreterFrame *frame, _PyStackRef *stack_pointer, int oparg, PyObject **recorded_value) {
*recorded_value = (PyObject *)NULL;
Py_INCREF(*recorded_value);
}
#define _RECORD_TOS_TYPE_INDEX 1
#define _RECORD_NOS_INDEX 2
#define _RECORD_NOS_GEN_FUNC_INDEX 3
#define _RECORD_CALLABLE_INDEX 4
#define _RECORD_BOUND_METHOD_INDEX 5
#define _RECORD_4OS_INDEX 6
const uint8_t _PyOpcode_RecordFunctionIndices[256] = {
[TO_BOOL_ALWAYS_TRUE] = _RECORD_TOS_TYPE_INDEX,
[BINARY_OP_SUBSCR_GETITEM] = _RECORD_NOS_INDEX,
[SEND_GEN] = _RECORD_NOS_GEN_FUNC_INDEX,
[LOAD_ATTR_INSTANCE_VALUE] = _RECORD_TOS_TYPE_INDEX,
[LOAD_ATTR_WITH_HINT] = _RECORD_TOS_TYPE_INDEX,
[LOAD_ATTR_SLOT] = _RECORD_TOS_TYPE_INDEX,
[LOAD_ATTR_CLASS_WITH_METACLASS_CHECK] = _RECORD_TOS_TYPE_INDEX,
[LOAD_ATTR_PROPERTY] = _RECORD_TOS_TYPE_INDEX,
[STORE_ATTR_WITH_HINT] = _RECORD_TOS_TYPE_INDEX,
[STORE_ATTR_SLOT] = _RECORD_TOS_TYPE_INDEX,
[FOR_ITER_GEN] = _RECORD_NOS_GEN_FUNC_INDEX,
[LOAD_ATTR_METHOD_WITH_VALUES] = _RECORD_TOS_TYPE_INDEX,
[LOAD_ATTR_METHOD_NO_DICT] = _RECORD_TOS_TYPE_INDEX,
[LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES] = _RECORD_TOS_TYPE_INDEX,
[LOAD_ATTR_NONDESCRIPTOR_NO_DICT] = _RECORD_TOS_TYPE_INDEX,
[LOAD_ATTR_METHOD_LAZY_DICT] = _RECORD_TOS_TYPE_INDEX,
[CALL_PY_GENERAL] = _RECORD_CALLABLE_INDEX,
[CALL_BOUND_METHOD_GENERAL] = _RECORD_BOUND_METHOD_INDEX,
[CALL_NON_PY_GENERAL] = _RECORD_CALLABLE_INDEX,
[CALL_BOUND_METHOD_EXACT_ARGS] = _RECORD_BOUND_METHOD_INDEX,
[CALL_PY_EXACT_ARGS] = _RECORD_CALLABLE_INDEX,
[CALL_ALLOC_AND_ENTER_INIT] = _RECORD_CALLABLE_INDEX,
[CALL_BUILTIN_CLASS] = _RECORD_CALLABLE_INDEX,
[CALL_BUILTIN_O] = _RECORD_CALLABLE_INDEX,
[CALL_BUILTIN_FAST] = _RECORD_CALLABLE_INDEX,
[CALL_BUILTIN_FAST_WITH_KEYWORDS] = _RECORD_CALLABLE_INDEX,
[CALL_METHOD_DESCRIPTOR_O] = _RECORD_CALLABLE_INDEX,
[CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = _RECORD_CALLABLE_INDEX,
[CALL_METHOD_DESCRIPTOR_NOARGS] = _RECORD_CALLABLE_INDEX,
[CALL_EX_PY] = _RECORD_4OS_INDEX,
};
const _Py_RecordFuncPtr _PyOpcode_RecordFunctions[7] = {
[0] = NULL,
[_RECORD_TOS_TYPE_INDEX] = _PyOpcode_RecordFunction_TOS_TYPE,
[_RECORD_NOS_INDEX] = _PyOpcode_RecordFunction_NOS,
[_RECORD_NOS_GEN_FUNC_INDEX] = _PyOpcode_RecordFunction_NOS_GEN_FUNC,
[_RECORD_CALLABLE_INDEX] = _PyOpcode_RecordFunction_CALLABLE,
[_RECORD_BOUND_METHOD_INDEX] = _PyOpcode_RecordFunction_BOUND_METHOD,
[_RECORD_4OS_INDEX] = _PyOpcode_RecordFunction_4OS,
};