Author: Armin Rigo <[email protected]>
Branch: c8-gil-like
Changeset: r1825:1621b474ec2b
Date: 2015-06-14 11:36 +0200
http://bitbucket.org/pypy/stmgc/changeset/1621b474ec2b/

Log:    Finish porting duhton-c8

diff --git a/duhton-c8/duhton.c b/duhton-c8/duhton.c
--- a/duhton-c8/duhton.c
+++ b/duhton-c8/duhton.c
@@ -4,6 +4,7 @@
 
 int main(int argc, char **argv)
 {
+    rewind_jmp_buf rjbuf;
     char *filename = NULL;
     int interactive = 1;
        int i;
@@ -35,6 +36,7 @@
        }
 
     Du_Initialize(num_threads);
+    stm_rewind_jmp_enterframe(&stm_thread_local, &rjbuf);
 
     while (1) {
         if (interactive) {
@@ -42,7 +44,7 @@
             fflush(stdout);
         }
         stm_enter_transactional_zone(&stm_thread_local);
-        stm_become_inevitable(&stm_thread_local, "starting point");
+        //stm_become_inevitable(&stm_thread_local, "starting point");
         DuObject *code = Du_Compile(filename, interactive);
 
         if (code == NULL) {
@@ -66,6 +68,7 @@
             break;
     }
 
+    stm_rewind_jmp_leaveframe(&stm_thread_local, &rjbuf);
     Du_Finalize();
     return 0;
 }
diff --git a/duhton-c8/glob.c b/duhton-c8/glob.c
--- a/duhton-c8/glob.c
+++ b/duhton-c8/glob.c
@@ -718,7 +718,7 @@
     Du_TransactionRun();
 
     stm_enter_transactional_zone(&stm_thread_local);
-    stm_become_inevitable(&stm_thread_local, "run-transactions finished");
+    //stm_become_inevitable(&stm_thread_local, "run-transactions finished");
     return Du_None;
 }
 
@@ -797,6 +797,8 @@
 
 void Du_Initialize(int num_threads)
 {
+    rewind_jmp_buf rjbuf;
+
     stm_setup();
 
     //stm_start_inevitable_transaction(&stm_thread_local);
@@ -810,8 +812,8 @@
     /* prebuilt objs stay on the shadowstack forever */
 
     stm_register_thread_local(&stm_thread_local);
+    stm_rewind_jmp_enterframe(&stm_thread_local, &rjbuf);
     stm_enter_transactional_zone(&stm_thread_local);
-    stm_become_inevitable(&stm_thread_local, "initialization");
 
     all_threads_count = num_threads;
     all_threads = (pthread_t*)malloc(sizeof(pthread_t) * num_threads);
@@ -860,6 +862,7 @@
     DuFrame_SetBuiltinMacro(Du_Globals, "assert", du_assert);
     DuFrame_SetSymbolStr(Du_Globals, "None", Du_None);
     stm_leave_transactional_zone(&stm_thread_local);
+    stm_rewind_jmp_leaveframe(&stm_thread_local, &rjbuf);
 }
 
 void Du_Finalize(void)
diff --git a/duhton-c8/object.c b/duhton-c8/object.c
--- a/duhton-c8/object.c
+++ b/duhton-c8/object.c
@@ -38,6 +38,8 @@
                                   uintptr_t offset_itemsize[2])
 {
     DuType *tp = Du_Types[((struct DuObject_s *)obj)->type_id];
+    if (tp->dt_cards_itemsize == 0)
+        Du_FatalError("object of type '%s' has no cards", tp->dt_name);
     offset_itemsize[0] = tp->dt_cards_offset;
     offset_itemsize[1] = tp->dt_cards_itemsize;
 }
diff --git a/duhton-c8/transaction.c b/duhton-c8/transaction.c
--- a/duhton-c8/transaction.c
+++ b/duhton-c8/transaction.c
@@ -74,17 +74,18 @@
 
 static DuObject *next_cell(void)
 {
-    DuObject *pending = TLOBJ;
+    DuObject *pending;
 
+    /* this code is critical enough so that we want it to
+       be serialized perfectly using inevitable transactions */
+    stm_become_inevitable(&stm_thread_local, "next_cell");
+
+    pending = TLOBJ;
     if (pending == NULL) {
         /* fish from the global list of pending transactions */
         DuConsObject *root;
 
       restart:
-        /* this code is critical enough so that we want it to
-           be serialized perfectly using inevitable transactions */
-        stm_start_inevitable_transaction(&stm_thread_local);
-
         root = du_pending_transactions;
         _du_read1(root);        /* not immutable... */
 
@@ -99,7 +100,7 @@
             return result;
         }
         else {
-            stm_commit_transaction();
+            _stm_commit_transaction();
 
             /* nothing to do, wait */
             int ts = __sync_add_and_fetch(&thread_sleeping, 1);
@@ -118,6 +119,7 @@
                 if (__sync_bool_compare_and_swap(&thread_sleeping, ts, ts - 1))
                     break;
             }
+            _stm_start_transaction(&stm_thread_local);
             goto restart;
         }
     }
@@ -125,8 +127,6 @@
     /* we have at least one thread-local transaction pending */
     TLOBJ = NULL;
 
-    stm_start_inevitable_transaction(&stm_thread_local);
-
     /* _du_read1(pending); IMMUTABLE */
     DuObject *result = _DuCons_CAR(pending);
     DuObject *next = _DuCons_NEXT(pending);
@@ -165,6 +165,7 @@
     rewind_jmp_buf rjbuf;
     stm_register_thread_local(&stm_thread_local);
     stm_rewind_jmp_enterframe(&stm_thread_local, &rjbuf);
+    stm_enter_transactional_zone(&stm_thread_local);
 
     TLOBJ = NULL;
 
@@ -176,15 +177,12 @@
         assert(TLOBJ == NULL);
 
         TLOBJ = cell;
-        stm_commit_transaction(); /* inevitable */
-        stm_start_transaction(&stm_thread_local);
+        stm_force_transaction_break(&stm_thread_local);
+
         cell = TLOBJ;
         TLOBJ = NULL;
 
         run_transaction(cell);
-
-        stm_commit_transaction();
-
     }
 
     stm_rewind_jmp_leaveframe(&stm_thread_local, &rjbuf);
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to