Author: Remi Meier <remi.me...@inf.ethz.ch>
Branch: 
Changeset: r1363:a5c6dc8a08d5
Date: 2014-09-05 16:12 +0200
http://bitbucket.org/pypy/stmgc/changeset/a5c6dc8a08d5/

Log:    add some very simple commit-log testing

diff --git a/c8/stm/misc.c b/c8/stm/misc.c
--- a/c8/stm/misc.c
+++ b/c8/stm/misc.c
@@ -69,4 +69,25 @@
     return (object_t *)list_item(
         STM_PSEGMENT->objects_pointing_to_nursery, index);
 }
+
+static volatile struct stm_commit_log_entry_s *_last_cl_entry;
+static long _last_cl_entry_index;
+void _stm_start_enum_last_cl_entry()
+{
+    _last_cl_entry = &commit_log_root;
+    volatile struct stm_commit_log_entry_s *cl = (volatile struct 
stm_commit_log_entry_s *)
+        &commit_log_root;
+
+    while ((cl = cl->next)) {
+        _last_cl_entry = cl;
+    }
+    _last_cl_entry_index = 0;
+}
+
+object_t *_stm_next_last_cl_entry()
+{
+    if (_last_cl_entry != &commit_log_root)
+        return _last_cl_entry->written[_last_cl_entry_index++];
+    return NULL;
+}
 #endif
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -90,6 +90,8 @@
 long _stm_count_objects_pointing_to_nursery(void);
 object_t *_stm_enum_modified_old_objects(long index);
 object_t *_stm_enum_objects_pointing_to_nursery(long index);
+object_t *_stm_next_last_cl_entry();
+void _stm_start_enum_last_cl_entry();
 #endif
 
 /* ==================== HELPERS ==================== */
diff --git a/c8/test/support.py b/c8/test/support.py
--- a/c8/test/support.py
+++ b/c8/test/support.py
@@ -67,6 +67,8 @@
 long _stm_count_objects_pointing_to_nursery(void);
 object_t *_stm_enum_modified_old_objects(long index);
 object_t *_stm_enum_objects_pointing_to_nursery(long index);
+object_t *_stm_next_last_cl_entry();
+void _stm_start_enum_last_cl_entry();
 
 void *memset(void *s, int c, size_t n);
 
@@ -373,6 +375,14 @@
         return None
     return map(lib._stm_enum_old_objects_with_cards, range(count))
 
+def last_commit_log_entries():
+    lib._stm_start_enum_last_cl_entry()
+    res = []
+    obj = lib._stm_next_last_cl_entry()
+    while obj != ffi.NULL:
+        res.append(obj)
+        obj = lib._stm_next_last_cl_entry()
+    return res
 
 
 
diff --git a/c8/test/test_basic.py b/c8/test/test_basic.py
--- a/c8/test/test_basic.py
+++ b/c8/test/test_basic.py
@@ -33,9 +33,12 @@
         self.switch(1)
         self.start_transaction()
         self.commit_transaction()
+        assert last_commit_log_entries() == []
+
         self.switch(0)
 
         self.commit_transaction()
+        assert last_commit_log_entries() == []
 
     def test_simple_read(self):
         self.start_transaction()
@@ -43,6 +46,7 @@
         stm_read(lp1)
         assert stm_was_read(lp1)
         self.commit_transaction()
+        assert last_commit_log_entries() == []
 
     def test_simple_write(self):
         self.start_transaction()
@@ -53,6 +57,7 @@
         assert modified_old_objects() == []             # object not old
         assert objects_pointing_to_nursery() == []    # short transaction
         self.commit_transaction()
+        assert last_commit_log_entries() == []
 
     def test_allocate_old(self):
         lp1 = stm_allocate_old(16)
@@ -101,6 +106,7 @@
         #
         self.switch(1)
         self.commit_transaction()
+        assert last_commit_log_entries() == [lp1]
         #
         py.test.raises(Conflict, self.switch, 0) # detects rw conflict
 
@@ -123,6 +129,7 @@
         assert (p2 - p1) % 4096 == 0
         assert stm_get_char(lp) == 'u'
         self.commit_transaction()
+        assert last_commit_log_entries() == [lp]
 
     def test_commit_fresh_objects2(self):
         self.switch(1)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to