[pypy-commit] stmgc default: avoid triggering a segfault to call a function

Raemi noreply at buildbot.pypy.org
Mon Nov 23 08:36:29 EST 2015


Author: Remi Meier <remi.meier at gmail.com>
Branch: 
Changeset: r1971:d31c9f671775
Date: 2015-11-23 14:23 +0100
http://bitbucket.org/pypy/stmgc/changeset/d31c9f671775/

Log:	avoid triggering a segfault to call a function

	Apparently, the obvious thing to do is not always obvious.

diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -925,8 +925,7 @@
 
 static void touch_all_pages_of_obj(object_t *obj, size_t obj_size)
 {
-    /* XXX should it be simpler, just really trying to read a dummy
-       byte in each page? */
+    /* XXX: make this function not needed */
     int my_segnum = STM_SEGMENT->segment_num;
     uintptr_t end_page, first_page = ((uintptr_t)obj) / 4096UL;
 
@@ -942,8 +941,8 @@
     for (page = first_page; page <= end_page; page++) {
         if (get_page_status_in(my_segnum, page) == PAGE_NO_ACCESS) {
             release_privatization_lock(STM_SEGMENT->segment_num);
-            volatile char *dummy = REAL_ADDRESS(STM_SEGMENT->segment_base, page * 4096UL);
-            *dummy;            /* force segfault */
+            /* emulate pagefault -> PAGE_ACCESSIBLE: */
+            handle_segfault_in_page(page);
             acquire_privatization_lock(STM_SEGMENT->segment_num);
         }
     }


More information about the pypy-commit mailing list