diff options
Diffstat (limited to 'includes/rts/storage')
-rw-r--r-- | includes/rts/storage/ClosureMacros.h | 33 | ||||
-rw-r--r-- | includes/rts/storage/Closures.h | 6 | ||||
-rw-r--r-- | includes/rts/storage/GC.h | 6 |
3 files changed, 27 insertions, 18 deletions
diff --git a/includes/rts/storage/ClosureMacros.h b/includes/rts/storage/ClosureMacros.h index 0e956c4fa3..5674322bd2 100644 --- a/includes/rts/storage/ClosureMacros.h +++ b/includes/rts/storage/ClosureMacros.h @@ -46,10 +46,13 @@ -------------------------------------------------------------------------- */ INLINE_HEADER void SET_INFO(StgClosure *c, const StgInfoTable *info) { - c->header.info = info; + RELAXED_STORE(&c->header.info, info); +} +INLINE_HEADER void SET_INFO_RELEASE(StgClosure *c, const StgInfoTable *info) { + RELEASE_STORE(&c->header.info, info); } INLINE_HEADER const StgInfoTable *GET_INFO(StgClosure *c) { - return c->header.info; + return RELAXED_LOAD(&c->header.info); } #if defined(TABLES_NEXT_TO_CODE) @@ -81,28 +84,28 @@ INLINE_HEADER StgConInfoTable *itbl_to_con_itbl(const StgInfoTable *i) {return ( EXTERN_INLINE const StgInfoTable *get_itbl(const StgClosure *c); EXTERN_INLINE const StgInfoTable *get_itbl(const StgClosure *c) { - return INFO_PTR_TO_STRUCT(c->header.info); + return INFO_PTR_TO_STRUCT(RELAXED_LOAD(&c->header.info)); } EXTERN_INLINE const StgRetInfoTable *get_ret_itbl(const StgClosure *c); EXTERN_INLINE const StgRetInfoTable *get_ret_itbl(const StgClosure *c) { - return RET_INFO_PTR_TO_STRUCT(c->header.info); + return RET_INFO_PTR_TO_STRUCT(RELAXED_LOAD(&c->header.info)); } INLINE_HEADER const StgFunInfoTable *get_fun_itbl(const StgClosure *c) { - return FUN_INFO_PTR_TO_STRUCT(c->header.info); + return FUN_INFO_PTR_TO_STRUCT(RELAXED_LOAD(&c->header.info)); } INLINE_HEADER const StgThunkInfoTable *get_thunk_itbl(const StgClosure *c) { - return THUNK_INFO_PTR_TO_STRUCT(c->header.info); + return THUNK_INFO_PTR_TO_STRUCT(RELAXED_LOAD(&c->header.info)); } INLINE_HEADER const StgConInfoTable *get_con_itbl(const StgClosure *c) { - return CON_INFO_PTR_TO_STRUCT((c)->header.info); + return CON_INFO_PTR_TO_STRUCT(RELAXED_LOAD(&c->header.info)); } INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con) @@ -137,13 +140,19 @@ INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con) #define SET_HDR(c,_info,ccs) \ { \ - (c)->header.info = _info; \ SET_PROF_HDR((StgClosure *)(c),ccs); \ + RELAXED_STORE(&(c)->header.info, _info); \ + } + +#define SET_HDR_RELEASE(c,_info,ccs) \ + { \ + SET_PROF_HDR((StgClosure *)(c),ccs); \ + RELEASE_STORE(&(c)->header.info, _info); \ } #define SET_ARR_HDR(c,info,costCentreStack,n_bytes) \ - SET_HDR(c,info,costCentreStack); \ - (c)->bytes = n_bytes; + (c)->bytes = n_bytes; \ + SET_HDR(c,info,costCentreStack); // Use when changing a closure from one kind to another #define OVERWRITE_INFO(c, new_info) \ @@ -251,8 +260,8 @@ INLINE_HEADER bool LOOKS_LIKE_INFO_PTR (StgWord p) INLINE_HEADER bool LOOKS_LIKE_CLOSURE_PTR (const void *p) { - return LOOKS_LIKE_INFO_PTR((StgWord) - (UNTAG_CONST_CLOSURE((const StgClosure *)(p)))->header.info); + const StgInfoTable *info = RELAXED_LOAD(&UNTAG_CONST_CLOSURE((const StgClosure *) (p))->header.info); + return LOOKS_LIKE_INFO_PTR((StgWord) info); } /* ----------------------------------------------------------------------------- diff --git a/includes/rts/storage/Closures.h b/includes/rts/storage/Closures.h index 3196efd3de..981e162ec1 100644 --- a/includes/rts/storage/Closures.h +++ b/includes/rts/storage/Closures.h @@ -340,9 +340,9 @@ typedef struct StgTVarWatchQueue_ { typedef struct { StgHeader header; - StgClosure *volatile current_value; - StgTVarWatchQueue *volatile first_watch_queue_entry; - StgInt volatile num_updates; + StgClosure *current_value; /* accessed via atomics */ + StgTVarWatchQueue *first_watch_queue_entry; /* accessed via atomics */ + StgInt num_updates; /* accessed via atomics */ } StgTVar; /* new_value == expected_value for read-only accesses */ diff --git a/includes/rts/storage/GC.h b/includes/rts/storage/GC.h index 9f4a0dde07..e8dc05048a 100644 --- a/includes/rts/storage/GC.h +++ b/includes/rts/storage/GC.h @@ -247,9 +247,9 @@ extern bool keepCAFs; INLINE_HEADER void initBdescr(bdescr *bd, generation *gen, generation *dest) { - bd->gen = gen; - bd->gen_no = gen->no; - bd->dest_no = dest->no; + RELAXED_STORE(&bd->gen, gen); + RELAXED_STORE(&bd->gen_no, gen->no); + RELAXED_STORE(&bd->dest_no, dest->no); #if !IN_STG_CODE /* See Note [RtsFlags is a pointer in STG code] */ |