Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r975:5edbae0c780a Date: 2014-03-12 08:04 +0100 http://bitbucket.org/pypy/stmgc/changeset/5edbae0c780a/
Log: Add last_abort__bytes_in_nursery. diff --git a/c7/stm/core.c b/c7/stm/core.c --- a/c7/stm/core.c +++ b/c7/stm/core.c @@ -466,7 +466,7 @@ struct stm_priv_segment_info_s *pseg = get_priv_segment(segment_num); /* throw away the content of the nursery */ - throw_away_nursery(pseg); + long bytes_in_nursery = throw_away_nursery(pseg); /* reset all the modified objects (incl. re-adding GCFLAG_WRITE_BARRIER) */ reset_modified_from_other_segments(segment_num); @@ -476,6 +476,7 @@ stm_thread_local_t *tl = pseg->pub.running_thread; tl->shadowstack = pseg->shadowstack_at_start_of_transaction; tl->thread_local_obj = pseg->threadlocal_at_start_of_transaction; + tl->last_abort__bytes_in_nursery = bytes_in_nursery; /* reset these lists to NULL too on abort */ LIST_FREE(pseg->objects_pointing_to_nursery); diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c --- a/c7/stm/nursery.c +++ b/c7/stm/nursery.c @@ -215,15 +215,15 @@ _collect_now(item)); } -static void throw_away_nursery(struct stm_priv_segment_info_s *pseg) +static size_t throw_away_nursery(struct stm_priv_segment_info_s *pseg) { /* reset the nursery by zeroing it */ - size_t size; + size_t nursery_used; char *realnursery; realnursery = REAL_ADDRESS(pseg->pub.segment_base, _stm_nursery_start); - size = pseg->pub.nursery_current - (stm_char *)_stm_nursery_start; - memset(realnursery, 0, size); + nursery_used = pseg->pub.nursery_current - (stm_char *)_stm_nursery_start; + memset(realnursery, 0, nursery_used); pseg->pub.nursery_current = (stm_char *)_stm_nursery_start; @@ -250,6 +250,7 @@ } tree_clear(pseg->nursery_objects_shadows); + return nursery_used; } #define MINOR_NOTHING_TO_DO(pseg) \ diff --git a/c7/stm/nursery.h b/c7/stm/nursery.h --- a/c7/stm/nursery.h +++ b/c7/stm/nursery.h @@ -11,7 +11,7 @@ static void minor_collection(bool commit); static void check_nursery_at_transaction_start(void); -static void throw_away_nursery(struct stm_priv_segment_info_s *pseg); +static size_t throw_away_nursery(struct stm_priv_segment_info_s *pseg); static void major_do_minor_collections(void); static inline bool must_abort(void) { diff --git a/c7/stmgc.h b/c7/stmgc.h --- a/c7/stmgc.h +++ b/c7/stmgc.h @@ -57,7 +57,10 @@ the following raw region of memory is cleared. */ char *mem_clear_on_abort; size_t mem_bytes_to_clear_on_abort; - /* the next fields are handled automatically by the library */ + /* after an abort, some details about the abort are stored there. + (these fields are not modified on a successful commit) */ + long last_abort__bytes_in_nursery; + /* the next fields are handled internally by the library */ int associated_segment_num; struct stm_thread_local_s *prev, *next; } stm_thread_local_t; diff --git a/c7/test/support.py b/c7/test/support.py --- a/c7/test/support.py +++ b/c7/test/support.py @@ -17,6 +17,7 @@ object_t *thread_local_obj; char *mem_clear_on_abort; size_t mem_bytes_to_clear_on_abort; + long last_abort__bytes_in_nursery; int associated_segment_num; ...; } stm_thread_local_t; 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 @@ -433,118 +433,16 @@ lp1 = self.pop_root() self.check_char_everywhere(lp1, 'X') - # def test_resolve_write_write_no_conflict(self): - # self.start_transaction() - # p1 = stm_allocate(16) - # p2 = stm_allocate(16) - # p1[8] = 'a' - # p2[8] = 'A' - # self.commit_transaction(False) - # self.start_transaction() - # # - # self.switch(1) - # self.start_transaction() - # stm_write(p1) - # p1[8] = 'b' - # self.commit_transaction(False) - # # - # self.switch(0) - # stm_write(p2) - # p2[8] = 'C' - # self.commit_transaction(False) - # assert p1[8] == 'b' - # assert p2[8] == 'C' - - # def test_page_extra_malloc_unchanged_page(self): - # self.start_transaction() - # p1 = stm_allocate(16) - # p2 = stm_allocate(16) - # p1[8] = 'A' - # p2[8] = 'a' - # self.commit_transaction(False) - # self.start_transaction() - # # - # self.switch(1) - # self.start_transaction() - # stm_write(p1) - # assert p1[8] == 'A' - # p1[8] = 'B' - # self.commit_transaction(False) - # # - # self.switch(0) - # stm_read(p2) - # assert p2[8] == 'a' - # p3 = stm_allocate(16) # goes into the same page, which is - # p3[8] = ':' # not otherwise modified - # self.commit_transaction(False) - # # - # assert p1[8] == 'B' - # assert p2[8] == 'a' - # assert p3[8] == ':' - - # def test_page_extra_malloc_changed_page_before(self): - # self.start_transaction() - # p1 = stm_allocate(16) - # p2 = stm_allocate(16) - # p1[8] = 'A' - # p2[8] = 'a' - # self.commit_transaction(False) - # self.start_transaction() - # # - # self.switch(1) - # self.start_transaction() - # stm_write(p1) - # assert p1[8] == 'A' - # p1[8] = 'B' - # self.commit_transaction(False) - # # - # self.switch(0) - # stm_write(p2) - # assert p2[8] == 'a' - # p2[8] = 'b' - # p3 = stm_allocate(16) # goes into the same page, which I already - # p3[8] = ':' # modified just above - # self.commit_transaction(False) - # # - # assert p1[8] == 'B' - # assert p2[8] == 'b' - # assert p3[8] == ':' - - # def test_page_extra_malloc_changed_page_after(self): - # self.start_transaction() - # p1 = stm_allocate(16) - # p2 = stm_allocate(16) - # p1[8] = 'A' - # p2[8] = 'a' - # self.commit_transaction(False) - # self.start_transaction() - # # - # self.switch(1) - # self.start_transaction() - # stm_write(p1) - # assert p1[8] == 'A' - # p1[8] = 'B' - # self.commit_transaction(False) - # # - # self.switch(0) - # p3 = stm_allocate(16) # goes into the same page, which I will - # p3[8] = ':' # modify just below - # stm_write(p2) - # assert p2[8] == 'a' - # p2[8] = 'b' - # self.commit_transaction(False) - # # - # assert p1[8] == 'B' - # assert p2[8] == 'b' - # assert p3[8] == ':' - - # def test_overflow_write_history(self): - # self.start_transaction() - # plist = [stm_allocate(n) for n in range(16, 256, 8)] - # self.commit_transaction(False) - # # - # for i in range(20): - # self.start_transaction() - # for p in plist: - # stm_write(p) - # self.commit_transaction(False) + def test_last_abort__bytes_in_nursery(self): + self.start_transaction() + stm_allocate(56) + self.abort_transaction() + assert self.get_stm_thread_local().last_abort__bytes_in_nursery == 56 + self.start_transaction() + assert self.get_stm_thread_local().last_abort__bytes_in_nursery == 56 + self.commit_transaction() + assert self.get_stm_thread_local().last_abort__bytes_in_nursery == 56 + self.start_transaction() + assert self.get_stm_thread_local().last_abort__bytes_in_nursery == 56 + self.abort_transaction() + assert self.get_stm_thread_local().last_abort__bytes_in_nursery == 0 _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit