Author: Armin Rigo <[email protected]>
Branch:
Changeset: r90636:fcd776f8ec36
Date: 2017-03-11 22:26 +0100
http://bitbucket.org/pypy/pypy/changeset/fcd776f8ec36/
Log: The hack to prevent function inlining no longer works with "clang
-flto". Fix it by using the proper way. Even if it is compiler-
dependent, we should be fine with two versions: MSVC and GCC/clang.
This is an attempted fix for the OS/X tests of
_continuation/greenlet/stackless.
diff --git a/rpython/translator/c/src/stacklet/stacklet.c
b/rpython/translator/c/src/stacklet/stacklet.c
--- a/rpython/translator/c/src/stacklet/stacklet.c
+++ b/rpython/translator/c/src/stacklet/stacklet.c
@@ -16,6 +16,7 @@
* can redefine it to upwards growing, 1.
*/
#define STACK_DIRECTION 0
+#define STATIC_NOINLINE __attribute__((noinline)) static
#include "src/stacklet/slp_platformselect.h"
@@ -56,11 +57,6 @@
stacklet_thread_handle stack_thrd; /* the thread where the stacklet is */
};
-void *(*_stacklet_switchstack)(void*(*)(void*, void*),
- void*(*)(void*, void*), void*) = NULL;
-void (*_stacklet_initialstub)(struct stacklet_thread_s *,
- stacklet_run_fn, void *) = NULL;
-
struct stacklet_thread_s {
struct stacklet_s *g_stack_chain_head; /* NULL <=> running main */
char *g_current_stack_stop;
@@ -252,8 +248,17 @@
return EMPTY_STACKLET_HANDLE;
}
-static void g_initialstub(struct stacklet_thread_s *thrd,
- stacklet_run_fn run, void *run_arg)
+STATIC_NOINLINE
+void *_stacklet_switchstack(void *(*save_state)(void*, void*),
+ void *(*restore_state)(void*, void*),
+ void *extra)
+{
+ return slp_switch(save_state, restore_state, extra);
+}
+
+STATIC_NOINLINE
+void g_initialstub(struct stacklet_thread_s *thrd,
+ stacklet_run_fn run, void *run_arg)
{
struct stacklet_s *result;
@@ -284,13 +289,6 @@
{
struct stacklet_thread_s *thrd;
- if (_stacklet_switchstack == NULL) {
- /* set up the following global with an indirection, which is needed
- to prevent any inlining */
- _stacklet_initialstub = g_initialstub;
- _stacklet_switchstack = slp_switch;
- }
-
thrd = malloc(sizeof(struct stacklet_thread_s));
if (thrd != NULL)
memset(thrd, 0, sizeof(struct stacklet_thread_s));
@@ -311,7 +309,7 @@
thrd->g_current_stack_stop = ((char *)&stackmarker) + 1;
thrd->g_current_stack_marker = (char *)&stackmarker;
- _stacklet_initialstub(thrd, run, run_arg);
+ g_initialstub(thrd, run, run_arg);
return thrd->g_source;
}
diff --git a/rpython/translator/c/src/stacklet/switch_x64_msvc.h
b/rpython/translator/c/src/stacklet/switch_x64_msvc.h
--- a/rpython/translator/c/src/stacklet/switch_x64_msvc.h
+++ b/rpython/translator/c/src/stacklet/switch_x64_msvc.h
@@ -5,3 +5,5 @@
void *(*restore_state)(void*, void*),
void *extra);
+#undef STATIC_NOINLINE
+#define STATIC_NOINLINE static __declspec(noinline)
diff --git a/rpython/translator/c/src/stacklet/switch_x86_msvc.h
b/rpython/translator/c/src/stacklet/switch_x86_msvc.h
--- a/rpython/translator/c/src/stacklet/switch_x86_msvc.h
+++ b/rpython/translator/c/src/stacklet/switch_x86_msvc.h
@@ -5,6 +5,9 @@
void *(*restore_state)(void*, void*),
void *extra);
+#undef STATIC_NOINLINE
+#define STATIC_NOINLINE static __declspec(noinline)
+
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit