Author: Remi Meier <[email protected]>
Branch: card-marking
Changeset: r1212:9759aad4236b
Date: 2014-05-19 15:58 +0200
http://bitbucket.org/pypy/stmgc/changeset/9759aad4236b/

Log:    expand the tests (still failing)

diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -44,8 +44,6 @@
 {
     assert(IMPLY(!(obj->stm_flags & GCFLAG_HAS_CARDS),
                  offset == 0));
-    if (offset)
-        abort();
 
     assert(_seems_to_be_running_transaction());
     assert(!_is_young(obj));
@@ -73,7 +71,7 @@
        'modified_old_objects' (but, because it had GCFLAG_WRITE_BARRIER,
        not in 'objects_pointing_to_nursery').  We'll detect this case
        by finding that we already own the write-lock. */
-    uintptr_t lock_idx = (((uintptr_t)obj) >> 4) - WRITELOCK_START;
+    uintptr_t lock_idx = get_write_lock_idx(obj);
     uint8_t lock_num = STM_PSEGMENT->write_lock_num;
     assert(lock_idx < sizeof(write_locks));
  retry:
diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -220,6 +220,10 @@
 
 #define REAL_ADDRESS(segment_base, src)   ((segment_base) + (uintptr_t)(src))
 
+static inline uintptr_t get_write_lock_idx(object_t *obj) {
+    return (((uintptr_t)obj) >> 4) - WRITELOCK_START;
+}
+
 static inline char *get_segment_base(long segment_num) {
     return stm_object_pages + segment_num * (NB_PAGES * 4096UL);
 }
@@ -252,6 +256,15 @@
     return rm == other_transaction_read_version;
 }
 
+static inline bool was_read_remote_card(char *base, object_t *obj, uintptr_t 
offset,
+                                        uint8_t other_transaction_read_version)
+{
+    uint8_t rm = ((struct stm_read_marker_s *)
+                  (base + (((uintptr_t)obj + offset) >> 4)))->rm;
+    assert(rm <= other_transaction_read_version);
+    return rm == other_transaction_read_version;
+}
+
 static inline void _duck(void) {
     /* put a call to _duck() between two instructions that set 0 into
        a %gs-prefixed address and that may otherwise be replaced with
diff --git a/c7/stm/misc.c b/c7/stm/misc.c
--- a/c7/stm/misc.c
+++ b/c7/stm/misc.c
@@ -40,6 +40,18 @@
     return (obj->stm_flags & _STM_GCFLAG_WRITE_BARRIER) == 0;
 }
 
+bool _stm_was_read_card(object_t *obj, uintptr_t offset)
+{
+    return was_read_remote_card(
+        STM_SEGMENT->segment_base, obj, offset,
+        STM_SEGMENT->transaction_read_version);
+}
+
+bool _stm_was_written_card(object_t *obj, uintptr_t offset)
+{
+    return write_locks[get_write_lock_idx((object_t*)((uintptr_t)obj + 
offset))];
+}
+
 #ifdef STM_TESTS
 uintptr_t _stm_get_private_page(uintptr_t pagenum)
 {
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -120,6 +120,8 @@
 #include <stdbool.h>
 bool _stm_was_read(object_t *obj);
 bool _stm_was_written(object_t *obj);
+bool _stm_was_read_card(object_t *obj, uintptr_t offset);
+bool _stm_was_written_card(object_t *obj, uintptr_t offset);
 uintptr_t _stm_get_private_page(uintptr_t pagenum);
 bool _stm_in_transaction(stm_thread_local_t *tl);
 char *_stm_get_segment_base(long index);
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -58,7 +58,9 @@
 bool _checked_stm_write(object_t *obj);
 bool _checked_stm_write_card(object_t *obj, uintptr_t offset);
 bool _stm_was_read(object_t *obj);
+bool _stm_was_read_card(object_t *obj, uintptr_t offset);
 bool _stm_was_written(object_t *obj);
+bool _stm_was_written_card(object_t *obj, uintptr_t offset);
 char *_stm_real_address(object_t *obj);
 char *_stm_get_segment_base(long index);
 bool _stm_in_transaction(stm_thread_local_t *tl);
@@ -438,6 +440,12 @@
 def stm_was_written(o):
     return lib._stm_was_written(o)
 
+def stm_was_read_card(o, offset):
+    return lib._stm_was_read_card(o, offset)
+
+def stm_was_written_card(o, offset):
+    return lib._stm_was_written_card(o, offset)
+
 
 def stm_start_safe_point():
     lib._stm_start_safe_point()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to