Author: Remi Meier <remi.me...@inf.ethz.ch> Branch: Changeset: r1356:45cc9257f06e Date: 2014-09-05 11:53 +0200 http://bitbucket.org/pypy/stmgc/changeset/45cc9257f06e/
Log: pass first isolation tests diff --git a/c8/stm/core.c b/c8/stm/core.c --- a/c8/stm/core.c +++ b/c8/stm/core.c @@ -36,7 +36,7 @@ assert(is_readable_log_page_in(i, pagenum)); /* still... */ /* copy the content from there to our segment */ - dprintf(("pagecopy pagenum:%lu, src: %lu, dst:%lu\n", pagenum, i, my_segnum)); + dprintf(("pagecopy pagenum:%lu, src: %lu, dst:%d\n", pagenum, i, my_segnum)); pagecopy((char*)(get_virt_page_of(my_segnum, pagenum) * 4096UL), (char*)(get_virt_page_of(i, pagenum) * 4096UL)); @@ -54,10 +54,9 @@ obj_size = stmcb_size_rounded_up(bk_obj); assert(obj_size < 4096); /* XXX */ - assert(obj->stm_flags & GCFLAG_WRITE_BARRIER); /* not written here */ memcpy(REAL_ADDRESS(STM_SEGMENT->segment_base, obj), bk_obj, obj_size); - assert(obj->stm_flags & GCFLAG_WRITE_BARRIER); /* still not written */ + assert(obj->stm_flags & GCFLAG_WRITE_BARRIER); /* not written */ } TREE_LOOP_END; @@ -75,7 +74,8 @@ { char *addr = siginfo->si_addr; dprintf(("si_addr: %p\n", addr)); - if (addr == NULL) { /* actual segfault */ + if (addr == NULL || addr < stm_object_pages || addr > stm_object_pages+TOTAL_MEMORY) { + /* actual segfault */ /* send to GDB */ kill(getpid(), SIGINT); } @@ -350,7 +350,7 @@ reset_transaction_read_version(); } - assert(tree_count(STM_PSEGMENT->modified_old_objects) == 0); + assert(tree_is_cleared(STM_PSEGMENT->modified_old_objects)); assert(list_is_empty(STM_PSEGMENT->objects_pointing_to_nursery)); check_nursery_at_transaction_start(); } @@ -387,9 +387,21 @@ minor_collection(1); - struct stm_commit_log_entry_s* entry = _validate_and_add_to_commit_log(); + _validate_and_add_to_commit_log(); + acquire_modified_objs_lock(STM_SEGMENT->segment_num); - /* XXX:discard backup copies */ + + struct tree_s *tree = STM_PSEGMENT->modified_old_objects; + wlog_t *item; + TREE_LOOP_FORWARD(tree, item); + object_t *obj = (object_t*)item->addr; + struct object_s* bk_obj = (struct object_s *)item->val; + free(bk_obj); + obj->stm_flags |= GCFLAG_WRITE_BARRIER; + TREE_LOOP_END; + + tree_clear(tree); + release_modified_objs_lock(STM_SEGMENT->segment_num); s_mutex_lock(); diff --git a/c8/stm/gcpage.c b/c8/stm/gcpage.c --- a/c8/stm/gcpage.c +++ b/c8/stm/gcpage.c @@ -51,7 +51,9 @@ object_t *o = (object_t *)(p - stm_object_pages); o->stm_flags = GCFLAG_WRITE_BARRIER; - dprintf(("allocate_old(%lu): %p, seg=%d\n", size_rounded_up, p, - get_segment_of_linear_address(p))); + dprintf(("allocate_old(%lu): %p, seg=%d, page=%lu\n", + size_rounded_up, p, + get_segment_of_linear_address(p), + (p - STM_SEGMENT->segment_base) / 4096UL)); return o; } diff --git a/c8/stm/list.c b/c8/stm/list.c --- a/c8/stm/list.c +++ b/c8/stm/list.c @@ -45,6 +45,7 @@ tree->raw_current = tree->raw_start; tree->count = 0; } + assert(tree->count == 0); } static struct tree_s *tree_create(void) @@ -99,6 +100,7 @@ newtree.raw_start = newitems; newtree.raw_current = newitems; newtree.raw_end = newitems + newalloc; + newtree.count = 0; _tree_clear_node(&newtree.toplevel); TREE_LOOP_FORWARD(tree, item) { @@ -146,7 +148,7 @@ /* reuse the deleted entry and that's it */ wlog1->addr = addr; wlog1->val = val; - tree->count++; + (tree->count)++; return; } /* the key must not already be present */ @@ -168,7 +170,7 @@ wlog->addr = addr; wlog->val = val; *(char **)p = (char *)wlog; - tree->count++; + (tree->count)++; } static bool tree_delete_item(struct tree_s *tree, uintptr_t addr) diff --git a/c8/stm/list.h b/c8/stm/list.h --- a/c8/stm/list.h +++ b/c8/stm/list.h @@ -124,8 +124,8 @@ } wlog_node_t; struct tree_s { + uintptr_t count; char *raw_start, *raw_current, *raw_end; - uintptr_t count; wlog_node_t toplevel; }; @@ -135,10 +135,12 @@ //static inline void tree_delete_not_used_any_more(struct tree_s *tree)... static inline bool tree_is_cleared(struct tree_s *tree) { + assert((tree->raw_current == tree->raw_start) == (tree->count == 0)); return tree->raw_current == tree->raw_start; } static inline uintptr_t tree_count(struct tree_s *tree) { + assert(tree->count >= 0); return tree->count; } diff --git a/c8/stm/misc.c b/c8/stm/misc.c --- a/c8/stm/misc.c +++ b/c8/stm/misc.c @@ -46,8 +46,8 @@ #ifdef STM_TESTS long _stm_count_modified_old_objects(void) { - if (STM_PSEGMENT->modified_old_objects == NULL) - return -1; + assert(STM_PSEGMENT->modified_old_objects); + assert(tree_count(STM_PSEGMENT->modified_old_objects) < 10000); return tree_count(STM_PSEGMENT->modified_old_objects); } diff --git a/c8/stm/pages.c b/c8/stm/pages.c --- a/c8/stm/pages.c +++ b/c8/stm/pages.c @@ -117,11 +117,16 @@ /* we hopefully hold the privatization lock: */ assert(get_priv_segment(segnum)->privatization_lock); - char *addr = get_virt_page_of(segnum, pagenum); + if ((prot == PROT_NONE && !is_readable_log_page_in(segnum, pagenum)) + || (prot == (PROT_READ|PROT_WRITE) && is_readable_log_page_in(segnum, pagenum))) + return; + + char *addr = (char*)(get_virt_page_of(segnum, pagenum) * 4096UL); mprotect(addr, count * 4096UL, prot); - dprintf(("pages_set_protection(%d, %lu, %lu, %d)\n", - segnum, pagenum, count, prot)); + dprintf(("pages_set_protection(%d, %lu, %lu, %d), virtpage:%lu\n", + segnum, pagenum, count, prot, + get_virt_page_of(segnum, pagenum))); uint64_t bitmask = 1UL << segnum; uintptr_t amount = count; diff --git a/c8/test/test_basic.py b/c8/test/test_basic.py --- a/c8/test/test_basic.py +++ b/c8/test/test_basic.py @@ -81,7 +81,6 @@ def test_read_write_1(self): lp1 = stm_allocate_old(16) stm_get_real_address(lp1)[HDR] = 'a' #setchar - lib._push_obj_to_other_segments(lp1) # self.start_transaction() self.commit_transaction() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit