Author: Remi Meier <[email protected]>
Branch: 
Changeset: r1333:8ee2f1a4c200
Date: 2014-09-03 10:03 +0200
http://bitbucket.org/pypy/stmgc/changeset/8ee2f1a4c200/

Log:    pass 2 simple tests

diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c
--- a/c8/stm/nursery.c
+++ b/c8/stm/nursery.c
@@ -30,6 +30,12 @@
     return (uintptr_t)obj < NURSERY_END;
 }
 
+long stm_can_move(object_t *obj)
+{
+    /* 'long' return value to avoid using 'bool' in the public interface */
+    return _is_in_nursery(obj);
+}
+
 
 /************************************************************/
 
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -67,6 +67,10 @@
 bool _stm_was_read(object_t *obj);
 bool _stm_was_written(object_t *obj);
 
+long stm_can_move(object_t *obj);
+char *_stm_real_address(object_t *o);
+void _stm_test_switch(stm_thread_local_t *tl);
+
 char *_stm_get_segment_base(long index);
 bool _stm_in_transaction(stm_thread_local_t *tl);
 void _stm_set_nursery_free_count(uint64_t free_count);
diff --git a/c8/test/support.py b/c8/test/support.py
--- a/c8/test/support.py
+++ b/c8/test/support.py
@@ -39,6 +39,10 @@
 bool _stm_in_transaction(stm_thread_local_t *tl);
 int _stm_get_flags(object_t *obj);
 
+long stm_can_move(object_t *obj);
+char *_stm_real_address(object_t *o);
+void _stm_test_switch(stm_thread_local_t *tl);
+
 void clear_jmpbuf(stm_thread_local_t *tl);
 long stm_start_transaction(stm_thread_local_t *tl);
 bool _check_commit_transaction(void);
@@ -330,15 +334,10 @@
 
 
 
-SHADOWSTACK_LENGTH = 1000
 _keepalive = weakref.WeakKeyDictionary()
 
 def _allocate_thread_local():
     tl = ffi.new("stm_thread_local_t *")
-    ss = ffi.new("struct stm_shadowentry_s[]", SHADOWSTACK_LENGTH)
-    _keepalive[tl] = ss
-    tl.shadowstack = ss
-    tl.shadowstack_base = ss
     lib.stm_register_thread_local(tl)
     return tl
 
@@ -355,17 +354,10 @@
         lib.stmcb_expand_marker = ffi.NULL
         lib.stmcb_debug_print = ffi.NULL
         tl = self.tls[self.current_thread]
-        if lib._stm_in_transaction(tl) and lib.stm_is_inevitable():
-            self.commit_transaction()      # must succeed!
+        assert not lib._stm_in_transaction(tl)
         #
         for n, tl in enumerate(self.tls):
-            if lib._stm_in_transaction(tl):
-                if self.current_thread != n:
-                    self.switch(n)
-                if lib.stm_is_inevitable():
-                    self.commit_transaction()   # must succeed!
-                else:
-                    self.abort_transaction()
+            assert not lib._stm_in_transaction(tl)
         #
         for tl in self.tls:
             lib.stm_unregister_thread_local(tl)
@@ -405,34 +397,18 @@
 
     def switch(self, thread_num):
         assert thread_num != self.current_thread
-        tl = self.tls[self.current_thread]
-        if lib._stm_in_transaction(tl):
-            stm_start_safe_point()
         #
         self.current_thread = thread_num
         tl2 = self.tls[thread_num]
         #
         if lib._stm_in_transaction(tl2):
             lib._stm_test_switch(tl2)
-            stm_stop_safe_point() # can raise Conflict
 
     def push_root(self, o):
-        assert ffi.typeof(o) == ffi.typeof("object_t *")
-        tl = self.tls[self.current_thread]
-        curlength = tl.shadowstack - tl.shadowstack_base
-        assert 0 <= curlength < SHADOWSTACK_LENGTH
-        tl.shadowstack[0].ss = ffi.cast("object_t *", o)
-        tl.shadowstack += 1
+        assert 0
 
     def pop_root(self):
-        tl = self.tls[self.current_thread]
-        curlength = tl.shadowstack - tl.shadowstack_base
-        assert curlength >= 1
-        if curlength == 1:
-            raise EmptyStack
-        assert 0 < curlength <= SHADOWSTACK_LENGTH
-        tl.shadowstack -= 1
-        return ffi.cast("object_t *", tl.shadowstack[0].ss)
+        assert 0
 
     def push_root_no_gc(self):
         "Pushes an invalid object, to crash in case the GC is called"
@@ -451,13 +427,3 @@
     def set_thread_local_obj(self, newobj):
         tl = self.tls[self.current_thread]
         tl.thread_local_obj = newobj
-
-    def become_inevitable(self):
-        tl = self.tls[self.current_thread]
-        if lib._check_become_inevitable(tl):
-            raise Conflict()
-
-    def become_globally_unique_transaction(self):
-        tl = self.tls[self.current_thread]
-        if lib._check_become_globally_unique_transaction(tl):
-            raise Conflict()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to