Commit 8413d838 authored by ian@well-typed.com's avatar ian@well-typed.com

Make a function for get_itbl, rather than using a CPP macro

This has several advantages:
* It can be called from gdb
* There is more type information for the user, and type checking
  for the compiler
* Less opportunity for things to go wrong, e.g. due to missing
  parentheses or repeated execution

The sizes of the non-debug .o files hasn't changed (other than
Inlines.o), so I'm pretty sure the compiled code is identical.
parent 75f2e87b
......@@ -50,12 +50,6 @@
#define GET_INFO(c) ((c)->header.info)
#define GET_ENTRY(c) (ENTRY_CODE(GET_INFO(c)))
#define get_itbl(c) (INFO_PTR_TO_STRUCT((c)->header.info))
#define get_ret_itbl(c) (RET_INFO_PTR_TO_STRUCT((c)->header.info))
#define get_fun_itbl(c) (FUN_INFO_PTR_TO_STRUCT((c)->header.info))
#define get_thunk_itbl(c) (THUNK_INFO_PTR_TO_STRUCT((c)->header.info))
#define get_con_itbl(c) (CON_INFO_PTR_TO_STRUCT((c)->header.info))
#define GET_TAG(con) (get_itbl(con)->srt_bitmap)
#ifdef TABLES_NEXT_TO_CODE
......@@ -80,6 +74,13 @@
#define itbl_to_con_itbl(i) ((StgConInfoTable *)(i))
#endif
EXTERN_INLINE StgInfoTable *get_itbl(StgClosure *c);
EXTERN_INLINE StgInfoTable *get_itbl(StgClosure *c) {return INFO_PTR_TO_STRUCT(c->header.info);}
#define get_ret_itbl(c) (RET_INFO_PTR_TO_STRUCT((c)->header.info))
#define get_fun_itbl(c) (FUN_INFO_PTR_TO_STRUCT((c)->header.info))
#define get_thunk_itbl(c) (THUNK_INFO_PTR_TO_STRUCT((c)->header.info))
#define get_con_itbl(c) (CON_INFO_PTR_TO_STRUCT((c)->header.info))
/* -----------------------------------------------------------------------------
Macros for building closures
-------------------------------------------------------------------------- */
......
......@@ -91,7 +91,7 @@ printThunkPayload( StgThunk *obj )
StgWord i, j;
const StgInfoTable* info;
info = get_itbl(obj);
info = get_itbl((StgClosure *)obj);
for (i = 0; i < info->layout.payload.ptrs; ++i) {
debugBelch(", ");
printPtr((StgPtr)obj->payload[i]);
......
......@@ -306,7 +306,7 @@ check_target:
// ASSUMPTION: tso->block_info must always point to a
// closure. In the threaded RTS it does.
switch (get_itbl(mvar)->type) {
switch (get_itbl((StgClosure *)mvar)->type) {
case MVAR_CLEAN:
case MVAR_DIRTY:
break;
......
......@@ -127,7 +127,7 @@ traverseWeakPtrList(void)
continue;
}
info = get_itbl(w);
info = get_itbl((StgClosure *)w);
switch (info->type) {
case WEAK:
......@@ -269,7 +269,7 @@ static rtsBool tidyThreadList (generation *gen)
t = tmp;
}
ASSERT(get_itbl(t)->type == TSO);
ASSERT(get_itbl((StgClosure *)t)->type == TSO);
next = t->global_link;
// if the thread is not masking exceptions but there are
......
......@@ -328,12 +328,12 @@ checkClosure( StgClosure* p )
// ASSERT(get_itbl(bq->bh)->type == BLACKHOLE);
ASSERT(LOOKS_LIKE_CLOSURE_PTR(bq->bh));
ASSERT(get_itbl(bq->owner)->type == TSO);
ASSERT(get_itbl((StgClosure *)(bq->owner))->type == TSO);
ASSERT(bq->queue == (MessageBlackHole*)END_TSO_QUEUE
|| bq->queue->header.info == &stg_MSG_BLACKHOLE_info);
ASSERT(bq->link == (StgBlockingQueue*)END_TSO_QUEUE ||
get_itbl(bq->link)->type == IND ||
get_itbl(bq->link)->type == BLOCKING_QUEUE);
get_itbl((StgClosure *)(bq->link))->type == IND ||
get_itbl((StgClosure *)(bq->link))->type == BLOCKING_QUEUE);
return sizeofW(StgBlockingQueue);
}
......@@ -567,7 +567,7 @@ checkGlobalTSOList (rtsBool checkTSOs)
for (tso=generations[g].threads; tso != END_TSO_QUEUE;
tso = tso->global_link) {
ASSERT(LOOKS_LIKE_CLOSURE_PTR(tso));
ASSERT(get_itbl(tso)->type == TSO);
ASSERT(get_itbl((StgClosure *)tso)->type == TSO);
if (checkTSOs)
checkTSO(tso);
......
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