pad step_workspace to 64 bytes, to speed up access to gct->steps[]
authorSimon Marlow <simonmarhaskell@gmail.com>
Wed, 16 Apr 2008 23:24:33 +0000 (23:24 +0000)
committerSimon Marlow <simonmarhaskell@gmail.com>
Wed, 16 Apr 2008 23:24:33 +0000 (23:24 +0000)
includes/Rts.h
rts/sm/GC.c
rts/sm/GCThread.h

index ec84ed9..1d455f0 100644 (file)
@@ -38,6 +38,12 @@ extern "C" {
 #define FLEXIBLE_ARRAY 0
 #endif
 
+#if __GNUC__ >= 3
+#define ATTRIBUTE_ALIGNED(n) __attribute__((aligned(n)))
+#else
+#define ATTRIBUTE_ALIGNED(n) /*nothing*/
+#endif
+
 /* Fix for mingw stat problem (done here so it's early enough) */
 #ifdef mingw32_HOST_OS
 #define __MSVCRT__ 1
index 8bdea7d..2b6dbb7 100644 (file)
@@ -203,6 +203,9 @@ GarbageCollect ( rtsBool force_major_gc )
   }
 #endif
 
+  ASSERT(sizeof(step_workspace) == 16 * sizeof(StgWord));
+  // otherwise adjust the padding in step_workspace.
+
   // tell the stats department that we've started a GC 
   stat_startGC();
 
index 8d171ae..338cca7 100644 (file)
@@ -95,7 +95,11 @@ typedef struct step_workspace_ {
     bdescr *     part_list;
     unsigned int n_part_blocks;      // count of above
 
-} step_workspace;
+    StgWord pad[5];
+
+} step_workspace ATTRIBUTE_ALIGNED(64);
+// align so that computing gct->steps[n] is a shift, not a multiply
+// fails if the size is <64, which is why we need the pad above
 
 /* ----------------------------------------------------------------------------
    GC thread object