Author: Armin Rigo <[email protected]>
Branch: c7-refactor
Changeset: r823:d9fd728c638d
Date: 2014-02-24 14:05 +0100
http://bitbucket.org/pypy/stmgc/changeset/d9fd728c638d/
Log: Refactor the next test
diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -63,8 +63,8 @@
/* List of old objects (older than the current transaction) that the
current transaction attempts to modify. This is used to track
- the STM status: it's old objects that where written to and that
- need to be copied to other segments upon commit. */
+ the STM status: they are old objects that where written to and
+ that need to be copied to other segments upon commit. */
struct list_s *modified_old_objects;
/* List of the modified old objects that may point to the nursery.
@@ -77,9 +77,9 @@
/* List of overflowed objects (from the same transaction but outside
the nursery) on which the write-barrier was triggered, so that
they likely contain a pointer to a nursery object. This is used
- by the GC: it's roots for the next minor collection. This is
- NULL if the current transaction didn't span a minor collection
- so far. */
+ by the GC: it's additional roots for the next minor collection.
+ This is NULL if the current transaction didn't span a minor
+ collection so far. */
struct list_s *overflow_objects_pointing_to_nursery;
/* Start time: to know approximately for how long a transaction has
diff --git a/c7/stm/misc.c b/c7/stm/misc.c
--- a/c7/stm/misc.c
+++ b/c7/stm/misc.c
@@ -47,22 +47,42 @@
}
#ifdef STM_TESTS
-object_t *_stm_enum_overflow_objects_pointing_to_nursery(void)
+long _stm_count_modified_old_objects(void)
{
- static long index = 0;
- struct list_s *lst = STM_PSEGMENT->overflow_objects_pointing_to_nursery;
- if (index < list_count(lst))
- return (object_t *)list_item(lst, index++);
- index = 0;
- return (object_t *)-1;
+ if (STM_PSEGMENT->modified_old_objects == NULL)
+ return -1;
+ return list_count(STM_PSEGMENT->modified_old_objects);
}
-object_t *_stm_enum_modified_old_objects(void)
+
+long _stm_count_old_objects_pointing_to_nursery(void)
{
- static long index = 0;
- struct list_s *lst = STM_PSEGMENT->modified_old_objects;
- if (index < list_count(lst))
- return (object_t *)list_item(lst, index++);
- index = 0;
- return (object_t *)-1;
+ if (STM_PSEGMENT->old_objects_pointing_to_nursery == NULL)
+ return -1;
+ return list_count(STM_PSEGMENT->old_objects_pointing_to_nursery);
+}
+
+long _stm_count_overflow_objects_pointing_to_nursery(void)
+{
+ if (STM_PSEGMENT->overflow_objects_pointing_to_nursery == NULL)
+ return -1;
+ return list_count(STM_PSEGMENT->overflow_objects_pointing_to_nursery);
+}
+
+object_t *_stm_enum_modified_old_objects(long index)
+{
+ return (object_t *)list_item(
+ STM_PSEGMENT->modified_old_objects, index);
+}
+
+object_t *_stm_enum_old_objects_pointing_to_nursery(long index)
+{
+ return (object_t *)list_item(
+ STM_PSEGMENT->old_objects_pointing_to_nursery, index);
+}
+
+object_t *_stm_enum_overflow_objects_pointing_to_nursery(long index)
+{
+ return (object_t *)list_item(
+ STM_PSEGMENT->overflow_objects_pointing_to_nursery, index);
}
#endif
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -81,8 +81,12 @@
void _stm_start_safe_point(void);
void _stm_stop_safe_point(void);
void _stm_set_nursery_free_count(uint64_t free_count);
-object_t *_stm_enum_overflow_objects_pointing_to_nursery(void);
-object_t *_stm_enum_modified_old_objects(void);
+long _stm_count_modified_old_objects(void);
+long _stm_count_old_objects_pointing_to_nursery(void);
+long _stm_count_overflow_objects_pointing_to_nursery(void);
+object_t *_stm_enum_modified_old_objects(long index);
+object_t *_stm_enum_old_objects_pointing_to_nursery(long index);
+object_t *_stm_enum_overflow_objects_pointing_to_nursery(long index);
#endif
#define _STM_GCFLAG_WRITE_BARRIER 0x01
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -76,8 +76,12 @@
ssize_t stmcb_size_rounded_up(struct object_s *obj);
-object_t *_stm_enum_overflow_objects_pointing_to_nursery(void);
-object_t *_stm_enum_modified_old_objects(void);
+long _stm_count_modified_old_objects(void);
+long _stm_count_old_objects_pointing_to_nursery(void);
+long _stm_count_overflow_objects_pointing_to_nursery(void);
+object_t *_stm_enum_modified_old_objects(long index);
+object_t *_stm_enum_old_objects_pointing_to_nursery(long index);
+object_t *_stm_enum_overflow_objects_pointing_to_nursery(long index);
void stm_collect(long level);
""")
@@ -365,13 +369,23 @@
def stm_get_flags(o):
return lib._stm_get_flags(o)
-def old_objects_pointing_to_young():
- return list(iter(lib._stm_enum_old_objects_pointing_to_young,
- ffi.cast("object_t *", -1)))
+def modified_old_objects():
+ count = lib._stm_count_modified_old_objects()
+ if count < 0:
+ return None
+ return map(lib._stm_enum_modified_old_objects, range(count))
-def modified_objects():
- return list(iter(lib._stm_enum_modified_objects,
- ffi.cast("object_t *", -1)))
+def old_objects_pointing_to_nursery():
+ count = lib._stm_count_old_objects_pointing_to_nursery()
+ if count < 0:
+ return None
+ return map(lib._stm_enum_old_objects_pointing_to_nursery, range(count))
+
+def overflow_objects_pointing_to_nursery():
+ count = lib._stm_count_overflow_objects_pointing_to_nursery()
+ if count < 0:
+ return None
+ return map(lib._stm_enum_overflow_objects_pointing_to_nursery,range(count))
SHADOWSTACK_LENGTH = 1000
diff --git a/c7/test/test_basic.py b/c7/test/test_basic.py
--- a/c7/test/test_basic.py
+++ b/c7/test/test_basic.py
@@ -50,7 +50,9 @@
assert stm_was_written(lp1)
stm_write(lp1)
assert stm_was_written(lp1)
- assert modified_objects() == [] # because same transaction
+ assert modified_old_objects() == [] # object not old
+ assert old_objects_pointing_to_nursery() == None # short transac.
+ assert overflow_objects_pointing_to_nursery() == None # short transac.
self.commit_transaction()
def test_allocate_old(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit