diff options
Diffstat (limited to 'ghc/includes')
-rw-r--r-- | ghc/includes/Bytecodes.h | 45 | ||||
-rw-r--r-- | ghc/includes/Closures.h | 23 | ||||
-rw-r--r-- | ghc/includes/Cmm.h | 4 | ||||
-rw-r--r-- | ghc/includes/Constants.h | 25 | ||||
-rw-r--r-- | ghc/includes/Storage.h | 69 | ||||
-rw-r--r-- | ghc/includes/mkDerivedConstants.c | 45 |
6 files changed, 111 insertions, 100 deletions
diff --git a/ghc/includes/Bytecodes.h b/ghc/includes/Bytecodes.h index f9a5182842..73003a3002 100644 --- a/ghc/includes/Bytecodes.h +++ b/ghc/includes/Bytecodes.h @@ -52,28 +52,29 @@ #define bci_ALLOC_AP 27 #define bci_ALLOC_PAP 28 #define bci_MKAP 29 -#define bci_UNPACK 30 -#define bci_PACK 31 -#define bci_TESTLT_I 32 -#define bci_TESTEQ_I 33 -#define bci_TESTLT_F 34 -#define bci_TESTEQ_F 35 -#define bci_TESTLT_D 36 -#define bci_TESTEQ_D 37 -#define bci_TESTLT_P 38 -#define bci_TESTEQ_P 39 -#define bci_CASEFAIL 40 -#define bci_JMP 41 -#define bci_CCALL 42 -#define bci_SWIZZLE 43 -#define bci_ENTER 44 -#define bci_RETURN 45 -#define bci_RETURN_P 46 -#define bci_RETURN_N 47 -#define bci_RETURN_F 48 -#define bci_RETURN_D 49 -#define bci_RETURN_L 50 -#define bci_RETURN_V 51 +#define bci_MKPAP 30 +#define bci_UNPACK 31 +#define bci_PACK 32 +#define bci_TESTLT_I 33 +#define bci_TESTEQ_I 34 +#define bci_TESTLT_F 35 +#define bci_TESTEQ_F 36 +#define bci_TESTLT_D 37 +#define bci_TESTEQ_D 38 +#define bci_TESTLT_P 39 +#define bci_TESTEQ_P 40 +#define bci_CASEFAIL 41 +#define bci_JMP 42 +#define bci_CCALL 43 +#define bci_SWIZZLE 44 +#define bci_ENTER 45 +#define bci_RETURN 46 +#define bci_RETURN_P 47 +#define bci_RETURN_N 48 +#define bci_RETURN_F 49 +#define bci_RETURN_D 50 +#define bci_RETURN_L 51 +#define bci_RETURN_V 52 /* If a BCO definitely requires less than this many words of stack, don't include an explicit STKCHECK insn in it. The interpreter diff --git a/ghc/includes/Closures.h b/ghc/includes/Closures.h index 8487893b33..152213ba5d 100644 --- a/ghc/includes/Closures.h +++ b/ghc/includes/Closures.h @@ -36,9 +36,15 @@ typedef struct { /* ----------------------------------------------------------------------------- The SMP header - - In SMP mode, we have an extra word of padding in a thunk's header. - (Note: thunks only; other closures do not have this padding word). + + A thunk has a padding word to take the updated value. This is so + that the update doesn't overwrite the payload, so we can avoid + needing to lock the thunk during entry and update. + + Note: this doesn't apply to THUNK_STATICs, which have no payload. + + Note: we leave this padding word in all ways, rather than just SMP, + so that we don't have to recompile all our libraries for SMP. -------------------------------------------------------------------------- */ typedef struct { @@ -62,13 +68,6 @@ typedef struct { #endif } StgHeader; -/* - * In SMP mode, a thunk has a padding word to take the updated value. - * This is so that the update doesn't overwrite the payload, so we can - * avoid needing to lock the thunk during entry and update. - * - * Note: this doesn't apply to THUNK_STATICs, which have no payload. - */ typedef struct { const struct _StgInfoTable* info; #ifdef PROFILING @@ -77,11 +76,11 @@ typedef struct { #ifdef GRAN StgGranHeader gran; #endif -#ifdef SMP StgSMPThunkHeader smp; -#endif } StgThunkHeader; +#define THUNK_EXTRA_HEADER_W (sizeofW(StgThunkHeader)-sizeofW(StgHeader)) + /* ----------------------------------------------------------------------------- Closure Types diff --git a/ghc/includes/Cmm.h b/ghc/includes/Cmm.h index 5a380594be..ea760a860f 100644 --- a/ghc/includes/Cmm.h +++ b/ghc/includes/Cmm.h @@ -340,11 +340,7 @@ * the value from GHC, but it seems like too much trouble to do that * for StgThunkHeader. */ -#ifdef SMP #define SIZEOF_StgThunkHeader SIZEOF_StgHeader+SIZEOF_StgSMPThunkHeader -#else -#define SIZEOF_StgThunkHeader SIZEOF_StgHeader -#endif #define StgThunk_payload(__ptr__,__ix__) \ W_[__ptr__+SIZEOF_StgThunkHeader+ WDS(__ix__)] diff --git a/ghc/includes/Constants.h b/ghc/includes/Constants.h index d02ae4d699..4f3c35b744 100644 --- a/ghc/includes/Constants.h +++ b/ghc/includes/Constants.h @@ -20,29 +20,12 @@ /* ----------------------------------------------------------------------------- Minimum closure sizes - Here we define the minimum size for updatable closures. All updates - will be performed on closures of this size. For non-updatable closures - the minimum size is 1 to allow for a forwarding pointer. - - When we used to keep the mutable list threaded through closures on - the heap, MIN_UPD_SIZE used to be 2. Now it's 1. - - o MIN_UPD_SIZE doesn't apply to stack closures, static closures - or non-updateable objects like PAPs or CONSTRs - o MIN_UPD_SIZE is big enough to contain any of the following: - o EVACUATED - o BLACKHOLE - o BLOCKING QUEUE - o IND, IND_PERM, IND_OLDGEN and IND_OLDGEN_PERM - (it need not be big enough for IND_STATIC - but it is) - o MIN_NONUPD_SIZE doesn't apply to stack closures, static closures - or updateable objects like APs, THUNKS or THUNK_SELECTORs - o MIN_NONUPD_SIZE is big enough to contain any of the following: - o EVACUATED + This is the minimum number of words in the payload of a + heap-allocated closure, so that the closure has enough room to be + overwritten with a forwarding pointer during garbage collection. -------------------------------------------------------------------------- */ -#define MIN_UPD_SIZE 1 -#define MIN_NONUPD_SIZE 1 +#define MIN_PAYLOAD_SIZE 1 /* ----------------------------------------------------------------------------- Constants to do with specialised closure types. diff --git a/ghc/includes/Storage.h b/ghc/includes/Storage.h index 035088e26b..8cfd511662 100644 --- a/ghc/includes/Storage.h +++ b/ghc/includes/Storage.h @@ -312,10 +312,10 @@ INLINE_HEADER StgOffset CONSTR_sizeW( nat p, nat np ) { return sizeofW(StgHeader) + p + np; } INLINE_HEADER StgOffset THUNK_SELECTOR_sizeW ( void ) -{ return stg_max(sizeofW(StgHeader)+MIN_UPD_SIZE, sizeofW(StgSelector)); } +{ return sizeofW(StgSelector); } INLINE_HEADER StgOffset BLACKHOLE_sizeW ( void ) -{ return sizeofW(StgHeader)+MIN_UPD_SIZE; } +{ return sizeofW(StgHeader)+MIN_PAYLOAD_SIZE; } /* -------------------------------------------------------------------------- Sizes of closures @@ -352,6 +352,71 @@ INLINE_HEADER StgWord tso_sizeW ( StgTSO *tso ) INLINE_HEADER StgWord bco_sizeW ( StgBCO *bco ) { return bco->size; } +STATIC_INLINE nat +closure_sizeW_ (StgClosure *p, StgInfoTable *info) +{ + switch (info->type) { + case THUNK_0_1: + case THUNK_1_0: + return sizeofW(StgThunk) + 1; + case FUN_0_1: + case CONSTR_0_1: + case FUN_1_0: + case CONSTR_1_0: + return sizeofW(StgHeader) + 1; + case THUNK_0_2: + case THUNK_1_1: + case THUNK_2_0: + return sizeofW(StgThunk) + 2; + case FUN_0_2: + case CONSTR_0_2: + case FUN_1_1: + case CONSTR_1_1: + case FUN_2_0: + case CONSTR_2_0: + return sizeofW(StgHeader) + 2; + case THUNK_SELECTOR: + return THUNK_SELECTOR_sizeW(); + case AP_STACK: + return ap_stack_sizeW((StgAP_STACK *)p); + case AP: + case PAP: + return pap_sizeW((StgPAP *)p); + case IND: + case IND_PERM: + case IND_OLDGEN: + case IND_OLDGEN_PERM: + return sizeofW(StgInd); + case ARR_WORDS: + return arr_words_sizeW((StgArrWords *)p); + case MUT_ARR_PTRS_CLEAN: + case MUT_ARR_PTRS_DIRTY: + case MUT_ARR_PTRS_FROZEN: + case MUT_ARR_PTRS_FROZEN0: + return mut_arr_ptrs_sizeW((StgMutArrPtrs*)p); + case TSO: + return tso_sizeW((StgTSO *)p); + case BCO: + return bco_sizeW((StgBCO *)p); + case TVAR_WAIT_QUEUE: + return sizeofW(StgTVarWaitQueue); + case TVAR: + return sizeofW(StgTVar); + case TREC_CHUNK: + return sizeofW(StgTRecChunk); + case TREC_HEADER: + return sizeofW(StgTRecHeader); + default: + return sizeW_fromITBL(info); + } +} + +STATIC_INLINE nat +closure_sizeW (StgClosure *p) +{ + return closure_sizeW_(p, get_itbl(p)); +} + /* ----------------------------------------------------------------------------- Sizes of stack frames -------------------------------------------------------------------------- */ diff --git a/ghc/includes/mkDerivedConstants.c b/ghc/includes/mkDerivedConstants.c index c78c8427ec..27d4fa9e7b 100644 --- a/ghc/includes/mkDerivedConstants.c +++ b/ghc/includes/mkDerivedConstants.c @@ -93,13 +93,6 @@ printf("#define SIZEOF_" str " (SIZEOF_StgHeader+%d)\n", size); #endif -#if defined(GEN_HASKELL) -#define def_thunk_size(str, size) /* nothing */ -#else -#define def_thunk_size(str, size) \ - printf("#define SIZEOF_" str " (SIZEOF_StgThunkHeader+%d)\n", size); -#endif - #define struct_size(s_type) \ def_size(#s_type, sizeof(s_type)); @@ -112,64 +105,38 @@ def_closure_size(#s_type, sizeof(s_type) - sizeof(StgHeader)); #define thunk_size(s_type) \ - def_size(#s_type "_NoHdr", sizeof(s_type) - sizeof(StgHeader)); \ - def_thunk_size(#s_type, sizeof(s_type) - sizeof(StgHeader)); + def_size(#s_type "_NoThunkHdr", sizeof(s_type) - sizeof(StgThunkHeader)); \ + closure_size(s_type) /* An access macro for use in C-- sources. */ #define closure_field_macro(str) \ printf("#define " str "(__ptr__) REP_" str "[__ptr__+SIZEOF_StgHeader+OFFSET_" str "]\n"); -#define thunk_field_macro(str) \ - printf("#define " str "(__ptr__) REP_" str "[__ptr__+SIZEOF_StgThunkHeader+OFFSET_" str "]\n"); - #define closure_field_offset_(str, s_type,field) \ def_offset(str, OFFSET(s_type,field) - sizeof(StgHeader)); -#define thunk_field_offset_(str, s_type, field) \ - closure_field_offset_(str, s_type, field) - #define closure_field_offset(s_type,field) \ closure_field_offset_(str(s_type,field),s_type,field) -#define thunk_field_offset(s_type,field) \ - thunk_field_offset_(str(s_type,field),s_type,field) - #define closure_payload_macro(str) \ printf("#define " str "(__ptr__,__ix__) W_[__ptr__+SIZEOF_StgHeader+OFFSET_" str " + WDS(__ix__)]\n"); -#define thunk_payload_macro(str) \ - printf("#define " str "(__ptr__,__ix__) W_[__ptr__+SIZEOF_StgThunkHeader+OFFSET_" str " + WDS(__ix__)]\n"); - #define closure_payload(s_type,field) \ closure_field_offset_(str(s_type,field),s_type,field); \ closure_payload_macro(str(s_type,field)); -#define thunk_payload(s_type,field) \ - thunk_field_offset_(str(s_type,field),s_type,field); \ - thunk_payload_macro(str(s_type,field)); - /* Byte offset and MachRep for a closure field, minus the header */ #define closure_field(s_type, field) \ closure_field_offset(s_type,field) \ field_type(s_type, field); \ closure_field_macro(str(s_type,field)) -#define thunk_field(s_type, field) \ - thunk_field_offset(s_type,field) \ - field_type(s_type, field); \ - thunk_field_macro(str(s_type,field)) - /* Byte offset and MachRep for a closure field, minus the header */ #define closure_field_(str, s_type, field) \ closure_field_offset_(str,s_type,field) \ field_type_(str, s_type, field); \ closure_field_macro(str) -#define thunk_field_(str, s_type, field) \ - thunk_field_offset_(str,s_type,field) \ - field_type_(str, s_type, field); \ - thunk_field_macro(str) - /* Byte offset for a TSO field, minus the header and variable prof bit. */ #define tso_payload_offset(s_type, field) \ def_offset(str(s_type,field), OFFSET(s_type,field) - sizeof(StgHeader) - sizeof(StgTSOProfInfo)); @@ -337,15 +304,15 @@ main(int argc, char *argv[]) closure_field(StgPAP, arity); closure_payload(StgPAP, payload); - closure_size(StgAP); + thunk_size(StgAP); closure_field(StgAP, n_args); closure_field(StgAP, fun); closure_payload(StgAP, payload); thunk_size(StgAP_STACK); - thunk_field(StgAP_STACK, size); - thunk_field(StgAP_STACK, fun); - thunk_payload(StgAP_STACK, payload); + closure_field(StgAP_STACK, size); + closure_field(StgAP_STACK, fun); + closure_payload(StgAP_STACK, payload); closure_field(StgInd, indirectee); |