Author: Armin Rigo <[email protected]>
Branch:
Changeset: r100:3f28eb08b77f
Date: 2013-06-12 19:12 +0200
http://bitbucket.org/pypy/stmgc/changeset/3f28eb08b77f/
Log: progress
diff --git a/c4/et.c b/c4/et.c
--- a/c4/et.c
+++ b/c4/et.c
@@ -120,7 +120,7 @@
/* we update P_prev->h_revision as a shortcut */
/* XXX check if this really gives a worse performance than only
doing this write occasionally based on a counter in d */
- P_prev->h_revision = v;
+ //P_prev->h_revision = v; XXX re-enable!
P = (gcptr)v;
v = ACCESS_ONCE(P->h_revision);
if (!(v & 1)) // "is a pointer", i.e. "has a more recent rev"
@@ -229,16 +229,26 @@
}
}
-gcptr _stm_nonrecord_barrier(gcptr G)
+gcptr _stm_nonrecord_barrier(gcptr P)
{
/* follows the logic in stm_DirectReadBarrier() */
struct tx_descriptor *d = thread_descriptor;
- gcptr P = G;
revision_t v;
+ fprintf(stderr, "_stm_nonrecord_barrier: %p ", P);
+
+ restart_all:
+ if (P->h_revision == stm_private_rev_num)
+ {
+ /* private */
+ fprintf(stderr, "private\n");
+ return P;
+ }
+
if (P->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED)
{
assert(!(P->h_revision & 1));
+ fprintf(stderr, "private_from_protected\n");
return P;
}
@@ -246,6 +256,9 @@
{
while (1)
{
+ assert(P->h_tid & GCFLAG_PUBLIC);
+ fprintf(stderr, "public ");
+
wlog_t *item;
gcptr L;
G2L_FIND(d->public_to_private, P, item, goto no_private_obj);
@@ -255,8 +268,7 @@
assert(P->h_tid & GCFLAG_PUBLIC_TO_PRIVATE);
assert(!(L->h_tid & GCFLAG_PUBLIC));
assert(is_private(L));
- fprintf(stderr, "_stm_nonrecord_barrier: %p -> %p "
- "public_to_private\n", G, L);
+ fprintf(stderr, "-public_to_private-> %p private\n", L);
return L;
no_private_obj:;
@@ -270,25 +282,38 @@
if (v & 2)
goto follow_stub;
P = (gcptr)v;
- assert(P->h_tid & GCFLAG_PUBLIC);
+ fprintf(stderr, "-> %p ", P);
}
if (UNLIKELY(v > d->start_time))
{
- fprintf(stderr, "_stm_nonrecord_barrier: %p -> NULL changed\n", G);
+ fprintf(stderr, "too recent!\n");
return NULL; // object too recent
}
- fprintf(stderr, "_stm_nonrecord_barrier: %p -> %p public\n", G, P);
+ fprintf(stderr, "\n");
}
else
{
- fprintf(stderr, "_stm_nonrecord_barrier: %p -> %p protected\n", G, P);
+ fprintf(stderr, "protected\n");
}
return P;
follow_stub:;
- fprintf(stderr, "_stm_nonrecord_barrier: %p -> %p stub\n ", G, P);
- P = (gcptr)(v - 2);
- return _stm_nonrecord_barrier(P);
+ if (STUB_THREAD(P) == d->public_descriptor)
+ {
+ P = (gcptr)(v - 2);
+ fprintf(stderr, "stub -> %p ", P);
+ }
+ else
+ {
+ P = (gcptr)(v - 2);
+ fprintf(stderr, "stub -foreign-> %p ", P);
+ if (P->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED)
+ {
+ P = (gcptr)P->h_revision; /* the backup copy */
+ fprintf(stderr, "-backup-> %p ", P);
+ }
+ }
+ goto restart_all;
}
#if 0
diff --git a/c4/test/test_et.py b/c4/test/test_et.py
--- a/c4/test/test_et.py
+++ b/c4/test/test_et.py
@@ -2,6 +2,9 @@
from support import *
+SHORTCUT = False # XXXXXXXXXXXXXXXXX
+
+
def setup_function(f):
lib.stm_clear_between_tests()
lib.stm_initialize_tests(getattr(f, 'max_aborts', 0))
@@ -146,6 +149,8 @@
p2.h_revision = ffi.cast("revision_t", p3)
assert lib.stm_read_barrier(p1) == p3
assert list_of_read_objects() == [p3]
+ if not SHORTCUT:
+ py.test.skip("re-enable!")
assert p1.h_revision == int(ffi.cast("revision_t", p3)) # shortcutted
def test_read_barrier_public_to_private():
@@ -222,7 +227,8 @@
assert classify(p2) == "public"
assert lib.rawgetlong(p2, 0) == 2782172
assert p2 == lib.stm_read_barrier(p) # short-circuit h_revision
- assert p.h_revision == int(ffi.cast("revision_t", p2))
+ if SHORTCUT:
+ assert p.h_revision == int(ffi.cast("revision_t", p2))
assert p2 == lib.stm_read_barrier(p)
assert p2 == plist[-1]
assert classify(p2) == "public"
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit