Skip to content

Commit

Permalink
Stackless issue python#283: concentrate platform dependent code in sl…
Browse files Browse the repository at this point in the history
…p_transfer.c and eliminate pycore_slp_platformselect.h

Extract the platform specific stack handling form "slp_eval_frame" into
a new function "slp_cstack_set_base_and_goodgap" in slp_transfer.c.
Move the definition of SLP_DO_NOT_OPTIMIZE_AWAY from pycore_stackless.h
to slp_transfer.c, because it is only used there.
Integrate include "pycore_slp_platformselect.h" into slp_transfer.c and
remove this header file.
Move "slp_transfer.c" form "Stackless/core" to "Stackless/platf",
because it depends on the platform.
Move all pycore_slp_switch_*.h header files from Include/internal to
Stackless/platf. These headers are included by "slp_transfer.c" only.
  • Loading branch information
akruis authored Jul 9, 2021
1 parent 33b8f81 commit 6a4c86b
Show file tree
Hide file tree
Showing 28 changed files with 420 additions and 412 deletions.
134 changes: 0 additions & 134 deletions Include/internal/pycore_slp_platformselect.h

This file was deleted.

6 changes: 5 additions & 1 deletion Include/internal/pycore_slp_pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

/* This include file is included from pycore_pystate.h only */

#include "pycore_slp_platformselect.h" /* for SLP_CSTACK_SLOTS */

/* adjust slots to typical size of a few recursions on your system */
#ifndef SLP_CSTACK_SLOTS
#define SLP_CSTACK_SLOTS 1024
#endif

/*
* Stackless runtime state
Expand Down
12 changes: 12 additions & 0 deletions Include/internal/pycore_stackless.h
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,18 @@ long slp_parse_thread_id(PyObject *thread_id, unsigned long *id);
(frame_)->f_executing <= SLP_FRAME_EXECUTING_YIELD_FROM)


/* Defined in slp_transfer.c */
int
slp_cstack_save_now(const PyThreadState *tstate, const void * pstackvar);
#define SLP_CSTACK_SAVE_NOW(tstate, stackvar) slp_cstack_save_now((tstate), &(stackvar))
void
slp_cstack_set_root(PyThreadState *tstate, const void * pstackvar);
#define SLP_CSTACK_SET_ROOT(tstate, stackvar) slp_cstack_set_root((tstate), &(stackvar))
PyObject *
slp_cstack_set_base_and_goodgap(PyThreadState *tstate, const void * pstackvar, PyFrameObject *f);



#endif /* #ifdef SLP_BUILD_CORE */

#else /* STACKLESS */
Expand Down
31 changes: 15 additions & 16 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ PYTHON_OBJS= \
Python/bltinmodule.o \
Python/ceval.o \
Stackless/core/cframeobject.o \
Stackless/core/slp_transfer.o \
Stackless/platf/slp_transfer.o \
Stackless/core/stacklesseval.o \
Stackless/core/stackless_util.o \
Stackless/module/channelobject.o \
Expand Down Expand Up @@ -989,8 +989,8 @@ regen-typeslots:
$(srcdir)/Objects/typeslots.inc.new
$(UPDATE_FILE) $(srcdir)/Objects/typeslots.inc $(srcdir)/Objects/typeslots.inc.new

Stackless/core/slp_transfer.o: $(srcdir)/Stackless/core/slp_transfer.c
$(CC) -c $(PY_CORE_CFLAGS) $(SLPFLAGS) -o $@ $(srcdir)/Stackless/core/slp_transfer.c
Stackless/platf/slp_transfer.o: $(srcdir)/Stackless/platf/slp_transfer.c
$(CC) -c $(PY_CORE_CFLAGS) $(SLPFLAGS) -o $@ $(srcdir)/Stackless/platf/slp_transfer.c

############################################################################
# Header files
Expand Down Expand Up @@ -1093,19 +1093,18 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_stackless.h \
$(srcdir)/Include/internal/pycore_slp_pystate.h \
$(srcdir)/Include/internal/pycore_slp_prickelpit.h \
$(srcdir)/Include/internal/pycore_slp_platformselect.h \
$(srcdir)/Include/internal/pycore_slp_switch_amd64_unix.h \
$(srcdir)/Include/internal/pycore_slp_switch_arm32_gcc.h \
$(srcdir)/Include/internal/pycore_slp_switch_arm_thumb_gcc.h \
$(srcdir)/Include/internal/pycore_slp_switch_mips_unix.h \
$(srcdir)/Include/internal/pycore_slp_switch_ppc_macosx.h \
$(srcdir)/Include/internal/pycore_slp_switch_ppc_unix.h \
$(srcdir)/Include/internal/pycore_slp_switch_ps3_SNTools.h \
$(srcdir)/Include/internal/pycore_slp_switch_s390_unix.h \
$(srcdir)/Include/internal/pycore_slp_switch_sparc_sun_gcc.h \
$(srcdir)/Include/internal/pycore_slp_switch_x64_msvc.h \
$(srcdir)/Include/internal/pycore_slp_switch_x86_msvc.h \
$(srcdir)/Include/internal/pycore_slp_switch_x86_unix.h \
$(srcdir)/Stackless/platf/switch_amd64_unix.h \
$(srcdir)/Stackless/platf/switch_arm32_gcc.h \
$(srcdir)/Stackless/platf/switch_arm_thumb_gcc.h \
$(srcdir)/Stackless/platf/switch_mips_unix.h \
$(srcdir)/Stackless/platf/switch_ppc_macosx.h \
$(srcdir)/Stackless/platf/switch_ppc_unix.h \
$(srcdir)/Stackless/platf/switch_ps3_SNTools.h \
$(srcdir)/Stackless/platf/switch_s390_unix.h \
$(srcdir)/Stackless/platf/switch_sparc_sun_gcc.h \
$(srcdir)/Stackless/platf/switch_x64_msvc.h \
$(srcdir)/Stackless/platf/switch_x86_msvc.h \
$(srcdir)/Stackless/platf/switch_x86_unix.h \
\
pyconfig.h \
$(PARSER_HEADERS) \
Expand Down
4 changes: 2 additions & 2 deletions Modules/_pickle.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#define SLP_BUILD_CORE
#include "stackless_api.h"
#include "pycore_slp_prickelpit.h"
#include "pycore_slp_platformselect.h" /* for stack saving */
#include "pycore_stackless.h"
#endif

