diff options
author | Mark Shannon <mark@hotpy.org> | 2022-01-28 12:42:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-28 12:42:30 (GMT) |
commit | 89fd7c34520aac493a8784a221366ed04452612b (patch) | |
tree | da2dd6dfe862b1351063e2c0ee2a3564c4773416 /Include | |
parent | 5a9e423473bf2c4eb32a0982e8d73420875db1da (diff) | |
download | cpython-89fd7c34520aac493a8784a221366ed04452612b.zip cpython-89fd7c34520aac493a8784a221366ed04452612b.tar.gz cpython-89fd7c34520aac493a8784a221366ed04452612b.tar.bz2 |
bpo-46329: Split calls into precall and call instructions. (GH-30855)
* Add PRECALL_FUNCTION opcode.
* Move 'call shape' varaibles into struct.
* Replace CALL_NO_KW and CALL_KW with KW_NAMES and CALL instructions.
* Specialize for builtin methods taking using the METH_FASTCALL | METH_KEYWORDS protocol.
* Allow kwnames for specialized calls to builtin types.
* Specialize calls to tuple(arg) and str(arg).
Diffstat (limited to 'Include')
-rw-r--r-- | Include/internal/pycore_code.h | 5 | ||||
-rw-r--r-- | Include/internal/pycore_frame.h | 3 | ||||
-rw-r--r-- | Include/opcode.h | 79 |
3 files changed, 49 insertions, 38 deletions
diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index bbf7a06..71dfe3e 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -38,7 +38,7 @@ typedef struct { typedef struct { uint32_t func_version; - uint16_t defaults_start; + uint16_t min_args; uint16_t defaults_len; } _PyCallCache; @@ -271,7 +271,8 @@ int _Py_Specialize_LoadGlobal(PyObject *globals, PyObject *builtins, _Py_CODEUNI int _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); int _Py_Specialize_BinarySubscr(PyObject *sub, PyObject *container, _Py_CODEUNIT *instr, SpecializedCacheEntry *cache); int _Py_Specialize_StoreSubscr(PyObject *container, PyObject *sub, _Py_CODEUNIT *instr); -int _Py_Specialize_CallNoKw(PyObject *callable, _Py_CODEUNIT *instr, int nargs, SpecializedCacheEntry *cache, PyObject *builtins); +int _Py_Specialize_CallNoKw(PyObject *callable, _Py_CODEUNIT *instr, int nargs, + PyObject *kwnames, SpecializedCacheEntry *cache, PyObject *builtins); void _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, SpecializedCacheEntry *cache); void _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, SpecializedCacheEntry *cache); diff --git a/Include/internal/pycore_frame.h b/Include/internal/pycore_frame.h index 937c13b..85b9cf0 100644 --- a/Include/internal/pycore_frame.h +++ b/Include/internal/pycore_frame.h @@ -189,6 +189,9 @@ _PyThreadState_BumpFramePointer(PyThreadState *tstate, size_t size) void _PyThreadState_PopFrame(PyThreadState *tstate, InterpreterFrame *frame); +InterpreterFrame * +_PyFrame_Push(PyThreadState *tstate, PyFunctionObject *func); + #ifdef __cplusplus } #endif diff --git a/Include/opcode.h b/Include/opcode.h index 02cdf42..bce7010 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -109,9 +109,10 @@ extern "C" { #define SET_UPDATE 163 #define DICT_MERGE 164 #define DICT_UPDATE 165 +#define PRECALL_FUNCTION 167 #define PRECALL_METHOD 168 -#define CALL_NO_KW 169 -#define CALL_KW 170 +#define CALL 171 +#define KW_NAMES 172 #define BINARY_OP_ADAPTIVE 2 #define BINARY_OP_ADD_INT 3 #define BINARY_OP_ADD_FLOAT 4 @@ -133,40 +134,45 @@ extern "C" { #define STORE_SUBSCR_ADAPTIVE 26 #define STORE_SUBSCR_LIST_INT 27 #define STORE_SUBSCR_DICT 28 -#define CALL_NO_KW_ADAPTIVE 29 -#define CALL_NO_KW_BUILTIN_O 34 -#define CALL_NO_KW_BUILTIN_FAST 36 -#define CALL_NO_KW_LEN 37 -#define CALL_NO_KW_ISINSTANCE 38 -#define CALL_NO_KW_PY_SIMPLE 39 -#define CALL_NO_KW_LIST_APPEND 40 -#define CALL_NO_KW_METHOD_DESCRIPTOR_O 41 -#define CALL_NO_KW_TYPE_1 42 -#define CALL_NO_KW_BUILTIN_CLASS_1 43 -#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 44 -#define JUMP_ABSOLUTE_QUICK 45 -#define LOAD_ATTR_ADAPTIVE 46 -#define LOAD_ATTR_INSTANCE_VALUE 47 -#define LOAD_ATTR_WITH_HINT 48 -#define LOAD_ATTR_SLOT 55 -#define LOAD_ATTR_MODULE 56 -#define LOAD_GLOBAL_ADAPTIVE 57 -#define LOAD_GLOBAL_MODULE 58 -#define LOAD_GLOBAL_BUILTIN 59 -#define LOAD_METHOD_ADAPTIVE 62 -#define LOAD_METHOD_CACHED 63 -#define LOAD_METHOD_CLASS 64 -#define LOAD_METHOD_MODULE 65 -#define LOAD_METHOD_NO_DICT 66 -#define STORE_ATTR_ADAPTIVE 67 -#define STORE_ATTR_INSTANCE_VALUE 72 -#define STORE_ATTR_SLOT 76 -#define STORE_ATTR_WITH_HINT 77 -#define LOAD_FAST__LOAD_FAST 78 -#define STORE_FAST__LOAD_FAST 79 -#define LOAD_FAST__LOAD_CONST 80 -#define LOAD_CONST__LOAD_FAST 81 -#define STORE_FAST__STORE_FAST 131 +#define CALL_ADAPTIVE 29 +#define CALL_BUILTIN_CLASS 34 +#define CALL_NO_KW_BUILTIN_O 36 +#define CALL_NO_KW_BUILTIN_FAST 37 +#define CALL_BUILTIN_FAST_WITH_KEYWORDS 38 +#define CALL_NO_KW_LEN 39 +#define CALL_NO_KW_ISINSTANCE 40 +#define CALL_PY_EXACT_ARGS 41 +#define CALL_PY_WITH_DEFAULTS 42 +#define CALL_NO_KW_LIST_APPEND 43 +#define CALL_NO_KW_METHOD_DESCRIPTOR_O 44 +#define CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 45 +#define CALL_NO_KW_STR_1 46 +#define CALL_NO_KW_TUPLE_1 47 +#define CALL_NO_KW_TYPE_1 48 +#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 55 +#define JUMP_ABSOLUTE_QUICK 56 +#define LOAD_ATTR_ADAPTIVE 57 +#define LOAD_ATTR_INSTANCE_VALUE 58 +#define LOAD_ATTR_WITH_HINT 59 +#define LOAD_ATTR_SLOT 62 +#define LOAD_ATTR_MODULE 63 +#define LOAD_GLOBAL_ADAPTIVE 64 +#define LOAD_GLOBAL_MODULE 65 +#define LOAD_GLOBAL_BUILTIN 66 +#define LOAD_METHOD_ADAPTIVE 67 +#define LOAD_METHOD_CACHED 72 +#define LOAD_METHOD_CLASS 76 +#define LOAD_METHOD_MODULE 77 +#define LOAD_METHOD_NO_DICT 78 +#define STORE_ATTR_ADAPTIVE 79 +#define STORE_ATTR_INSTANCE_VALUE 80 +#define STORE_ATTR_SLOT 81 +#define STORE_ATTR_WITH_HINT 131 +#define LOAD_FAST__LOAD_FAST 140 +#define STORE_FAST__LOAD_FAST 141 +#define LOAD_FAST__LOAD_CONST 143 +#define LOAD_CONST__LOAD_FAST 150 +#define STORE_FAST__STORE_FAST 153 #define DO_TRACING 255 #ifdef NEED_OPCODE_JUMP_TABLES static uint32_t _PyOpcode_RelativeJump[8] = { @@ -193,6 +199,7 @@ static uint32_t _PyOpcode_Jump[8] = { #define HAS_CONST(op) (false\ || ((op) == 100) \ + || ((op) == 172) \ ) #define NB_ADD 0 |