[pypy-commit] stmgc use-gcc: Port the changes from c7
arigo
noreply at buildbot.pypy.org
Thu Jul 2 13:10:30 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: use-gcc
Changeset: r1887:33d8c4cbcb32
Date: 2015-07-02 12:06 +0100
http://bitbucket.org/pypy/stmgc/changeset/33d8c4cbcb32/
Log: Port the changes from c7
diff --git a/c8/demo/Makefile b/c8/demo/Makefile
--- a/c8/demo/Makefile
+++ b/c8/demo/Makefile
@@ -19,18 +19,20 @@
COMMON = -I.. -pthread -lrt -g -Wall -Werror -DSTM_LARGEMALLOC_TEST
+CC = gcc-seg-gs
+
# note that 'build' is partially optimized but still contains all asserts
debug-%: %.c ${H_FILES} ${C_FILES}
- clang $(COMMON) -DSTM_DEBUGPRINT -DSTM_GC_NURSERY=128 -O0 \
+ $(CC) $(COMMON) -DSTM_DEBUGPRINT -DSTM_GC_NURSERY=128 -O0 \
$< -o debug-$* ../stmgc.c
build-%: %.c ${H_FILES} ${C_FILES}
- clang $(COMMON) -DSTM_GC_NURSERY=128 -O1 $< -o build-$* ../stmgc.c
+ $(CC) $(COMMON) -DSTM_GC_NURSERY=128 -O1 $< -o build-$* ../stmgc.c
release-%: %.c ${H_FILES} ${C_FILES}
- clang $(COMMON) -DNDEBUG -O2 $< -o release-$* ../stmgc.c
+ $(CC) $(COMMON) -DNDEBUG -O2 $< -o release-$* ../stmgc.c
release-htm-%: %.c ../../htm-c7/stmgc.? ../../htm-c7/htm.h
- clang $(COMMON) -O2 $< -o release-htm-$* ../../htm-c7/stmgc.c -DUSE_HTM
+ $(CC) $(COMMON) -O2 $< -o release-htm-$* ../../htm-c7/stmgc.c -DUSE_HTM
diff --git a/c8/demo/demo2.c b/c8/demo/demo2.c
--- a/c8/demo/demo2.c
+++ b/c8/demo/demo2.c
@@ -214,7 +214,7 @@
void teardown_list(void)
{
- STM_POP_ROOT_RET(stm_thread_local);
+ STM_POP_ROOT_DROP(stm_thread_local);
}
@@ -255,6 +255,7 @@
stm_rewind_jmp_leaveframe(&stm_thread_local, &rjbuf);
unregister_thread_local();
status = sem_post(&done); assert(status == 0);
+ (void)status;
return NULL;
}
@@ -292,6 +293,7 @@
rewind_jmp_buf rjbuf;
status = sem_init(&done, 0, 0); assert(status == 0);
+ (void)status;
stm_setup();
stm_register_thread_local(&stm_thread_local);
@@ -308,6 +310,7 @@
for (i = 1; i <= NTHREADS; i++) {
status = sem_wait(&done); assert(status == 0);
+ (void)status;
}
final_check();
diff --git a/c8/demo/demo_random2.c b/c8/demo/demo_random2.c
--- a/c8/demo/demo_random2.c
+++ b/c8/demo/demo_random2.c
@@ -485,6 +485,7 @@
stm_unregister_thread_local(&stm_thread_local);
status = sem_post(&done); assert(status == 0);
+ (void)status;
return NULL;
}
diff --git a/c8/demo/test_shadowstack.c b/c8/demo/test_shadowstack.c
--- a/c8/demo/test_shadowstack.c
+++ b/c8/demo/test_shadowstack.c
@@ -53,7 +53,7 @@
then do a major collection. It should still be found by the
tracing logic. */
stm_force_transaction_break(&stm_thread_local);
- STM_POP_ROOT_RET(stm_thread_local);
+ STM_POP_ROOT_DROP(stm_thread_local);
STM_POP_ROOT(stm_thread_local, node);
assert(node->value == 129821);
STM_PUSH_ROOT(stm_thread_local, NULL);
diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -868,7 +868,6 @@
_cards_cleared_in_object(get_priv_segment(STM_SEGMENT->segment_num), obj, false);
}
-__attribute__((always_inline))
static void write_slowpath_overflow_obj(object_t *obj, bool mark_card)
{
assert(obj->stm_flags & GCFLAG_WRITE_BARRIER);
@@ -927,7 +926,6 @@
release_privatization_lock(STM_SEGMENT->segment_num);
}
-__attribute__((always_inline))
static void write_slowpath_common(object_t *obj, bool mark_card)
{
assert(_seems_to_be_running_transaction());
@@ -1070,6 +1068,7 @@
obj, index, get_index_to_card_index(index), CARD_MARKED));
}
+__attribute__((flatten))
void _stm_write_slowpath(object_t *obj) {
write_slowpath_common(obj, /* mark_card */ false);
}
diff --git a/c8/stm/fprintcolor.c b/c8/stm/fprintcolor.c
--- a/c8/stm/fprintcolor.c
+++ b/c8/stm/fprintcolor.c
@@ -1,3 +1,5 @@
+#include <stdarg.h>
+
/* ------------------------------------------------------------ */
#ifdef STM_DEBUGPRINT
/* ------------------------------------------------------------ */
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -21,7 +21,15 @@
#endif
-#define TLPREFIX __attribute__((address_space(256)))
+#ifdef __SEG_GS /* on a custom patched gcc */
+# define TLPREFIX __seg_gs
+# define _STM_RM_SUFFIX :8
+#elif defined(__clang__) /* on a clang, hopefully made bug-free */
+# define TLPREFIX __attribute__((address_space(256)))
+# define _STM_RM_SUFFIX /* nothing */
+#else
+# error "needs either a GCC with __seg_gs support, or a bug-freed clang"
+#endif
typedef TLPREFIX struct object_s object_t;
typedef TLPREFIX struct stm_segment_info_s stm_segment_info_t;
@@ -35,18 +43,18 @@
'STM_SEGMENT->transaction_read_version' if and only if the
object was read in the current transaction. The nurseries
also have corresponding read markers, but they are never used. */
- uint8_t rm;
+ unsigned char rm _STM_RM_SUFFIX;
};
struct stm_segment_info_s {
- uint8_t transaction_read_version;
- uint8_t no_safe_point_here; /* set from outside, triggers an assert */
+ unsigned int transaction_read_version;
int segment_num;
char *segment_base;
stm_char *nursery_current;
stm_char *nursery_mark;
uintptr_t nursery_end;
struct stm_thread_local_s *running_thread;
+ uint8_t no_safe_point_here; /* set from outside, triggers an assert */
};
#define STM_SEGMENT ((stm_segment_info_t *)4352)
@@ -357,6 +365,7 @@
#define STM_PUSH_ROOT(tl, p) ((tl).shadowstack++->ss = (object_t *)(p))
#define STM_POP_ROOT(tl, p) ((p) = (typeof(p))((--(tl).shadowstack)->ss))
#define STM_POP_ROOT_RET(tl) ((--(tl).shadowstack)->ss)
+#define STM_POP_ROOT_DROP(tl) ((void)(--(tl).shadowstack))
/* Every thread needs to have a corresponding stm_thread_local_t
structure. It may be a "__thread" global variable or something else.
@@ -370,7 +379,12 @@
/* At some key places, like the entry point of the thread and in the
function with the interpreter's dispatch loop, you need to declare
- a local variable of type 'rewind_jmp_buf' and call these macros. */
+ a local variable of type 'rewind_jmp_buf' and call these macros.
+ IMPORTANT: a function in which you call stm_rewind_jmp_enterframe()
+ must never change the value of its own arguments! If they are
+ passed on the stack, gcc can change the value directly there, but
+ we're missing the logic to save/restore this part!
+*/
#define stm_rewind_jmp_enterprepframe(tl, rjbuf) \
rewind_jmp_enterprepframe(&(tl)->rjthread, rjbuf, (tl)->shadowstack)
#define stm_rewind_jmp_enterframe(tl, rjbuf) \
@@ -657,7 +671,7 @@
#define STM_POP_MARKER(tl) ({ \
object_t *_popped = STM_POP_ROOT_RET(tl); \
- STM_POP_ROOT_RET(tl); \
+ STM_POP_ROOT_DROP(tl); \
_popped; \
})
@@ -760,11 +774,11 @@
/* ==================== END ==================== */
-static void (*stmcb_expand_marker)(char *segment_base, uintptr_t odd_number,
+extern void (*stmcb_expand_marker)(char *segment_base, uintptr_t odd_number,
object_t *following_object,
char *outputbuf, size_t outputbufsize);
-static void (*stmcb_debug_print)(const char *cause, double time,
+extern void (*stmcb_debug_print)(const char *cause, double time,
const char *marker);
#endif
diff --git a/c8/test/common.py b/c8/test/common.py
--- a/c8/test/common.py
+++ b/c8/test/common.py
@@ -3,7 +3,7 @@
assert sys.maxint == 9223372036854775807, "requires a 64-bit environment"
# ----------
-os.environ['CC'] = 'clang'
+os.environ['CC'] = 'gcc-seg-gs'
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
diff --git a/c8/test/support.py b/c8/test/support.py
--- a/c8/test/support.py
+++ b/c8/test/support.py
@@ -574,7 +574,7 @@
],
undef_macros=['NDEBUG'],
include_dirs=[parent_dir],
- extra_compile_args=['-g', '-O0', '-Wall', '-ferror-limit=5'],
+ extra_compile_args=['-g', '-O0', '-Wall'], #, '-ferror-limit=5'],
extra_link_args=['-g', '-lrt'],
force_generic_engine=True)
diff --git a/c8/test/test_list.py b/c8/test/test_list.py
--- a/c8/test/test_list.py
+++ b/c8/test/test_list.py
@@ -56,7 +56,7 @@
''', define_macros=[('STM_TESTS', '1')],
undef_macros=['NDEBUG'],
include_dirs=[parent_dir],
- extra_compile_args=['-g', '-O0', '-Werror', '-ferror-limit=1'],
+ extra_compile_args=['-g', '-O0', '-Werror'],
force_generic_engine=True)
# ____________________________________________________________
diff --git a/c8/test/test_rewind.c b/c8/test/test_rewind.c
--- a/c8/test/test_rewind.c
+++ b/c8/test/test_rewind.c
@@ -174,12 +174,26 @@
void foo(int *x) { ++*x; }
__attribute__((noinline))
-void f6(int a1, int a2, int a3, int a4, int a5, int a6, int a7,
- int a8, int a9, int a10, int a11, int a12, int a13)
+void f6(int c1, int c2, int c3, int c4, int c5, int c6, int c7,
+ int c8, int c9, int c10, int c11, int c12, int c13)
{
rewind_jmp_buf buf;
rewind_jmp_enterframe(>hread, &buf, NULL);
+ int a1 = c1;
+ int a2 = c2;
+ int a3 = c3;
+ int a4 = c4;
+ int a5 = c5;
+ int a6 = c6;
+ int a7 = c7;
+ int a8 = c8;
+ int a9 = c9;
+ int a10 = c10;
+ int a11 = c11;
+ int a12 = c12;
+ int a13 = c13;
+
rewind_jmp_setjmp(>hread, NULL);
gevent(a1); gevent(a2); gevent(a3); gevent(a4);
gevent(a5); gevent(a6); gevent(a7); gevent(a8);
diff --git a/c8/test/test_rewind.py b/c8/test/test_rewind.py
--- a/c8/test/test_rewind.py
+++ b/c8/test/test_rewind.py
@@ -1,11 +1,11 @@
import os
def run_test(opt):
- err = os.system("clang -g -O%s -Werror -DRJBUF_CUSTOM_MALLOC -I../stm"
+ err = os.system("gcc-seg-gs -g -O%s -Werror -DRJBUF_CUSTOM_MALLOC -I../stm"
" -o test_rewind_O%s test_rewind.c ../stm/rewind_setjmp.c"
% (opt, opt))
if err != 0:
- raise OSError("clang failed on test_rewind.c")
+ raise OSError("gcc-seg-gs failed on test_rewind.c")
for testnum in [1, 2, 3, 4, 5, 6, 7, "TL1", "TL2"]:
print '=== O%s: RUNNING TEST %s ===' % (opt, testnum)
err = os.system("./test_rewind_O%s %s" % (opt, testnum))
More information about the pypy-commit
mailing list