[pypy-commit] stmgc c7: stm_alloc_old

Raemi noreply at buildbot.pypy.org
Tue Jan 14 16:48:58 CET 2014


Author: Remi Meier <remi.meier at gmail.com>
Branch: c7
Changeset: r610:607e5b19ffe2
Date: 2014-01-14 16:48 +0100
http://bitbucket.org/pypy/stmgc/changeset/607e5b19ffe2/

Log:	stm_alloc_old

diff --git a/c7/core.c b/c7/core.c
--- a/c7/core.c
+++ b/c7/core.c
@@ -68,6 +68,7 @@
 
 
 /************************************************************/
+uintptr_t _stm_reserve_page(void);
 
 static void spin_loop(void)
 {
@@ -128,6 +129,15 @@
 }
 
 
+object_t *_stm_allocate_old(size_t size)
+{
+    assert(size <= 4096);
+    localchar_t* addr = (localchar_t*)(_stm_reserve_page() * 4096);
+    object_t* o = (object_t*)addr;
+    o->stm_flags |= GCFLAG_WRITE_BARRIER;
+    return o;
+}
+
 
 static void _stm_privatize(uintptr_t pagenum)
 {
diff --git a/c7/core.h b/c7/core.h
--- a/c7/core.h
+++ b/c7/core.h
@@ -31,6 +31,9 @@
 
 enum {
     GCFLAG_WRITE_BARRIER = (1 << 0),
+    /* set if the write-barrier slowpath needs to trigger. set on all
+       old objects if there was no write-barrier on it in the same
+       transaction and no collection inbetween. */
 };
 
 struct object_s {
@@ -94,4 +97,5 @@
 object_t *_stm_tl_address(char *ptr);
 
 bool _stm_is_in_nursery(char *ptr);
+object_t *_stm_allocate_old(size_t size);
 #endif
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -48,6 +48,7 @@
 char *_stm_real_address(object_t *o);
 object_t *_stm_tl_address(char *ptr);
 bool _stm_is_in_nursery(char *ptr);
+object_t *_stm_allocate_old(size_t size);
 
 void *memset(void *s, int c, size_t n);
 """)
@@ -86,9 +87,15 @@
 def is_in_nursery(ptr):
     return lib._stm_is_in_nursery(ptr)
 
+def stm_allocate_old(size):
+    return lib._stm_real_address(lib._stm_allocate_old(size))
+
 def stm_allocate(size):
     return lib._stm_real_address(lib.stm_allocate(size))
 
+def stm_get_tl_address(ptr):
+    return int(ffi.cast('uintptr_t', lib._stm_tl_address(ptr)))
+
 def stm_read(ptr):
     lib.stm_read(lib._stm_tl_address(ptr))
 
diff --git a/c7/test/test_basic.py b/c7/test/test_basic.py
--- a/c7/test/test_basic.py
+++ b/c7/test/test_basic.py
@@ -44,6 +44,18 @@
         stm_write(p1)
         assert stm_was_written(p1)
 
+    def test_write_on_old(self):
+        p1 = stm_allocate_old(16)
+        p1tl = stm_get_tl_address(p1)
+        self.switch(1)
+        p2 = stm_allocate_old(16)
+        p2tl = stm_get_tl_address(p2)
+        assert p1tl != p2tl
+        
+        
+        
+        
+
     def test_read_write_1(self):
         stm_start_transaction()
         p1 = stm_allocate(16)


More information about the pypy-commit mailing list