[pypy-commit] pypy stmgc-c7: import stmgc/19bb1dde7aca

arigo noreply at buildbot.pypy.org
Fri Feb 13 16:39:09 CET 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r75856:3a99d6cba477
Date: 2015-02-13 16:38 +0100
http://bitbucket.org/pypy/pypy/changeset/3a99d6cba477/

Log:	import stmgc/19bb1dde7aca

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 @@
-65a89cd8a6c0
+19bb1dde7aca
diff --git a/rpython/translator/stm/src_stm/stm/gcpage.c b/rpython/translator/stm/src_stm/stm/gcpage.c
--- a/rpython/translator/stm/src_stm/stm/gcpage.c
+++ b/rpython/translator/stm/src_stm/stm/gcpage.c
@@ -128,6 +128,26 @@
     return o;
 }
 
+object_t *stm_allocate_preexisting(ssize_t size_rounded_up,
+                                   const char *initial_data)
+{
+    acquire_privatization_lock();
+
+    char *p = allocate_outside_nursery_large(size_rounded_up);
+    uintptr_t nobj = p - stm_object_pages;
+    long j;
+    for (j = 0; j <= NB_SEGMENTS; j++) {
+        char *dest = get_segment_base(j) + nobj;
+        memcpy(dest, initial_data, size_rounded_up);
+        ((struct object_s *)dest)->stm_flags = GCFLAG_WRITE_BARRIER;
+    }
+
+    release_privatization_lock();
+
+    write_fence();     /* make sure 'nobj' is fully initialized from
+                          all threads here */
+    return (object_t *)nobj;
+}
 
 /************************************************************/
 
diff --git a/rpython/translator/stm/src_stm/stm/hashtable.c b/rpython/translator/stm/src_stm/stm/hashtable.c
--- a/rpython/translator/stm/src_stm/stm/hashtable.c
+++ b/rpython/translator/stm/src_stm/stm/hashtable.c
@@ -298,25 +298,16 @@
                synchronization with other pieces of the code that may
                change.
             */
-            acquire_privatization_lock();
-            char *p = allocate_outside_nursery_large(
-                          sizeof(stm_hashtable_entry_t));
-            entry = (stm_hashtable_entry_t *)(p - stm_object_pages);
-
-            long j;
-            for (j = 0; j <= NB_SEGMENTS; j++) {
-                struct stm_hashtable_entry_s *e;
-                e = (struct stm_hashtable_entry_s *)
-                        REAL_ADDRESS(get_segment_base(j), entry);
-                e->header.stm_flags = GCFLAG_WRITE_BARRIER;
-                e->userdata = stm_hashtable_entry_userdata;
-                e->index = index;
-                e->object = NULL;
-            }
+            struct stm_hashtable_entry_s initial = {
+                .userdata = stm_hashtable_entry_userdata,
+                .index = index,
+                .object = NULL
+            };
+            entry = (stm_hashtable_entry_t *)
+                stm_allocate_preexisting(sizeof(stm_hashtable_entry_t),
+                                         (char *)&initial.header);
             hashtable->additions += 0x100;
-            release_privatization_lock();
         }
-        write_fence();     /* make sure 'entry' is fully initialized here */
         table->items[i] = entry;
         write_fence();     /* make sure 'table->items' is written here */
         VOLATILE_TABLE(table)->resize_counter = rc - 6;    /* unlock */
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
@@ -563,6 +563,16 @@
     object_t *object;
 };
 
+/* Make an object "that always existed".  Can be used for cases where
+   the object pointer could also be seen by other running transactions
+   even if the current one did not commit yet (by means outside the
+   normal scope of stmgc).  Must provide the initial content of the
+   object seen in all threads; afterwards, the running transaction can
+   use stm_write() and make local changes.
+*/
+object_t *stm_allocate_preexisting(ssize_t size_rounded_up,
+                                   const char *initial_data);
+
 /* ==================== END ==================== */
 
 #endif


More information about the pypy-commit mailing list