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

Convert more RTS macros to functions

No size changes in the non-debug object files
parent 5f01b6dd
...@@ -46,11 +46,14 @@ ...@@ -46,11 +46,14 @@
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#define SET_INFO(c,i) ((c)->header.info = (i)) INLINE_HEADER void SET_INFO(StgClosure *c, const StgInfoTable *info) {
#define GET_INFO(c) ((c)->header.info) c->header.info = info;
#define GET_ENTRY(c) (ENTRY_CODE(GET_INFO(c))) }
INLINE_HEADER const StgInfoTable *GET_INFO(StgClosure *c) {
return c->header.info;
}
#define GET_TAG(con) (get_itbl(con)->srt_bitmap) #define GET_ENTRY(c) (ENTRY_CODE(GET_INFO(c)))
#ifdef TABLES_NEXT_TO_CODE #ifdef TABLES_NEXT_TO_CODE
EXTERN_INLINE StgInfoTable *INFO_PTR_TO_STRUCT(const StgInfoTable *info); EXTERN_INLINE StgInfoTable *INFO_PTR_TO_STRUCT(const StgInfoTable *info);
...@@ -90,6 +93,10 @@ INLINE_HEADER StgThunkInfoTable *get_thunk_itbl(const StgClosure *c) {return THU ...@@ -90,6 +93,10 @@ INLINE_HEADER StgThunkInfoTable *get_thunk_itbl(const StgClosure *c) {return THU
INLINE_HEADER StgConInfoTable *get_con_itbl(const StgClosure *c) {return CON_INFO_PTR_TO_STRUCT((c)->header.info);} INLINE_HEADER StgConInfoTable *get_con_itbl(const StgClosure *c) {return CON_INFO_PTR_TO_STRUCT((c)->header.info);}
INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con) {
return get_itbl(con)->srt_bitmap;
}
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Macros for building closures Macros for building closures
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
...@@ -142,7 +149,7 @@ INLINE_HEADER StgConInfoTable *get_con_itbl(const StgClosure *c) {return CON_INF ...@@ -142,7 +149,7 @@ INLINE_HEADER StgConInfoTable *get_con_itbl(const StgClosure *c) {return CON_INF
// Use when changing a closure from one kind to another // Use when changing a closure from one kind to another
#define OVERWRITE_INFO(c, new_info) \ #define OVERWRITE_INFO(c, new_info) \
OVERWRITING_CLOSURE((StgClosure *)(c)); \ OVERWRITING_CLOSURE((StgClosure *)(c)); \
SET_INFO((c), (new_info)); \ SET_INFO((StgClosure *)(c), (new_info)); \
LDV_RECORD_CREATE(c); LDV_RECORD_CREATE(c);
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
......
...@@ -339,7 +339,7 @@ eval_obj: ...@@ -339,7 +339,7 @@ eval_obj:
{ {
StgUpdateFrame *__frame; StgUpdateFrame *__frame;
__frame = (StgUpdateFrame *)Sp; __frame = (StgUpdateFrame *)Sp;
SET_INFO(__frame, (StgInfoTable *)&stg_upd_frame_info); SET_INFO((StgClosure *)__frame, (StgInfoTable *)&stg_upd_frame_info);
__frame->updatee = (StgClosure *)(ap); __frame->updatee = (StgClosure *)(ap);
} }
......
...@@ -259,7 +259,7 @@ printClosure( StgClosure *obj ) ...@@ -259,7 +259,7 @@ printClosure( StgClosure *obj )
{ {
StgUpdateFrame* u = (StgUpdateFrame*)obj; StgUpdateFrame* u = (StgUpdateFrame*)obj;
debugBelch("UPDATE_FRAME("); debugBelch("UPDATE_FRAME(");
printPtr((StgPtr)GET_INFO(u)); printPtr((StgPtr)GET_INFO((StgClosure *)u));
debugBelch(","); debugBelch(",");
printPtr((StgPtr)u->updatee); printPtr((StgPtr)u->updatee);
debugBelch(")\n"); debugBelch(")\n");
...@@ -270,7 +270,7 @@ printClosure( StgClosure *obj ) ...@@ -270,7 +270,7 @@ printClosure( StgClosure *obj )
{ {
StgCatchFrame* u = (StgCatchFrame*)obj; StgCatchFrame* u = (StgCatchFrame*)obj;
debugBelch("CATCH_FRAME("); debugBelch("CATCH_FRAME(");
printPtr((StgPtr)GET_INFO(u)); printPtr((StgPtr)GET_INFO((StgClosure *)u));
debugBelch(","); debugBelch(",");
printPtr((StgPtr)u->handler); printPtr((StgPtr)u->handler);
debugBelch(")\n"); debugBelch(")\n");
...@@ -290,7 +290,7 @@ printClosure( StgClosure *obj ) ...@@ -290,7 +290,7 @@ printClosure( StgClosure *obj )
{ {
StgStopFrame* u = (StgStopFrame*)obj; StgStopFrame* u = (StgStopFrame*)obj;
debugBelch("STOP_FRAME("); debugBelch("STOP_FRAME(");
printPtr((StgPtr)GET_INFO(u)); printPtr((StgPtr)GET_INFO((StgClosure *)u));
debugBelch(")\n"); debugBelch(")\n");
break; break;
} }
......
...@@ -794,11 +794,11 @@ unchain_thunk_selectors(StgSelector *p, StgClosure *val) ...@@ -794,11 +794,11 @@ unchain_thunk_selectors(StgSelector *p, StgClosure *val)
// entered, and should result in a NonTermination exception. // entered, and should result in a NonTermination exception.
((StgThunk *)p)->payload[0] = val; ((StgThunk *)p)->payload[0] = val;
write_barrier(); write_barrier();
SET_INFO(p, &stg_sel_0_upd_info); SET_INFO((StgClosure *)p, &stg_sel_0_upd_info);
} else { } else {
((StgInd *)p)->indirectee = val; ((StgInd *)p)->indirectee = val;
write_barrier(); write_barrier();
SET_INFO(p, &stg_IND_info); SET_INFO((StgClosure *)p, &stg_IND_info);
} }
// For the purposes of LDV profiling, we have created an // For the purposes of LDV profiling, we have created an
...@@ -885,7 +885,7 @@ selector_chain: ...@@ -885,7 +885,7 @@ selector_chain:
// - if evac, we need to call evacuate(), because we // - if evac, we need to call evacuate(), because we
// need the write-barrier stuff. // need the write-barrier stuff.
// - undo the chain we've built to point to p. // - undo the chain we've built to point to p.
SET_INFO(p, (const StgInfoTable *)info_ptr); SET_INFO((StgClosure *)p, (const StgInfoTable *)info_ptr);
*q = (StgClosure *)p; *q = (StgClosure *)p;
if (evac) evacuate(q); if (evac) evacuate(q);
unchain_thunk_selectors(prev_thunk_selector, (StgClosure *)p); unchain_thunk_selectors(prev_thunk_selector, (StgClosure *)p);
...@@ -895,7 +895,7 @@ selector_chain: ...@@ -895,7 +895,7 @@ selector_chain:
#else #else
// Save the real info pointer (NOTE: not the same as get_itbl()). // Save the real info pointer (NOTE: not the same as get_itbl()).
info_ptr = (StgWord)p->header.info; info_ptr = (StgWord)p->header.info;
SET_INFO(p,&stg_WHITEHOLE_info); SET_INFO((StgClosure *)p,&stg_WHITEHOLE_info);
#endif #endif
field = INFO_PTR_TO_STRUCT((StgInfoTable *)info_ptr)->layout.selector_offset; field = INFO_PTR_TO_STRUCT((StgInfoTable *)info_ptr)->layout.selector_offset;
...@@ -1073,7 +1073,7 @@ selector_loop: ...@@ -1073,7 +1073,7 @@ selector_loop:
bale_out: bale_out:
// We didn't manage to evaluate this thunk; restore the old info // We didn't manage to evaluate this thunk; restore the old info
// pointer. But don't forget: we still need to evacuate the thunk itself. // pointer. But don't forget: we still need to evacuate the thunk itself.
SET_INFO(p, (const StgInfoTable *)info_ptr); SET_INFO((StgClosure *)p, (const StgInfoTable *)info_ptr);
// THREADED_RTS: we just unlocked the thunk, so another thread // THREADED_RTS: we just unlocked the thunk, so another thread
// might get in and update it. copy() will lock it again and // might get in and update it. copy() will lock it again and
// check whether it was updated in the meantime. // check whether it was updated in the meantime.
......
...@@ -113,7 +113,7 @@ revertCAFs( void ) ...@@ -113,7 +113,7 @@ revertCAFs( void )
c != (StgIndStatic *)END_OF_STATIC_LIST; c != (StgIndStatic *)END_OF_STATIC_LIST;
c = (StgIndStatic *)c->static_link) c = (StgIndStatic *)c->static_link)
{ {
SET_INFO(c, c->saved_info); SET_INFO((StgClosure *)c, c->saved_info);
c->saved_info = NULL; c->saved_info = NULL;
// could, but not necessary: c->static_link = NULL; // could, but not necessary: c->static_link = NULL;
} }
......
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