[pypy-commit] stmgc default: Test and fix: we need to decouple enterframe() from taking the
arigo
noreply at buildbot.pypy.org
Thu Aug 21 17:20:11 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r1322:7949c54b03a5
Date: 2014-08-21 17:20 +0200
http://bitbucket.org/pypy/stmgc/changeset/7949c54b03a5/
Log: Test and fix: we need to decouple enterframe() from taking the
__builtin_frame_address(0).
diff --git a/c7/stm/rewind_setjmp.h b/c7/stm/rewind_setjmp.h
--- a/c7/stm/rewind_setjmp.h
+++ b/c7/stm/rewind_setjmp.h
@@ -74,8 +74,13 @@
/* remember the current stack and ss_stack positions */
#define rewind_jmp_enterframe(rjthread, rjbuf, ss) do { \
+ rewind_jmp_prepareframe(rjbuf); \
+ rewind_jmp_enterprepframe(rjthread, rjbuf, ss); \
+} while (0)
+#define rewind_jmp_prepareframe(rjbuf) \
+ ((rjbuf)->frame_base = __builtin_frame_address(0))
+#define rewind_jmp_enterprepframe(rjthread, rjbuf, ss) do { \
assert((((long)(ss)) & 1) == 0); \
- (rjbuf)->frame_base = __builtin_frame_address(0); \
(rjbuf)->shadowstack_base = (char *)(ss); \
(rjbuf)->prev = (rjthread)->head; \
(rjthread)->head = (rjbuf); \
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -328,6 +328,8 @@
/* 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. */
+#define stm_rewind_jmp_enterprepframe(tl, rjbuf) \
+ rewind_jmp_enterprepframe(&(tl)->rjthread, rjbuf, (tl)->shadowstack)
#define stm_rewind_jmp_enterframe(tl, rjbuf) \
rewind_jmp_enterframe(&(tl)->rjthread, rjbuf, (tl)->shadowstack)
#define stm_rewind_jmp_leaveframe(tl, rjbuf) \
diff --git a/c7/test/test_rewind.c b/c7/test/test_rewind.c
--- a/c7/test/test_rewind.c
+++ b/c7/test/test_rewind.c
@@ -285,6 +285,48 @@
/************************************************************/
+__attribute__((noinline))
+int _7start_transaction()
+{
+ int result = rewind_jmp_setjmp(>hread, NULL);
+ return result;
+}
+
+__attribute__((noinline))
+int _7enter_callback(rewind_jmp_buf *buf)
+{
+ rewind_jmp_enterprepframe(>hread, buf, NULL);
+ return _7start_transaction();
+}
+
+__attribute__((noinline))
+int _7bootstrap()
+{
+ rewind_jmp_longjmp(>hread);
+ return 0;
+}
+
+__attribute__((noinline))
+int _7leave_callback(rewind_jmp_buf *buf)
+{
+ rewind_jmp_leaveframe(>hread, buf, NULL);
+ return 0;
+}
+
+void test7(void)
+{
+ rewind_jmp_buf buf;
+ register long bla = 3;
+ rewind_jmp_prepareframe(&buf);
+ if (_7enter_callback(&buf) == 0) {
+ _7bootstrap();
+ }
+ _7leave_callback(&buf);
+ assert(bla == 3);
+}
+
+/************************************************************/
+
int rj_malloc_count = 0;
void *rj_malloc(size_t size)
@@ -313,6 +355,7 @@
else if (!strcmp(argv[1], "4")) test4();
else if (!strcmp(argv[1], "5")) test5();
else if (!strcmp(argv[1], "6")) test6();
+ else if (!strcmp(argv[1], "7")) test7();
else if (!strcmp(argv[1], "TL1")) testTL1();
else if (!strcmp(argv[1], "TL2")) testTL2();
else
diff --git a/c7/test/test_rewind.py b/c7/test/test_rewind.py
--- a/c7/test/test_rewind.py
+++ b/c7/test/test_rewind.py
@@ -6,7 +6,7 @@
% (opt, opt))
if err != 0:
raise OSError("clang failed on test_rewind.c")
- for testnum in [1, 2, 3, 4, 5, 6, "TL1", "TL2"]:
+ 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))
if err != 0:
More information about the pypy-commit
mailing list