[pypy-commit] stmgc default: Change back to accessing read-markers through a non-aliasing type to allow for
Raemi
noreply at buildbot.pypy.org
Fri Feb 6 16:12:18 CET 2015
Author: Remi Meier <remi.meier at inf.ethz.ch>
Branch:
Changeset: r1609:ddd64fd996c7
Date: 2015-02-06 16:13 +0100
http://bitbucket.org/pypy/stmgc/changeset/ddd64fd996c7/
Log: Change back to accessing read-markers through a non-aliasing type to
allow for better optimizations by the c compiler. It should be safe
now as we do not ever rely on read markers in the signal handler any
more (by doing an stm_validate()).
diff --git a/c8/stm/gcpage.c b/c8/stm/gcpage.c
--- a/c8/stm/gcpage.c
+++ b/c8/stm/gcpage.c
@@ -521,7 +521,8 @@
long i;
for (i = 1; i < NB_SEGMENTS; i++) {
/* reset read marker */
- *((char *)(get_segment_base(i) + (((uintptr_t)obj) >> 4))) = 0;
+ ((struct stm_read_marker_s *)
+ (get_segment_base(i) + (((uintptr_t)obj) >> 4)))->rm = 0;
}
return false;
}
@@ -547,7 +548,8 @@
long i;
for (i = 1; i < NB_SEGMENTS; i++) {
/* reset read marker */
- *((char *)(get_segment_base(i) + (((uintptr_t)obj) >> 4))) = 0;
+ ((struct stm_read_marker_s *)
+ (get_segment_base(i) + (((uintptr_t)obj) >> 4)))->rm = 0;
}
return false;
}
diff --git a/c8/stm/misc.c b/c8/stm/misc.c
--- a/c8/stm/misc.c
+++ b/c8/stm/misc.c
@@ -31,7 +31,8 @@
bool _stm_was_read(object_t *obj)
{
- uint8_t rm = *((char *)(STM_SEGMENT->segment_base + (((uintptr_t)obj) >> 4)));
+ uint8_t rm = ((struct stm_read_marker_s *)
+ (STM_SEGMENT->segment_base + (((uintptr_t)obj) >> 4)))->rm;
assert(rm <= STM_SEGMENT->transaction_read_version);
return rm == STM_SEGMENT->transaction_read_version;
}
diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c
--- a/c8/stm/nursery.c
+++ b/c8/stm/nursery.c
@@ -266,7 +266,8 @@
/* mark slot as unread (it can only have the read marker
in this segment) */
- *((char *)(pseg->pub.segment_base + (((uintptr_t)obj) >> 4))) = 0;
+ ((struct stm_read_marker_s *)
+ (pseg->pub.segment_base + (((uintptr_t)obj) >> 4)))->rm = 0;
_stm_large_free(stm_object_pages + item->addr);
} TREE_LOOP_END;
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -24,8 +24,19 @@
typedef TLPREFIX struct object_s object_t;
typedef TLPREFIX struct stm_segment_info_s stm_segment_info_t;
+typedef TLPREFIX struct stm_read_marker_s stm_read_marker_t;
typedef TLPREFIX char stm_char;
+struct stm_read_marker_s {
+ /* In every segment, every object has a corresponding read marker.
+ We assume that objects are at least 16 bytes long, and use
+ their address divided by 16. The read marker is equal to
+ 'STM_SEGMENT->transaction_read_version' if and only if the
+ object was read in the current transaction. The nurseries
+ also have corresponding read markers, but they are never used. */
+ uint8_t rm;
+};
+
struct stm_segment_info_s {
uint8_t transaction_read_version;
int segment_num;
@@ -80,7 +91,6 @@
bool _stm_is_accessible_page(uintptr_t pagenum);
-long stm_can_move(object_t *obj);
void _stm_test_switch(stm_thread_local_t *tl);
void _stm_test_switch_segment(int segnum);
void _push_obj_to_other_segments(object_t *obj);
@@ -149,7 +159,8 @@
__attribute__((always_inline))
static inline void stm_read(object_t *obj)
{
- *((stm_char *)(((uintptr_t)obj) >> 4)) = STM_SEGMENT->transaction_read_version;
+ ((stm_read_marker_t *)(((uintptr_t)obj) >> 4))->rm =
+ STM_SEGMENT->transaction_read_version;
}
__attribute__((always_inline))
@@ -226,6 +237,8 @@
long stm_id(object_t *obj);
void stm_set_prebuilt_identityhash(object_t *obj, long hash);
+long stm_can_move(object_t *obj);
+
object_t *stm_setup_prebuilt(object_t *);
object_t *stm_setup_prebuilt_weakref(object_t *);
More information about the pypy-commit
mailing list