[pypy-commit] stmgc c7-refactor: Add a passing test
arigo
noreply at buildbot.pypy.org
Sun Feb 16 10:15:05 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: c7-refactor
Changeset: r750:e9e218f7fa5e
Date: 2014-02-16 10:12 +0100
http://bitbucket.org/pypy/stmgc/changeset/e9e218f7fa5e/
Log: Add a passing test
diff --git a/c7/stm/misc.c b/c7/stm/misc.c
--- a/c7/stm/misc.c
+++ b/c7/stm/misc.c
@@ -47,6 +47,11 @@
obj->stm_flags) & _STM_GCFLAG_WRITE_BARRIER_CALLED);
}
+uint8_t _stm_creation_marker(object_t *obj)
+{
+ return ((stm_creation_marker_t *)(((uintptr_t)obj) >> 8))->cm;
+}
+
static inline bool was_read_remote(char *base, object_t *obj,
uint8_t other_transaction_read_version)
{
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -86,6 +86,7 @@
#ifdef STM_TESTS
bool _stm_was_read(object_t *obj);
bool _stm_was_written(object_t *obj);
+uint8_t _stm_creation_marker(object_t *obj);
bool _stm_in_nursery(object_t *obj);
bool _stm_in_transaction(stm_thread_local_t *tl);
char *_stm_real_address(object_t *o);
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -53,6 +53,7 @@
bool _checked_stm_write(object_t *obj);
bool _stm_was_read(object_t *obj);
bool _stm_was_written(object_t *obj);
+uint8_t _stm_creation_marker(object_t *obj);
bool _stm_in_nursery(object_t *obj);
char *_stm_real_address(object_t *obj);
object_t *_stm_segment_address(char *ptr);
@@ -342,6 +343,9 @@
def stm_was_written(o):
return lib._stm_was_written(o)
+def stm_creation_marker(o):
+ return lib._stm_creation_marker(o)
+
def stm_stop_transaction():
if lib._stm_stop_transaction():
raise Conflict()
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
@@ -13,3 +13,23 @@
u1 = int(ffi.cast("uintptr_t", lp1))
u2 = int(ffi.cast("uintptr_t", lp2))
assert (u1 & ~255) != (u2 & ~255)
+
+ def test_creation_marker_in_nursery(self):
+ self.start_transaction()
+ lp1 = stm_allocate(16)
+ lp2 = stm_allocate(16)
+ assert stm_creation_marker(lp1) == 0xff
+ assert stm_creation_marker(lp2) == 0xff
+ u1 = int(ffi.cast("uintptr_t", lp1))
+ u2 = int(ffi.cast("uintptr_t", lp2))
+ assert u2 == u1 + 16
+ self.commit_transaction()
+
+ assert stm_creation_marker(lp1) == 0
+ assert stm_creation_marker(lp2) == 0
+
+ self.start_transaction()
+ lp3 = stm_allocate(16)
+ assert stm_creation_marker(lp1) == 0
+ assert stm_creation_marker(lp2) == 0
+ assert stm_creation_marker(lp3) == 0xff
More information about the pypy-commit
mailing list