X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FClosureMacros.h;h=f40f6aace6d283f3ddfe74d39f255e824b13677a;hb=a0f46309637779ccc141ec531e9b128596a5bba0;hp=e2519bb5039c23cea559a10c615d5431ec85329f;hpb=423d477bfecd490de1449c59325c8776f91d7aac;p=ghc-hetmet.git diff --git a/ghc/includes/ClosureMacros.h b/ghc/includes/ClosureMacros.h index e2519bb..f40f6aa 100644 --- a/ghc/includes/ClosureMacros.h +++ b/ghc/includes/ClosureMacros.h @@ -114,7 +114,7 @@ #define SET_PROF_HDR(c,ccs_) \ ((c)->header.prof.ccs = ccs_, \ LDV_RECORD_CREATE((c))) -#endif // DEBUG_RETAINER +#endif /* DEBUG_RETAINER */ #define SET_STATIC_PROF_HDR(ccs_) \ prof : { ccs : (CostCentreStack *)ccs_, hp : { rs : NULL } }, #else @@ -161,30 +161,28 @@ /* ----------------------------------------------------------------------------- How to get hold of the static link field for a static closure. - - Note that we have to use (*cast(T*,&e)) instead of cast(T,e) - because C won't let us take the address of a casted - expression. Huh? -------------------------------------------------------------------------- */ -#define STATIC_LINK(info,p) \ - (*(StgClosure**)(&((p)->payload[info->layout.payload.ptrs + \ - info->layout.payload.nptrs]))) - -/* These macros are optimised versions of the above for certain - * closure types. They *must* be equivalent to the generic - * STATIC_LINK. - * - * You may be surprised that the STATIC_LINK field for a THUNK_STATIC - * is at offset 2; that's because a THUNK_STATIC always has two words - * of (non-ptr) padding, to make room for the IND_STATIC that is - * going to overwrite it. It doesn't do any harm, because a - * THUNK_STATIC needs this extra word for the IND_STATIC's saved_info - * field anyhow. Hmm, this is all rather delicate. --SDM - */ -#define FUN_STATIC_LINK(p) ((p)->payload[0]) -#define THUNK_STATIC_LINK(p) ((p)->payload[2]) -#define IND_STATIC_LINK(p) ((p)->payload[1]) +/* These are hard-coded. */ +#define FUN_STATIC_LINK(p) (&(p)->payload[0]) +#define THUNK_STATIC_LINK(p) (&(p)->payload[1]) +#define IND_STATIC_LINK(p) (&(p)->payload[1]) + +INLINE_HEADER StgClosure ** +STATIC_LINK(const StgInfoTable *info, StgClosure *p) +{ + switch (info->type) { + case THUNK_STATIC: + return THUNK_STATIC_LINK(p); + case FUN_STATIC: + return FUN_STATIC_LINK(p); + case IND_STATIC: + return IND_STATIC_LINK(p); + default: + return &(p)->payload[info->layout.payload.ptrs + + info->layout.payload.nptrs]; + } +} #define STATIC_LINK2(info,p) \ (*(StgClosure**)(&((p)->payload[info->layout.payload.ptrs + \