[pypy-commit] stmgc marker: Another convenient marker macro, and test for all three macros
arigo
noreply at buildbot.pypy.org
Sat Apr 19 12:31:35 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: marker
Changeset: r1167:3b0945ccae76
Date: 2014-04-19 12:31 +0200
http://bitbucket.org/pypy/stmgc/changeset/3b0945ccae76/
Log: Another convenient marker macro, and test for all three macros
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -287,6 +287,17 @@
_popped; \
})
+#define STM_UPDATE_MARKER_NUM(tl, odd_num) do { \
+ uintptr_t _odd_num = (odd_num); \
+ assert(_odd_num & 1); \
+ struct stm_shadowentry_s *_ss = (tl).shadowstack - 2; \
+ while (!(((uintptr_t)(_ss->ss)) & 1)) { \
+ _ss--; \
+ assert(_ss >= (tl).shadowstack_base); \
+ } \
+ _ss->ss = (object_t *)_odd_num; \
+} while (0)
+
/* Every thread needs to have a corresponding stm_thread_local_t
structure. It may be a "__thread" global variable or something else.
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -125,6 +125,10 @@
void (*stmcb_expand_marker)(uintptr_t odd_number, object_t *following_object,
char *outputbuf, size_t outputbufsize);
+
+void stm_push_marker(stm_thread_local_t *, uintptr_t, object_t *);
+void stm_update_marker_num(stm_thread_local_t *, uintptr_t);
+void stm_pop_marker(stm_thread_local_t *);
""")
@@ -279,6 +283,21 @@
}
}
+void stm_push_marker(stm_thread_local_t *tl, uintptr_t onum, object_t *ob)
+{
+ STM_PUSH_MARKER(*tl, onum, ob);
+}
+
+void stm_update_marker_num(stm_thread_local_t *tl, uintptr_t onum)
+{
+ STM_UPDATE_MARKER_NUM(*tl, onum);
+}
+
+void stm_pop_marker(stm_thread_local_t *tl)
+{
+ STM_POP_MARKER(*tl);
+}
+
''', sources=source_files,
define_macros=[('STM_TESTS', '1'),
('STM_LARGEMALLOC_TEST', '1'),
diff --git a/c7/test/test_marker.py b/c7/test/test_marker.py
--- a/c7/test/test_marker.py
+++ b/c7/test/test_marker.py
@@ -80,3 +80,37 @@
assert tl.longest_marker_state == lib.STM_TIME_RUN_ABORTED_OTHER
assert 0.099 <= tl.longest_marker_time <= 0.9
assert ffi.string(tl.longest_marker_self) == '29 %r' % (p,)
+
+ def test_macros(self):
+ self.start_transaction()
+ p = stm_allocate(16)
+ tl = self.get_stm_thread_local()
+ lib.stm_push_marker(tl, 29, p)
+ p1 = self.pop_root()
+ assert p1 == p
+ p1 = self.pop_root()
+ assert p1 == ffi.cast("object_t *", 29)
+ py.test.raises(EmptyStack, self.pop_root)
+ #
+ lib.stm_push_marker(tl, 29, p)
+ lib.stm_update_marker_num(tl, 27)
+ p1 = self.pop_root()
+ assert p1 == p
+ p1 = self.pop_root()
+ assert p1 == ffi.cast("object_t *", 27)
+ py.test.raises(EmptyStack, self.pop_root)
+ #
+ lib.stm_push_marker(tl, 29, p)
+ self.push_root(p)
+ lib.stm_update_marker_num(tl, 27)
+ p1 = self.pop_root()
+ assert p1 == p
+ p1 = self.pop_root()
+ assert p1 == p
+ p1 = self.pop_root()
+ assert p1 == ffi.cast("object_t *", 27)
+ py.test.raises(EmptyStack, self.pop_root)
+ #
+ lib.stm_push_marker(tl, 29, p)
+ lib.stm_pop_marker(tl)
+ py.test.raises(EmptyStack, self.pop_root)
More information about the pypy-commit
mailing list