[pypy-commit] pypy stmgc-c4: import stmgc
Raemi
noreply at buildbot.pypy.org
Mon Nov 18 11:21:01 CET 2013
Author: Remi Meier <remi.meier at gmail.com>
Branch: stmgc-c4
Changeset: r68202:88a0f0cc46a5
Date: 2013-11-18 11:20 +0100
http://bitbucket.org/pypy/pypy/changeset/88a0f0cc46a5/
Log: import stmgc
diff --git a/rpython/translator/stm/src_stm/et.c b/rpython/translator/stm/src_stm/et.c
--- a/rpython/translator/stm/src_stm/et.c
+++ b/rpython/translator/stm/src_stm/et.c
@@ -139,6 +139,7 @@
d->count_reads++;
assert(IMPLIES(!(P->h_tid & GCFLAG_OLD), stmgc_is_in_nursery(d, P)));
+ assert(G->h_revision != 0);
restart_all:
if (P->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED)
@@ -356,7 +357,7 @@
assert(P->h_tid & GCFLAG_PUBLIC);
assert(IMPLIES(!(P->h_tid & GCFLAG_OLD),
stmgc_is_in_nursery(thread_descriptor, P)));
-
+ assert(P->h_revision != 0);
revision_t v = ACCESS_ONCE(P->h_revision);
assert(IS_POINTER(v)); /* "is a pointer", "has a more recent revision" */
@@ -661,6 +662,7 @@
gcptr stm_RepeatWriteBarrier(gcptr P)
{
+ assert(P->h_revision != 0);
assert(IMPLIES(!(P->h_tid & GCFLAG_OLD),
stmgc_is_in_nursery(thread_descriptor, P)));
@@ -674,6 +676,7 @@
gcptr stm_WriteBarrier(gcptr P)
{
+ assert(P->h_revision != 0);
assert(!(P->h_tid & GCFLAG_IMMUTABLE));
assert((P->h_tid & GCFLAG_STUB) ||
stmgc_size(P) > sizeof(struct stm_stub_s) - WORD);
diff --git a/rpython/translator/stm/src_stm/extra.c b/rpython/translator/stm/src_stm/extra.c
--- a/rpython/translator/stm/src_stm/extra.c
+++ b/rpython/translator/stm/src_stm/extra.c
@@ -66,7 +66,7 @@
intptr_t stm_allocate_public_integer_address(gcptr obj)
-{
+{ /* push roots! */
struct tx_descriptor *d = thread_descriptor;
gcptr stub;
intptr_t result;
@@ -76,6 +76,12 @@
During major collections, we visit them and update
their references. */
+ /* stm_register_integer_address needs to run in inevitable
+ transaction */
+ stm_push_root(obj);
+ stm_become_inevitable("stm_allocate_public_integer_address");
+ obj = stm_pop_root();
+
/* we don't want to deal with young objs */
if (!(obj->h_tid & GCFLAG_OLD)) {
stm_push_root(obj);
@@ -94,9 +100,11 @@
orig = (gcptr)obj->h_original;
}
- if (orig->h_tid & GCFLAG_PUBLIC) {
- /* the original is public, so we can take that as a non-movable
- object to register */
+ if ((orig->h_tid & (GCFLAG_PUBLIC | GCFLAG_PREBUILT_ORIGINAL))
+ == (GCFLAG_PUBLIC | GCFLAG_PREBUILT_ORIGINAL)) {
+ /* public is not enough as public stubs may get replaced
+ by the protected object they point to, if they are in the
+ same thread (I think...) */
result = (intptr_t)orig;
}
else {
@@ -116,9 +124,11 @@
result = (intptr_t)stub;
}
spinlock_release(d->public_descriptor->collection_lock);
+
+ dprintf(("allocate_public_int_adr(%p): %p", obj, (void*)result));
+
stm_register_integer_address(result);
- dprintf(("allocate_public_int_adr(%p): %p", obj, (void*)result));
return result;
}
diff --git a/rpython/translator/stm/src_stm/gcpage.c b/rpython/translator/stm/src_stm/gcpage.c
--- a/rpython/translator/stm/src_stm/gcpage.c
+++ b/rpython/translator/stm/src_stm/gcpage.c
@@ -219,10 +219,11 @@
/***** registering of small stubs as integer addresses *****/
void stm_register_integer_address(intptr_t adr)
-{
+{ /* needs to be inevitable! */
wlog_t *found;
gcptr obj = (gcptr)adr;
/* current limitations for 'adr': smallstub or h_original */
+ assert(stm_active == 2);
assert((obj->h_tid & GCFLAG_SMALLSTUB)
|| (obj->h_original == 0 || obj->h_tid & GCFLAG_PREBUILT_ORIGINAL));
assert(obj->h_tid & GCFLAG_PUBLIC);
@@ -242,7 +243,7 @@
}
void stm_unregister_integer_address(intptr_t adr)
-{
+{ /* push roots! */
wlog_t *found;
gcptr obj = (gcptr)adr;
@@ -250,6 +251,11 @@
|| (obj->h_original == 0 || obj->h_tid & GCFLAG_PREBUILT_ORIGINAL));
assert(obj->h_tid & GCFLAG_PUBLIC);
+ /* become inevitable because we would have to re-register them
+ on abort, but make sure only to re-register if not registered
+ in the same aborted transaction (XXX) */
+ stm_become_inevitable("stm_unregister_integer_address()");
+
stmgcpage_acquire_global_lock();
/* find and decrement refcount */
@@ -528,12 +534,18 @@
G2L_LOOP_FORWARD(registered_objs, item) {
gcptr R = item->addr;
assert(R->h_tid & GCFLAG_PUBLIC);
-
- if ((R->h_original == 0) || (R->h_tid & GCFLAG_PREBUILT_ORIGINAL)) {
- /* the obj is an original and will therefore survive: */
- gcptr V = stmgcpage_visit(R);
- assert(V == R);
+
+ if (R->h_tid & GCFLAG_PREBUILT_ORIGINAL) {
+ /* already done by mark_prebuilt_roots */
+ assert((R->h_tid & (GCFLAG_MARKED|GCFLAG_VISITED|GCFLAG_PUBLIC))
+ == (GCFLAG_MARKED|GCFLAG_VISITED|GCFLAG_PUBLIC));
+ continue;
}
+ /* else if (R->h_original == 0) { */
+ /* /\* the obj is an original and will therefore survive: *\/ */
+ /* gcptr V = visit_public(R, NULL); */
+ /* assert(V == R); */
+ /* } */
else {
assert(R->h_tid & GCFLAG_SMALLSTUB); /* only case for now */
/* make sure R stays valid: */
diff --git a/rpython/translator/stm/src_stm/nursery.c b/rpython/translator/stm/src_stm/nursery.c
--- a/rpython/translator/stm/src_stm/nursery.c
+++ b/rpython/translator/stm/src_stm/nursery.c
@@ -85,7 +85,7 @@
}
#ifdef _GC_DEBUG
if (P != NULL) {
- assert(P->h_tid != 0);
+ assert((P->h_tid & STM_USER_TID_MASK) == (tid & STM_USER_TID_MASK));
assert_cleared(((char *)P) + sizeof(revision_t),
size - sizeof(revision_t));
}
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 @@
-14ac008e70a5
+68677625f2be
diff --git a/rpython/translator/stm/src_stm/stmgc.h b/rpython/translator/stm/src_stm/stmgc.h
--- a/rpython/translator/stm/src_stm/stmgc.h
+++ b/rpython/translator/stm/src_stm/stmgc.h
@@ -39,9 +39,9 @@
/* allocates a public reference to the object that will
not be freed until stm_unregister_integer_address is
- called on the result */
+ called on the result (push roots!) */
intptr_t stm_allocate_public_integer_address(gcptr);
-void stm_unregister_integer_address(intptr_t);
+void stm_unregister_integer_address(intptr_t); /* push roots too! */
/* returns a never changing hash for the object */
@@ -194,6 +194,7 @@
void stm_call_on_abort(void *key, void callback(void *));
/* only user currently is stm_allocate_public_integer_address() */
+/* needs to be in an inevitable transaction! */
void stm_register_integer_address(intptr_t);
/* enter single-threaded mode. Used e.g. when patching assembler
More information about the pypy-commit
mailing list