Author: Remi Meier <remi.me...@inf.ethz.ch> Branch: Changeset: r1336:3efac6fcb465 Date: 2014-09-03 10:35 +0200 http://bitbucket.org/pypy/stmgc/changeset/3efac6fcb465/
Log: re-introduce objects_pointing_to_nursery diff --git a/c8/stm/core.c b/c8/stm/core.c --- a/c8/stm/core.c +++ b/c8/stm/core.c @@ -5,7 +5,16 @@ void _stm_write_slowpath(object_t *obj) { + assert(_seems_to_be_running_transaction()); + assert(!_is_in_nursery(obj)); + assert(obj->stm_flags & GCFLAG_WRITE_BARRIER); + stm_read(obj); + + LIST_APPEND(STM_PSEGMENT->modified_old_objects, obj); + + LIST_APPEND(STM_PSEGMENT->objects_pointing_to_nursery, obj); + obj->stm_flags &= ~GCFLAG_WRITE_BARRIER; } static void reset_transaction_read_version(void) @@ -54,6 +63,7 @@ } assert(list_is_empty(STM_PSEGMENT->modified_old_objects)); + assert(list_is_empty(STM_PSEGMENT->objects_pointing_to_nursery)); check_nursery_at_transaction_start(); } @@ -75,6 +85,9 @@ static void _finish_transaction() { stm_thread_local_t *tl = STM_SEGMENT->running_thread; + + list_clear(STM_PSEGMENT->objects_pointing_to_nursery); + release_thread_segment(tl); /* cannot access STM_SEGMENT or STM_PSEGMENT from here ! */ } diff --git a/c8/stm/core.h b/c8/stm/core.h --- a/c8/stm/core.h +++ b/c8/stm/core.h @@ -51,6 +51,7 @@ struct stm_segment_info_s pub; struct list_s *modified_old_objects; + struct list_s *objects_pointing_to_nursery; /* For debugging */ #ifndef NDEBUG diff --git a/c8/stm/misc.c b/c8/stm/misc.c --- a/c8/stm/misc.c +++ b/c8/stm/misc.c @@ -44,7 +44,6 @@ #ifdef STM_TESTS - long _stm_count_modified_old_objects(void) { if (STM_PSEGMENT->modified_old_objects == NULL) @@ -52,10 +51,22 @@ return list_count(STM_PSEGMENT->modified_old_objects); } +long _stm_count_objects_pointing_to_nursery(void) +{ + if (STM_PSEGMENT->objects_pointing_to_nursery == NULL) + return -1; + return list_count(STM_PSEGMENT->objects_pointing_to_nursery); +} object_t *_stm_enum_modified_old_objects(long index) { return (object_t *)list_item( STM_PSEGMENT->modified_old_objects, index); } + +object_t *_stm_enum_objects_pointing_to_nursery(long index) +{ + return (object_t *)list_item( + STM_PSEGMENT->objects_pointing_to_nursery, index); +} #endif diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -77,6 +77,8 @@ { dprintf(("minor_collection commit=%d\n", (int)commit)); + assert(list_is_empty(STM_PSEGMENT->objects_pointing_to_nursery)); + throw_away_nursery(get_priv_segment(STM_SEGMENT->segment_num)); } diff --git a/c8/stm/setup.c b/c8/stm/setup.c --- a/c8/stm/setup.c +++ b/c8/stm/setup.c @@ -112,6 +112,7 @@ pr->pub.segment_num = i; pr->pub.segment_base = segment_base; pr->modified_old_objects = list_create(); + pr->objects_pointing_to_nursery = list_create(); pr->pub.transaction_read_version = 0xff; } @@ -137,6 +138,8 @@ long i; for (i = 1; i <= NB_SEGMENTS; i++) { struct stm_priv_segment_info_s *pr = get_priv_segment(i); + assert(list_is_empty(pr->objects_pointing_to_nursery)); + list_free(pr->objects_pointing_to_nursery); list_free(pr->modified_old_objects); } diff --git a/c8/stmgc.h b/c8/stmgc.h --- a/c8/stmgc.h +++ b/c8/stmgc.h @@ -75,7 +75,9 @@ bool _stm_in_transaction(stm_thread_local_t *tl); void _stm_set_nursery_free_count(uint64_t free_count); long _stm_count_modified_old_objects(void); +long _stm_count_objects_pointing_to_nursery(void); object_t *_stm_enum_modified_old_objects(long index); +object_t *_stm_enum_objects_pointing_to_nursery(long index); #endif /* ==================== HELPERS ==================== */ diff --git a/c8/test/support.py b/c8/test/support.py --- a/c8/test/support.py +++ b/c8/test/support.py @@ -54,7 +54,9 @@ object_t * _get_ptr(object_t *obj, int n); long _stm_count_modified_old_objects(void); +long _stm_count_objects_pointing_to_nursery(void); object_t *_stm_enum_modified_old_objects(long index); +object_t *_stm_enum_objects_pointing_to_nursery(long index); void *memset(void *s, int c, size_t n); 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 @@ -51,7 +51,7 @@ stm_write(lp1) assert stm_was_written(lp1) assert modified_old_objects() == [] # object not old - assert objects_pointing_to_nursery() == None # short transaction + assert objects_pointing_to_nursery() == [] # short transaction self.commit_transaction() def test_allocate_old(self): @@ -214,7 +214,7 @@ self.commit_transaction() - + def test_start_transaction_updates(self): self.start_transaction() lp1 = stm_allocate(16) @@ -233,7 +233,7 @@ self.switch(0) self.start_transaction() assert stm_get_char(lp1) == 'b' - + def test_resolve_no_conflict_empty(self): self.start_transaction() @@ -254,11 +254,11 @@ self.commit_transaction() lp1 = self.pop_root() # 'a' in SHARED_PAGE - + self.start_transaction() - + self.switch(1) - + self.start_transaction() stm_write(lp1) # privatize page p1 = stm_get_real_address(lp1) @@ -307,7 +307,7 @@ self.push_root(lp1) self.commit_transaction() lp1 = self.pop_root() - + self.start_transaction() stm_read(lp1) # @@ -325,7 +325,7 @@ self.push_root(lp1) self.commit_transaction() lp1 = self.pop_root() - + self.start_transaction() # self.switch(1) @@ -344,7 +344,7 @@ self.push_root(lp1) self.commit_transaction() lp1 = self.pop_root() - + self.start_transaction() stm_write(lp1) # acquire lock # _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit