Commit 840a1cb0 authored by Austin Seipp's avatar Austin Seipp

includes: detabify/dewhitespace rts/storage/ClosureMacros.h

Signed-off-by: default avatarAustin Seipp <austin@well-typed.com>
parent 98b1b13f
...@@ -25,25 +25,25 @@ ...@@ -25,25 +25,25 @@
"info pointer" The first word of the closure. Might point "info pointer" The first word of the closure. Might point
to either the end or the beginning of the to either the end or the beginning of the
info table, depending on whether we're using info table, depending on whether we're using
the mini interpreter or not. GET_INFO(c) the mini interpreter or not. GET_INFO(c)
retrieves the info pointer of a closure. retrieves the info pointer of a closure.
"info table" The info table structure associated with a "info table" The info table structure associated with a
closure. This is always a pointer to the closure. This is always a pointer to the
beginning of the structure, so we can beginning of the structure, so we can
use standard C structure indexing to pull out use standard C structure indexing to pull out
the fields. get_itbl(c) returns a pointer to the fields. get_itbl(c) returns a pointer to
the info table for closure c. the info table for closure c.
An address of the form xxxx_info points to the end of the info An address of the form xxxx_info points to the end of the info
table or the beginning of the info table depending on whether we're table or the beginning of the info table depending on whether we're
mangling or not respectively. So, mangling or not respectively. So,
c->header.info = xxx_info c->header.info = xxx_info
makes absolute sense, whether mangling or not. makes absolute sense, whether mangling or not.
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
INLINE_HEADER void SET_INFO(StgClosure *c, const StgInfoTable *info) { INLINE_HEADER void SET_INFO(StgClosure *c, const StgInfoTable *info) {
...@@ -103,8 +103,8 @@ INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con) { ...@@ -103,8 +103,8 @@ INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con) {
#ifdef PROFILING #ifdef PROFILING
#ifdef DEBUG_RETAINER #ifdef DEBUG_RETAINER
/* /*
For the sake of debugging, we take the safest way for the moment. Actually, this For the sake of debugging, we take the safest way for the moment. Actually, this
is useful to check the sanity of heap before beginning retainer profiling. is useful to check the sanity of heap before beginning retainer profiling.
flip is defined in RetainerProfile.c, and declared as extern in RetainerProfile.h. flip is defined in RetainerProfile.c, and declared as extern in RetainerProfile.h.
Note: change those functions building Haskell objects from C datatypes, i.e., Note: change those functions building Haskell objects from C datatypes, i.e.,
...@@ -116,7 +116,7 @@ INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con) { ...@@ -116,7 +116,7 @@ INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con) {
/* /*
For retainer profiling only: we do not have to set (c)->header.prof.hp.rs to For retainer profiling only: we do not have to set (c)->header.prof.hp.rs to
NULL | flip (flip is defined in RetainerProfile.c) because even when flip NULL | flip (flip is defined in RetainerProfile.c) because even when flip
is 1, rs is invalid and will be initialized to NULL | flip later when is 1, rs is invalid and will be initialized to NULL | flip later when
the closure *c is visited. the closure *c is visited.
*/ */
/* /*
...@@ -136,14 +136,14 @@ INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con) { ...@@ -136,14 +136,14 @@ INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con) {
#define SET_PROF_HDR(c,ccs) #define SET_PROF_HDR(c,ccs)
#endif #endif
#define SET_HDR(c,_info,ccs) \ #define SET_HDR(c,_info,ccs) \
{ \ { \
(c)->header.info = _info; \ (c)->header.info = _info; \
SET_PROF_HDR((StgClosure *)(c),ccs); \ SET_PROF_HDR((StgClosure *)(c),ccs); \
} }
#define SET_ARR_HDR(c,info,costCentreStack,n_bytes) \ #define SET_ARR_HDR(c,info,costCentreStack,n_bytes) \
SET_HDR(c,info,costCentreStack); \ SET_HDR(c,info,costCentreStack); \
(c)->bytes = n_bytes; (c)->bytes = n_bytes;
// Use when changing a closure from one kind to another // Use when changing a closure from one kind to another
...@@ -163,17 +163,17 @@ INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con) { ...@@ -163,17 +163,17 @@ INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con) {
INLINE_HEADER StgClosure ** INLINE_HEADER StgClosure **
STATIC_LINK(const StgInfoTable *info, StgClosure *p) STATIC_LINK(const StgInfoTable *info, StgClosure *p)
{ {
switch (info->type) { switch (info->type) {
case THUNK_STATIC: case THUNK_STATIC:
return THUNK_STATIC_LINK(p); return THUNK_STATIC_LINK(p);
case FUN_STATIC: case FUN_STATIC:
return FUN_STATIC_LINK(p); return FUN_STATIC_LINK(p);
case IND_STATIC: case IND_STATIC:
return IND_STATIC_LINK(p); return IND_STATIC_LINK(p);
default: default:
return &(p)->payload[info->layout.payload.ptrs + return &(p)->payload[info->layout.payload.ptrs +
info->layout.payload.nptrs]; info->layout.payload.nptrs];
} }
} }
...@@ -350,58 +350,58 @@ closure_sizeW_ (StgClosure *p, StgInfoTable *info) ...@@ -350,58 +350,58 @@ closure_sizeW_ (StgClosure *p, StgInfoTable *info)
switch (info->type) { switch (info->type) {
case THUNK_0_1: case THUNK_0_1:
case THUNK_1_0: case THUNK_1_0:
return sizeofW(StgThunk) + 1; return sizeofW(StgThunk) + 1;
case FUN_0_1: case FUN_0_1:
case CONSTR_0_1: case CONSTR_0_1:
case FUN_1_0: case FUN_1_0:
case CONSTR_1_0: case CONSTR_1_0:
return sizeofW(StgHeader) + 1; return sizeofW(StgHeader) + 1;
case THUNK_0_2: case THUNK_0_2:
case THUNK_1_1: case THUNK_1_1:
case THUNK_2_0: case THUNK_2_0:
return sizeofW(StgThunk) + 2; return sizeofW(StgThunk) + 2;
case FUN_0_2: case FUN_0_2:
case CONSTR_0_2: case CONSTR_0_2:
case FUN_1_1: case FUN_1_1:
case CONSTR_1_1: case CONSTR_1_1:
case FUN_2_0: case FUN_2_0:
case CONSTR_2_0: case CONSTR_2_0:
return sizeofW(StgHeader) + 2; return sizeofW(StgHeader) + 2;
case THUNK: case THUNK:
return thunk_sizeW_fromITBL(info); return thunk_sizeW_fromITBL(info);
case THUNK_SELECTOR: case THUNK_SELECTOR:
return THUNK_SELECTOR_sizeW(); return THUNK_SELECTOR_sizeW();
case AP_STACK: case AP_STACK:
return ap_stack_sizeW((StgAP_STACK *)p); return ap_stack_sizeW((StgAP_STACK *)p);
case AP: case AP:
return ap_sizeW((StgAP *)p); return ap_sizeW((StgAP *)p);
case PAP: case PAP:
return pap_sizeW((StgPAP *)p); return pap_sizeW((StgPAP *)p);
case IND: case IND:
case IND_PERM: case IND_PERM:
return sizeofW(StgInd); return sizeofW(StgInd);
case ARR_WORDS: case ARR_WORDS:
return arr_words_sizeW((StgArrWords *)p); return arr_words_sizeW((StgArrWords *)p);
case MUT_ARR_PTRS_CLEAN: case MUT_ARR_PTRS_CLEAN:
case MUT_ARR_PTRS_DIRTY: case MUT_ARR_PTRS_DIRTY:
case MUT_ARR_PTRS_FROZEN: case MUT_ARR_PTRS_FROZEN:
case MUT_ARR_PTRS_FROZEN0: case MUT_ARR_PTRS_FROZEN0:
return mut_arr_ptrs_sizeW((StgMutArrPtrs*)p); return mut_arr_ptrs_sizeW((StgMutArrPtrs*)p);
case SMALL_MUT_ARR_PTRS_CLEAN: case SMALL_MUT_ARR_PTRS_CLEAN:
case SMALL_MUT_ARR_PTRS_DIRTY: case SMALL_MUT_ARR_PTRS_DIRTY:
case SMALL_MUT_ARR_PTRS_FROZEN: case SMALL_MUT_ARR_PTRS_FROZEN:
case SMALL_MUT_ARR_PTRS_FROZEN0: case SMALL_MUT_ARR_PTRS_FROZEN0:
return small_mut_arr_ptrs_sizeW((StgSmallMutArrPtrs*)p); return small_mut_arr_ptrs_sizeW((StgSmallMutArrPtrs*)p);
case TSO: case TSO:
return sizeofW(StgTSO); return sizeofW(StgTSO);
case STACK: case STACK:
return stack_sizeW((StgStack*)p); return stack_sizeW((StgStack*)p);
case BCO: case BCO:
return bco_sizeW((StgBCO *)p); return bco_sizeW((StgBCO *)p);
case TREC_CHUNK: case TREC_CHUNK:
return sizeofW(StgTRecChunk); return sizeofW(StgTRecChunk);
default: default:
return sizeW_fromITBL(info); return sizeW_fromITBL(info);
} }
} }
...@@ -425,16 +425,16 @@ EXTERN_INLINE StgWord stack_frame_sizeW( StgClosure *frame ) ...@@ -425,16 +425,16 @@ EXTERN_INLINE StgWord stack_frame_sizeW( StgClosure *frame )
switch (info->i.type) { switch (info->i.type) {
case RET_FUN: case RET_FUN:
return sizeofW(StgRetFun) + ((StgRetFun *)frame)->size; return sizeofW(StgRetFun) + ((StgRetFun *)frame)->size;
case RET_BIG: case RET_BIG:
return 1 + GET_LARGE_BITMAP(&info->i)->size; return 1 + GET_LARGE_BITMAP(&info->i)->size;
case RET_BCO: case RET_BCO:
return 2 + BCO_BITMAP_SIZE((StgBCO *)((P_)frame)[1]); return 2 + BCO_BITMAP_SIZE((StgBCO *)((P_)frame)[1]);
default: default:
return 1 + BITMAP_SIZE(info->i.layout.bitmap); return 1 + BITMAP_SIZE(info->i.layout.bitmap);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment