Fix offset calculation in __stg_gc_fun
authorSimon Marlow <marlowsd@gmail.com>
Mon, 6 Jul 2015 13:09:50 +0000 (14:09 +0100)
committerSimon Marlow <marlowsd@gmail.com>
Mon, 6 Jul 2015 14:16:06 +0000 (15:16 +0100)
Summary:
We were not treating the offset as a signed field in this rare case,
so it would blow up if the offset was negative.

Test Plan: Looked at the assembly

Reviewers: austin, bgamari, rwbarton

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1042

rts/HeapStackCheck.cmm
utils/deriveConstants/DeriveConstants.hs

index a1e18ca..9430a09 100644 (file)
@@ -405,8 +405,9 @@ __stg_gc_fun /* explicit stack */
         if (type == ARG_GEN_BIG) {
 #ifdef TABLES_NEXT_TO_CODE
             // bitmap field holds an offset
-            size = StgLargeBitmap_size( StgFunInfoExtra_bitmap(info)
-                                        + %GET_ENTRY(UNTAG(R1)) /* ### */ );
+            size = StgLargeBitmap_size(
+                      TO_W_(StgFunInfoExtraRev_bitmap_offset(info))
+                      + %GET_ENTRY(UNTAG(R1)) /* ### */ );
 #else
             size = StgLargeBitmap_size( StgFunInfoExtra_bitmap(info) );
 #endif
index ccf9028..6563550 100644 (file)
@@ -568,6 +568,7 @@ wanteds = concat
           ,structField  C    "StgFunInfoExtraRev" "fun_type"
           ,structFieldH Both "StgFunInfoExtraRev" "arity"
           ,structField_ C    "StgFunInfoExtraRev_bitmap" "StgFunInfoExtraRev" "b.bitmap"
+          ,structField_ C    "StgFunInfoExtraRev_bitmap_offset" "StgFunInfoExtraRev" "b.bitmap_offset"
 
           ,structField C "StgLargeBitmap" "size"
           ,fieldOffset C "StgLargeBitmap" "bitmap"