diff options
Diffstat (limited to 'Include')
-rw-r--r-- | Include/cpython/object.h | 12 | ||||
-rw-r--r-- | Include/internal/pycore_code.h | 52 | ||||
-rw-r--r-- | Include/internal/pycore_crossinterp.h | 7 | ||||
-rw-r--r-- | Include/internal/pycore_function.h | 7 | ||||
-rw-r--r-- | Include/internal/pycore_opcode_metadata.h | 3 | ||||
-rw-r--r-- | Include/internal/pycore_opcode_utils.h | 2 | ||||
-rw-r--r-- | Include/internal/pycore_runtime_init.h | 2 | ||||
-rw-r--r-- | Include/internal/pycore_uop_metadata.h | 6 | ||||
-rw-r--r-- | Include/typeslots.h | 1 |
9 files changed, 16 insertions, 76 deletions
diff --git a/Include/cpython/object.h b/Include/cpython/object.h index 36000c887b2..973d358ed8e 100644 --- a/Include/cpython/object.h +++ b/Include/cpython/object.h @@ -143,11 +143,6 @@ typedef struct { * backwards-compatibility */ typedef Py_ssize_t printfunc; -/* Specialize a binary op by setting the descriptor pointer */ -struct _PyBinopSpecializationDescr; -typedef int (*binop_specialize_func)(PyObject *v, PyObject *w, int oparg, - struct _PyBinopSpecializationDescr **descr); - // If this structure is modified, Doc/includes/typestruct.h should be updated // as well. struct _typeobject { @@ -238,13 +233,6 @@ struct _typeobject { /* bitset of which type-watchers care about this type */ unsigned char tp_watched; - /* callback that may specialize BINARY_OP - * this is an experimental API based on the ideas in the paper - * Cross Module Quickening - The Curious Case of C Extensions - * by Felix Berlakovich and Stefan Brunthaler. - */ - binop_specialize_func tp_binop_specialize; - /* Number of tp_version_tag values used. * Set to _Py_ATTR_CACHE_UNUSED if the attribute cache is * disabled for this type (e.g. due to custom MRO entries). diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index e1fd483d4a1..b135e30b7ad 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -434,8 +434,6 @@ write_location_entry_start(uint8_t *ptr, int code, int length) * On a specialization failure, the backoff counter is restarted. */ -#include "pycore_backoff.h" - // A value of 1 means that we attempt to specialize the *second* time each // instruction is executed. Executing twice is a much better indicator of // "hotness" than executing once, but additional warmup delays only prevent @@ -482,18 +480,13 @@ adaptive_counter_backoff(_Py_BackoffCounter counter) { /* Specialization Extensions */ /* callbacks for an external specialization */ - -struct _PyBinopSpecializationDescr; - typedef int (*binaryopguardfunc)(PyObject *lhs, PyObject *rhs); -typedef PyObject* (*binaryopactionfunc)(PyObject *lhs, PyObject *rhs); -typedef void (*binaryopfreefunc)(struct _PyBinopSpecializationDescr *descr); +typedef PyObject *(*binaryopactionfunc)(PyObject *lhs, PyObject *rhs); -typedef struct _PyBinopSpecializationDescr { +typedef struct { int oparg; binaryopguardfunc guard; binaryopactionfunc action; - binaryopfreefunc free; } _PyBinaryOpSpecializationDescr; /* Comparison bit masks. */ @@ -621,47 +614,6 @@ PyAPI_FUNC(int) _PyCode_SetUnboundVarCounts( PyObject *globalsns, PyObject *builtinsns); - -/* "Stateless" code is a function or code object which does not rely on - * external state or internal state. It may rely on arguments and - * builtins, but not globals or a closure. Thus it does not rely - * on __globals__ or __closure__, and a stateless function - * is equivalent to its code object. - * - * Stateless code also does not keep any persistent state - * of its own, so it can't have any executors, monitoring, - * instrumentation, or "extras" (i.e. co_extra). - * - * Stateless code may create nested functions, including closures. - * However, nested functions must themselves be stateless, except they - * *can* close on the enclosing locals. - * - * Stateless code may return any value, including nested functions and closures. - * - * Stateless code that takes no arguments and doesn't return anything - * may be treated like a script. - * - * We consider stateless code to be "portable" if it does not return any - * any object that holds a reference to any of the code's locals. Thus - * generators and coroutines are not portable. Likewise a function - * that returns a closure is not portable. The concept of - * portability is useful in cases where the code is run - * in a different execution context than where - * the return value will be used. */ - -PyAPI_FUNC(int) _PyCode_CheckNoInternalState(PyCodeObject *, const char **); -PyAPI_FUNC(int) _PyCode_CheckNoExternalState( - PyCodeObject *, - _PyCode_var_counts_t *, - const char **); -PyAPI_FUNC(int) _PyCode_VerifyStateless( - PyThreadState *, - PyCodeObject *, - PyObject *globalnames, - PyObject *globalsns, - PyObject *builtinsns); - -PyAPI_FUNC(int) _PyCode_CheckPureFunction(PyCodeObject *, const char **); PyAPI_FUNC(int) _PyCode_ReturnsOnlyNone(PyCodeObject *); diff --git a/Include/internal/pycore_crossinterp.h b/Include/internal/pycore_crossinterp.h index 4b4617fdbcb..9de61ef5412 100644 --- a/Include/internal/pycore_crossinterp.h +++ b/Include/internal/pycore_crossinterp.h @@ -185,6 +185,13 @@ PyAPI_FUNC(int) _PyMarshal_GetXIData( PyObject *, _PyXIData_t *); +// _PyObject_GetXIData() for code objects +PyAPI_FUNC(PyObject *) _PyCode_FromXIData(_PyXIData_t *); +PyAPI_FUNC(int) _PyCode_GetXIData( + PyThreadState *, + PyObject *, + _PyXIData_t *); + /* using cross-interpreter data */ diff --git a/Include/internal/pycore_function.h b/Include/internal/pycore_function.h index a30d52d49bd..209252b2ddc 100644 --- a/Include/internal/pycore_function.h +++ b/Include/internal/pycore_function.h @@ -35,13 +35,6 @@ PyFunctionObject *_PyFunction_LookupByVersion(uint32_t version, PyObject **p_cod extern PyObject *_Py_set_function_type_params( PyThreadState* unused, PyObject *func, PyObject *type_params); - -/* See pycore_code.h for explanation about what "stateless" means. */ - -PyAPI_FUNC(int) -_PyFunction_VerifyStateless(PyThreadState *, PyObject *); - - #ifdef __cplusplus } #endif diff --git a/Include/internal/pycore_opcode_metadata.h b/Include/internal/pycore_opcode_metadata.h index 7c4b6c60374..0e34074f160 100644 --- a/Include/internal/pycore_opcode_metadata.h +++ b/Include/internal/pycore_opcode_metadata.h @@ -1082,7 +1082,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[267] = { [BINARY_OP_ADD_FLOAT] = { true, INSTR_FMT_IXC0000, HAS_EXIT_FLAG | HAS_ERROR_FLAG }, [BINARY_OP_ADD_INT] = { true, INSTR_FMT_IXC0000, HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, [BINARY_OP_ADD_UNICODE] = { true, INSTR_FMT_IXC0000, HAS_EXIT_FLAG | HAS_ERROR_FLAG }, - [BINARY_OP_EXTEND] = { true, INSTR_FMT_IXC0000, HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [BINARY_OP_EXTEND] = { true, INSTR_FMT_IXC0000, HAS_DEOPT_FLAG | HAS_ESCAPES_FLAG }, [BINARY_OP_INPLACE_ADD_UNICODE] = { true, INSTR_FMT_IXC0000, HAS_LOCAL_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, [BINARY_OP_MULTIPLY_FLOAT] = { true, INSTR_FMT_IXC0000, HAS_EXIT_FLAG | HAS_ERROR_FLAG }, [BINARY_OP_MULTIPLY_INT] = { true, INSTR_FMT_IXC0000, HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, @@ -1333,6 +1333,7 @@ _PyOpcode_macro_expansion[256] = { [BINARY_OP_ADD_FLOAT] = { .nuops = 3, .uops = { { _GUARD_TOS_FLOAT, OPARG_SIMPLE, 0 }, { _GUARD_NOS_FLOAT, OPARG_SIMPLE, 0 }, { _BINARY_OP_ADD_FLOAT, OPARG_SIMPLE, 5 } } }, [BINARY_OP_ADD_INT] = { .nuops = 3, .uops = { { _GUARD_TOS_INT, OPARG_SIMPLE, 0 }, { _GUARD_NOS_INT, OPARG_SIMPLE, 0 }, { _BINARY_OP_ADD_INT, OPARG_SIMPLE, 5 } } }, [BINARY_OP_ADD_UNICODE] = { .nuops = 3, .uops = { { _GUARD_TOS_UNICODE, OPARG_SIMPLE, 0 }, { _GUARD_NOS_UNICODE, OPARG_SIMPLE, 0 }, { _BINARY_OP_ADD_UNICODE, OPARG_SIMPLE, 5 } } }, + [BINARY_OP_EXTEND] = { .nuops = 2, .uops = { { _GUARD_BINARY_OP_EXTEND, 4, 1 }, { _BINARY_OP_EXTEND, 4, 1 } } }, [BINARY_OP_INPLACE_ADD_UNICODE] = { .nuops = 3, .uops = { { _GUARD_TOS_UNICODE, OPARG_SIMPLE, 0 }, { _GUARD_NOS_UNICODE, OPARG_SIMPLE, 0 }, { _BINARY_OP_INPLACE_ADD_UNICODE, OPARG_SIMPLE, 5 } } }, [BINARY_OP_MULTIPLY_FLOAT] = { .nuops = 3, .uops = { { _GUARD_TOS_FLOAT, OPARG_SIMPLE, 0 }, { _GUARD_NOS_FLOAT, OPARG_SIMPLE, 0 }, { _BINARY_OP_MULTIPLY_FLOAT, OPARG_SIMPLE, 5 } } }, [BINARY_OP_MULTIPLY_INT] = { .nuops = 3, .uops = { { _GUARD_TOS_INT, OPARG_SIMPLE, 0 }, { _GUARD_NOS_INT, OPARG_SIMPLE, 0 }, { _BINARY_OP_MULTIPLY_INT, OPARG_SIMPLE, 5 } } }, diff --git a/Include/internal/pycore_opcode_utils.h b/Include/internal/pycore_opcode_utils.h index 79a1a242556..62af06dc01c 100644 --- a/Include/internal/pycore_opcode_utils.h +++ b/Include/internal/pycore_opcode_utils.h @@ -56,8 +56,6 @@ extern "C" { #define IS_RETURN_OPCODE(opcode) \ (opcode == RETURN_VALUE) -#define IS_RAISE_OPCODE(opcode) \ - (opcode == RAISE_VARARGS || opcode == RERAISE) /* Flags used in the oparg for MAKE_FUNCTION */ diff --git a/Include/internal/pycore_runtime_init.h b/Include/internal/pycore_runtime_init.h index 2b2e439681f..4200d91a2fc 100644 --- a/Include/internal/pycore_runtime_init.h +++ b/Include/internal/pycore_runtime_init.h @@ -233,8 +233,6 @@ extern PyTypeObject _PyExc_MemoryError; ._data = (LITERAL), \ } -#include "pycore_runtime_init_generated.h" - #ifdef __cplusplus } #endif diff --git a/Include/internal/pycore_uop_metadata.h b/Include/internal/pycore_uop_metadata.h index a7e14538164..912b1e56692 100644 --- a/Include/internal/pycore_uop_metadata.h +++ b/Include/internal/pycore_uop_metadata.h @@ -94,7 +94,8 @@ const uint16_t _PyUop_Flags[MAX_UOP_ID+1] = { [_BINARY_OP_SUBTRACT_FLOAT] = HAS_ERROR_FLAG | HAS_PURE_FLAG, [_BINARY_OP_ADD_UNICODE] = HAS_ERROR_FLAG | HAS_PURE_FLAG, [_BINARY_OP_INPLACE_ADD_UNICODE] = HAS_LOCAL_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, - [_BINARY_OP_EXTEND] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG | HAS_PURE_FLAG, + [_GUARD_BINARY_OP_EXTEND] = HAS_DEOPT_FLAG | HAS_ESCAPES_FLAG, + [_BINARY_OP_EXTEND] = HAS_ESCAPES_FLAG | HAS_PURE_FLAG, [_BINARY_SLICE] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, [_STORE_SLICE] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, [_BINARY_OP_SUBSCR_LIST_INT] = HAS_DEOPT_FLAG | HAS_ESCAPES_FLAG, @@ -423,6 +424,7 @@ const char *const _PyOpcode_uop_name[MAX_UOP_ID+1] = { [_GET_ITER] = "_GET_ITER", [_GET_LEN] = "_GET_LEN", [_GET_YIELD_FROM_ITER] = "_GET_YIELD_FROM_ITER", + [_GUARD_BINARY_OP_EXTEND] = "_GUARD_BINARY_OP_EXTEND", [_GUARD_CALLABLE_LEN] = "_GUARD_CALLABLE_LEN", [_GUARD_CALLABLE_STR_1] = "_GUARD_CALLABLE_STR_1", [_GUARD_CALLABLE_TUPLE_1] = "_GUARD_CALLABLE_TUPLE_1", @@ -760,6 +762,8 @@ int _PyUop_num_popped(int opcode, int oparg) return 2; case _BINARY_OP_INPLACE_ADD_UNICODE: return 2; + case _GUARD_BINARY_OP_EXTEND: + return 0; case _BINARY_OP_EXTEND: return 2; case _BINARY_SLICE: diff --git a/Include/typeslots.h b/Include/typeslots.h index 980e714714e..a7f3017ec02 100644 --- a/Include/typeslots.h +++ b/Include/typeslots.h @@ -93,5 +93,4 @@ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030E0000 /* New in 3.14 */ #define Py_tp_token 83 -#define Py_tp_binop_specialize 84 #endif |