Commits

Remi Meier committed 70275e7

add failing test for partially uncommitted pages / uncommitted objects

Comments (0)

Files changed (3)

        or PRIVATE), but not committed yet. So only visible from
        this transaction. */
     GCFLAG_NOT_COMMITTED = (1 << 1),
-
+    /* only used during collections to mark an obj as moved out of the
+       generation it was in */
     GCFLAG_MOVED = (1 << 2),
 };
 
 
 struct object_s {
     uint8_t stm_flags;            /* reserved for the STM library */
-    uint8_t stm_write_lock;       /* 1 if writeable by some thread */
     /* make sure it doesn't get bigger than 4 bytes for performance
      reasons */
 };
 extern size_t stmcb_size(struct object_s *);
 extern void stmcb_trace(struct object_s *, void (object_t **));
 
+uint8_t _stm_get_flags(object_t *obj);
+uint8_t _stm_get_page_flag(int pagenum);
 enum {
     SHARED_PAGE=0,
     REMAPPING_PAGE,
     PRIVATE_PAGE,
     UNCOMMITTED_SHARED_PAGE,
 };  /* flag_page_private */
-uint8_t _stm_get_page_flag(int pagenum);
+
+enum {
+    GCFLAG_WRITE_BARRIER = 1,
+    GCFLAG_NOT_COMMITTED = 2,
+    GCFLAG_MOVED = 4
+};
+
+
 """)
 
 lib = ffi.verify('''
 }
 
 
+uint8_t _stm_get_flags(object_t *obj) {
+    return obj->stm_flags;
+}
+
+
 bool _checked_stm_write(object_t *object) {
     jmpbufptr_t here;
     if (__builtin_setjmp(here) == 0) { // returned directly
     startp = start // 4096
     return range(startp, startp + stm_get_obj_size(o) // 4096 + 1)
 
+def stm_get_flags(o):
+    return lib._stm_get_flags(o)
+
 
 class BaseTest(object):
 

c7/test/test_basic.py

         rnew = stm_get_real_address(new)
         assert rnew[4097] == '\0'
         
+    def test_partial_alloced_pages(self):
+        stm_start_transaction()
+        new = stm_allocate(16)
+        stm_push_root(new)
+        stm_minor_collect()
+        new = stm_pop_root()
+        assert stm_get_page_flag(stm_get_obj_pages(new)[0]) == lib.UNCOMMITTED_SHARED_PAGE
+        assert stm_get_flags(new) & lib.GCFLAG_NOT_COMMITTED
 
-            
+        stm_stop_transaction()
+        assert stm_get_page_flag(stm_get_obj_pages(new)[0]) == lib.SHARED_PAGE
+        assert not (stm_get_flags(new) & lib.GCFLAG_NOT_COMMITTED)
 
 
     # def test_resolve_write_write_no_conflict(self):