Author: Remi Meier <[email protected]>
Branch: implement-id
Changeset: r218:7ed5c33f287e
Date: 2013-06-20 21:09 +0200
http://bitbucket.org/pypy/stmgc/changeset/7ed5c33f287e/
Log: doesn't crash
diff --git a/c4/nursery.c b/c4/nursery.c
--- a/c4/nursery.c
+++ b/c4/nursery.c
@@ -59,7 +59,7 @@
assert(tid == (tid & STM_USER_TID_MASK));
P->h_tid = tid;
P->h_revision = stm_private_rev_num;
- P->h_original = NULL;
+ P->h_original = 0;
return P;
}
@@ -77,7 +77,7 @@
if (P->h_original)
L->h_original = P->h_original;
else
- L->h_original = P;
+ L->h_original = (revision_t)P;
return L;
}
@@ -93,7 +93,7 @@
if (P->h_original)
L->h_original = P->h_original;
else
- L->h_original = P;
+ L->h_original = (revision_t)P;
return L;
}
@@ -114,28 +114,21 @@
//p->h_original == NULL
if (!(p->h_tid & GCFLAG_OLD)) {//(is_in_nursery(p)) {
- // preallocate old "original" outside
+ struct tx_descriptor *d = thread_descriptor;
+ spinlock_acquire(d->public_descriptor->collection_lock, 'I');
+ // preallocate old "original" outside;
// like stealing
- gcptr O = stmgc_duplicate_old(L);
- L->h_revision = (revision_t)O;
- L->h_original = O;
- L->h_tid |= GCFLAG_HAS_ID;
+ gcptr O = stmgc_duplicate_old(p);
+ p->h_revision = (revision_t)O;
+ p->h_original = (revision_t)O;
+ p->h_tid |= GCFLAG_HAS_ID;
-
- // could be stolen
- if (p->h_tid & GCFLAG_NURSERY_MOVED) {
-
- }
- }
- else if (p->h_tid & GCFLAG_NURSERY_MOVED) {
- if (p->h_tid & GCFLAG_PUBLIC) {
- // moved by stealing
-
- }
-
+ spinlock_release(d->public_descriptor->collection_lock);
+ return (revision_t)O;
}
else {
- assert(0);
+ // p is the original itself
+ return (revision_t)p;
}
}
@@ -161,7 +154,7 @@
return fresh_old_copy;
}
-static inline void copy_to_old_id_copy(gcptr obj, gcptr id)
+inline void copy_to_old_id_copy(gcptr obj, gcptr id)
{
size_t size = stmcb_size(obj);
memcpy(id, obj, size);
@@ -191,7 +184,8 @@
if (obj->h_tid & GCFLAG_HAS_ID) {
/* already has a place to go to */
- fresh_old_copy = copy_to_old_id_copy(obj, obj->h_original);
+ copy_to_old_id_copy(obj, (gcptr)obj->h_original);
+ fresh_old_copy = (gcptr)obj->h_original;
}
else {
/* make a copy of it outside */
diff --git a/c4/steal.c b/c4/steal.c
--- a/c4/steal.c
+++ b/c4/steal.c
@@ -11,6 +11,8 @@
struct stm_object_s stubs[STUB_NB_OBJS];
};
+inline void copy_to_old_id_copy(gcptr obj, gcptr id);
+
gcptr stm_stub_malloc(struct tx_public_descriptor *pd)
{
assert(pd->collection_lock != 0);
@@ -152,16 +154,16 @@
if (!(L->h_tid & GCFLAG_OLD)) {
gcptr O;
if (L->h_tid & GCFLAG_HAS_ID) {
+ O = (gcptr)L->h_original;
L->h_tid &= ~GCFLAG_HAS_ID;
- L->h_revision = (revision_t)L->h_original;
- copy_to_old_id_copy(L, L->h_original);
- O = L->h_original;
+ L->h_revision = (revision_t)O;
+ copy_to_old_id_copy(L, (gcptr)L->h_original);
} else {
/* Copy the object out of the other thread's nursery,
if needed */
O = stmgc_duplicate_old(L);
L->h_revision = (revision_t)O;
- L->h_original = O;
+ L->h_original = (revision_t)O;
}
L->h_tid |= GCFLAG_PUBLIC | GCFLAG_NURSERY_MOVED;
/* subtle: we need to remove L from the fxcache of the target
diff --git a/c4/steal.h b/c4/steal.h
--- a/c4/steal.h
+++ b/c4/steal.h
@@ -2,7 +2,7 @@
#define _SRCSTM_STEAL_H
-#define STUB_BLOCK_SIZE (16 * WORD) /* power of two */
+#define STUB_BLOCK_SIZE (32 * WORD) /* power of two */
#define STUB_THREAD(h) (*(struct tx_public_descriptor **) \
(((revision_t)(h)) & ~(STUB_BLOCK_SIZE-1)))
diff --git a/c4/stmgc.h b/c4/stmgc.h
--- a/c4/stmgc.h
+++ b/c4/stmgc.h
@@ -10,7 +10,7 @@
typedef struct stm_object_s {
revision_t h_tid;
revision_t h_revision;
- gcptr h_original;
+ revision_t h_original;
} *gcptr;
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit