Author: Armin Rigo <[email protected]>
Branch:
Changeset: r83:185610f34659
Date: 2013-06-09 10:23 +0200
http://bitbucket.org/pypy/stmgc/changeset/185610f34659/
Log: tweaks
diff --git a/c4/et.c b/c4/et.c
--- a/c4/et.c
+++ b/c4/et.c
@@ -74,25 +74,18 @@
v = ACCESS_ONCE(P->h_revision);
if (!(v & 1)) // "is a pointer", i.e.
{ // "has a more recent revision"
- /* if we land on a P in read_barrier_cache: just return it */
- gcptr P_next = (gcptr)v;
- if (FXCACHE_AT(P_next) == P_next)
- {
- fprintf(stderr, "read_barrier: %p -> %p fxcache\n", G, P_next);
- return P_next;
- }
-
- if (P->h_tid & GCFLAG_STUB)
+ if (v & 2)
goto follow_stub;
gcptr P_prev = P;
- P = P_next;
+ P = (gcptr)v;
assert(P->h_tid & GCFLAG_PUBLIC);
v = ACCESS_ONCE(P->h_revision);
+
if (!(v & 1)) // "is a pointer", i.e.
{ // "has a more recent revision"
- if (P->h_tid & GCFLAG_STUB)
+ if (v & 2)
goto follow_stub;
/* we update P_prev->h_revision as a shortcut */
@@ -104,6 +97,13 @@
}
}
+ /* if we land on a P in read_barrier_cache: just return it */
+ if (FXCACHE_AT(P) == P)
+ {
+ fprintf(stderr, "read_barrier: %p -> %p fxcache\n", G, P);
+ return P;
+ }
+
if (P->h_tid & GCFLAG_PUBLIC_TO_PRIVATE)
{
wlog_t *item;
@@ -144,7 +144,7 @@
if (foreign_pd == d->public_descriptor)
{
/* same thread */
- P = (gcptr)P->h_revision;
+ P = (gcptr)v;
assert(!(P->h_tid & GCFLAG_PUBLIC));
if (P->h_revision == stm_private_rev_num)
{
@@ -735,7 +735,7 @@
gcptr stub = stm_stub_malloc(d->public_descriptor);
stub->h_tid = GCFLAG_PUBLIC | GCFLAG_STUB;
- stub->h_revision = (revision_t)L;
+ stub->h_revision = ((revision_t)L) | 2;
item->val = stub;
} G2L_LOOP_END;
diff --git a/c4/et.h b/c4/et.h
--- a/c4/et.h
+++ b/c4/et.h
@@ -50,9 +50,10 @@
* GCFLAG_STOLEN is set of protected objects after we notice that they
* have been stolen.
*
- * GCFLAG_STUB is set on stub objects made by stealing or by major
- * collections. It's removed once the stub's protected h_revision
- * target is stolen and replaced by a regular public object.
+ * GCFLAG_STUB is set for debugging on stub objects made by stealing or
+ * by major collections. 'p_stub->h_revision' might be a value
+ * that is == 2 (mod 4): in this case they point to a protected/private
+ * object that belongs to the thread 'STUB_THREAD(p_stub)'.
*/
#define GCFLAG_OLD (STM_FIRST_GCFLAG << 0)
#define GCFLAG_VISITED (STM_FIRST_GCFLAG << 1)
@@ -63,7 +64,7 @@
#define GCFLAG_WRITE_BARRIER (STM_FIRST_GCFLAG << 6)
#define GCFLAG_NURSERY_MOVED (STM_FIRST_GCFLAG << 7)
#define GCFLAG_STOLEN (STM_FIRST_GCFLAG << 8)
-#define GCFLAG_STUB (STM_FIRST_GCFLAG << 9)
+#define GCFLAG_STUB (STM_FIRST_GCFLAG << 9) /* debugging */
/* this value must be reflected in PREBUILT_FLAGS in stmgc.h */
#define GCFLAG_PREBUILT (GCFLAG_VISITED | \
@@ -166,6 +167,7 @@
gcptr _stm_nonrecord_barrier(gcptr, int *);
gcptr stm_get_backup_copy(gcptr);
gcptr stm_get_read_obj(long); /* debugging */
+gcptr stmgc_duplicate(gcptr);
int DescriptorInit(void);
void DescriptorDone(void);
diff --git a/c4/steal.c b/c4/steal.c
--- a/c4/steal.c
+++ b/c4/steal.c
@@ -49,18 +49,17 @@
spinlock_acquire(foreign_pd->collection_lock, 'S'); /*stealing*/
- if (!(P->h_tid & GCFLAG_STUB))
+ revision_t v = ACCESS_ONCE(P->h_revision);
+ if ((v & 3) != 2)
goto done; /* un-stubbed while we waited for the lock */
- /* XXX check for now that P is a regular protected object */
- gcptr L = (gcptr)P->h_revision;
+ gcptr L = (gcptr)(v - 2);
gcptr Q = stmgc_duplicate(L);
Q->h_tid |= GCFLAG_PUBLIC;
- P->h_revision = (revision_t)Q;
smp_wmb();
- P->h_tid &= ~GCFLAG_STUB;
+ P->h_revision = (revision_t)Q;
done:
spinlock_release(foreign_pd->collection_lock);
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit