Author: Armin Rigo <[email protected]>
Branch: stmgc-c7-rewindjmp
Changeset: r72795:b56e8c73f107
Date: 2014-08-12 17:37 +0200
http://bitbucket.org/pypy/pypy/changeset/b56e8c73f107/

Log:    import stmgc/1815f493a1c5

diff --git a/rpython/translator/stm/src_stm/revision 
b/rpython/translator/stm/src_stm/revision
--- a/rpython/translator/stm/src_stm/revision
+++ b/rpython/translator/stm/src_stm/revision
@@ -1,1 +1,1 @@
-bdc151305c79
+1815f493a1c5
diff --git a/rpython/translator/stm/src_stm/stm/core.c 
b/rpython/translator/stm/src_stm/stm/core.c
--- a/rpython/translator/stm/src_stm/stm/core.c
+++ b/rpython/translator/stm/src_stm/stm/core.c
@@ -394,7 +394,7 @@
 #ifdef STM_NO_AUTOMATIC_SETJMP
     long repeat_count = 0;    /* test/support.py */
 #else
-    long repeat_count = rewind_jmp_setjmp(&tl->rjthread);
+    long repeat_count = stm_rewind_jmp_setjmp(tl);
 #endif
     _stm_start_transaction(tl, false);
     return repeat_count;
@@ -829,7 +829,7 @@
     dprintf(("commit_transaction\n"));
 
     assert(STM_SEGMENT->nursery_end == NURSERY_END);
-    rewind_jmp_forget(&STM_SEGMENT->running_thread->rjthread);
+    stm_rewind_jmp_forget(STM_SEGMENT->running_thread);
 
     /* if a major collection is required, do it here */
     if (is_major_collection_requested()) {
@@ -984,12 +984,23 @@
     reset_modified_from_other_segments(segment_num);
     _verify_cards_cleared_in_all_lists(pseg);
 
-    /* reset the tl->shadowstack and thread_local_obj to their original
-       value before the transaction start */
+    /* reset tl->shadowstack and thread_local_obj to their original
+       value before the transaction start.  Also restore the content
+       of the shadowstack here. */
     stm_thread_local_t *tl = pseg->pub.running_thread;
+#ifdef STM_NO_AUTOMATIC_SETJMP
+    /* In tests, we don't save and restore the shadowstack correctly.
+       Be sure to not change items below shadowstack_at_start_of_transaction.
+       There is no such restrictions in non-Python-based tests. */
     assert(tl->shadowstack >= pseg->shadowstack_at_start_of_transaction);
-    pseg->shadowstack_at_abort = tl->shadowstack;
     tl->shadowstack = pseg->shadowstack_at_start_of_transaction;
+#else
+    /* NB. careful, this function might be called more than once to
+       abort a given segment.  Make sure that
+       stm_rewind_jmp_restore_shadowstack() is idempotent. */
+    stm_rewind_jmp_restore_shadowstack(tl);
+    assert(tl->shadowstack == pseg->shadowstack_at_start_of_transaction);
+#endif
     tl->thread_local_obj = pseg->threadlocal_at_start_of_transaction;
     tl->last_abort__bytes_in_nursery = bytes_in_nursery;
 
@@ -1064,7 +1075,7 @@
 #ifdef STM_NO_AUTOMATIC_SETJMP
     _test_run_abort(tl);
 #else
-    rewind_jmp_longjmp(&tl->rjthread);
+    stm_rewind_jmp_longjmp(tl);
 #endif
 }
 
@@ -1079,7 +1090,7 @@
         marker_fetch_inev();
         wait_for_end_of_inevitable_transaction(NULL);
         STM_PSEGMENT->transaction_state = TS_INEVITABLE;
-        rewind_jmp_forget(&STM_SEGMENT->running_thread->rjthread);
+        stm_rewind_jmp_forget(STM_SEGMENT->running_thread);
         clear_callbacks_on_abort();
     }
     else {
diff --git a/rpython/translator/stm/src_stm/stm/core.h 
b/rpython/translator/stm/src_stm/stm/core.h
--- a/rpython/translator/stm/src_stm/stm/core.h
+++ b/rpython/translator/stm/src_stm/stm/core.h
@@ -187,7 +187,6 @@
        'thread_local_obj' field. */
     struct stm_shadowentry_s *shadowstack_at_start_of_transaction;
     object_t *threadlocal_at_start_of_transaction;
-    struct stm_shadowentry_s *shadowstack_at_abort;
 
     /* Already signalled to commit soon: */
     bool signalled_to_commit_soon;
diff --git a/rpython/translator/stm/src_stm/stm/forksupport.c 
b/rpython/translator/stm/src_stm/stm/forksupport.c
--- a/rpython/translator/stm/src_stm/stm/forksupport.c
+++ b/rpython/translator/stm/src_stm/stm/forksupport.c
@@ -185,7 +185,7 @@
 
     rewind_jmp_buf rjbuf;
     stm_rewind_jmp_enterframe(tl, &rjbuf);
-    if (rewind_jmp_setjmp(&tl->rjthread) == 0) {
+    if (stm_rewind_jmp_setjmp(tl) == 0) {
 #ifndef NDEBUG
         pr->running_pthread = pthread_self();
 #endif
@@ -194,7 +194,7 @@
         strcpy(pr->marker_self, "fork");
         stm_abort_transaction();
     }
-    rewind_jmp_forget(&tl->rjthread);
+    stm_rewind_jmp_forget(tl);
     stm_rewind_jmp_leaveframe(tl, &rjbuf);
 }
 
diff --git a/rpython/translator/stm/src_stm/stmgc.h 
b/rpython/translator/stm/src_stm/stmgc.h
--- a/rpython/translator/stm/src_stm/stmgc.h
+++ b/rpython/translator/stm/src_stm/stmgc.h
@@ -332,9 +332,20 @@
    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_enterframe(tl, rjbuf)       \
-    rewind_jmp_enterframe(&(tl)->rjthread, rjbuf)
+    rewind_jmp_enterframe(&(tl)->rjthread, rjbuf, (tl)->shadowstack)
 #define stm_rewind_jmp_leaveframe(tl, rjbuf)       \
-    rewind_jmp_leaveframe(&(tl)->rjthread, rjbuf)
+    rewind_jmp_leaveframe(&(tl)->rjthread, rjbuf, (tl)->shadowstack)
+#define stm_rewind_jmp_setjmp(tl)                  \
+    rewind_jmp_setjmp(&(tl)->rjthread, (tl)->shadowstack)
+#define stm_rewind_jmp_longjmp(tl)                 \
+    rewind_jmp_longjmp(&(tl)->rjthread)
+#define stm_rewind_jmp_forget(tl)                  \
+    rewind_jmp_forget(&(tl)->rjthread)
+#define stm_rewind_jmp_restore_shadowstack(tl)  do {     \
+    assert(rewind_jmp_armed(&(tl)->rjthread));           \
+    (tl)->shadowstack = (struct stm_shadowentry_s *)     \
+        rewind_jmp_restore_shadowstack(&(tl)->rjthread); \
+} while (0)
 
 /* Starting and ending transactions.  stm_read(), stm_write() and
    stm_allocate() should only be called from within a transaction.
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to