Author: Remi Meier <remi.me...@gmail.com> Branch: c7 Changeset: r625:90bb5600924e Date: 2014-01-17 14:53 +0100 http://bitbucket.org/pypy/stmgc/changeset/90bb5600924e/
Log: partially implement aborting diff --git a/c7/core.c b/c7/core.c --- a/c7/core.c +++ b/c7/core.c @@ -911,19 +911,69 @@ stm_stop_lock(); } + +static void reset_modified_from_other_threads() +{ + /* pull the right versions from other threads in order + to reset our pages as part of an abort */ + + struct stm_list_s *modified = _STM_TL2->modified_objects; + char *local_base = _STM_TL2->thread_base; + char *remote_base = get_thread_base(1 - _STM_TL2->thread_num); + char *t0_base = get_thread_base(0); + + STM_LIST_FOREACH(modified, ({ + /* note: same as push_modified_to... but src/dst swapped + XXX: unify both... */ + char *dst = REAL_ADDRESS(local_base, item); + char *src = REAL_ADDRESS(remote_base, item); + size_t size = stmcb_size((struct object_s*)src); + memcpy(dst, src, size); + + /* copying from the other thread re-added the + WRITE_BARRIER flag */ + assert(item->stm_flags & GCFLAG_WRITE_BARRIER); + + struct object_s *t0_obj = (struct object_s*) + REAL_ADDRESS(t0_base, item); + if (t0_base != local_base) { + /* clear the write-lock (WE have modified the obj) */ + assert(t0_obj->stm_write_lock); + t0_obj->stm_write_lock = 0; + } else { + /* done by the memcpy */ + assert(!t0_obj->stm_write_lock); + } + })); +} + + void stm_abort_transaction(void) { + /* here we hold the shared lock as a reader or writer */ assert(_STM_TL2->running_transaction); - // XXX reset all the modified objects!! + /* reset all the modified objects (incl. re-adding GCFLAG_WRITE_BARRIER) */ + reset_modified_from_other_threads(); stm_list_clear(_STM_TL2->modified_objects); - /* re-add GCFLAG_WRITE_BARRIER */ + /* 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_TL2->old_objects_to_trace); /* clear the nursery */ + localchar_t *nursery_base = (localchar_t*)(FIRST_NURSERY_PAGE * 4096); + memset((void*)real_address((object_t*)nursery_base), 0x0, + _STM_TL2->nursery_current - nursery_base); + _STM_TL2->nursery_current = nursery_base; - /* unreserve uncommitted_pages */ + /* unreserve uncommitted_pages and mark them as SHARED again */ + /* STM_LIST_FOREACH(_STM_TL2->uncommitted_pages, ({ */ + /* uintptr_t pagenum = (uintptr_t)item; */ + /* flag_page_private[pagenum] = SHARED_PAGE; */ + /* })); */ + stm_list_clear(_STM_TL2->uncommitted_pages); + /* XXX: forget about GCFLAG_UNCOMMITTED objects */ _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit