summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2022-08-24 10:02:53 (GMT)
committerGitHub <noreply@github.com>2022-08-24 10:02:53 (GMT)
commit420f39f457a97a9379f8423a81776bef428d0746 (patch)
tree9f82619ae6d7b39f3342f2b960240c6912447422 /Include
parent6bda5b85b53443f3467865fbf85cbe72932e7cd6 (diff)
downloadcpython-420f39f457a97a9379f8423a81776bef428d0746.zip
cpython-420f39f457a97a9379f8423a81776bef428d0746.tar.gz
cpython-420f39f457a97a9379f8423a81776bef428d0746.tar.bz2
gh-93678: add _testinternalcapi.optimize_cfg() and test utils for compiler optimization unit tests (GH-96007)
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_compile.h5
-rw-r--r--Include/internal/pycore_global_strings.h2
-rw-r--r--Include/internal/pycore_runtime_init_generated.h14
3 files changed, 21 insertions, 0 deletions
diff --git a/Include/internal/pycore_compile.h b/Include/internal/pycore_compile.h
index 06a6082..1a628a0 100644
--- a/Include/internal/pycore_compile.h
+++ b/Include/internal/pycore_compile.h
@@ -38,6 +38,11 @@ extern int _PyAST_Optimize(
struct _arena *arena,
_PyASTOptimizeState *state);
+/* Access compiler internals for unit testing */
+PyAPI_FUNC(PyObject*) _PyCompile_OptimizeCfg(
+ PyObject *instructions,
+ PyObject *consts);
+
#ifdef __cplusplus
}
#endif
diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h
index aada220..c736bfe 100644
--- a/Include/internal/pycore_global_strings.h
+++ b/Include/internal/pycore_global_strings.h
@@ -298,6 +298,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(code)
STRUCT_FOR_ID(command)
STRUCT_FOR_ID(comment_factory)
+ STRUCT_FOR_ID(consts)
STRUCT_FOR_ID(context)
STRUCT_FOR_ID(cookie)
STRUCT_FOR_ID(copy)
@@ -407,6 +408,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(input)
STRUCT_FOR_ID(insert_comments)
STRUCT_FOR_ID(insert_pis)
+ STRUCT_FOR_ID(instructions)
STRUCT_FOR_ID(intern)
STRUCT_FOR_ID(intersection)
STRUCT_FOR_ID(isatty)
diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h
index 09890cd..58d9e93 100644
--- a/Include/internal/pycore_runtime_init_generated.h
+++ b/Include/internal/pycore_runtime_init_generated.h
@@ -807,6 +807,7 @@ extern "C" {
INIT_ID(code), \
INIT_ID(command), \
INIT_ID(comment_factory), \
+ INIT_ID(consts), \
INIT_ID(context), \
INIT_ID(cookie), \
INIT_ID(copy), \
@@ -916,6 +917,7 @@ extern "C" {
INIT_ID(input), \
INIT_ID(insert_comments), \
INIT_ID(insert_pis), \
+ INIT_ID(instructions), \
INIT_ID(intern), \
INIT_ID(intersection), \
INIT_ID(isatty), \
@@ -1916,6 +1918,8 @@ _PyUnicode_InitStaticStrings(void) {
PyUnicode_InternInPlace(&string);
string = &_Py_ID(comment_factory);
PyUnicode_InternInPlace(&string);
+ string = &_Py_ID(consts);
+ PyUnicode_InternInPlace(&string);
string = &_Py_ID(context);
PyUnicode_InternInPlace(&string);
string = &_Py_ID(cookie);
@@ -2134,6 +2138,8 @@ _PyUnicode_InitStaticStrings(void) {
PyUnicode_InternInPlace(&string);
string = &_Py_ID(insert_pis);
PyUnicode_InternInPlace(&string);
+ string = &_Py_ID(instructions);
+ PyUnicode_InternInPlace(&string);
string = &_Py_ID(intern);
PyUnicode_InternInPlace(&string);
string = &_Py_ID(intersection);
@@ -5755,6 +5761,10 @@ _PyStaticObjects_CheckRefcnt(void) {
_PyObject_Dump((PyObject *)&_Py_ID(comment_factory));
Py_FatalError("immortal object has less refcnt than expected _PyObject_IMMORTAL_REFCNT");
};
+ if (Py_REFCNT((PyObject *)&_Py_ID(consts)) < _PyObject_IMMORTAL_REFCNT) {
+ _PyObject_Dump((PyObject *)&_Py_ID(consts));
+ Py_FatalError("immortal object has less refcnt than expected _PyObject_IMMORTAL_REFCNT");
+ };
if (Py_REFCNT((PyObject *)&_Py_ID(context)) < _PyObject_IMMORTAL_REFCNT) {
_PyObject_Dump((PyObject *)&_Py_ID(context));
Py_FatalError("immortal object has less refcnt than expected _PyObject_IMMORTAL_REFCNT");
@@ -6191,6 +6201,10 @@ _PyStaticObjects_CheckRefcnt(void) {
_PyObject_Dump((PyObject *)&_Py_ID(insert_pis));
Py_FatalError("immortal object has less refcnt than expected _PyObject_IMMORTAL_REFCNT");
};
+ if (Py_REFCNT((PyObject *)&_Py_ID(instructions)) < _PyObject_IMMORTAL_REFCNT) {
+ _PyObject_Dump((PyObject *)&_Py_ID(instructions));
+ Py_FatalError("immortal object has less refcnt than expected _PyObject_IMMORTAL_REFCNT");
+ };
if (Py_REFCNT((PyObject *)&_Py_ID(intern)) < _PyObject_IMMORTAL_REFCNT) {
_PyObject_Dump((PyObject *)&_Py_ID(intern));
Py_FatalError("immortal object has less refcnt than expected _PyObject_IMMORTAL_REFCNT");