Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r1305:50d22a5baf26
Date: 2014-08-12 18:08 +0200
http://bitbucket.org/pypy/stmgc/changeset/50d22a5baf26/

Log:    Kill STM_STACK_MARKER_{NEW,OLD} and use 'moved_off_ssbase' instead.

diff --git a/c7/stm/marker.c b/c7/stm/marker.c
--- a/c7/stm/marker.c
+++ b/c7/stm/marker.c
@@ -18,10 +18,9 @@
     struct stm_shadowentry_s *current = tl->shadowstack - 1;
     struct stm_shadowentry_s *base = tl->shadowstack_base;
 
-    /* The shadowstack_base contains STM_STACK_MARKER_OLD, which is
-       a convenient stopper for the loop below but which shouldn't
-       be returned. */
-    assert(base->ss == (object_t *)STM_STACK_MARKER_OLD);
+    /* The shadowstack_base contains -1, which is a convenient stopper for
+       the loop below but which shouldn't be returned. */
+    assert(base->ss == (object_t *)-1);
 
     while (!(((uintptr_t)current->ss) & 1)) {
         current--;
diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c
--- a/c7/stm/nursery.c
+++ b/c7/stm/nursery.c
@@ -156,27 +156,22 @@
 {
     stm_thread_local_t *tl = STM_SEGMENT->running_thread;
     struct stm_shadowentry_s *current = tl->shadowstack;
-    struct stm_shadowentry_s *base = tl->shadowstack_base;
-    while (1) {
+    struct stm_shadowentry_s *finalbase = tl->shadowstack_base;
+    struct stm_shadowentry_s *ssbase;
+    ssbase = (struct stm_shadowentry_s *)tl->rjthread.moved_off_ssbase;
+    if (ssbase == NULL)
+        ssbase = finalbase;
+    else
+        assert(finalbase <= ssbase && ssbase <= current);
+
+    while (current > ssbase) {
         --current;
-        OPT_ASSERT(current >= base);
-
         uintptr_t x = (uintptr_t)current->ss;
 
         if ((x & 3) == 0) {
             /* the stack entry is a regular pointer (possibly NULL) */
             minor_trace_if_young(&current->ss);
         }
-        else if (x == STM_STACK_MARKER_NEW) {
-            /* the marker was not already seen: mark it as seen,
-               but continue looking more deeply in the shadowstack */
-            current->ss = (object_t *)STM_STACK_MARKER_OLD;
-        }
-        else if (x == STM_STACK_MARKER_OLD) {
-            /* the marker was already seen: we can stop the
-               root stack tracing at this point */
-            break;
-        }
         else {
             /* it is an odd-valued marker, ignore */
         }
diff --git a/c7/stm/setup.c b/c7/stm/setup.c
--- a/c7/stm/setup.c
+++ b/c7/stm/setup.c
@@ -201,13 +201,13 @@
     struct stm_shadowentry_s *s = (struct stm_shadowentry_s *)start;
     tl->shadowstack = s;
     tl->shadowstack_base = s;
-    STM_PUSH_ROOT(*tl, STM_STACK_MARKER_OLD);
+    STM_PUSH_ROOT(*tl, -1);
 }
 
 static void _done_shadow_stack(stm_thread_local_t *tl)
 {
     assert(tl->shadowstack > tl->shadowstack_base);
-    assert(tl->shadowstack_base->ss == (object_t *)STM_STACK_MARKER_OLD);
+    assert(tl->shadowstack_base->ss == (object_t *)-1);
 
     char *start = (char *)tl->shadowstack_base;
     _shadowstack_trap_page(start, PROT_READ | PROT_WRITE);
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -313,8 +313,6 @@
 #define STM_PUSH_ROOT(tl, p)   ((tl).shadowstack++->ss = (object_t *)(p))
 #define STM_POP_ROOT(tl, p)    ((p) = (typeof(p))((--(tl).shadowstack)->ss))
 #define STM_POP_ROOT_RET(tl)   ((--(tl).shadowstack)->ss)
-#define STM_STACK_MARKER_NEW  (-41)
-#define STM_STACK_MARKER_OLD  (-43)
 
 
 /* Every thread needs to have a corresponding stm_thread_local_t
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -12,8 +12,6 @@
 #define _STM_FAST_ALLOC ...
 #define _STM_GCFLAG_WRITE_BARRIER ...
 #define _STM_CARD_SIZE ...
-#define STM_STACK_MARKER_NEW ...
-#define STM_STACK_MARKER_OLD ...
 
 struct stm_shadowentry_s {
     object_t *ss;
@@ -622,7 +620,7 @@
 
     def push_root_no_gc(self):
         "Pushes an invalid object, to crash in case the GC is called"
-        self.push_root(ffi.cast("object_t *", -1))
+        self.push_root(ffi.cast("object_t *", 8))
 
     def check_char_everywhere(self, obj, expected_content, offset=HDR):
         for i in range(len(self.tls)):
diff --git a/c7/test/test_gcpage.py b/c7/test/test_gcpage.py
--- a/c7/test/test_gcpage.py
+++ b/c7/test/test_gcpage.py
@@ -234,7 +234,7 @@
         p1 = stm_allocate(600)
         stm_set_char(p1, 'o')
         self.push_root(p1)
-        self.push_root(ffi.cast("object_t *", lib.STM_STACK_MARKER_NEW))
+        self.push_root(ffi.cast("object_t *", 123))
         p2 = stm_allocate(600)
         stm_set_char(p2, 't')
         self.push_root(p2)
@@ -243,7 +243,7 @@
         #
         p2 = self.pop_root()
         m = self.pop_root()
-        assert m == ffi.cast("object_t *", lib.STM_STACK_MARKER_OLD)
+        assert m == ffi.cast("object_t *", 123)
         p1 = self.pop_root()
         assert stm_get_char(p1) == 'o'
         assert stm_get_char(p2) == 't'
diff --git a/c7/test/test_nursery.py b/c7/test/test_nursery.py
--- a/c7/test/test_nursery.py
+++ b/c7/test/test_nursery.py
@@ -203,7 +203,7 @@
         p1 = stm_allocate(600)
         stm_set_char(p1, 'o')
         self.push_root(p1)
-        self.push_root(ffi.cast("object_t *", lib.STM_STACK_MARKER_NEW))
+        self.push_root(ffi.cast("object_t *", 123))
         p2 = stm_allocate(600)
         stm_set_char(p2, 't')
         self.push_root(p2)
@@ -212,12 +212,13 @@
         #
         p2 = self.pop_root()
         m = self.pop_root()
-        assert m == ffi.cast("object_t *", lib.STM_STACK_MARKER_OLD)
+        assert m == ffi.cast("object_t *", 123)
         p1 = self.pop_root()
         assert stm_get_char(p1) == 'o'
         assert stm_get_char(p2) == 't'
 
     def test_marker_2(self):
+        py.test.skip("testing this requires working shadowstack saving logic")
         self.start_transaction()
         p1 = stm_allocate(600)
         stm_set_char(p1, 'o')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to