Author: Remi Meier <[email protected]>
Branch: weakref
Changeset: r426:4cad3aa5a20b
Date: 2013-07-19 15:46 +0200
http://bitbucket.org/pypy/stmgc/changeset/4cad3aa5a20b/
Log: magically make it work (we shouldn't run over list_of_read_objects
after a major collection decided to partially fix it (or not at
all))
diff --git a/c4/demo_random.c b/c4/demo_random.c
--- a/c4/demo_random.c
+++ b/c4/demo_random.c
@@ -205,10 +205,10 @@
weaknodeptr allocate_weaknodeptr(nodeptr to)
{
weaknodeptr w;
- push_roots(1);
+ push_roots();
w = (weaknodeptr)stm_weakref_allocate(WEAKNODE_SIZE, GCTID_WEAKREF,
(gcptr)to);
- pop_roots(1);
+ pop_roots();
return w;
}
@@ -490,7 +490,6 @@
assert(stm_get_tid((gcptr)ww) == GCTID_WEAKREF);
if (ww->node) {
check((gcptr)ww->node);
- return (gcptr)ww->node;
}
else {
t->weakref = NULL;
diff --git a/c4/extra.c b/c4/extra.c
--- a/c4/extra.c
+++ b/c4/extra.c
@@ -3,7 +3,7 @@
void stm_copy_to_old_id_copy(gcptr obj, gcptr id)
{
- //assert(!is_in_nursery(thread_descriptor, id));
+ //assert(!stmgc_is_in_nursery(thread_descriptor, id));
assert(id->h_tid & GCFLAG_OLD);
size_t size = stmgc_size(obj);
diff --git a/c4/gcpage.c b/c4/gcpage.c
--- a/c4/gcpage.c
+++ b/c4/gcpage.c
@@ -461,11 +461,11 @@
assert(gcptrlist_size(&d->public_with_young_copy) == 0);
assert(gcptrlist_size(&d->public_descriptor->stolen_objects) == 0);
assert(gcptrlist_size(&d->public_descriptor->stolen_young_stubs) == 0);
+ assert(gcptrlist_size(&d->old_objects_to_trace) == 0);
/* NOT NECESSARILY EMPTY:
- list_of_read_objects
- private_from_protected
- public_to_private
- - old_objects_to_trace
*/
assert(gcptrlist_size(&d->list_of_read_objects) ==
d->num_read_objects_known_old);
@@ -497,8 +497,15 @@
/* If we're aborting this transaction anyway, we don't need to do
* more here.
*/
- if (d->active < 0)
- return; /* already "aborted" during forced minor collection */
+ if (d->active < 0) {
+ /* already "aborted" during forced minor collection
+ clear list of read objects so that a possible minor collection
+ before the abort doesn't trip
+ fix_list_of_read_objects should not run */
+ gcptrlist_clear(&d->list_of_read_objects);
+ d->num_read_objects_known_old = 0;
+ return;
+ }
if (d->active == 2) {
/* inevitable transaction: clear the list of read objects */
@@ -527,6 +534,9 @@
dprintf(("ABRT_COLLECT_MAJOR %p: "
"%p was read but modified already\n", d, obj));
AbortTransactionAfterCollect(d, ABRT_COLLECT_MAJOR);
+ /* fix_list_of_read_objects should not run */
+ gcptrlist_clear(&d->list_of_read_objects);
+ d->num_read_objects_known_old = 0;
return;
}
diff --git a/c4/nursery.c b/c4/nursery.c
--- a/c4/nursery.c
+++ b/c4/nursery.c
@@ -1,7 +1,6 @@
#include "stmimpl.h"
-
-static int is_in_nursery(struct tx_descriptor *d, gcptr obj)
+int stmgc_is_in_nursery(struct tx_descriptor *d, gcptr obj)
{
return (d->nursery_base <= (char*)obj && ((char*)obj) < d->nursery_end);
}
@@ -155,7 +154,7 @@
gcptr fresh_old_copy;
struct tx_descriptor *d = thread_descriptor;
- if (!is_in_nursery(d, obj)) {
+ if (!stmgc_is_in_nursery(d, obj)) {
/* not a nursery object */
}
else {
@@ -382,7 +381,7 @@
for (i = d->list_of_read_objects.size - 1; i >= limit; --i) {
gcptr obj = items[i];
- if (!is_in_nursery(d, obj)) {
+ if (!stmgc_is_in_nursery(d, obj)) {
/* non-young or visited young objects are kept */
continue;
}
diff --git a/c4/nursery.h b/c4/nursery.h
--- a/c4/nursery.h
+++ b/c4/nursery.h
@@ -67,5 +67,6 @@
size_t stmgc_size(gcptr);
void stmgc_trace(gcptr, void visit(gcptr *));
void stmgc_minor_collect_soon(void);
+int stmgc_is_in_nursery(struct tx_descriptor *d, gcptr obj);
#endif
diff --git a/c4/test/support.py b/c4/test/support.py
--- a/c4/test/support.py
+++ b/c4/test/support.py
@@ -134,6 +134,7 @@
#define GCFLAG_STUB ...
#define GCFLAG_PRIVATE_FROM_PROTECTED ...
#define GCFLAG_HAS_ID ...
+ #define GCFLAG_IMMUTABLE ...
#define ABRT_MANUAL ...
typedef struct { ...; } page_header_t;
''')
diff --git a/c4/test/test_weakref.py b/c4/test/test_weakref.py
--- a/c4/test/test_weakref.py
+++ b/c4/test/test_weakref.py
@@ -15,7 +15,7 @@
def test_weakref_invalidate(self):
p2 = nalloc(HDR)
p1 = lib.stm_weakref_allocate(WEAKREF_SIZE, WEAKREF_TID, p2)
- assert p1.h_tid == WEAKREF_TID # no GC flags
+ assert p1.h_tid == WEAKREF_TID | GCFLAG_IMMUTABLE
assert p1.h_revision == lib.get_private_rev_num()
assert lib.rawgetptr(p1, 0) == p2
lib.stm_push_root(p1)
@@ -31,7 +31,7 @@
def test_weakref_keep(self):
p2 = nalloc(HDR)
p1 = lib.stm_weakref_allocate(WEAKREF_SIZE, WEAKREF_TID, p2)
- assert p1.h_tid == WEAKREF_TID # no GC flags
+ assert p1.h_tid == WEAKREF_TID | GCFLAG_IMMUTABLE
assert p1.h_revision == lib.get_private_rev_num()
assert lib.rawgetptr(p1, 0) == p2
lib.stm_push_root(p1)
@@ -44,7 +44,7 @@
def test_weakref_old_keep(self):
p2 = oalloc(HDR)
p1 = lib.stm_weakref_allocate(WEAKREF_SIZE, WEAKREF_TID, p2)
- assert p1.h_tid == WEAKREF_TID # no GC flags
+ assert p1.h_tid == WEAKREF_TID | GCFLAG_IMMUTABLE
assert p1.h_revision == lib.get_private_rev_num()
assert lib.rawgetptr(p1, 0) == p2
lib.stm_push_root(p1)
diff --git a/c4/weakref.c b/c4/weakref.c
--- a/c4/weakref.c
+++ b/c4/weakref.c
@@ -18,10 +18,6 @@
/***** Minor collection *****/
-static int is_in_nursery(struct tx_descriptor *d, gcptr obj)
-{
- return (d->nursery_base <= (char*)obj && ((char*)obj) < d->nursery_end);
-}
void stm_move_young_weakrefs(struct tx_descriptor *d)
{
@@ -39,7 +35,7 @@
gcptr pointing_to = WEAKREF_PTR(weakref, size);
assert(pointing_to != NULL);
- if (is_in_nursery(d, pointing_to)) {
+ if (stmgc_is_in_nursery(d, pointing_to)) {
if (pointing_to->h_tid & GCFLAG_NURSERY_MOVED) {
dprintf(("weakref ptr moved %p->%p\n",
WEAKREF_PTR(weakref, size),
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit