[project @ 2005-03-17 12:45:08 by simonmar]
authorsimonmar <unknown>
Thu, 17 Mar 2005 12:45:09 +0000 (12:45 +0000)
committersimonmar <unknown>
Thu, 17 Mar 2005 12:45:09 +0000 (12:45 +0000)
Rearrange the fields of CostCentreStack to leave no (or less) room for
arbitrary padding decisions by C compilers.

ghc/compiler/codeGen/CgProf.hs
ghc/includes/StgProf.h

index 5177072..844f1d7 100644 (file)
@@ -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
index 82e5529..b94066e 100644 (file)
 /* -----------------------------------------------------------------------------
  * 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;