From: simonmar Date: Fri, 17 Mar 2000 14:37:22 +0000 (+0000) Subject: [project @ 2000-03-17 14:37:21 by simonmar] X-Git-Tag: Approximately_9120_patches~4955 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=b53f0596d8afc5d6f1dcc335e7aed5afdd0a5578;p=ghc-hetmet.git [project @ 2000-03-17 14:37:21 by simonmar] More random cleanups. --- diff --git a/ghc/includes/ClosureMacros.h b/ghc/includes/ClosureMacros.h index 6cfeb66..b1ac095 100644 --- a/ghc/includes/ClosureMacros.h +++ b/ghc/includes/ClosureMacros.h @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- - * $Id: ClosureMacros.h,v 1.20 1999/10/27 09:57:48 simonmar Exp $ + * $Id: ClosureMacros.h,v 1.21 2000/03/17 14:37:21 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -213,28 +213,17 @@ static __inline__ StgOffset CAF_sizeW ( void ) * Sizes of closures * ------------------------------------------------------------------------*/ -static __inline__ StgOffset size_fromITBL( const StgInfoTable* itbl ) -{ return sizeof(StgClosure) - + sizeof(StgPtr) * itbl->layout.payload.ptrs - + sizeof(StgWord) * itbl->layout.payload.nptrs; } - static __inline__ StgOffset sizeW_fromITBL( const StgInfoTable* itbl ) { return sizeofW(StgClosure) + sizeofW(StgPtr) * itbl->layout.payload.ptrs + sizeofW(StgWord) * itbl->layout.payload.nptrs; } -static __inline__ StgOffset pap_size( StgPAP* x ) -{ return sizeof(StgPAP) - + sizeof(StgWord) * x->n_args; } - static __inline__ StgOffset pap_sizeW( StgPAP* x ) { return PAP_sizeW(x->n_args); } -/* These two functions give the same result - but have slightly - * different types. - */ static __inline__ StgOffset arr_words_sizeW( StgArrWords* x ) { return sizeofW(StgArrWords) + x->words; } + static __inline__ StgOffset mut_arr_ptrs_sizeW( StgMutArrPtrs* x ) { return sizeofW(StgMutArrPtrs) + x->ptrs; } @@ -264,8 +253,6 @@ static __inline__ StgWord tso_sizeW ( StgTSO *tso ) #define SET_STATIC_GRAN_HDR #endif -/* there is no PAR header, as far as I can tell -- SDM */ - #ifdef PAR #define SET_PAR_HDR(c,stuff) #define SET_STATIC_PAR_HDR(stuff) @@ -275,47 +262,47 @@ static __inline__ StgWord tso_sizeW ( StgTSO *tso ) #endif #ifdef TICKY_TICKY -#define SET_TICKY_HDR(c,stuff) /* old: (c)->header.ticky.updated = stuff */ -#define SET_STATIC_TICKY_HDR(stuff) /* old: ticky : { updated : stuff } */ +#define SET_TICKY_HDR(c,stuff) /* old: (c)->header.ticky.updated = stuff */ +#define SET_STATIC_TICKY_HDR(stuff) /* old: ticky : { updated : stuff } */ #else #define SET_TICKY_HDR(c,stuff) #define SET_STATIC_TICKY_HDR(stuff) #endif -#define SET_HDR(c,info,ccs) \ - { \ - SET_INFO(c,info); \ +#define SET_HDR(c,info,ccs) \ + { \ + SET_INFO(c,info); \ SET_GRAN_HDR((StgClosure *)(c),ThisPE); \ SET_PAR_HDR((StgClosure *)(c),LOCAL_GA); \ SET_PROF_HDR((StgClosure *)(c),ccs); \ SET_TICKY_HDR((StgClosure *)(c),0); \ } -#define SET_ARR_HDR(c,info,costCentreStack,n_words) \ - SET_HDR(c,info,costCentreStack); \ +#define SET_ARR_HDR(c,info,costCentreStack,n_words) \ + SET_HDR(c,info,costCentreStack); \ (c)->words = n_words; /* ----------------------------------------------------------------------------- Static closures are defined as follows: -SET_STATIC_HDR(PrelBase_CZh_closure,PrelBase_CZh_info,costCentreStack,const); + SET_STATIC_HDR(PrelBase_CZh_closure,PrelBase_CZh_info,costCentreStack,const); The info argument must have type 'StgInfoTable' or 'StgSRTInfoTable', since we use '&' to get its address in the macro. -------------------------------------------------------------------------- */ -#define SET_STATIC_HDR(label,info,costCentreStack,closure_class,info_class) \ - info_class info; \ - closure_class StgClosure label = { \ +#define SET_STATIC_HDR(label,info,costCentreStack,closure_class,info_class) \ + info_class info; \ + closure_class StgClosure label = { \ STATIC_HDR(info,costCentreStack) -#define STATIC_HDR(info,ccs) \ - header : { \ - INIT_INFO(info), \ - SET_STATIC_GRAN_HDR \ - SET_STATIC_PAR_HDR(LOCAL_GA) \ - SET_STATIC_PROF_HDR(ccs) \ - SET_STATIC_TICKY_HDR(0) \ +#define STATIC_HDR(info,ccs) \ + header : { \ + INIT_INFO(info), \ + SET_STATIC_GRAN_HDR \ + SET_STATIC_PAR_HDR(LOCAL_GA) \ + SET_STATIC_PROF_HDR(ccs) \ + SET_STATIC_TICKY_HDR(0) \ } /* how to get hold of the static link field for a static closure. @@ -323,9 +310,10 @@ SET_STATIC_HDR(PrelBase_CZh_closure,PrelBase_CZh_info,costCentreStack,const); * 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) \ - (*stgCast(StgClosure**,&((p)->payload[info->layout.payload.ptrs + \ +#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. @@ -334,8 +322,8 @@ SET_STATIC_HDR(PrelBase_CZh_closure,PrelBase_CZh_info,costCentreStack,const); #define THUNK_STATIC_LINK(p) ((p)->payload[2]) #define IND_STATIC_LINK(p) ((p)->payload[1]) -#define STATIC_LINK2(info,p) \ - (*stgCast(StgClosure**,&((p)->payload[info->layout.payload.ptrs + \ +#define STATIC_LINK2(info,p) \ + (*(StgClosure**)(&((p)->payload[info->layout.payload.ptrs + \ info->layout.payload.nptrs + 1]))) /* ----------------------------------------------------------------------------- @@ -352,14 +340,6 @@ SET_STATIC_HDR(PrelBase_CZh_closure,PrelBase_CZh_info,costCentreStack,const); #define CLOSURE_TBL(lbl) const StgClosure *lbl[] = { /* ----------------------------------------------------------------------------- - Payload access - -------------------------------------------------------------------------- */ - -#define payloadPtr( c, i ) (*stgCast(StgPtr*, ((c)->payload+(i)))) -#define payloadCPtr( c, i ) (*stgCast(StgClosure**, ((c)->payload+(i)))) -#define payloadWord( c, i ) (*stgCast(StgWord*, ((c)->payload+(i)))) - -/* ----------------------------------------------------------------------------- CONSTRs. -------------------------------------------------------------------------- */ diff --git a/ghc/rts/Assembler.c b/ghc/rts/Assembler.c index dec5bd9..b0a42cc 100644 --- a/ghc/rts/Assembler.c +++ b/ghc/rts/Assembler.c @@ -5,8 +5,8 @@ * Copyright (c) 1994-1998. * * $RCSfile: Assembler.c,v $ - * $Revision: 1.22 $ - * $Date: 1999/12/07 11:49:09 $ + * $Revision: 1.23 $ + * $Date: 2000/03/17 14:37:21 $ * * This module provides functions to construct BCOs and other closures * required by the bytecode compiler. @@ -178,8 +178,8 @@ static void asmResolveRef( AsmObject obj, AsmNat i, AsmClosure reference ) case CONSTR: { StgClosure* con = stgCast(StgClosure*,obj->closure); - ASSERT(i < get_itbl(con)->layout.payload.nptrs && payloadCPtr(con,i) == NULL); - payloadCPtr(con,i) = reference; + ASSERT(i < get_itbl(con)->layout.payload.nptrs && con->payload[i] == NULL); + con->payload[i] = reference; break; } case AP_UPD: @@ -190,8 +190,8 @@ static void asmResolveRef( AsmObject obj, AsmNat i, AsmClosure reference ) ASSERT(ap->fun == NULL); ap->fun = reference; } else { - ASSERT(payloadCPtr(ap,i-1) == NULL); - payloadCPtr(ap,i-1) = reference; + ASSERT(ap->payload[i-1] == NULL); + ap->payload[i-1] = reference; } break; } @@ -323,8 +323,8 @@ void asmEndCon( AsmCon con ) StgClosure* c = asmAlloc(CONSTR_sizeW(p,np)); StgClosure* o = stgCast(StgClosure*,c); SET_HDR(o,con->info,??); - mapQueue(Ptrs, AsmObject, con->object.ptrs, payloadCPtr(o,i) = NULL); - { nat i; for( i=0; iobject.ptrs, o->payload[i] = NULL); + { nat i; for( i=0; ipayload[p+i] = (StgClosure *)0xdeadbeef; }} asmEndObject(&con->object,c); } diff --git a/ghc/rts/Evaluator.c b/ghc/rts/Evaluator.c index 0624184..0d07a96 100644 --- a/ghc/rts/Evaluator.c +++ b/ghc/rts/Evaluator.c @@ -5,8 +5,8 @@ * Copyright (c) 1994-1998. * * $RCSfile: Evaluator.c,v $ - * $Revision: 1.41 $ - * $Date: 2000/03/17 13:30:23 $ + * $Revision: 1.42 $ + * $Date: 2000/03/17 14:37:21 $ * ---------------------------------------------------------------------------*/ #include "Rts.h" @@ -41,7 +41,8 @@ #include /* These are for primops */ #endif - +/* Allegedly useful macro */ +#define payloadWord( c, i ) (*stgCast(StgWord*, ((c)->payload+(i)))) /* An incredibly useful abbreviation. * Interestingly, there are some uses of END_TSO_QUEUE_closure that @@ -772,7 +773,7 @@ StgThreadReturnCode enter( Capability* cap, StgClosure* obj0 ) nat np = info->layout.payload.nptrs; nat i; for(i=0; i < p; ++i) { - payloadCPtr(o,i) = xPopCPtr(); + o->payload[i] = xPopCPtr(); } for(i=0; i < np; ++i) { payloadWord(o,p+i) = 0xdeadbeef; @@ -794,7 +795,7 @@ StgThreadReturnCode enter( Capability* cap, StgClosure* obj0 ) nat np = info->layout.payload.nptrs; nat i; for(i=0; i < p; ++i) { - payloadCPtr(o,i) = xPopCPtr(); + o->payload[i] = xPopCPtr(); } for(i=0; i < np; ++i) { payloadWord(o,p+i) = 0xdeadbeef; @@ -867,7 +868,7 @@ StgThreadReturnCode enter( Capability* cap, StgClosure* obj0 ) || itbl->type == CONSTR_0_2 ); while (--i>=0) { - xPushCPtr(payloadCPtr(o,i)); + xPushCPtr(o->payload[i]); } Continue; } diff --git a/ghc/rts/Exception.hc b/ghc/rts/Exception.hc index a9c1c9a..294fa85 100644 --- a/ghc/rts/Exception.hc +++ b/ghc/rts/Exception.hc @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Exception.hc,v 1.10 2000/03/17 13:30:23 simonmar Exp $ + * $Id: Exception.hc,v 1.11 2000/03/17 14:37:21 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -283,8 +283,8 @@ INFO_TABLE(catch_info,catch_entry,2,0,FUN,,EF_,0,0); STGFUN(catch_entry) { FB_ - R2.cl = payloadCPtr(R1.cl,1); /* h */ - R1.cl = payloadCPtr(R1.cl,0); /* x */ + R2.cl = R1.cl->payload[1]; /* h */ + R1.cl = R1.cl->payload[0]; /* x */ JMP_(catchzh_fast); FE_ } diff --git a/ghc/rts/Printer.c b/ghc/rts/Printer.c index c165ada..3550d6c 100644 --- a/ghc/rts/Printer.c +++ b/ghc/rts/Printer.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Printer.c,v 1.21 2000/02/14 10:59:30 sewardj Exp $ + * $Id: Printer.c,v 1.22 2000/03/17 14:37:21 simonmar Exp $ * * (c) The GHC Team, 1994-2000. * @@ -89,10 +89,10 @@ static void printStdObject( StgClosure *obj, char* tag ) printPtr((StgPtr)obj->header.info); for (i = 0; i < info->layout.payload.ptrs; ++i) { fprintf(stderr,", "); - printPtr(payloadPtr(obj,i)); + printPtr((StgPtr)obj->payload[i]); } for (j = 0; j < info->layout.payload.nptrs; ++j) { - fprintf(stderr,", %xd#",payloadWord(obj,i+j)); + fprintf(stderr,", %pd#",obj->payload[i+j]); } fprintf(stderr,")\n"); } @@ -116,7 +116,7 @@ void printClosure( StgClosure *obj ) fprintf(stderr,"AP_UPD("); printPtr((StgPtr)ap->fun); for (i = 0; i < ap->n_args; ++i) { fprintf(stderr,", "); - printPtr(payloadPtr(ap,i)); + printPtr(ap->payload[i]); } fprintf(stderr,")\n"); break; @@ -129,7 +129,7 @@ void printClosure( StgClosure *obj ) fprintf(stderr,"PAP("); printPtr((StgPtr)pap->fun); for (i = 0; i < pap->n_args; ++i) { fprintf(stderr,", "); - printPtr(payloadPtr(pap,i)); + printPtr((StgPtr)pap->payload[i]); } fprintf(stderr,")\n"); break; @@ -229,10 +229,10 @@ void printClosure( StgClosure *obj ) fprintf(stderr,"(tag=%d)",info->srt_len); for (i = 0; i < info->layout.payload.ptrs; ++i) { fprintf(stderr,", "); - printPtr(payloadPtr(obj,i)); + printPtr((StgPtr)obj->payload[i]); } for (j = 0; j < info->layout.payload.nptrs; ++j) { - fprintf(stderr,", %x#",payloadWord(obj,i+j)); + fprintf(stderr,", %p#", obj->payload[i+j]); } fprintf(stderr,")\n"); break; diff --git a/ghc/rts/Sanity.c b/ghc/rts/Sanity.c index e5a1f50..70eb38a 100644 --- a/ghc/rts/Sanity.c +++ b/ghc/rts/Sanity.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Sanity.c,v 1.17 2000/03/17 13:30:24 simonmar Exp $ + * $Id: Sanity.c,v 1.18 2000/03/17 14:37:21 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -246,7 +246,7 @@ checkClosure( StgClosure* p ) { nat i; for (i = 0; i < info->layout.payload.ptrs; i++) { - ASSERT(LOOKS_LIKE_PTR(payloadPtr(p,i))); + ASSERT(LOOKS_LIKE_PTR(p->payload[i])); } return stg_max(sizeW_fromITBL(info), sizeofW(StgHeader) + MIN_UPD_SIZE); } @@ -288,7 +288,7 @@ checkClosure( StgClosure* p ) { nat i; for (i = 0; i < info->layout.payload.ptrs; i++) { - ASSERT(LOOKS_LIKE_PTR(payloadPtr(p,i))); + ASSERT(LOOKS_LIKE_PTR(p->payload[i])); } return sizeW_fromITBL(info); } diff --git a/ghc/rts/Schedule.c b/ghc/rts/Schedule.c index 16295f9..5ffd4b6 100644 --- a/ghc/rts/Schedule.c +++ b/ghc/rts/Schedule.c @@ -1,5 +1,5 @@ /* --------------------------------------------------------------------------- - * $Id: Schedule.c,v 1.55 2000/03/17 13:30:24 simonmar Exp $ + * $Id: Schedule.c,v 1.56 2000/03/17 14:37:21 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -2304,7 +2304,7 @@ raiseAsync(StgTSO *tso, StgClosure *exception) o = (StgClosure *)allocate(sizeofW(StgClosure)+1); TICK_ALLOC_SE_THK(1,0); SET_HDR(o,&seq_info,su->header.prof.ccs /* ToDo */); - payloadCPtr(o,0) = (StgClosure *)ap; + o->payload[0] = (StgClosure *)ap; IF_DEBUG(scheduler, fprintf(stderr, "scheduler: Built "); diff --git a/ghc/rts/parallel/Pack.c b/ghc/rts/parallel/Pack.c index b5484a1..cebe92c 100644 --- a/ghc/rts/parallel/Pack.c +++ b/ghc/rts/parallel/Pack.c @@ -1,6 +1,6 @@ /* Time-stamp: - $Id: Pack.c,v 1.2 2000/01/13 14:34:08 hwloidl Exp $ + $Id: Pack.c,v 1.3 2000/03/17 14:37:22 simonmar Exp $ Graph packing and unpacking code for sending it to another processor and retrieving the original graph structure from the packet. @@ -1185,10 +1185,10 @@ StgClosure *closure; Pack(closure); for (i = 0; i < ptrs; ++i) { /* extract i-th pointer from closure */ - QueueClosure((StgClosure *)payloadPtr(closure,i)); + QueueClosure((StgClosure *)(closure->payload[i])); IF_GRAN_DEBUG(pack, belch("** [%p (%s) (Queueing closure) ....]", - payloadPtr(closure,i), info_type(payloadPtr(closure,i)))); + closure->payload[i], info_type(payloadPtr(closure,i)))); } /*