From b8ced282cd2a56e47f628bc760980bb7b9f25d9a Mon Sep 17 00:00:00 2001 From: simonmar Date: Thu, 17 Mar 2005 12:45:09 +0000 Subject: [PATCH] [project @ 2005-03-17 12:45:08 by simonmar] Rearrange the fields of CostCentreStack to leave no (or less) room for arbitrary padding decisions by C compilers. --- ghc/compiler/codeGen/CgProf.hs | 4 ++-- ghc/includes/StgProf.h | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ghc/compiler/codeGen/CgProf.hs b/ghc/compiler/codeGen/CgProf.hs index 5177072..844f1d7 100644 --- a/ghc/compiler/codeGen/CgProf.hs +++ b/ghc/compiler/codeGen/CgProf.hs @@ -316,12 +316,12 @@ emitCostCentreStackDecl ccs mkCCostCentre cc, zero, -- struct _CostCentreStack *prevStack; zero, -- struct _IndexTable *indexTable; - zero, -- StgWord selected; zero64, -- StgWord64 scc_count; + zero, -- StgWord selected; zero, -- StgWord time_ticks; zero64, -- StgWord64 mem_alloc; - zero, -- StgWord inherited_ticks; zero64, -- StgWord64 inherited_alloc; + zero, -- StgWord inherited_ticks; zero -- CostCentre *root; ] ; emitDataLits (mkCCSLabel ccs) lits diff --git a/ghc/includes/StgProf.h b/ghc/includes/StgProf.h index 82e5529..b94066e 100644 --- a/ghc/includes/StgProf.h +++ b/ghc/includes/StgProf.h @@ -12,6 +12,12 @@ /* ----------------------------------------------------------------------------- * Data Structures * ---------------------------------------------------------------------------*/ +// NB. be careful to avoid unwanted padding between fields, by +// putting the 8-byte fields on an 8-byte boundary. Padding can +// vary between C compilers, and we don't take into account any +// possible padding when generating CCS and CC decls in the code +// generator (compiler/codeGen/CgProf.hs). + typedef struct _CostCentre { StgInt ccID; @@ -20,14 +26,13 @@ typedef struct _CostCentre { /* used for accumulating costs at the end of the run... */ StgWord time_ticks; - StgWord64 mem_alloc; + StgWord64 mem_alloc; // align 8 (see above) StgInt is_caf; struct _CostCentre *link; } CostCentre; - typedef struct _CostCentreStack { StgInt ccsID; @@ -35,12 +40,12 @@ typedef struct _CostCentreStack { struct _CostCentreStack *prevStack; struct _IndexTable *indexTable; + StgWord64 scc_count; // align 8 (see above) StgWord selected; - StgWord64 scc_count; StgWord time_ticks; - StgWord64 mem_alloc; + StgWord64 mem_alloc; // align 8 (see above) + StgWord64 inherited_alloc; // align 8 (see above) StgWord inherited_ticks; - StgWord64 inherited_alloc; CostCentre *root; } CostCentreStack; -- 1.7.10.4