[pypy-commit] stmgc default: ensure that the write of an stm_read() happens before the actual reading by making the C compiler believe that the write may alias the read (prevents some optimizations)
Raemi
noreply at buildbot.pypy.org
Mon Sep 8 14:16:58 CEST 2014
Author: Remi Meier <remi.meier at inf.ethz.ch>
Branch:
Changeset: r1366:e0c1255cc369
Date: 2014-09-08 14:18 +0200
http://bitbucket.org/pypy/stmgc/changeset/e0c1255cc369/
Log: ensure that the write of an stm_read() happens before the actual
reading by making the C compiler believe that the write may alias
the read (prevents some optimizations)
diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -262,7 +262,7 @@
OPT_ASSERT((uintptr_t)STM_PSEGMENT->last_commit_log_entry->next == -1);
to = &(STM_PSEGMENT->last_commit_log_entry->next);
- bool yes = __sync_bool_compare_and_swap(to, -1, new);
+ bool yes = __sync_bool_compare_and_swap(to, (void*)-1, new);
OPT_ASSERT(yes);
return;
}
diff --git a/c8/stm/misc.c b/c8/stm/misc.c
--- a/c8/stm/misc.c
+++ b/c8/stm/misc.c
@@ -31,8 +31,7 @@
bool _stm_was_read(object_t *obj)
{
- uint8_t rm = ((struct stm_read_marker_s *)
- (STM_SEGMENT->segment_base + (((uintptr_t)obj) >> 4)))->rm;
+ uint8_t rm = *((char *)(STM_SEGMENT->segment_base + (((uintptr_t)obj) >> 4)));
assert(rm <= STM_SEGMENT->transaction_read_version);
return rm == STM_SEGMENT->transaction_read_version;
}
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -24,19 +24,8 @@
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;
@@ -126,8 +115,7 @@
__attribute__((always_inline))
static inline void stm_read(object_t *obj)
{
- ((stm_read_marker_t *)(((uintptr_t)obj) >> 4))->rm =
- STM_SEGMENT->transaction_read_version;
+ *((stm_char *)(((uintptr_t)obj) >> 4)) = STM_SEGMENT->transaction_read_version;
}
__attribute__((always_inline))
More information about the pypy-commit
mailing list