Skip to content

Commit 931f432

Browse files
committed
Apply the patches from python/cpython#130005 too
1 parent aaa6424 commit 931f432

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

cpython-windows/build.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,10 +1332,15 @@ def build_cpython(
13321332
and build_platform == "x64"
13331333
):
13341334
# On 3.14.0a5, PGO cannot be run on ceval so we disable it there
1335-
# See https://github.com/python/cpython/pull/130009
1335+
# See https://github.com/python/cpython/issues/130004
13361336
# We should be able to drop this patch in 3.14.0a6
13371337
exec_and_log(
1338-
["patch", "-p1", "-i", SUPPORT / "patch-disable-pgo-ceval-3.14.patch"],
1338+
[
1339+
"patch",
1340+
"-p1",
1341+
"-i",
1342+
SUPPORT / "patch-disable-pgo-ceval-3.14.patch",
1343+
],
13391344
str(cpython_source_path),
13401345
env,
13411346
exit_on_error=False,

cpython-windows/patch-disable-pgo-ceval-3.14.patch

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,54 @@ index c6a7a0f841f027..5f8f0ae69ef31b 100644
1919
+ defined(_Py_USING_PGO))
2020
#define DO_NOT_OPTIMIZE_INTERP_LOOP
2121
#endif
22-
22+
diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props
23+
index dbdb6b743bea37..17abfa85201a90 100644
24+
--- a/PCbuild/pyproject.props
25+
+++ b/PCbuild/pyproject.props
26+
@@ -53,6 +53,7 @@
27+
<ClCompile>
28+
<AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)Include\internal\mimalloc;$(GeneratedPyConfigDir);$(PySourcePath)PC;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
29+
<PreprocessorDefinitions>WIN32;$(_Py3NamePreprocessorDefinition);$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PyStatsPreprocessorDefinition)$(_PydPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
30+
+ <PreprocessorDefinitions Condition="'$(SupportPGO)' and ($(Configuration) == 'PGInstrument' or $(Configuration) == 'PGUpdate')">_Py_USING_PGO=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
31+
32+
<Optimization>MaxSpeed</Optimization>
33+
<IntrinsicFunctions>true</IntrinsicFunctions>
34+
diff --git a/Python/ceval.c b/Python/ceval.c
35+
index 1e4f1f3af20aca..c6a7a0f841f027 100644
36+
--- a/Python/ceval.c
37+
+++ b/Python/ceval.c
38+
@@ -764,6 +764,23 @@ _PyObjectArray_Free(PyObject **array, PyObject **scratch)
39+
#define PY_EVAL_C_STACK_UNITS 2
40+
41+
42+
+/* _PyEval_EvalFrameDefault is too large to optimize for speed with PGO on MSVC
43+
+ when the JIT is enabled or GIL is disabled. Disable that optimization around
44+
+ this function only. If this is fixed upstream, we should gate this on the
45+
+ version of MSVC.
46+
+ */
47+
+#if (defined(_MSC_VER) && \
48+
+ defined(_Py_USING_PGO) && \
49+
+ (defined(_Py_JIT) || \
50+
+ defined(Py_GIL_DISABLED)))
51+
+#define DO_NOT_OPTIMIZE_INTERP_LOOP
52+
+#endif
53+
+
54+
+#ifdef DO_NOT_OPTIMIZE_INTERP_LOOP
55+
+# pragma optimize("t", off)
56+
+/* This setting is reversed below following _PyEval_EvalFrameDefault */
57+
+#endif
58+
+
59+
#ifdef Py_TAIL_CALL_INTERP
60+
#include "opcode_targets.h"
61+
#include "generated_cases.c.h"
62+
@@ -986,6 +1003,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
63+
return NULL;
64+
}
65+
66+
+#ifdef DO_NOT_OPTIMIZE_INTERP_LOOP
67+
+# pragma optimize("", on)
68+
+#endif
69+
+
70+
#if defined(__GNUC__)
71+
# pragma GCC diagnostic pop
72+
#elif defined(_MSC_VER) /* MS_WINDOWS */

0 commit comments

Comments
 (0)