Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-89279: In ceval.c, redefine some macros for speed #32387

Merged
merged 27 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0be9d62
TEMPORARY hacks to show inline decisions
gvanrossum Apr 6, 2022
abd9118
In ceval.c, redefine some macros for speed
gvanrossum Apr 7, 2022
1724056
Merge remote-tracking branch 'origin/main' into inline
gvanrossum Apr 7, 2022
50e3d7b
Victor's review
gvanrossum Apr 7, 2022
59da3bf
Merge branch 'python:main' into inline
gvanrossum Apr 7, 2022
ab6660e
Add _Py_atomic_load_32bit_impl and use cast macro
gvanrossum Apr 7, 2022
ae6b53c
Move _Py_atomic_load_32bit_impl out of '#if'
gvanrossum Apr 7, 2022
01cff81
Go back to full PGO test suite
gvanrossum Apr 8, 2022
69da380
Longer comment; improve _Py_atomic_load_relaxed
gvanrossum Apr 8, 2022
2894f6e
Only specialize atomic-load-relaxed if MSC
gvanrossum Apr 9, 2022
4b70976
Try _Py_atomic_load_relaxed_int32
gvanrossum Apr 9, 2022
5617fcd
MSC is better off with the default Py_UNREACHABLE()
gvanrossum Apr 11, 2022
a901b91
Update bpo numbers to GH issue numbers
gvanrossum Apr 11, 2022
cceb531
Split accidentally merged lines
gvanrossum Apr 13, 2022
26e8107
Delete temporary /d2inlinelogfull option
gvanrossum Apr 13, 2022
11084c0
Merge branch 'main' into inline
gvanrossum Apr 13, 2022
b7dfcdc
📜🤖 Added by blurb_it.
blurb-it[bot] Apr 13, 2022
9a5c57c
Use static_assert() in _Py_atomic_load_relaxed_int32
gvanrossum Apr 19, 2022
a8cba6e
Revert "MSC is better off with the default Py_UNREACHABLE()"
gvanrossum Apr 19, 2022
c43ec56
Add comment referring to GH-89279 for is_method()
gvanrossum Apr 19, 2022
9a15194
static_assert() is only a C++ feature
gvanrossum Apr 19, 2022
5c992d2
Merge remote-tracking branch 'origin/main' into inline
gvanrossum Apr 20, 2022
7b342e4
Also redefine _Py_DECREF_SPECIALIZED as a macro
gvanrossum Apr 20, 2022
3b21c52
Reformat macros for readability
gvanrossum Apr 21, 2022
41cb067
Try to silence warnings
gvanrossum Apr 21, 2022
87aaf81
Update Python/ceval.c
vstinner Apr 21, 2022
3508f45
Update Python/ceval.c
vstinner Apr 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PCbuild/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ set parallel=/m
set verbose=/nologo /v:m /clp:summary
set kill=
set do_pgo=
set pgo_job=-m test --pgo
set pgo_job=-c0

:CheckOpts
if "%~1"=="-h" goto Usage
Expand Down
2 changes: 1 addition & 1 deletion PCbuild/pyproject.props
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<ControlFlowGuard Condition="$(EnableControlFlowGuard) != ''">$(EnableControlFlowGuard)</ControlFlowGuard>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalOptions Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">/d2inlinelogfull:_PyEval_EvalFrameDefault %(AdditionalOptions)</AdditionalOptions> <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<ClCompile Condition="$(Configuration) == 'Debug'">
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
Expand Down
15 changes: 15 additions & 0 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@
# error "ceval.c must be build with Py_BUILD_CORE define for best performance"
#endif

#if !defined(Py_DEBUG)
// The MSVC compiler fails to inline these, and they're kind of important.
gvanrossum marked this conversation as resolved.
Show resolved Hide resolved

#undef Py_DECREF
#define Py_DECREF(arg) { PyObject *op = arg; if (--op->ob_refcnt == 0) { destructor d = Py_TYPE(op)->tp_dealloc; (*d)(op); } }
gvanrossum marked this conversation as resolved.
Show resolved Hide resolved

#undef Py_IS_TYPE
#define Py_IS_TYPE(ob, type) ((PyObject *)(ob)->ob_type == (type))

#undef Py_XDECREF
#define Py_XDECREF(arg) { PyObject *op1 = arg; if (op1 != NULL) { Py_DECREF(op1); } }
gvanrossum marked this conversation as resolved.
Show resolved Hide resolved

#endif

/* Forward declarations */
static PyObject *trace_call_function(
PyThreadState *tstate, PyObject *callable, PyObject **stack,
Expand Down Expand Up @@ -1579,6 +1593,7 @@ static inline bool
is_method(PyObject **stack_pointer, int args) {
return PEEK(args+2) != NULL;
}
#define is_method(stack_pointer, args) (PEEK((args)+2) != NULL)
gvanrossum marked this conversation as resolved.
Show resolved Hide resolved
gvanrossum marked this conversation as resolved.
Show resolved Hide resolved

#define KWNAMES_LEN() \
(call_shape.kwnames == NULL ? 0 : ((int)PyTuple_GET_SIZE(call_shape.kwnames)))
Expand Down