diff options
author | Mark Shannon <mark@hotpy.org> | 2021-06-14 10:04:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-14 10:04:09 (GMT) |
commit | eecbc7c3900a7f40d8498b151db543a202c72f74 (patch) | |
tree | 6be5d67366f8df3e24c3dbed0786ec3c4a29bf1b /Include/internal | |
parent | fafcfff9262ae9dee03a00006638dfcbcfc23a7b (diff) | |
download | cpython-eecbc7c3900a7f40d8498b151db543a202c72f74.zip cpython-eecbc7c3900a7f40d8498b151db543a202c72f74.tar.gz cpython-eecbc7c3900a7f40d8498b151db543a202c72f74.tar.bz2 |
bpo-44338: Port LOAD_GLOBAL to PEP 659 adaptive interpreter (GH-26638)
* Add specializations of LOAD_GLOBAL.
* Add more stats.
* Remove old opcache; it is no longer used.
* Add NEWS
Diffstat (limited to 'Include/internal')
-rw-r--r-- | Include/internal/pycore_code.h | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index bfc2deb..098fbe4 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -48,6 +48,11 @@ typedef struct { uint32_t dk_version_or_hint; } _PyLoadAttrCache; +typedef struct { + uint32_t module_keys_version; + uint32_t builtin_keys_version; +} _PyLoadGlobalCache; + /* Add specialized versions of entries to this union. * * Do not break the invariant: sizeof(SpecializedCacheEntry) == 8 @@ -62,6 +67,7 @@ typedef union { _PyEntryZero zero; _PyAdaptiveEntry adaptive; _PyLoadAttrCache load_attr; + _PyLoadGlobalCache load_global; } SpecializedCacheEntry; #define INSTRUCTIONS_PER_ENTRY (sizeof(SpecializedCacheEntry)/sizeof(_Py_CODEUNIT)) @@ -254,8 +260,6 @@ PyAPI_FUNC(PyCodeObject *) _PyCode_New(struct _PyCodeConstructor *); /* Private API */ -int _PyCode_InitOpcache(PyCodeObject *co); - /* Getters for internal PyCodeObject data. */ PyAPI_FUNC(PyObject *) _PyCode_GetVarnames(PyCodeObject *); PyAPI_FUNC(PyObject *) _PyCode_GetCellvars(PyCodeObject *); @@ -318,24 +322,25 @@ cache_backoff(_PyAdaptiveEntry *entry) { /* Specialization functions */ int _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); +int _Py_Specialize_LoadGlobal(PyObject *globals, PyObject *builtins, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); #define SPECIALIZATION_STATS 0 #if SPECIALIZATION_STATS -typedef struct _specialization_stats { +typedef struct _stats { uint64_t specialization_success; uint64_t specialization_failure; - uint64_t loadattr_hit; - uint64_t loadattr_deferred; - uint64_t loadattr_miss; - uint64_t loadattr_deopt; + uint64_t hit; + uint64_t deferred; + uint64_t miss; + uint64_t deopt; } SpecializationStats; -extern SpecializationStats _specialization_stats; -#define STAT_INC(name) _specialization_stats.name++ +extern SpecializationStats _specialization_stats[256]; +#define STAT_INC(opname, name) _specialization_stats[opname].name++ void _Py_PrintSpecializationStats(void); #else -#define STAT_INC(name) ((void)0) +#define STAT_INC(opname, name) ((void)0) #endif |