diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-08-25 15:42:20 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-08-25 15:42:20 +0100 |
commit | 0ab537c563d0b937aaef29e2bb962793d308b174 (patch) | |
tree | 2c6b70c614645504ae4c97af0869834ab7c504cc | |
parent | 773570edf681e26d4cd7f7a628f22c14a73b92fe (diff) | |
download | haskell-0ab537c563d0b937aaef29e2bb962793d308b174.tar.gz |
More CPP macros -> inline functions
All the wibble seem to have cancelled out, and (non-debug) object sizes
are back to where they started.
I'm not 100% sure that the types are optimal, but at least now the
functions have types and we can fix them if necessary.
-rw-r--r-- | includes/rts/storage/ClosureMacros.h | 26 | ||||
-rw-r--r-- | rts/Interpreter.c | 2 | ||||
-rw-r--r-- | rts/sm/Compact.c | 6 | ||||
-rw-r--r-- | rts/sm/Evac.c | 6 |
4 files changed, 22 insertions, 18 deletions
diff --git a/includes/rts/storage/ClosureMacros.h b/includes/rts/storage/ClosureMacros.h index fd8151eb5c..4eefb6b881 100644 --- a/includes/rts/storage/ClosureMacros.h +++ b/includes/rts/storage/ClosureMacros.h @@ -53,21 +53,25 @@ #define GET_TAG(con) (get_itbl(con)->srt_bitmap) #ifdef TABLES_NEXT_TO_CODE -#define INFO_PTR_TO_STRUCT(info) ((StgInfoTable *)(info) - 1) -#define RET_INFO_PTR_TO_STRUCT(info) ((StgRetInfoTable *)(info) - 1) -#define FUN_INFO_PTR_TO_STRUCT(info) ((StgFunInfoTable *)(info) - 1) -#define THUNK_INFO_PTR_TO_STRUCT(info) ((StgThunkInfoTable *)(info) - 1) -#define CON_INFO_PTR_TO_STRUCT(info) ((StgConInfoTable *)(info) - 1) +EXTERN_INLINE StgInfoTable *INFO_PTR_TO_STRUCT(const StgInfoTable *info); +EXTERN_INLINE StgInfoTable *INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgInfoTable *)info - 1;} +EXTERN_INLINE StgRetInfoTable *RET_INFO_PTR_TO_STRUCT(const StgInfoTable *info); +EXTERN_INLINE StgRetInfoTable *RET_INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgRetInfoTable *)info - 1;} +INLINE_HEADER StgFunInfoTable *FUN_INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgFunInfoTable *)info - 1;} +INLINE_HEADER StgThunkInfoTable *THUNK_INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgThunkInfoTable *)info - 1;} +INLINE_HEADER StgConInfoTable *CON_INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgConInfoTable *)info - 1;} INLINE_HEADER StgFunInfoTable *itbl_to_fun_itbl(const StgInfoTable *i) {return (StgFunInfoTable *)(i + 1) - 1;} INLINE_HEADER StgRetInfoTable *itbl_to_ret_itbl(const StgInfoTable *i) {return (StgRetInfoTable *)(i + 1) - 1;} INLINE_HEADER StgThunkInfoTable *itbl_to_thunk_itbl(const StgInfoTable *i) {return (StgThunkInfoTable *)(i + 1) - 1;} INLINE_HEADER StgConInfoTable *itbl_to_con_itbl(const StgInfoTable *i) {return (StgConInfoTable *)(i + 1) - 1;} #else -#define INFO_PTR_TO_STRUCT(info) ((StgInfoTable *)info) -#define RET_INFO_PTR_TO_STRUCT(info) ((StgRetInfoTable *)info) -#define FUN_INFO_PTR_TO_STRUCT(info) ((StgFunInfoTable *)info) -#define THUNK_INFO_PTR_TO_STRUCT(info) ((StgThunkInfoTable *)info) -#define CON_INFO_PTR_TO_STRUCT(info) ((StgConInfoTable *)info) +EXTERN_INLINE StgInfoTable *INFO_PTR_TO_STRUCT(const StgInfoTable *info); +EXTERN_INLINE StgInfoTable *INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgInfoTable *)info;} +EXTERN_INLINE StgRetInfoTable *RET_INFO_PTR_TO_STRUCT(const StgInfoTable *info); +EXTERN_INLINE StgRetInfoTable *RET_INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgRetInfoTable *)info;} +INLINE_HEADER StgThunkInfoTable *FUN_INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgFunInfoTable *)info;} +INLINE_HEADER StgThunkInfoTable *THUNK_INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgThunkInfoTable *)info;} +INLINE_HEADER StgConInfoTable *CON_INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgConInfoTable *)info;} INLINE_HEADER StgFunInfoTable *itbl_to_fun_itbl(const StgInfoTable *i) {return (StgFunInfoTable *)i;} INLINE_HEADER StgRetInfoTable *itbl_to_ret_itbl(const StgInfoTable *i) {return (StgRetInfoTable *)i;} INLINE_HEADER StgThunkInfoTable *itbl_to_thunk_itbl(const StgInfoTable *i) {return (StgThunkInfoTable *)i;} @@ -227,7 +231,7 @@ TAG_CLOSURE(StgWord tag,StgClosure * p) INLINE_HEADER rtsBool LOOKS_LIKE_INFO_PTR_NOT_NULL (StgWord p) { - StgInfoTable *info = INFO_PTR_TO_STRUCT(p); + StgInfoTable *info = INFO_PTR_TO_STRUCT((StgInfoTable *)p); return info->type != INVALID_OBJECT && info->type < N_CLOSURE_TYPES; } diff --git a/rts/Interpreter.c b/rts/Interpreter.c index d879fd3e77..f3e070000b 100644 --- a/rts/Interpreter.c +++ b/rts/Interpreter.c @@ -1183,7 +1183,7 @@ run_BCO: int i; int o_itbl = BCO_GET_LARGE_ARG; int n_words = BCO_NEXT; - StgInfoTable* itbl = INFO_PTR_TO_STRUCT(BCO_LIT(o_itbl)); + StgInfoTable* itbl = INFO_PTR_TO_STRUCT((StgInfoTable *)BCO_LIT(o_itbl)); int request = CONSTR_sizeW( itbl->layout.payload.ptrs, itbl->layout.payload.nptrs ); StgClosure* con = (StgClosure*)allocate_NONUPD(cap,request); diff --git a/rts/sm/Compact.c b/rts/sm/Compact.c index 987f78b497..6a50f436d7 100644 --- a/rts/sm/Compact.c +++ b/rts/sm/Compact.c @@ -382,7 +382,7 @@ thread_stack(StgPtr p, StgPtr stack_end) StgRetFun *ret_fun = (StgRetFun *)p; StgFunInfoTable *fun_info; - fun_info = FUN_INFO_PTR_TO_STRUCT(UNTAG_CLOSURE((StgClosure *) + fun_info = FUN_INFO_PTR_TO_STRUCT((StgInfoTable *)UNTAG_CLOSURE((StgClosure *) get_threaded_info((StgPtr)ret_fun->fun))); // *before* threading it! thread(&ret_fun->fun); @@ -404,7 +404,7 @@ thread_PAP_payload (StgClosure *fun, StgClosure **payload, StgWord size) StgWord bitmap; StgFunInfoTable *fun_info; - fun_info = FUN_INFO_PTR_TO_STRUCT(UNTAG_CLOSURE((StgClosure *) + fun_info = FUN_INFO_PTR_TO_STRUCT((StgInfoTable *)UNTAG_CLOSURE((StgClosure *) get_threaded_info((StgPtr)fun))); ASSERT(fun_info->i.type != PAP); @@ -818,7 +818,7 @@ update_fwd_compact( bdescr *blocks ) // that if (p&BLOCK_MASK) >= (free&BLOCK_MASK), then we // definitely have enough room. Also see bug #1147. iptr = get_threaded_info(p); - info = INFO_PTR_TO_STRUCT(UNTAG_CLOSURE((StgClosure *)iptr)); + info = INFO_PTR_TO_STRUCT((StgInfoTable *)UNTAG_CLOSURE((StgClosure *)iptr)); q = p; diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c index 20a5b098c2..867cef81fb 100644 --- a/rts/sm/Evac.c +++ b/rts/sm/Evac.c @@ -875,7 +875,7 @@ selector_chain: // make sure someone else didn't get here first... if (IS_FORWARDING_PTR(info_ptr) || - INFO_PTR_TO_STRUCT(info_ptr)->type != THUNK_SELECTOR) { + INFO_PTR_TO_STRUCT((StgInfoTable *)info_ptr)->type != THUNK_SELECTOR) { // v. tricky now. The THUNK_SELECTOR has been evacuated // by another thread, and is now either a forwarding ptr or IND. // We need to extract ourselves from the current situation @@ -898,7 +898,7 @@ selector_chain: SET_INFO(p,&stg_WHITEHOLE_info); #endif - field = INFO_PTR_TO_STRUCT(info_ptr)->layout.selector_offset; + field = INFO_PTR_TO_STRUCT((StgInfoTable *)info_ptr)->layout.selector_offset; // The selectee might be a constructor closure, // so we untag the pointer. @@ -959,7 +959,7 @@ selector_loop: info_ptr = (StgWord)UNTAG_CLOSURE(val)->header.info; if (!IS_FORWARDING_PTR(info_ptr)) { - info = INFO_PTR_TO_STRUCT(info_ptr); + info = INFO_PTR_TO_STRUCT((StgInfoTable *)info_ptr); switch (info->type) { case IND: case IND_PERM: |