[pypy-commit] pypy stmgc-c7-rewindjmp: Hack hack hack: going for the minimal amount of changes first

arigo noreply at buildbot.pypy.org
Thu Aug 14 16:19:19 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7-rewindjmp
Changeset: r72799:2cc154f95ab3
Date: 2014-08-14 16:17 +0200
http://bitbucket.org/pypy/pypy/changeset/2cc154f95ab3/

Log:	Hack hack hack: going for the minimal amount of changes first

diff --git a/rpython/translator/stm/src_stm/stmgcintf.c b/rpython/translator/stm/src_stm/stmgcintf.c
--- a/rpython/translator/stm/src_stm/stmgcintf.c
+++ b/rpython/translator/stm/src_stm/stmgcintf.c
@@ -155,34 +155,35 @@
     pypy_stm_nursery_low_fill_mark = _stm_nursery_start + limit;
 }
 
-void pypy_stm_start_transaction(stm_jmpbuf_t *jmpbuf_ptr,
-                                volatile long *v_counter)
+static long _pypy_stm_start_transaction(void)
 {
     pypy_stm_nursery_low_fill_mark = 1;  /* will be set to a correct value below */
-    _stm_start_transaction(&stm_thread_local, jmpbuf_ptr);
+    long counter = stm_start_transaction(&stm_thread_local);
 
-    _pypy_stm_initialize_nursery_low_fill_mark(*v_counter);
-    *v_counter = *v_counter + 1;
+    _pypy_stm_initialize_nursery_low_fill_mark(counter);
 
     pypy_stm_ready_atomic = 1; /* reset after abort */
+
+    return counter;
 }
 
 void pypy_stm_perform_transaction(object_t *arg, int callback(object_t *, int))
 {   /* must save roots around this call */
-    stm_jmpbuf_t jmpbuf;
-    long volatile v_counter = 0;
-    int (*volatile v_callback)(object_t *, int) = callback;
+    //
+    // XXX this function should be killed!  We no longer need a
+    // callback-based approach at all.
+
 #ifndef NDEBUG
     struct stm_shadowentry_s *volatile v_old_shadowstack =
         stm_thread_local.shadowstack;
 #endif
-
+    rewind_jmp_buf rjbuf;
+    stm_rewind_jmp_enterframe(&stm_thread_local, &rjbuf);
     //STM_PUSH_ROOT(stm_thread_local, STM_STACK_MARKER_NEW);
     STM_PUSH_ROOT(stm_thread_local, arg);
 
     while (1) {
         long counter;
-
         if (pypy_stm_should_break_transaction()) { //pypy_stm_ready_atomic == 1) {
             /* Not in an atomic transaction; but it might be an inevitable
                transaction.
@@ -191,18 +192,12 @@
 
             stm_commit_transaction();
 
-            /* After setjmp(), the local variables v_* are preserved because
-               they are volatile.  The other local variables should be
-               declared below than this point only.
-            */
-            while (__builtin_setjmp(jmpbuf) == 1) { /*redo setjmp*/ }
-            counter = v_counter;
-            pypy_stm_start_transaction(&jmpbuf, &v_counter);
+            counter = _pypy_stm_start_transaction();
         }
         else {
             /* In an atomic transaction */
             //assert(pypy_stm_nursery_low_fill_mark == (uintptr_t) -1);
-            counter = v_counter;
+            counter = 0;
         }
 
         /* invoke the callback in the new transaction */
@@ -210,32 +205,17 @@
         assert(v_old_shadowstack == stm_thread_local.shadowstack);// - 1);
         STM_PUSH_ROOT(stm_thread_local, arg);
 
-        long result = v_callback(arg, counter);
+        long result = callback(arg, counter);
         if (result <= 0)
             break;
-        v_counter = 0;
-    }
-
-    if (STM_SEGMENT->jmpbuf_ptr == &jmpbuf) {
-        /* we can't leave this function leaving a non-inevitable
-           transaction whose jmpbuf points into this function.
-           we could break the transaction here but we instead rely
-           on the caller to break it. Since we have to use an inevitable
-           transaction anyway, using the current one may be cheaper.
-        */
-        _stm_become_inevitable("perform_transaction left with inevitable");
-    }
-    /* double-check */
-    if (pypy_stm_ready_atomic == 1) {
-    }
-    else {
-        assert(pypy_stm_nursery_low_fill_mark == (uintptr_t) -1);
     }
 
     STM_POP_ROOT_RET(stm_thread_local);             /* pop the 'arg' */
     //uintptr_t x = (uintptr_t)STM_POP_ROOT_RET(stm_thread_local);
     //assert(x == STM_STACK_MARKER_NEW || x == STM_STACK_MARKER_OLD);
     assert(v_old_shadowstack == stm_thread_local.shadowstack);
+
+    stm_rewind_jmp_leaveframe(&stm_thread_local, &rjbuf);
 }
 
 void _pypy_stm_inev_state(void)
diff --git a/rpython/translator/stm/src_stm/stmgcintf.h b/rpython/translator/stm/src_stm/stmgcintf.h
--- a/rpython/translator/stm/src_stm/stmgcintf.h
+++ b/rpython/translator/stm/src_stm/stmgcintf.h
@@ -39,7 +39,7 @@
 static inline void pypy_stm_become_inevitable(const char *msg)
 {
     assert(STM_SEGMENT->running_thread == &stm_thread_local);
-    if (STM_SEGMENT->jmpbuf_ptr != NULL) {
+    if (!stm_is_inevitable()) {
         _pypy_stm_become_inevitable(msg);
     }
 }
@@ -92,8 +92,7 @@
 long pypy_stm_enter_callback_call(void);
 void pypy_stm_leave_callback_call(long);
 void pypy_stm_set_transaction_length(double);
-void pypy_stm_perform_transaction(object_t *, int(object_t *, int));
-void pypy_stm_start_transaction(stm_jmpbuf_t *, volatile long *);
+void pypy_stm_perform_transaction(object_t *, int(object_t *, int));//XXX
 
 static inline int pypy_stm_should_break_transaction(void)
 {


More information about the pypy-commit mailing list