summaryrefslogtreecommitdiffstats
path: root/Include/internal
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2019-06-03 12:30:58 (GMT)
committerGitHub <noreply@github.com>2019-06-03 12:30:58 (GMT)
commit91234a16367b56ca03ee289f7c03a34d4cfec4c8 (patch)
tree81d13661e09df4712009641eaba30e4599f1b776 /Include/internal
parent29ec4228106ed5f970d1c3666614f4a51bad192c (diff)
downloadcpython-91234a16367b56ca03ee289f7c03a34d4cfec4c8.zip
cpython-91234a16367b56ca03ee289f7c03a34d4cfec4c8.tar.gz
cpython-91234a16367b56ca03ee289f7c03a34d4cfec4c8.tar.bz2
bpo-26219: per opcode cache for LOAD_GLOBAL (GH-12884)
This patch implements per opcode cache mechanism, and use it in only LOAD_GLOBAL opcode. Based on Yury's opcache3.patch in bpo-26219.
Diffstat (limited to 'Include/internal')
-rw-r--r--Include/internal/pycore_ceval.h3
-rw-r--r--Include/internal/pycore_code.h27
2 files changed, 30 insertions, 0 deletions
diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index d44afdf..2c6df9a 100644
--- a/Include/internal/pycore_ceval.h
+++ b/Include/internal/pycore_ceval.h
@@ -31,6 +31,9 @@ PyAPI_FUNC(void) _PyEval_SignalAsyncExc(
PyAPI_FUNC(void) _PyEval_ReInitThreads(
_PyRuntimeState *runtime);
+/* Private function */
+void _PyEval_Fini(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h
new file mode 100644
index 0000000..88956f1
--- /dev/null
+++ b/Include/internal/pycore_code.h
@@ -0,0 +1,27 @@
+#ifndef Py_INTERNAL_CODE_H
+#define Py_INTERNAL_CODE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ PyObject *ptr; /* Cached pointer (borrowed reference) */
+ uint64_t globals_ver; /* ma_version of global dict */
+ uint64_t builtins_ver; /* ma_version of builtin dict */
+} _PyOpcache_LoadGlobal;
+
+struct _PyOpcache {
+ union {
+ _PyOpcache_LoadGlobal lg;
+ } u;
+ char optimized;
+};
+
+/* Private API */
+int _PyCode_InitOpcache(PyCodeObject *co);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_INTERNAL_CODE_H */