More random cleanups.
/* ----------------------------------------------------------------------------
- * $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
*
* 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; }
#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)
#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.
* 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.
#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])))
/* -----------------------------------------------------------------------------
#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.
-------------------------------------------------------------------------- */
* 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.
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:
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;
}
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; i<np; ++i ) { payloadWord(o,p+i) = 0xdeadbeef; } }
+ mapQueue(Ptrs, AsmObject, con->object.ptrs, o->payload[i] = NULL);
+ { nat i; for( i=0; i<np; ++i ) { o->payload[p+i] = (StgClosure *)0xdeadbeef; }}
asmEndObject(&con->object,c);
}
* 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"
#include <ieee754.h> /* 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
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;
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;
|| itbl->type == CONSTR_0_2
);
while (--i>=0) {
- xPushCPtr(payloadCPtr(o,i));
+ xPushCPtr(o->payload[i]);
}
Continue;
}
/* -----------------------------------------------------------------------------
- * $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
*
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_
}
/* -----------------------------------------------------------------------------
- * $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.
*
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");
}
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;
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;
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;
/* -----------------------------------------------------------------------------
- * $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
*
{
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);
}
{
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);
}
/* ---------------------------------------------------------------------------
- * $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
*
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 ");
/*
Time-stamp: <Thu Dec 16 1999 18:21:17 Stardate: [-30]4058.61 software>
- $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.
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))));
}
/*