diff options
author | Mark Shannon <mark@hotpy.org> | 2021-08-09 09:40:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-09 09:40:21 (GMT) |
commit | ac75f6bdd4748b3378dd321f862d13aa1898f77a (patch) | |
tree | dacf952f54673797cd885c3da50e06dc358468ac /Include | |
parent | b854557b49083d8625a433eb36aacb0c87d67c52 (diff) | |
download | cpython-ac75f6bdd4748b3378dd321f862d13aa1898f77a.zip cpython-ac75f6bdd4748b3378dd321f862d13aa1898f77a.tar.gz cpython-ac75f6bdd4748b3378dd321f862d13aa1898f77a.tar.bz2 |
bpo-44826: Specialize STORE_ATTR (GH-27590)
* Generalize cache names for LOAD_ATTR to allow store and delete specializations.
* Factor out specialization of attribute dictionary access.
* Specialize STORE_ATTR.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/internal/pycore_code.h | 5 | ||||
-rw-r--r-- | Include/internal/pycore_dict.h | 3 | ||||
-rw-r--r-- | Include/opcode.h | 4 |
3 files changed, 10 insertions, 2 deletions
diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index 312939e..3d8f9c2 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -23,7 +23,7 @@ typedef struct { typedef struct { uint32_t tp_version; uint32_t dk_version_or_hint; -} _PyLoadAttrCache; +} _PyAttrCache; typedef struct { uint32_t module_keys_version; @@ -43,7 +43,7 @@ typedef struct { typedef union { _PyEntryZero zero; _PyAdaptiveEntry adaptive; - _PyLoadAttrCache load_attr; + _PyAttrCache attr; _PyLoadGlobalCache load_global; } SpecializedCacheEntry; @@ -297,6 +297,7 @@ cache_backoff(_PyAdaptiveEntry *entry) { /* Specialization functions */ int _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); +int _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); int _Py_Specialize_LoadGlobal(PyObject *globals, PyObject *builtins, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); int _Py_Specialize_BinarySubscr(PyObject *sub, PyObject *container, _Py_CODEUNIT *instr); diff --git a/Include/internal/pycore_dict.h b/Include/internal/pycore_dict.h index b2c64b2..2becc30 100644 --- a/Include/internal/pycore_dict.h +++ b/Include/internal/pycore_dict.h @@ -89,6 +89,9 @@ struct _dictkeysobject { #define DK_ENTRIES(dk) \ ((PyDictKeyEntry*)(&((int8_t*)((dk)->dk_indices))[DK_SIZE(dk) * DK_IXSIZE(dk)])) +extern uint64_t _pydict_global_version; + +#define DICT_NEXT_VERSION() (++_pydict_global_version) #ifdef __cplusplus } diff --git a/Include/opcode.h b/Include/opcode.h index 7bebb87..50b7832 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -149,6 +149,10 @@ extern "C" { #define LOAD_GLOBAL_ADAPTIVE 41 #define LOAD_GLOBAL_MODULE 42 #define LOAD_GLOBAL_BUILTIN 43 +#define STORE_ATTR_ADAPTIVE 44 +#define STORE_ATTR_SPLIT_KEYS 45 +#define STORE_ATTR_SLOT 46 +#define STORE_ATTR_WITH_HINT 47 #ifdef NEED_OPCODE_JUMP_TABLES static uint32_t _PyOpcode_RelativeJump[8] = { 0U, |