[pypy-commit] pypy stm-thread-2: Remove "struct gcroot_s".
arigo
noreply at buildbot.pypy.org
Fri Sep 7 15:45:36 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-thread-2
Changeset: r57211:6ee3fa0d04d6
Date: 2012-09-07 15:43 +0200
http://bitbucket.org/pypy/pypy/changeset/6ee3fa0d04d6/
Log: Remove "struct gcroot_s".
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
@@ -364,6 +364,11 @@
CancelLocks(d);
+ gcptrlist_clear(&d->list_of_read_objects);
+ gcptrlist_clear(&d->gcroots);
+ g2l_clear(&d->global_to_local);
+ fxcache_clear(&d->recent_reads_cache);
+
#ifdef RPY_STM_DEBUG_PRINT
PYPY_DEBUG_START("stm-abort");
if (PYPY_HAVE_DEBUG_PRINTS)
@@ -391,10 +396,10 @@
static void init_transaction(struct tx_descriptor *d)
{
assert(d->active == 0);
- gcptrlist_clear(&d->list_of_read_objects);
- gcptrlist_clear(&d->gcroots);
- g2l_clear(&d->global_to_local);
- fxcache_clear(&d->recent_reads_cache);
+ assert(d->list_of_read_objects.size == 0);
+ assert(d->gcroots.size == 0);
+ assert(!g2l_any_entry(&d->global_to_local));
+ assert(fxcache_is_clear(&d->recent_reads_cache));
}
void BeginTransaction(jmp_buf* buf)
@@ -443,15 +448,14 @@
gcptr *items = d->gcroots.items;
for (i=0; i<=lastitem; i+=2)
{
- gcptr R = items[i];
+ gcptr R = items[i]->h_revision;
revision_t v = (revision_t)items[i+1];
- if (v != 0)
- {
- R->h_revision = v;
- // if we're going to retry later, and abort,
- // then we must not re-cancel the same entries
- items[i+1] = 0;
- }
+ if (v == 0)
+ break;
+ R->h_revision = v;
+ // if we're going to retry later, and abort,
+ // then we must not re-cancel the same entries
+ items[i+1] = (gcptr)0;
}
}
@@ -484,10 +488,12 @@
}
}
-static gcptr *FindRootsForLocalCollect(void)
+static gcptr *FindRootsForLocalCollect(struct tx_descriptor *d)
{
- struct tx_descriptor *d = thread_descriptor;
wlog_t *item;
+ if (d->gcroots.size != 0)
+ return d->gcroots.items;
+
G2L_LOOP_FORWARD(d->global_to_local, item)
{
gcptr R = item->addr;
@@ -520,7 +526,7 @@
struct tx_descriptor *d = thread_descriptor;
assert(d->active != 0);
if (d->gcroots.size == 0)
- FindRootsForLocalCollect(); /* for tests */
+ FindRootsForLocalCollect(d); /* for tests */
AcquireLocks(d);
@@ -556,8 +562,15 @@
if (!ValidateDuringCommit(d))
AbortTransaction(2);
}
+ /* we cannot abort any more from here */
+ d->setjmp_buf = NULL;
+ gcptrlist_clear(&d->list_of_read_objects);
+ g2l_clear(&d->global_to_local);
+ fxcache_clear(&d->recent_reads_cache);
+
UpdateChainHeads(d, cur_time);
+ gcptrlist_clear(&d->gcroots);
d->num_commits++;
d->active = 0;
}
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
@@ -48,12 +48,10 @@
}
}
-#if 0
static int g2l_any_entry(struct G2L *g2l)
{
return g2l->raw_current != g2l->raw_start;
}
-#endif
#define _G2L_LOOP(g2l, item, INITIAL, _PLUS_) \
{ \
@@ -266,6 +264,15 @@
revision_t cache[FX_ENTRIES];
};
+static int fxcache_is_clear(struct FXCache *fxcache)
+{
+ int i;
+ for (i=0; i<FX_ENTRIES; i++)
+ if (fxcache->cache[i])
+ return 0;
+ return 1;
+}
+
static void fxcache_clear(struct FXCache *fxcache)
{
memset(fxcache, 0, sizeof(struct FXCache));
diff --git a/pypy/translator/stm/src_stm/rpyintf.c b/pypy/translator/stm/src_stm/rpyintf.c
--- a/pypy/translator/stm/src_stm/rpyintf.c
+++ b/pypy/translator/stm/src_stm/rpyintf.c
@@ -39,7 +39,7 @@
struct tx_descriptor *d = thread_descriptor;
wlog_t *item;
void *tls = stm_get_tls();
- gcptr *gcroots = FindRootsForLocalCollect();
+ gcptr *gcroots = FindRootsForLocalCollect(d);
while (gcroots[0] != NULL)
{
@@ -203,7 +203,7 @@
}
void stm_nogc_stop_transaction(void)
{
- struct gcroot_s *gcroots;
+ gcptr *gcroots;
gcptr W = stm_nogc_chained_list;
stm_nogc_chained_list = NULL;
while (W) {
@@ -216,14 +216,14 @@
W = W_next;
}
- gcroots = FindRootsForLocalCollect();
- while (gcroots->R != NULL) {
- W = gcroots->L;
+ gcroots = FindRootsForLocalCollect(thread_descriptor);
+ while (gcroots[0] != NULL) {
+ W = gcroots[0];
assert((W->h_tid & (GCFLAG_GLOBAL |
GCFLAG_NOT_WRITTEN |
GCFLAG_LOCAL_COPY)) == GCFLAG_LOCAL_COPY);
W->h_tid |= GCFLAG_GLOBAL | GCFLAG_NOT_WRITTEN;
- gcroots++;
+ gcroots += 2;
}
}
void *pypy_g__stm_duplicate(void *src)
More information about the pypy-commit
mailing list