Author: Armin Rigo <ar...@tunes.org>
Branch: stmgc-c7
Changeset: r70261:5f7df771c0e1
Date: 2014-03-24 18:48 +0100
http://bitbucket.org/pypy/pypy/changeset/5f7df771c0e1/

Log:    import stmgc/ee65d7dc215e

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 @@
-a33130d9f35c
+ee65d7dc215e
diff --git a/rpython/translator/stm/src_stm/stm/forksupport.c 
b/rpython/translator/stm/src_stm/stm/forksupport.c
--- a/rpython/translator/stm/src_stm/stm/forksupport.c
+++ b/rpython/translator/stm/src_stm/stm/forksupport.c
@@ -13,6 +13,7 @@
 static bool fork_was_in_transaction;
 
 static char *setup_mmap(char *reason);            /* forward, in setup.c */
+static void setup_protection_settings(void);      /* forward, in setup.c */
 static pthread_t *_get_cpth(stm_thread_local_t *);/* forward, in setup.c */
 
 
@@ -227,6 +228,10 @@
     }
     assert(stm_all_thread_locals == fork_this_tl);
 
+    /* Restore the base setting of PROT_NONE pages.
+     */
+    setup_protection_settings();
+
     /* Make all pages shared again.
      */
     uintptr_t pagenum, endpagenum;
diff --git a/rpython/translator/stm/src_stm/stm/nursery.c 
b/rpython/translator/stm/src_stm/stm/nursery.c
--- a/rpython/translator/stm/src_stm/stm/nursery.c
+++ b/rpython/translator/stm/src_stm/stm/nursery.c
@@ -223,8 +223,13 @@
 
     realnursery = REAL_ADDRESS(pseg->pub.segment_base, _stm_nursery_start);
     nursery_used = pseg->pub.nursery_current - (stm_char *)_stm_nursery_start;
+    OPT_ASSERT((nursery_used & 7) == 0);
     memset(realnursery, 0, nursery_used);
 
+    /* assert that the rest of the nursery still contains only zeroes */
+    assert_memset_zero(realnursery + nursery_used,
+                       (NURSERY_END - _stm_nursery_start) - nursery_used);
+
     pseg->pub.nursery_current = (stm_char *)_stm_nursery_start;
 
     /* free any object left from 'young_outside_nursery' */
@@ -375,6 +380,7 @@
 void _stm_set_nursery_free_count(uint64_t free_count)
 {
     assert(free_count <= NURSERY_SIZE);
+    assert((free_count & 7) == 0);
     _stm_nursery_start = NURSERY_END - free_count;
 
     long i;
diff --git a/rpython/translator/stm/src_stm/stm/setup.c 
b/rpython/translator/stm/src_stm/stm/setup.c
--- a/rpython/translator/stm/src_stm/stm/setup.c
+++ b/rpython/translator/stm/src_stm/stm/setup.c
@@ -15,6 +15,30 @@
     return result;
 }
 
+static void setup_protection_settings(void)
+{
+    /* The segment 0 is not used to run transactions, but contains the
+       shared copy of the pages.  We mprotect all pages before so that
+       accesses fail, up to and including the pages corresponding to the
+       nurseries of the other segments. */
+    mprotect(stm_object_pages, END_NURSERY_PAGE * 4096UL, PROT_NONE);
+
+    long i;
+    for (i = 1; i <= NB_SEGMENTS; i++) {
+        char *segment_base = get_segment_base(i);
+
+        /* In each segment, the first page is where TLPREFIX'ed
+           NULL accesses land.  We mprotect it so that accesses fail. */
+        mprotect(segment_base, 4096, PROT_NONE);
+
+        /* Pages in range(2, FIRST_READMARKER_PAGE) are never used */
+        if (FIRST_READMARKER_PAGE > 2)
+            mprotect(segment_base + 8192,
+                     (FIRST_READMARKER_PAGE - 2) * 4096UL,
+                     PROT_NONE);
+    }
+}
+
 void stm_setup(void)
 {
     /* Check that some values are acceptable */
@@ -33,33 +57,18 @@
     assert(_STM_FAST_ALLOC <= NB_NURSERY_PAGES * 4096);
 
     stm_object_pages = setup_mmap("initial stm_object_pages mmap()");
-
-    /* The segment 0 is not used to run transactions, but contains the
-       shared copy of the pages.  We mprotect all pages before so that
-       accesses fail, up to and including the pages corresponding to the
-       nurseries of the other segments. */
-    mprotect(stm_object_pages, END_NURSERY_PAGE * 4096UL, PROT_NONE);
+    setup_protection_settings();
 
     long i;
     for (i = 1; i <= NB_SEGMENTS; i++) {
         char *segment_base = get_segment_base(i);
 
-        /* In each segment, the first page is where TLPREFIX'ed
-           NULL accesses land.  We mprotect it so that accesses fail. */
-        mprotect(segment_base, 4096, PROT_NONE);
-
         /* Fill the TLS page (page 1) with 0xDC, for debugging */
         memset(REAL_ADDRESS(segment_base, 4096), 0xDC, 4096);
         /* Make a "hole" at STM_PSEGMENT (which includes STM_SEGMENT) */
         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,
-                     PROT_NONE);
-
         /* Initialize STM_PSEGMENT */
         struct stm_priv_segment_info_s *pr = get_priv_segment(i);
         assert(1 <= i && i < 255);   /* 255 is WL_VISITED in gcpage.c */
diff --git a/rpython/translator/stm/src_stm/stm/weakref.c 
b/rpython/translator/stm/src_stm/stm/weakref.c
--- a/rpython/translator/stm/src_stm/stm/weakref.c
+++ b/rpython/translator/stm/src_stm/stm/weakref.c
@@ -126,7 +126,9 @@
             }
 
             ssize_t size = 16;
-            object_t *pointing_to = *WEAKREF_PTR(weakref, size);
+            stm_char *wr = (stm_char *)WEAKREF_PTR(weakref, size);
+            char *real_wr = REAL_ADDRESS(stm_object_pages, wr);
+            object_t *pointing_to = *(object_t **)real_wr;
             assert(pointing_to != NULL);
             if (!mark_visited_test(pointing_to)) {
                 //assert(flag_page_private[(uintptr_t)weakref / 4096UL] != 
PRIVATE_PAGE);
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to