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 /includes | |
parent | dd1b4fddacf398f120099268538a358c6f6f4761 (diff) | |
download | haskell-4a44ab330285643a6bee6acc6bd47d44118a6def.tar.gz |
rts: Shrink size of STACK's dirty and marking fields
Diffstat (limited to 'includes')
-rw-r--r-- | includes/rts/storage/TSO.h | 4 | ||||
-rw-r--r-- | includes/stg/SMP.h | 19 |
2 files changed, 21 insertions, 2 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) |