Author: Armin Rigo <[email protected]>
Branch: stm-gc
Changeset: r54525:a046810511bf
Date: 2012-04-19 11:57 +0200
http://bitbucket.org/pypy/pypy/changeset/a046810511bf/
Log: Partial fix: don't record orecs when running in an inevitable
transaction (like the main thread). Should be improved also for
non-inevitable transactions as documented in lists.c.
diff --git a/pypy/translator/stm/src_stm/et.c b/pypy/translator/stm/src_stm/et.c
--- a/pypy/translator/stm/src_stm/et.c
+++ b/pypy/translator/stm/src_stm/et.c
@@ -412,14 +412,21 @@
/* lazy/lazy read instrumentation */
#define STM_DO_READ(READ_OPERATION) \
+ if (is_inevitable(d)) { \
+ /* if is_inevitable(), then we don't need to do the checking of */ \
+ /* o->version done below --- but more importantly, we don't need */ \
+ /* to insert o in the OrecList */ \
+ READ_OPERATION; \
+ } \
+ else { \
retry: \
/* read the orec BEFORE we read anything else */ \
ovt = o->version; \
CFENCE; \
\
- /* this tx doesn't hold any locks, so if the lock for this addr is \
- held, there is contention. A lock is never hold for too long, \
- so spinloop until it is released. */ \
+ /* this tx doesn't hold any locks, so if the lock for this addr is */ \
+ /* held, there is contention. A lock is never hold for too long, */ \
+ /* so spinloop until it is released. */ \
if (IS_LOCKED_OR_NEWER(ovt, d->start_time)) \
{ \
if (IS_LOCKED(ovt)) { \
@@ -440,7 +447,8 @@
if (__builtin_expect(o->version != ovt, 0)) \
goto retry; /* oups, try again */ \
\
- oreclist_insert(&d->reads, (orec_t*)o);
+ oreclist_insert(&d->reads, (orec_t*)o); \
+ }
#define STM_READ_WORD(SIZE, SUFFIX, TYPE) \
@@ -451,8 +459,9 @@
owner_version_t ovt; \
\
assert(sizeof(TYPE) == SIZE); \
- \
- /* XXX try to remove this check from the main path */ \
+ /* XXX try to remove this check from the main path: */ \
+ /* d is NULL only when in non-main threads but */ \
+ /* outside a transaction. */ \
if (d == NULL) \
return *(TYPE *)(((char *)addr) + offset); \
\
@@ -468,7 +477,8 @@
not_found:; \
} \
\
- STM_DO_READ(TYPE tmp = *(TYPE *)(((char *)addr) + offset)); \
+ TYPE tmp; \
+ STM_DO_READ(tmp = *(TYPE *)(((char *)addr) + offset)); \
return tmp; \
}
diff --git a/pypy/translator/stm/src_stm/lists.c
b/pypy/translator/stm/src_stm/lists.c
--- a/pypy/translator/stm/src_stm/lists.c
+++ b/pypy/translator/stm/src_stm/lists.c
@@ -230,6 +230,9 @@
static void oreclist_insert(struct OrecList *oreclist, orec_t *newitem)
{
+ /* XXX it would be a good idea to try to compactify the list,
+ by removing duplicate entries. We are only interested in
+ the set of entries present, and the order doesn't matter. */
if (oreclist->size == oreclist->alloc)
_oreclist_grow(oreclist);
oreclist->items[oreclist->size++] = newitem;
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit