Commits

Remi Meier committed 88a0f0c

import stmgc

Comments (0)

Files changed (6)

rpython/translator/stm/src_stm/et.c

 
   d->count_reads++;
   assert(IMPLIES(!(P->h_tid & GCFLAG_OLD), stmgc_is_in_nursery(d, P)));
+  assert(G->h_revision != 0);
 
  restart_all:
   if (P->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED)
   assert(P->h_tid & GCFLAG_PUBLIC);
   assert(IMPLIES(!(P->h_tid & GCFLAG_OLD), 
                  stmgc_is_in_nursery(thread_descriptor, P)));
-
+  assert(P->h_revision != 0);
 
   revision_t v = ACCESS_ONCE(P->h_revision);
   assert(IS_POINTER(v));  /* "is a pointer", "has a more recent revision" */
 
 gcptr stm_RepeatWriteBarrier(gcptr P)
 {
+  assert(P->h_revision != 0);
   assert(IMPLIES(!(P->h_tid & GCFLAG_OLD), 
                  stmgc_is_in_nursery(thread_descriptor, P)));
 
 
 gcptr stm_WriteBarrier(gcptr P)
 {
+  assert(P->h_revision != 0);
   assert(!(P->h_tid & GCFLAG_IMMUTABLE));
   assert((P->h_tid & GCFLAG_STUB) ||
          stmgc_size(P) > sizeof(struct stm_stub_s) - WORD);

rpython/translator/stm/src_stm/extra.c

 
 
 intptr_t stm_allocate_public_integer_address(gcptr obj)
-{
+{                               /* push roots! */
     struct tx_descriptor *d = thread_descriptor;
     gcptr stub;
     intptr_t result;
        During major collections, we visit them and update
        their references. */
 
+    /* stm_register_integer_address needs to run in inevitable
+       transaction */
+    stm_push_root(obj);
+    stm_become_inevitable("stm_allocate_public_integer_address");
+    obj = stm_pop_root();
+
     /* we don't want to deal with young objs */
     if (!(obj->h_tid & GCFLAG_OLD)) {
         stm_push_root(obj);
         orig = (gcptr)obj->h_original;
     }
     
-    if (orig->h_tid & GCFLAG_PUBLIC) {
-        /* the original is public, so we can take that as a non-movable
-         object to register */
+    if ((orig->h_tid & (GCFLAG_PUBLIC | GCFLAG_PREBUILT_ORIGINAL))
+        == (GCFLAG_PUBLIC | GCFLAG_PREBUILT_ORIGINAL)) {
+        /* public is not enough as public stubs may get replaced
+           by the protected object they point to, if they are in the 
+           same thread (I think...) */
         result = (intptr_t)orig;
     }
     else {
         result = (intptr_t)stub;
     }
     spinlock_release(d->public_descriptor->collection_lock);
+
+    dprintf(("allocate_public_int_adr(%p): %p", obj, (void*)result));
+
     stm_register_integer_address(result);
 
-    dprintf(("allocate_public_int_adr(%p): %p", obj, (void*)result));
     return result;
 }
 

rpython/translator/stm/src_stm/gcpage.c

 /***** registering of small stubs as integer addresses *****/
 
 void stm_register_integer_address(intptr_t adr)
-{
+{                               /* needs to be inevitable! */
     wlog_t *found;
     gcptr obj = (gcptr)adr;
     /* current limitations for 'adr': smallstub or h_original */
+    assert(stm_active == 2);
     assert((obj->h_tid & GCFLAG_SMALLSTUB)
            || (obj->h_original == 0 || obj->h_tid & GCFLAG_PREBUILT_ORIGINAL));
     assert(obj->h_tid & GCFLAG_PUBLIC);
 }
 
 void stm_unregister_integer_address(intptr_t adr)
-{
+{                               /* push roots! */
     wlog_t *found;
     gcptr obj = (gcptr)adr;
 
            || (obj->h_original == 0 || obj->h_tid & GCFLAG_PREBUILT_ORIGINAL));
     assert(obj->h_tid & GCFLAG_PUBLIC);
 
+    /* become inevitable because we would have to re-register them
+       on abort, but make sure only to re-register if not registered
+       in the same aborted transaction (XXX) */
+    stm_become_inevitable("stm_unregister_integer_address()");
+
     stmgcpage_acquire_global_lock();
 
     /* find and decrement refcount */
     G2L_LOOP_FORWARD(registered_objs, item) {
         gcptr R = item->addr;
         assert(R->h_tid & GCFLAG_PUBLIC);
-
-        if ((R->h_original == 0) || (R->h_tid & GCFLAG_PREBUILT_ORIGINAL)) {
-            /* the obj is an original and will therefore survive: */
-            gcptr V = stmgcpage_visit(R);
-            assert(V == R);
+        
+        if (R->h_tid & GCFLAG_PREBUILT_ORIGINAL) {
+            /* already done by mark_prebuilt_roots */
+            assert((R->h_tid & (GCFLAG_MARKED|GCFLAG_VISITED|GCFLAG_PUBLIC))
+                   == (GCFLAG_MARKED|GCFLAG_VISITED|GCFLAG_PUBLIC));
+            continue;
         }
+        /* else if (R->h_original == 0) { */
+        /*     /\* the obj is an original and will therefore survive: *\/ */
+        /*     gcptr V = visit_public(R, NULL); */
+        /*     assert(V == R); */
+        /* } */
         else {
             assert(R->h_tid & GCFLAG_SMALLSTUB); /* only case for now */
             /* make sure R stays valid: */

rpython/translator/stm/src_stm/nursery.c

     }
 #ifdef _GC_DEBUG
     if (P != NULL) {
-        assert(P->h_tid != 0);
+        assert((P->h_tid & STM_USER_TID_MASK) == (tid & STM_USER_TID_MASK));
         assert_cleared(((char *)P) + sizeof(revision_t),
                        size - sizeof(revision_t));
     }

rpython/translator/stm/src_stm/revision

-14ac008e70a5
+68677625f2be

rpython/translator/stm/src_stm/stmgc.h

 
 /* allocates a public reference to the object that will 
    not be freed until stm_unregister_integer_address is 
-   called on the result */
+   called on the result (push roots!) */
 intptr_t stm_allocate_public_integer_address(gcptr);
-void stm_unregister_integer_address(intptr_t);
+void stm_unregister_integer_address(intptr_t); /* push roots too! */
 
 
 /* returns a never changing hash for the object */
 void stm_call_on_abort(void *key, void callback(void *));
 
 /* only user currently is stm_allocate_public_integer_address() */
+/* needs to be in an inevitable transaction! */
 void stm_register_integer_address(intptr_t);
 
 /* enter single-threaded mode. Used e.g. when patching assembler
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.