[pypy-commit] stmgc c7-refactor: At transaction start, align the current_nursery and set creation markers

arigo noreply at buildbot.pypy.org
Sun Feb 16 10:09:38 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: c7-refactor
Changeset: r749:4bffa49c22a5
Date: 2014-02-16 10:07 +0100
http://bitbucket.org/pypy/stmgc/changeset/4bffa49c22a5/

Log:	At transaction start, align the current_nursery and set creation
	markers

diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -116,6 +116,8 @@
 
     assert(list_is_empty(STM_PSEGMENT->modified_objects));
     assert(list_is_empty(STM_PSEGMENT->creation_markers));
+
+    align_nursery_at_transaction_start();
 }
 
 
diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c
--- a/c7/stm/nursery.c
+++ b/c7/stm/nursery.c
@@ -84,3 +84,19 @@
     }
     abort();
 }
+
+static void align_nursery_at_transaction_start(void)
+{
+    /* When the transaction start, we must align the 'nursery_current'
+       and set creation markers for the part of the section the follows.
+    */
+    uintptr_t c = (uintptr_t)STM_SEGMENT->nursery_current;
+    c = NURSERY_ALIGN(c);
+    STM_SEGMENT->nursery_current = (stm_char *)c;
+
+    uint64_t size = STM_SEGMENT->nursery_section_end - c;
+    if (size > 0) {
+        set_creation_markers((stm_char *)c, size,
+                             CM_CURRENT_TRANSACTION_IN_NURSERY);
+    }
+}
diff --git a/c7/stm/nursery.h b/c7/stm/nursery.h
--- a/c7/stm/nursery.h
+++ b/c7/stm/nursery.h
@@ -1,2 +1,2 @@
 
-/* empty */
+static void align_nursery_at_transaction_start(void);
diff --git a/c7/stm/pages.c b/c7/stm/pages.c
--- a/c7/stm/pages.c
+++ b/c7/stm/pages.c
@@ -85,6 +85,7 @@
 
     assert((((uintptr_t)p) & 255) == 0);
     assert((size & 255) == 0);
+    assert(size > 0);
 
     char *addr = REAL_ADDRESS(STM_SEGMENT->segment_base, ((uintptr_t)p) >> 8);
     memset(addr, newvalue, size >> 8);
diff --git a/c7/test/test_nursery.py b/c7/test/test_nursery.py
new file mode 100644
--- /dev/null
+++ b/c7/test/test_nursery.py
@@ -0,0 +1,15 @@
+from support import *
+import py
+
+class TestBasic(BaseTest):
+
+    def test_align_nursery_to_256_bytes(self):
+        self.start_transaction()
+        lp1 = stm_allocate(16)
+        self.commit_transaction()
+        self.start_transaction()
+        lp2 = stm_allocate(16)
+        #
+        u1 = int(ffi.cast("uintptr_t", lp1))
+        u2 = int(ffi.cast("uintptr_t", lp2))
+        assert (u1 & ~255) != (u2 & ~255)


More information about the pypy-commit mailing list