Author: Remi Meier <remi.me...@inf.ethz.ch> Branch: stmgc-c8-gcc Changeset: r79353:9ef3acdbc233 Date: 2015-09-01 17:31 +0200 http://bitbucket.org/pypy/pypy/changeset/9ef3acdbc233/
Log: import stmgc with hashtable fixes diff --git a/rpython/translator/stm/src_stm/revision b/rpython/translator/stm/src_stm/revision --- a/rpython/translator/stm/src_stm/revision +++ b/rpython/translator/stm/src_stm/revision @@ -1,1 +1,1 @@ -08c773f2b6ef +58f9e6d56296 diff --git a/rpython/translator/stm/src_stm/stm/core.h b/rpython/translator/stm/src_stm/stm/core.h --- a/rpython/translator/stm/src_stm/stm/core.h +++ b/rpython/translator/stm/src_stm/stm/core.h @@ -267,14 +267,6 @@ return stm_object_pages + segment_num * (NB_PAGES * 4096UL); } -static inline long get_num_segment_containing_address(char *addr) -{ - uintptr_t delta = addr - stm_object_pages; - uintptr_t result = delta / (NB_PAGES * 4096UL); - assert(result < NB_SEGMENTS); - return result; -} - static inline struct stm_segment_info_s *get_segment(long segment_num) { return (struct stm_segment_info_s *)REAL_ADDRESS( diff --git a/rpython/translator/stm/src_stm/stm/finalizer.c b/rpython/translator/stm/src_stm/stm/finalizer.c --- a/rpython/translator/stm/src_stm/stm/finalizer.c +++ b/rpython/translator/stm/src_stm/stm/finalizer.c @@ -486,12 +486,7 @@ LIST_FREE(f->run_finalizers); } -/* XXX: can there be a race between _invoke_general_finalizers - and _commit_finalizer on g_finalizers (+other places?)? - XXX: what happens in _execute_finalizer if the transaction - conflicts (or fails to become inevitable) in a finalizer? - (the run_finalizers list is half-way cleared?) - XXX: according to translator.backendopt.finalizer, getfield_gc +/* XXX: according to translator.backendopt.finalizer, getfield_gc for primitive types is a safe op in light finalizers. I don't think that's correct in general (maybe if getfield on *dying obj*). diff --git a/rpython/translator/stm/src_stm/stm/hashtable.c b/rpython/translator/stm/src_stm/stm/hashtable.c --- a/rpython/translator/stm/src_stm/stm/hashtable.c +++ b/rpython/translator/stm/src_stm/stm/hashtable.c @@ -285,7 +285,8 @@ if (rc > 6) { /* we can only enter here once! If we allocate stuff, we may run the GC, and so 'hashtableobj' might move afterwards. */ - if (_is_in_nursery(hashtableobj)) { + if (_is_in_nursery(hashtableobj) + && will_allocate_in_nursery(sizeof(stm_hashtable_entry_t))) { /* this also means that the hashtable is from this transaction and not visible to other segments yet, so the new entry can be nursery-allocated. */ @@ -325,9 +326,6 @@ stm_allocate_preexisting(sizeof(stm_hashtable_entry_t), (char *)&initial.header); hashtable->additions++; - /* make sure .object is NULL in all segments before - "publishing" the entry in the hashtable: */ - write_fence(); } table->items[i] = entry; write_fence(); /* make sure 'table->items' is written here */ @@ -362,6 +360,9 @@ stm_write((object_t *)entry); + /* this restriction may be lifted, see test_new_entry_if_nursery_full: */ + assert(IMPLY(_is_young((object_t *)entry), _is_young(hobj))); + uintptr_t i = list_count(STM_PSEGMENT->modified_old_objects); if (i > 0 && list_item(STM_PSEGMENT->modified_old_objects, i - 3) == (uintptr_t)entry) { @@ -486,7 +487,7 @@ objects in the segment of the running transaction. Otherwise, the base case is to read them all from segment zero. */ - long segnum = get_num_segment_containing_address((char *)hobj); + long segnum = get_segment_of_linear_address((char *)hobj); if (!IS_OVERFLOW_OBJ(get_priv_segment(segnum), hobj)) segnum = 0; diff --git a/rpython/translator/stm/src_stm/stm/nursery.h b/rpython/translator/stm/src_stm/stm/nursery.h --- a/rpython/translator/stm/src_stm/stm/nursery.h +++ b/rpython/translator/stm/src_stm/stm/nursery.h @@ -27,6 +27,20 @@ get_priv_segment(other_segment_num)->safe_point != SP_RUNNING); } +static inline bool will_allocate_in_nursery(size_t size_rounded_up) { + OPT_ASSERT(size_rounded_up >= 16); + OPT_ASSERT((size_rounded_up & 7) == 0); + + if (UNLIKELY(size_rounded_up >= _STM_FAST_ALLOC)) + return false; + + stm_char *p = STM_SEGMENT->nursery_current; + stm_char *end = p + size_rounded_up; + if (UNLIKELY((uintptr_t)end > STM_SEGMENT->nursery_end)) + return false; + return true; +} + #define must_abort() is_abort(STM_SEGMENT->nursery_end) static object_t *find_shadow(object_t *obj); _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit