Author: Remi Meier
Branch: c7
Changeset: r681:c9bb5552e354
Date: 2014-01-28 11:20 +0100
http://bitbucket.org/pypy/stmgc/changeset/c9bb5552e354/
Log: fix bugs in the nursery
diff --git a/c7/core.c b/c7/core.c
--- a/c7/core.c
+++ b/c7/core.c
@@ -24,6 +24,12 @@
uint8_t write_locks[READMARKER_END - READMARKER_START];
+struct _thread_local1_s* _stm_dbg_get_tl(int thread)
+{
+ if (thread == -1)
+ return (struct _thread_local1_s*)real_address((object_t*)_STM_TL);
+ return (struct _thread_local1_s*)REAL_ADDRESS(get_thread_base(thread),
_STM_TL);
+}
bool _stm_was_read_remote(char *base, object_t *obj)
{
@@ -228,6 +234,9 @@
_stm_restore_local_state(thread_num);
_STM_TL->nursery_current = (localchar_t*)(FIRST_NURSERY_PAGE * 4096);
+ memset((void*)real_address((object_t*)_STM_TL->nursery_current), 0x0,
+ (FIRST_AFTER_NURSERY_PAGE - FIRST_NURSERY_PAGE) * 4096); /* clear
nursery */
+
_STM_TL->shadow_stack = (object_t**)malloc(LENGTH_SHADOW_STACK *
sizeof(void*));
_STM_TL->shadow_stack_base = _STM_TL->shadow_stack;
@@ -397,10 +406,6 @@
/* here we hold the shared lock as a reader or writer */
assert(_STM_TL->running_transaction);
-
- /* reset shadowstack */
- _STM_TL->shadow_stack = _STM_TL->old_shadow_stack;
-
nursery_on_abort();
assert(_STM_TL->jmpbufptr != NULL);
diff --git a/c7/core.h b/c7/core.h
--- a/c7/core.h
+++ b/c7/core.h
@@ -128,6 +128,7 @@
#define REAL_ADDRESS(object_pages, src) ((object_pages) + (uintptr_t)(src))
+
static inline struct object_s *real_address(object_t *src)
{
return (struct object_s*)REAL_ADDRESS(_STM_TL->thread_base, src);
@@ -158,6 +159,7 @@
return object_pages + thread_num * (NB_PAGES * 4096UL);
}
+
static inline void spin_loop(void)
{
asm("pause" : : : "memory");
@@ -226,5 +228,7 @@
void _stm_minor_collect();
#define stm_become_inevitable(msg) /* XXX implement me! */
+struct _thread_local1_s* _stm_dbg_get_tl(int thread); /* -1 is current thread
*/
+
#endif
diff --git a/c7/nursery.c b/c7/nursery.c
--- a/c7/nursery.c
+++ b/c7/nursery.c
@@ -63,6 +63,8 @@
/* reserve a fresh new page (XXX: from the end!) */
page = stm_pages_reserve(1);
+ assert(memset(real_address((object_t*)(page * 4096)), 0xdd, 4096));
+
result = (localchar_t *)(page * 4096UL);
alloc->start = (uintptr_t)result;
alloc->stop = alloc->start + (4096 / size) * size;
@@ -99,6 +101,7 @@
void trace_if_young(object_t **pobj)
{
+ /* takes a normal pointer to a thread-local pointer to an object */
if (*pobj == NULL)
return;
if (!_stm_is_young(*pobj))
@@ -125,6 +128,7 @@
moved->stm_flags |= GCFLAG_NOT_COMMITTED;
if (is_small) /* means, not allocated by large-malloc */
moved->stm_flags |= GCFLAG_SMALL;
+ assert(size == _stm_data_size((struct
object_s*)REAL_ADDRESS(get_thread_base(0), moved)));
LIST_APPEND(_STM_TL->uncommitted_objects, moved);
(*pobj)->stm_flags |= GCFLAG_MOVED;
@@ -195,6 +199,7 @@
_STM_TL->nursery_current = new_current;
assert((uintptr_t)new_current < (1L << 32));
if ((uintptr_t)new_current > FIRST_AFTER_NURSERY_PAGE * 4096) {
+ _STM_TL->nursery_current = current; /* reset for nursery-clearing in
minor_collect!! */
current = collect_and_reserve(size);
}
@@ -263,7 +268,9 @@
void nursery_on_abort()
{
-
+ /* reset shadowstack */
+ _STM_TL->shadow_stack = _STM_TL->old_shadow_stack;
+
/* clear old_objects_to_trace (they will have the WRITE_BARRIER flag
set because the ones we care about are also in modified_objects) */
stm_list_clear(_STM_TL->old_objects_to_trace);
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit