mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
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
This commit is contained in:
parent
fafcfff926
commit
eecbc7c390
9 changed files with 209 additions and 337 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue