diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-10-18 16:21:19 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-10-20 21:15:52 -0400 |
commit | 4a44ab330285643a6bee6acc6bd47d44118a6def (patch) | |
tree | 9ec6b94725cf9bda4fc418a43eb4c5b87a25750d | |
parent | dd1b4fddacf398f120099268538a358c6f6f4761 (diff) | |
download | haskell-4a44ab330285643a6bee6acc6bd47d44118a6def.tar.gz |
rts: Shrink size of STACK's dirty and marking fields
-rw-r--r-- | includes/rts/storage/TSO.h | 4 | ||||
-rw-r--r-- | includes/stg/SMP.h | 19 | ||||
-rw-r--r-- | rts/sm/NonMovingMark.c | 8 |
3 files changed, 25 insertions, 6 deletions
diff --git a/includes/rts/storage/TSO.h b/includes/rts/storage/TSO.h index d56ae8ad27..070ecbebaa 100644 --- a/includes/rts/storage/TSO.h +++ b/includes/rts/storage/TSO.h @@ -240,8 +240,8 @@ typedef struct StgTSO_ { typedef struct StgStack_ { StgHeader header; StgWord32 stack_size; // stack size in *words* - StgWord dirty; // non-zero => dirty - StgWord marking; // non-zero => someone is currently marking the stack + StgWord8 dirty; // non-zero => dirty + StgWord8 marking; // non-zero => someone is currently marking the stack StgPtr sp; // current stack pointer StgWord stack[]; } StgStack; diff --git a/includes/stg/SMP.h b/includes/stg/SMP.h index 4be11d1f64..260a916d40 100644 --- a/includes/stg/SMP.h +++ b/includes/stg/SMP.h @@ -49,6 +49,7 @@ EXTERN_INLINE StgWord xchg(StgPtr p, StgWord w); * } */ EXTERN_INLINE StgWord cas(StgVolatilePtr p, StgWord o, StgWord n); +EXTERN_INLINE StgWord8 cas_word8(StgWord8 *volatile p, StgWord8 o, StgWord8 n); /* * Atomic addition by the provided quantity @@ -283,6 +284,12 @@ cas(StgVolatilePtr p, StgWord o, StgWord n) return __sync_val_compare_and_swap(p, o, n); } +EXTERN_INLINE StgWord8 +cas_word8(StgWord8 *volatile p, StgWord8 o, StgWord8 n) +{ + return __sync_val_compare_and_swap(p, o, n); +} + // RRN: Generalized to arbitrary increments to enable fetch-and-add in // Haskell code (fetchAddIntArray#). // PT: add-and-fetch, returns new value @@ -428,6 +435,18 @@ cas(StgVolatilePtr p, StgWord o, StgWord n) return result; } +EXTERN_INLINE StgWord8 cas_word8(StgWord8 *volatile p, StgWord8 o, StgWord8 n); +EXTERN_INLINE StgWord8 +cas_word8(StgWord8 *volatile p, StgWord8 o, StgWord8 n) +{ + StgWord8 result; + result = *p; + if (result == o) { + *p = n; + } + return result; +} + EXTERN_INLINE StgWord atomic_inc(StgVolatilePtr p, StgWord incr); EXTERN_INLINE StgWord atomic_inc(StgVolatilePtr p, StgWord incr) diff --git a/rts/sm/NonMovingMark.c b/rts/sm/NonMovingMark.c index b273b09b05..9d046ce068 100644 --- a/rts/sm/NonMovingMark.c +++ b/rts/sm/NonMovingMark.c @@ -595,9 +595,9 @@ void updateRemembSetPushStack(Capability *cap, StgStack *stack) { // N.B. caller responsible for checking nonmoving_write_barrier_enabled if (needs_upd_rem_set_mark((StgClosure *) stack)) { - StgWord marking = stack->marking; + StgWord8 marking = stack->marking; // See Note [StgStack dirtiness flags and concurrent marking] - if (cas(&stack->marking, marking, nonmovingMarkEpoch) + if (cas_word8(&stack->marking, marking, nonmovingMarkEpoch) != nonmovingMarkEpoch) { // We have claimed the right to mark the stack. debugTrace(DEBUG_nonmoving_gc, "upd_rem_set: STACK %p", stack->sp); @@ -1341,11 +1341,11 @@ mark_closure (MarkQueue *queue, StgClosure *p, StgClosure **origin) case STACK: { // See Note [StgStack dirtiness flags and concurrent marking] StgStack *stack = (StgStack *) p; - StgWord marking = stack->marking; + StgWord8 marking = stack->marking; // N.B. stack->marking must be != nonmovingMarkEpoch unless // someone has already marked it. - if (cas(&stack->marking, marking, nonmovingMarkEpoch) + if (cas_word8(&stack->marking, marking, nonmovingMarkEpoch) != nonmovingMarkEpoch) { // We have claimed the right to mark the stack. mark_stack(queue, stack); |