Author: Armin Rigo <[email protected]>
Branch: c7-refactor
Changeset: r733:51a343395a8e
Date: 2014-02-14 16:38 +0100
http://bitbucket.org/pypy/stmgc/changeset/51a343395a8e/

Log:    in-progress

diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -23,7 +23,8 @@
 #define FIRST_READMARKER_PAGE (READMARKER_START / 4096UL)
 #define NB_READMARKER_PAGES   (FIRST_OBJECT_PAGE - FIRST_READMARKER_PAGE)
 
-#define CURTRANS_START        ((FIRST_OBJECT_PAGE * 4096UL) >> 8)
+#define CREATMARKER_START     ((FIRST_OBJECT_PAGE * 4096UL) >> 8)
+#define FIRST_CREATMARKER_PAGE (CREATMARKER_START / 4096UL)
 
 
 enum {
diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c
--- a/c7/stm/nursery.c
+++ b/c7/stm/nursery.c
@@ -19,8 +19,10 @@
    then they might be allocted outside sections but still in the nursery. */
 #define MEDIUM_OBJECT         (8*1024)
 
-/* size in bytes of the alignment of any section requested */
-#define NURSERY_ALIGNMENT     256
+/* size in bytes of the "line".  Should be equal to the line used by
+   stm_creation_marker_t. */
+#define NURSERY_LINE_SHIFT    8
+#define NURSERY_LINE          (1 << NURSERY_LINE_SHIFT)
 
 /************************************************************/
 
@@ -35,6 +37,7 @@
 
 static void setup_nursery(void)
 {
+    assert((NURSERY_SECTION_SIZE % NURSERY_LINE) == 0);
     assert(MEDIUM_OBJECT < LARGE_OBJECT);
     assert(LARGE_OBJECT < NURSERY_SECTION_SIZE);
     nursery_ctl.used = 0;
@@ -48,7 +51,7 @@
 
 
 #define NURSERY_ALIGN(bytes)  \
-    (((bytes) + NURSERY_ALIGNMENT - 1) & ~(NURSERY_ALIGNMENT - 1))
+    (((bytes) + NURSERY_LINE - 1) & ~(NURSERY_LINE - 1))
 
 static stm_char *allocate_from_nursery(uint64_t bytes)
 {
@@ -73,6 +76,10 @@
                NURSERY_SECTION_SIZE);
         STM_SEGMENT->nursery_current = p + size_rounded_up;
         STM_SEGMENT->nursery_section_end = (uintptr_t)p + NURSERY_SECTION_SIZE;
+        /* Also fill the corresponding creation markers with 0xff. */
+        memset(REAL_ADDRESS(STM_SEGMENT->segment_base,
+                            ((uintptr_t)p) >> NURSERY_LINE_SHIFT),
+               0xff, NURSERY_SECTION_SIZE >> NURSERY_LINE_SHIFT);
         return p;
     }
     abort();
diff --git a/c7/stm/setup.c b/c7/stm/setup.c
--- a/c7/stm/setup.c
+++ b/c7/stm/setup.c
@@ -21,7 +21,9 @@
     assert(READMARKER_START < READMARKER_END);
     assert(READMARKER_END <= 4096UL * FIRST_OBJECT_PAGE);
     assert(FIRST_OBJECT_PAGE < NB_PAGES);
-    assert(CURTRANS_START >= 8192);
+    assert(CREATMARKER_START >= 8192);
+    assert(2 <= FIRST_CREATMARKER_PAGE);
+    assert(FIRST_CREATMARKER_PAGE <= FIRST_READMARKER_PAGE);
     assert((NB_PAGES * 4096UL) >> 8 <= (FIRST_OBJECT_PAGE * 4096UL) >> 4);
     assert((END_NURSERY_PAGE * 4096UL) >> 8 <=
            (FIRST_READMARKER_PAGE * 4096UL));
@@ -48,9 +50,10 @@
         memset(REAL_ADDRESS(segment_base, STM_PSEGMENT), 0,
                sizeof(*STM_PSEGMENT));
 
-        /* Pages in range(2, FIRST_READMARKER_PAGE) are never used */
-        if (FIRST_READMARKER_PAGE > 2)
-            mprotect(segment_base + 8192, (FIRST_READMARKER_PAGE - 2) * 4096UL,
+        /* Pages in range(2, FIRST_CREATMARKER_PAGE) are never used */
+        if (FIRST_CREATMARKER_PAGE > 2)
+            mprotect(segment_base + 8192,
+                     (FIRST_CREATMARKER_PAGE - 2) * 4096UL,
                      PROT_NONE);
 
         struct stm_priv_segment_info_s *pr = get_priv_segment(i);
diff --git a/c7/test/test_basic.py b/c7/test/test_basic.py
--- a/c7/test/test_basic.py
+++ b/c7/test/test_basic.py
@@ -29,12 +29,12 @@
 
     def test_transaction_start_stop(self):
         self.start_transaction()
-        
+
         self.switch(1)
         self.start_transaction()
         self.commit_transaction()
         self.switch(0)
-        
+
         self.commit_transaction()
 
     def test_simple_read(self):
@@ -57,22 +57,21 @@
         self.switch(1)
         lp2 = stm_allocate_old(16)
         assert lp1 != lp2
-        
+
     def test_write_on_old(self):
         lp1 = stm_allocate_old(16)
         self.start_transaction()
         stm_write(lp1)
         assert stm_was_written(lp1)
         stm_set_char(lp1, 'a')
-        
+
         self.switch(1)
         self.start_transaction()
         stm_read(lp1)
         assert stm_was_read(lp1)
         assert stm_get_char(lp1) == '\0'
         self.commit_transaction()
-        
-        
+
     def test_read_write_1(self):
         lp1 = stm_allocate_old(16)
         stm_get_real_address(lp1)[HDR] = 'a' #setchar
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to