[pypy-commit] stmgc card-marking: use stmcb_get_card_base_itemsize instead of stmcb_index_to_byte_offset
Raemi
noreply at buildbot.pypy.org
Mon May 26 10:03:10 CEST 2014
Author: Remi Meier <remi.meier at inf.ethz.ch>
Branch: card-marking
Changeset: r1245:d6fca1fcaadb
Date: 2014-05-26 10:04 +0200
http://bitbucket.org/pypy/stmgc/changeset/d6fca1fcaadb/
Log: use stmcb_get_card_base_itemsize instead of
stmcb_index_to_byte_offset
diff --git a/c7/demo/demo2.c b/c7/demo/demo2.c
--- a/c7/demo/demo2.c
+++ b/c7/demo/demo2.c
@@ -43,7 +43,20 @@
n = (struct node_s*)obj;
visit((object_t **)&n->next);
}
-
+long stmcb_should_use_cards(struct object_s *obj)
+{
+ return 0;
+}
+void stmcb_get_card_base_itemsize(
+ struct object_s *obj, uintptr_t *base_offset, ssize_t *item_size)
+{
+ abort();
+}
+void stmcb_trace_cards(struct object_s *obj, void visit(object_t **),
+ uintptr_t start, uintptr_t stop)
+{
+ abort();
+}
void stmcb_commit_soon() {}
static void expand_marker(char *base, uintptr_t odd_number,
diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -558,7 +558,11 @@
/* Combine multiple marked cards and do a memcpy for them. We don't
try yet to use page_copy() or otherwise take into account privatization
of pages (except _has_private_page_in_range) */
- uintptr_t start = 0;
+ uintptr_t base_offset;
+ ssize_t item_size;
+ stmcb_get_card_base_itemsize(realobj, &base_offset, &item_size);
+
+ uintptr_t start_card_index = -1;
while (card_index <= last_card_index) {
uintptr_t card_lock_idx = first_card_index + card_index;
uint8_t card_value = write_locks[card_lock_idx];
@@ -568,32 +572,40 @@
if (card_value == CARD_MARKED_OLD) {
write_locks[card_lock_idx] = CARD_CLEAR;
- if (start == 0) { /* first marked card */
- start = (uintptr_t)obj + stmcb_index_to_byte_offset(
- realobj, get_card_index_to_index(card_index));
+ if (start_card_index == -1) { /* first marked card */
+ start_card_index = card_index;
+ /* start = (uintptr_t)obj + stmcb_index_to_byte_offset( */
+ /* realobj, get_card_index_to_index(card_index)); */
}
}
- if (start /* something to copy */
+ if (start_card_index != -1 /* something to copy */
&& (card_value != CARD_MARKED_OLD /* found non-marked card */
|| card_index == last_card_index)) { /* this is the last card */
/* do the copying: */
- uintptr_t copy_size;
+ uintptr_t start, copy_size;
uintptr_t next_card_offset;
- uintptr_t next_card = card_index;
+ uintptr_t start_card_offset;
+ uintptr_t next_card_index = card_index;
if (card_value == CARD_MARKED_OLD) {
/* card_index is the last card of the object, but we need
to go one further to get the right offset */
- next_card++;
+ next_card_index++;
}
- next_card_offset = stmcb_index_to_byte_offset(
- realobj, get_card_index_to_index(next_card));
+
+ start_card_offset = base_offset +
+ get_card_index_to_index(start_card_index) * item_size;
+
+ next_card_offset = base_offset +
+ get_card_index_to_index(next_card_index) * item_size;
if (next_card_offset > obj_size)
next_card_offset = obj_size;
- copy_size = next_card_offset - (start - (uintptr_t)obj);
+ start = (uintptr_t)obj + start_card_offset;
+ copy_size = next_card_offset - start_card_offset;
+ OPT_ASSERT(copy_size > 0);
/* dprintf(("copy %lu bytes\n", copy_size)); */
@@ -616,8 +628,7 @@
memcpy(dst, src, copy_size);
}
- copy_size = 0;
- start = 0;
+ start_card_index = -1;
}
card_index++;
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -250,13 +250,20 @@
*/
extern ssize_t stmcb_size_rounded_up(struct object_s *);
extern void stmcb_trace(struct object_s *, void (object_t **));
+/* called to determine if we should use cards for this object.
+ (makes most sense for big arrays with references) */
+extern long stmcb_should_use_cards(struct object_s *);
+/* a special trace-callback that is only called for the marked
+ ranges of indices (using stm_write_card(o, index)) */
extern void stmcb_trace_cards(struct object_s *, void (object_t **),
uintptr_t start, uintptr_t stop);
-/* needs to work with index > any valid index (can just return
- object's size then) */
-extern uintptr_t stmcb_index_to_byte_offset(struct object_s *,
- uintptr_t index);
-extern long stmcb_should_use_cards(struct object_s *);
+/* this function will be called on objects that support cards
+ (stmcb_should_use_cards() returned True). It returns the
+ base_offset (in bytes) inside the object from where the
+ indices start, and item_size (in bytes) for the size of
+ one item */
+extern void stmcb_get_card_base_itemsize(
+ struct object_s *, uintptr_t *base_offset, ssize_t *item_size);
extern void stmcb_commit_soon(void);
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -317,15 +317,16 @@
}
}
-uintptr_t stmcb_index_to_byte_offset(struct object_s *obj, uintptr_t index)
+void stmcb_get_card_base_itemsize(
+ struct object_s *obj, uintptr_t *base_offset, ssize_t *item_size)
{
struct myobj_s *myobj = (struct myobj_s*)obj;
if (myobj->type_id < 421420) {
abort(); // works, but we want to test otherwise
/* basic case: index=byteoffset */
- return index;
}
- return sizeof(struct myobj_s) + index * sizeof(object_t*);
+ *base_offset = sizeof(struct myobj_s);
+ *item_size = sizeof(object_t *);
}
long stmcb_should_use_cards(struct object_s *obj)
More information about the pypy-commit
mailing list