PyDoc_STRVAR(pickle_module_doc,
Expand Down Expand Up @@ -3962,7 +3962,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
#ifdef STACKLESS
/* but we save the stack after a fixed watermark */
{
/* use a variable, because SLP_CSTACK_SAVE_NOW evaluates ts several times. */
/* use a variable, because SLP_CSTACK_SAVE_NOW may evaluate ts several times. */
PyThreadState *ts = PyThreadState_GET();
if (SLP_CSTACK_SAVE_NOW(ts, self)) {
int res;
Expand Down
7 changes: 3 additions & 4 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,8 @@
<ClInclude Include="..\Include\internal\pycore_stackless.h" />
<ClInclude Include="..\Include\internal\pycore_slp_pystate.h" />
<ClInclude Include="..\Include\internal\pycore_slp_prickelpit.h" />
<ClInclude Include="..\Include\internal\pycore_slp_platformselect.h" />
<ClInclude Include="..\Include\internal\pycore_slp_switch_x64_msvc.h" />
<ClInclude Include="..\Include\internal\pycore_slp_switch_x86_msvc.h" />
<ClInclude Include="..\Stackless\platf\switch_x64_msvc.h" />
<ClInclude Include="..\Stackless\platf\switch_x86_msvc.h" />
<ClInclude Include="..\Include\stackless.h" />
<ClInclude Include="..\Include\stackless_api.h" />
</ItemGroup>
Expand Down Expand Up @@ -439,7 +438,7 @@
<ClCompile Include="..\Python\thread.c" />
<ClCompile Include="..\Python\traceback.c" />
<ClCompile Include="..\Stackless\core\cframeobject.c" />
<ClCompile Include="..\Stackless\core\slp_transfer.c" />
<ClCompile Include="..\Stackless\platf\slp_transfer.c" />
<ClCompile Include="..\Stackless\core\stacklesseval.c" />
<ClCompile Include="..\Stackless\core\stackless_util.c" />
<ClCompile Include="..\Stackless\module\channelobject.c" />
Expand Down
11 changes: 4 additions & 7 deletions PCbuild/pythoncore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -525,13 +525,10 @@
<ClInclude Include="..\Include\internal\pycore_slp_pystate.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_slp_platformselect.h">
<ClInclude Include="..\Stackless\platf\switch_x64_msvc.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_slp_switch_x64_msvc.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_slp_switch_x86_msvc.h">
<ClInclude Include="..\Stackless\platf\switch_x86_msvc.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_slp_prickelpit.h">
Expand Down Expand Up @@ -1163,8 +1160,8 @@
<ClCompile Include="..\Stackless\core\cframeobject.c">
<Filter>Stackless\core</Filter>
</ClCompile>
<ClCompile Include="..\Stackless\core\slp_transfer.c">
<Filter>Stackless\core</Filter>
<ClCompile Include="..\Stackless\platf\slp_transfer.c">
<Filter>Stackless\platf</Filter>
</ClCompile>
<ClCompile Include="..\Stackless\core\stackless_util.c">
<Filter>Stackless\core</Filter>
Expand Down
1 change: 0 additions & 1 deletion Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "setobject.h"
#include "structmember.h"
#include "pycore_stackless.h"
#include "pycore_slp_platformselect.h" /* for stack saving */

#include <ctype.h>

Expand Down
5 changes: 5 additions & 0 deletions Stackless/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ What's New in Stackless 3.X.X?

*Release date: 20XX-XX-XX*

- https://github.com/stackless-dev/stackless/issues/283
Platform dependent source code is now completely in "Stackless/platf". The
API header files do not depend on the platform any longer and the header
"pycore_slp_platformselect.h" does not exist any more.

- https://github.com/stackless-dev/stackless/issues/281
Per tasklet profiling and tracing state information is now stored in the
tasklet itself. This increases the size of tasklet objects a bit, but saves a
Expand Down
Loading

0 comments on commit 6a4c86b

Please sign in to comment.