[pypy-commit] stmgc c7: first allocs working
Raemi
noreply at buildbot.pypy.org
Tue Jan 14 15:34:31 CET 2014
Author: Remi Meier <remi.meier at gmail.com>
Branch: c7
Changeset: r606:22e3df474bf9
Date: 2014-01-14 15:28 +0100
http://bitbucket.org/pypy/stmgc/changeset/22e3df474bf9/
Log: first allocs working
diff --git a/c7/core.c b/c7/core.c
--- a/c7/core.c
+++ b/c7/core.c
@@ -188,6 +188,12 @@
return object_pages + thread_num * (NB_PAGES * 4096UL);
}
+bool _stm_is_in_nursery(char *ptr)
+{
+ object_t * o = _stm_tl_address(ptr);
+ assert(o);
+ return (uintptr_t)o < FIRST_AFTER_NURSERY_PAGE * 4096;
+}
char *_stm_real_address(object_t *o)
{
@@ -358,6 +364,7 @@
localchar_t *current = _STM_TL2->nursery_current;
localchar_t *new_current = current + size;
+ _STM_TL2->nursery_current = new_current;
if ((uintptr_t)new_current > FIRST_AFTER_NURSERY_PAGE * 4096) {
/* XXX: do minor collection */
abort();
@@ -447,6 +454,8 @@
assert(thread_num < 2); /* only 2 threads for now */
_stm_restore_local_state(thread_num);
+
+ _STM_TL2->nursery_current = (localchar_t*)(FIRST_OBJECT_PAGE * 4096);
_STM_TL2->modified_objects = stm_list_create();
assert(!_STM_TL2->running_transaction);
diff --git a/c7/core.h b/c7/core.h
--- a/c7/core.h
+++ b/c7/core.h
@@ -92,4 +92,6 @@
void stm_stop_transaction(void);
char *_stm_real_address(object_t *o);
object_t *_stm_tl_address(char *ptr);
+
+bool _stm_is_in_nursery(char *ptr);
#endif
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -47,6 +47,7 @@
char *_stm_real_address(object_t *o);
object_t *_stm_tl_address(char *ptr);
+bool _stm_is_in_nursery(char *ptr);
void *memset(void *s, int c, size_t n);
""")
@@ -67,6 +68,9 @@
force_generic_engine=True)
+def is_in_nursery(ptr):
+ return lib._stm_is_in_nursery(ptr)
+
def stm_allocate(size):
return lib._stm_real_address(lib.stm_allocate(size))
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
@@ -5,21 +5,23 @@
def test_empty(self):
pass
-
+
def test_thread_local_allocations(self):
p1 = stm_allocate(16)
p2 = stm_allocate(16)
- assert intptr(p2) - intptr(p1) == 16
+ assert is_in_nursery(p1)
+ assert is_in_nursery(p2)
+ assert p2 - p1 == 16
p3 = stm_allocate(16)
- assert intptr(p3) - intptr(p2) == 16
+ assert p3 - p2 == 16
#
self.switch("sub1")
p1s = stm_allocate(16)
- assert abs(intptr(p1s) - intptr(p3)) >= 4000
+ assert abs(p1s - p3) >= 4000
#
self.switch("main")
p4 = stm_allocate(16)
- assert intptr(p4) - intptr(p3) == 16
+ assert p4 - p3 == 16
def test_read_write_1(self):
stm_start_transaction()
More information about the pypy-commit
mailing list