Author: Remi Meier <[email protected]>
Branch: c7
Changeset: r648:1df99f66dc6d
Date: 2014-01-19 10:48 +0100
http://bitbucket.org/pypy/stmgc/changeset/1df99f66dc6d/

Log:    pushing some roots in duhton and reset shadowstack on abort

diff --git a/c7/core.c b/c7/core.c
--- a/c7/core.c
+++ b/c7/core.c
@@ -58,7 +58,7 @@
     struct stm_list_s *new_object_ranges;
     struct alloc_for_size_s alloc[LARGE_OBJECT_WORDS];
     localchar_t *nursery_current;
-
+    object_t **old_shadow_stack;
     struct stm_list_s *old_objects_to_trace;
     /* pages newly allocated in the current transaction only containing
        uncommitted objects */
@@ -776,6 +776,8 @@
     _STM_TL1->jmpbufptr = jmpbufptr;
     _STM_TL2->running_transaction = 1;
     _STM_TL2->need_abort = 0;
+
+    _STM_TL2->old_shadow_stack = _STM_TL1->shadow_stack;
 }
 
 #if 0
@@ -961,6 +963,9 @@
            _STM_TL2->nursery_current - nursery_base);
     _STM_TL2->nursery_current = nursery_base;
 
+    /* reset shadowstack */
+    _STM_TL1->shadow_stack = _STM_TL2->old_shadow_stack;
+
     /* unreserve uncommitted_pages and mark them as SHARED again */
         /* STM_LIST_FOREACH(_STM_TL2->uncommitted_pages, ({ */
         /*         uintptr_t pagenum = (uintptr_t)item; */
diff --git a/c7/reader_writer_lock.c b/c7/reader_writer_lock.c
--- a/c7/reader_writer_lock.c
+++ b/c7/reader_writer_lock.c
@@ -11,7 +11,7 @@
    Shared-Memory Multiprocessors". Converting the algorithm from
    assembly language to C yields:
 */
-
+#include <assert.h>
 #include "reader_writer_lock.h"
 
 
@@ -54,11 +54,13 @@
 
 int rwticket_wrtrylock(rwticket *l)
 {
-       unsigned me = l->s.users;
+    unsigned cmp = l->u;
+    
+       unsigned me = cmp & 0xff;//l->s.users;
        unsigned char menew = me + 1;
-       unsigned read = l->s.read << 8;
-       unsigned cmp = (me << 16) + read + me;
-       unsigned cmpnew = (menew << 16) + read + me;
+    // unsigned read = (cmp & 0xffff) >> 8;//l->s.read << 8;
+       //unsigned cmp = (me << 16) + read + me;
+       unsigned cmpnew = (menew << 16) | (cmp & 0x0000ffff); //(menew << 16) + 
read + me;
 
        if (cmpxchg(&l->u, cmp, cmpnew) == cmp) return 0;
        
@@ -81,6 +83,8 @@
 
 int rwticket_rdtrylock(rwticket *l)
 {
+    assert(0);
+    /* XXX implement like wrtrylock */
        unsigned me = l->s.users;
        unsigned write = l->s.write;
        unsigned char menew = me + 1;
diff --git a/duhton/demo/container_transaction.duh 
b/duhton/demo/container_transaction.duh
--- a/duhton/demo/container_transaction.duh
+++ b/duhton/demo/container_transaction.duh
@@ -3,11 +3,11 @@
 
 (defun g (thread n)
     (set c (+ (get c) 1))
-    (if (> (get c) 2000)
+    (if (> (get c) 20000)
         (print (quote overflow) (get c))
-      (if (< n 1000)
+      (if (< n 10000)
           (transaction f thread (+ n 1))
-        (if (< (get c) 2000)
+        (if (< (get c) 20000)
             (print (quote not-enough))
           (print (quote ok))))))
 
diff --git a/duhton/transaction.c b/duhton/transaction.c
--- a/duhton/transaction.c
+++ b/duhton/transaction.c
@@ -181,7 +181,10 @@
         while (__builtin_setjmp(here) == 1) { }
         stm_start_transaction(&here);
         run_transaction(cell);
+        _du_save1(stm_thread_local_obj);
         stm_stop_transaction();
+        _du_restore1(stm_thread_local_obj);
+
     }
 
     return NULL;
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to