summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>2021-08-17 14:55:55 (GMT)
committerGitHub <noreply@github.com>2021-08-17 14:55:55 (GMT)
commit96346cb6d0593ef9ec122614347ccb053cd63433 (patch)
tree9f2b952134803d5de5229ece709b19e29ef0e7ab /Include
parentfcd651d16fc5ac3d07dd3f57f1001a861a2e7d23 (diff)
downloadcpython-96346cb6d0593ef9ec122614347ccb053cd63433.zip
cpython-96346cb6d0593ef9ec122614347ccb053cd63433.tar.gz
cpython-96346cb6d0593ef9ec122614347ccb053cd63433.tar.bz2
bpo-44889: Specialize LOAD_METHOD with PEP 659 adaptive interpreter (GH-27722)
Adds four new instructions: * LOAD_METHOD_ADAPTIVE * LOAD_METHOD_CACHED * LOAD_METHOD_MODULE * LOAD_METHOD_CLASS
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_code.h7
-rw-r--r--Include/opcode.h22
2 files changed, 20 insertions, 9 deletions
diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h
index 282089c..6289acd 100644
--- a/Include/internal/pycore_code.h
+++ b/Include/internal/pycore_code.h
@@ -30,6 +30,11 @@ typedef struct {
uint32_t builtin_keys_version;
} _PyLoadGlobalCache;
+typedef struct {
+ /* Borrowed ref in LOAD_METHOD */
+ PyObject *obj;
+} _PyObjectCache;
+
/* Add specialized versions of entries to this union.
*
* Do not break the invariant: sizeof(SpecializedCacheEntry) == 8
@@ -45,6 +50,7 @@ typedef union {
_PyAdaptiveEntry adaptive;
_PyAttrCache attr;
_PyLoadGlobalCache load_global;
+ _PyObjectCache obj;
} SpecializedCacheEntry;
#define INSTRUCTIONS_PER_ENTRY (sizeof(SpecializedCacheEntry)/sizeof(_Py_CODEUNIT))
@@ -299,6 +305,7 @@ cache_backoff(_PyAdaptiveEntry *entry) {
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_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache);
int _Py_Specialize_BinarySubscr(PyObject *sub, PyObject *container, _Py_CODEUNIT *instr);
#define PRINT_SPECIALIZATION_STATS 0
diff --git a/Include/opcode.h b/Include/opcode.h
index 3334242..6b02982 100644
--- a/Include/opcode.h
+++ b/Include/opcode.h
@@ -149,15 +149,19 @@ 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
-#define LOAD_FAST__LOAD_FAST 48
-#define STORE_FAST__LOAD_FAST 58
-#define LOAD_FAST__LOAD_CONST 80
-#define LOAD_CONST__LOAD_FAST 81
-#define STORE_FAST__STORE_FAST 87
+#define LOAD_METHOD_ADAPTIVE 44
+#define LOAD_METHOD_CACHED 45
+#define LOAD_METHOD_CLASS 46
+#define LOAD_METHOD_MODULE 47
+#define STORE_ATTR_ADAPTIVE 48
+#define STORE_ATTR_SPLIT_KEYS 58
+#define STORE_ATTR_SLOT 80
+#define STORE_ATTR_WITH_HINT 81
+#define LOAD_FAST__LOAD_FAST 87
+#define STORE_FAST__LOAD_FAST 88
+#define LOAD_FAST__LOAD_CONST 120
+#define LOAD_CONST__LOAD_FAST 122
+#define STORE_FAST__STORE_FAST 123
#ifdef NEED_OPCODE_JUMP_TABLES
static uint32_t _PyOpcode_RelativeJump[8] = {
0U,