X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=includes%2FInfoTables.h;h=0c6ab52745380e26de719a1616dc284eb3ede56c;hb=4b8dfb01980b44bc3284c87aadeada130f94f85f;hp=77171f1bc0a13cd32ec35e2e81e2937c14663881;hpb=6e9450db95482a72b2c9659ab0e9324260aa3f56;p=ghc-hetmet.git diff --git a/includes/InfoTables.h b/includes/InfoTables.h index 77171f1..0c6ab52 100644 --- a/includes/InfoTables.h +++ b/includes/InfoTables.h @@ -9,78 +9,49 @@ #ifndef INFOTABLES_H #define INFOTABLES_H -/* ----------------------------------------------------------------------------- - Profiling info - -------------------------------------------------------------------------- */ - -typedef struct { - char *closure_type; - char *closure_desc; -} StgProfInfo; - -/* ----------------------------------------------------------------------------- - Parallelism info - -------------------------------------------------------------------------- */ - -#if 0 && (defined(PAR) || defined(GRAN)) - -/* CURRENTLY UNUSED - ToDo: use this in StgInfoTable (mutually recursive) -- HWL */ - -typedef struct { - StgInfoTable *rbh_infoptr; /* infoptr to the RBH */ -} StgParInfo; - -#endif /* 0 */ - -/* - Copied from ghc-0.29; ToDo: check this code -- HWL - - In the parallel system, all updatable closures have corresponding - revertible black holes. When we are assembly-mangling, we guarantee - that the revertible black hole code precedes the normal entry code, so - that the RBH info table resides at a fixed offset from the normal info - table. Otherwise, we add the RBH info table pointer to the end of the - normal info table and vice versa. - - Currently has to use a !RBH_MAGIC_OFFSET setting. - Still todo: init of par.infoptr field in all infotables!! -*/ - -#if defined(PAR) || defined(GRAN) - -# ifdef RBH_MAGIC_OFFSET - -# error magic offset not yet implemented - -# define RBH_INFO_WORDS 0 -# define INCLUDE_RBH_INFO(infoptr) - -# define RBH_INFOPTR(infoptr) (((P_)infoptr) - RBH_MAGIC_OFFSET) -# define REVERT_INFOPTR(infoptr) (((P_)infoptr) + RBH_MAGIC_OFFSET) +/* ---------------------------------------------------------------------------- + Relative pointers -# else + Several pointer fields in info tables are expressed as offsets + relative to the info pointer, so that we can generate + position-independent code. -# define RBH_INFO_WORDS 1 -# define INCLUDE_RBH_INFO(info) rbh_infoptr : &(info) + Note [x86-64-relative] + There is a complication on the x86_64 platform, where pointeres are + 64 bits, but the tools don't support 64-bit relative relocations. + However, the default memory model (small) ensures that all symbols + have values in the lower 2Gb of the address space, so offsets all + fit in 32 bits. Hence we can use 32-bit offset fields. -# define RBH_INFOPTR(infoptr) (((StgInfoTable *)(infoptr))->rbh_infoptr) -# define REVERT_INFOPTR(infoptr) (((StgInfoTable *)(infoptr))->rbh_infoptr) + When going via-C, the mangler arranges that we only generate + relative relocations between symbols in the same segment (the text + segment). The NCG, however, puts things in the right sections and + uses 32-bit relative offsets instead. -# endif + Somewhere between binutils-2.16.1 and binutils-2.16.91.0.6, + support for 64-bit PC-relative relocations was added, so maybe this + hackery can go away sometime. + ------------------------------------------------------------------------- */ -/* see ParallelRts.h */ -/* -EXTFUN(RBH_entry); -StgClosure *convertToRBH(StgClosure *closure); -#if defined(GRAN) -void convertFromRBH(StgClosure *closure); -#elif defined(PAR) -void convertToFetchMe(StgPtr closure, globalAddr *ga); +#if x86_64_TARGET_ARCH +#define OFFSET_FIELD(n) StgHalfInt n; StgHalfWord __pad_##n; +#else +#define OFFSET_FIELD(n) StgInt n; #endif -*/ +/* ----------------------------------------------------------------------------- + Profiling info + -------------------------------------------------------------------------- */ + +typedef struct { +#ifndef TABLES_NEXT_TO_CODE + char *closure_type; + char *closure_desc; +#else + OFFSET_FIELD(closure_type_off); + OFFSET_FIELD(closure_desc_off); #endif +} StgProfInfo; /* ----------------------------------------------------------------------------- Ticky info @@ -129,7 +100,7 @@ typedef struct { extern StgWord16 closure_flags[]; -#define closureFlags(c) (closure_flags[get_itbl(c)->type]) +#define closureFlags(c) (closure_flags[get_itbl(UNTAG_CLOSURE(c))->type]) #define closure_HNF(c) ( closureFlags(c) & _HNF) #define closure_BITMAP(c) ( closureFlags(c) & _BTM) @@ -210,26 +181,6 @@ typedef struct StgLargeSRT_ { } StgLargeSRT; /* ---------------------------------------------------------------------------- - Relative pointers - - Several pointer fields in info tables are expressed as offsets - relative to the info pointer, so that we can generate - position-independent code. - - There is a complication on the x86_64 platform, where pointeres are - 64 bits, but the tools don't support 64-bit relative relocations. - However, the default memory model (small) ensures that all symbols - have values in the lower 2Gb of the address space, so offsets all - fit in 32 bits. Hence we can use 32-bit offset fields. - ------------------------------------------------------------------------- */ - -#if x86_64_TARGET_ARCH -#define OFFSET_FIELD(n) StgHalfInt n; StgHalfWord __pad_##n; -#else -#define OFFSET_FIELD(n) StgInt n; -#endif - -/* ---------------------------------------------------------------------------- Info Tables ------------------------------------------------------------------------- */ @@ -267,9 +218,6 @@ typedef struct _StgInfoTable { StgFunPtr entry; /* pointer to the entry code */ #endif -#if defined(PAR) || defined(GRAN) - struct _StgInfoTable *rbh_infoptr; -#endif #ifdef PROFILING StgProfInfo prof; #endif @@ -388,8 +336,12 @@ typedef struct _StgConInfoTable { StgInfoTable i; #endif +#ifndef TABLES_NEXT_TO_CODE + char *con_desc; +#else OFFSET_FIELD(con_desc) // the name of the data constructor // as: Package:Module.Name +#endif #if defined(TABLES_NEXT_TO_CODE) StgInfoTable i; @@ -412,6 +364,16 @@ typedef struct _StgConInfoTable { #endif /* + * GET_CON_DESC(info) + * info must be a StgConInfoTable*. + */ +#ifdef TABLES_NEXT_TO_CODE +#define GET_CON_DESC(info) ((char *)((StgWord)((info)+1) + (info->con_desc))) +#else +#define GET_CON_DESC(info) ((info)->con_desc) +#endif + +/* * GET_FUN_SRT(info) * info must be a StgFunInfoTable* */ @@ -435,5 +397,17 @@ typedef struct _StgConInfoTable { #define GET_FUN_LARGE_BITMAP(info) ((StgLargeBitmap*) ((info)->f.b.bitmap)) #endif - +/* + * GET_PROF_TYPE, GET_PROF_DESC + */ +#ifdef TABLES_NEXT_TO_CODE +#define GET_PROF_TYPE(info) ((char *)((StgWord)((info)+1) + (info->prof.closure_type_off))) +#else +#define GET_PROF_TYPE(info) ((info)->prof.closure_type) +#endif +#ifdef TABLES_NEXT_TO_CODE +#define GET_PROF_DESC(info) ((char *)((StgWord)((info)+1) + (info->prof.closure_desc_off))) +#else +#define GET_PROF_DESC(info) ((info)->prof.closure_desc) +#endif #endif /* INFOTABLES_H */