Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC/Cmm/Info.hs
    ... ... @@ -28,7 +28,7 @@ module GHC.Cmm.Info (
    28 28
       conInfoTableSizeB,
    
    29 29
       stdSrtBitmapOffset,
    
    30 30
       stdClosureTypeOffset,
    
    31
    -  stdPtrsOffset, stdNonPtrsOffset,
    
    31
    +  stdPtrsOffset, stdNonPtrsOffset
    
    32 32
     ) where
    
    33 33
     
    
    34 34
     import GHC.Prelude
    
    ... ... @@ -194,7 +194,7 @@ mkInfoTableContents profile
    194 194
            ; let (srt_label, srt_bitmap) = mkSRTLit platform info_lbl srt
    
    195 195
            ; (liveness_lit, liveness_data) <- mkLivenessBits platform frame
    
    196 196
            ; let
    
    197
    -             std_info = mkStdInfoTable profile prof_lits rts_tag srt_bitmap liveness_lit
    
    197
    +             std_info = mkStdInfoTable profile prof_lits rts_tag srt_bitmap [liveness_lit]
    
    198 198
                  rts_tag | Just tag <- mb_rts_tag = tag
    
    199 199
                          | null liveness_data     = rET_SMALL -- Fits in extra_bits
    
    200 200
                          | otherwise              = rET_BIG   -- Does not; extra_bits is
    
    ... ... @@ -202,7 +202,8 @@ mkInfoTableContents profile
    202 202
            ; return (prof_data ++ liveness_data, (std_info, srt_label)) }
    
    203 203
     
    
    204 204
       | HeapRep _ ptrs nonptrs closure_type <- smrep
    
    205
    -  = do { let layout  = packIntsCLit platform ptrs nonptrs
    
    205
    +  = do { let layout  = [ mkStgHalfWordCLit platform ptrs,
    
    206
    +                         mkStgHalfWordCLit platform nonptrs]
    
    206 207
            ; (prof_lits, prof_data) <- mkProfLits platform prof
    
    207 208
            ; let (srt_label, srt_bitmap) = mkSRTLit platform info_lbl srt
    
    208 209
            ; (mb_srt_field, mb_layout, extra_bits, ct_data)
    
    ... ... @@ -214,11 +215,23 @@ mkInfoTableContents profile
    214 215
            ; return (prof_data ++ ct_data, (std_info, extra_bits)) }
    
    215 216
       where
    
    216 217
         platform = profilePlatform profile
    
    218
    +    mk_extra_bits :: Int -> Int -> [CmmLit]
    
    219
    +    mk_extra_bits low high
    
    220
    +      = if platformTablesNextToCode platform
    
    221
    +           -- In mkInfoTable do_one_info extra bits are reversed for TNTC
    
    222
    +           -- so we must generate the high address halfword before
    
    223
    +           -- the low address halfword.
    
    224
    +        then [ mkStgHalfWordCLit platform high
    
    225
    +             , mkStgHalfWordCLit platform low
    
    226
    +             ]
    
    227
    +        else [ mkStgHalfWordCLit platform low
    
    228
    +             , mkStgHalfWordCLit platform high
    
    229
    +             ]
    
    217 230
         mk_pieces :: ClosureTypeInfo -> [CmmLit]
    
    218
    -              -> UniqDSM ( Maybe CmmLit  -- Override the SRT field with this
    
    219
    -                         , Maybe CmmLit  -- Override the layout field with this
    
    220
    -                         , [CmmLit]           -- "Extra bits" for info table
    
    221
    -                         , [RawCmmDecl])      -- Auxiliary data decls
    
    231
    +              -> UniqDSM ( Maybe CmmLit   -- Override the SRT field with this
    
    232
    +                         , Maybe [CmmLit] -- Override the layout field with this
    
    233
    +                         , [CmmLit]       -- "Extra bits" for info table
    
    234
    +                         , [RawCmmDecl])  -- Auxiliary data decls
    
    222 235
         mk_pieces (Constr con_tag con_descr) _no_srt    -- A data constructor
    
    223 236
           = do { (descr_lit, decl) <- newStringLit con_descr
    
    224 237
                ; return ( Just (CmmInt (fromIntegral con_tag)
    
    ... ... @@ -230,18 +243,19 @@ mkInfoTableContents profile
    230 243
     
    
    231 244
         mk_pieces (ThunkSelector offset) _no_srt
    
    232 245
           = return (Just (CmmInt 0 (halfWordWidth platform)),
    
    233
    -                Just (mkWordCLit platform (fromIntegral offset)), [], [])
    
    246
    +                Just [(mkWordCLit platform (fromIntegral offset))], [], [])
    
    234 247
              -- Layout known (one free var); we use the layout field for offset
    
    235 248
     
    
    236 249
         mk_pieces (Fun arity (ArgSpec fun_type)) srt_label
    
    237
    -      = do { let extra_bits = packIntsCLit platform fun_type arity : srt_label
    
    250
    +      = do { let extra_bits = mk_extra_bits fun_type arity
    
    251
    +                           ++ srt_label
    
    238 252
                ; return (Nothing, Nothing,  extra_bits, []) }
    
    239 253
     
    
    240 254
         mk_pieces (Fun arity (ArgGen arg_bits)) srt_label
    
    241 255
           = do { (liveness_lit, liveness_data) <- mkLivenessBits platform arg_bits
    
    242 256
                ; let fun_type | null liveness_data = aRG_GEN
    
    243 257
                               | otherwise          = aRG_GEN_BIG
    
    244
    -                 extra_bits = [ packIntsCLit platform fun_type arity ]
    
    258
    +                 extra_bits = mk_extra_bits fun_type arity
    
    245 259
                                ++ (if inlineSRT platform then [] else [ srt_lit ])
    
    246 260
                                ++ [ liveness_lit, slow_entry ]
    
    247 261
                ; return (Nothing, Nothing, extra_bits, liveness_data) }
    
    ... ... @@ -255,11 +269,13 @@ mkInfoTableContents profile
    255 269
     
    
    256 270
     mkInfoTableContents _ _ _ = panic "mkInfoTableContents"   -- NonInfoTable dealt with earlier
    
    257 271
     
    
    258
    -packIntsCLit :: Platform -> Int -> Int -> CmmLit
    
    259
    -packIntsCLit platform a b = packHalfWordsCLit platform
    
    260
    -                           (toStgHalfWord platform (fromIntegral a))
    
    261
    -                           (toStgHalfWord platform (fromIntegral b))
    
    272
    +mkStgWordCLit :: Platform -> StgWord -> CmmLit
    
    273
    +mkStgWordCLit platform wd = CmmInt (fromStgWord wd) (wordWidth platform)
    
    262 274
     
    
    275
    +mkStgHalfWordCLit :: Platform -> Int -> CmmLit
    
    276
    +mkStgHalfWordCLit platform hwd
    
    277
    +  = CmmInt (fromStgHalfWord (toStgHalfWord platform (fromIntegral hwd)))
    
    278
    +           (halfWordWidth platform)
    
    263 279
     
    
    264 280
     mkSRTLit :: Platform
    
    265 281
              -> CLabel
    
    ... ... @@ -385,15 +401,15 @@ mkStdInfoTable
    385 401
        -> (CmmLit,CmmLit)   -- Closure type descr and closure descr  (profiling)
    
    386 402
        -> Int               -- Closure RTS tag
    
    387 403
        -> CmmLit            -- SRT length
    
    388
    -   -> CmmLit            -- layout field
    
    404
    +   -> [CmmLit]          -- layout field
    
    389 405
        -> [CmmLit]
    
    390 406
     
    
    391
    -mkStdInfoTable profile (type_descr, closure_descr) cl_type srt layout_lit
    
    407
    +mkStdInfoTable profile (type_descr, closure_descr) cl_type srt layout_lits
    
    392 408
      =      -- Parallel revertible-black hole field
    
    393 409
         prof_info
    
    394 410
             -- Ticky info (none at present)
    
    395 411
             -- Debug info (none at present)
    
    396
    - ++ [layout_lit, tag, srt]
    
    412
    + ++ layout_lits ++ [tag, srt]
    
    397 413
     
    
    398 414
      where
    
    399 415
         platform = profilePlatform profile
    

  • compiler/GHC/Cmm/Utils.hs
    ... ... @@ -13,10 +13,9 @@ module GHC.Cmm.Utils(
    13 13
     
    
    14 14
             -- CmmLit
    
    15 15
             zeroCLit, mkIntCLit,
    
    16
    -        mkWordCLit, packHalfWordsCLit,
    
    16
    +        mkWordCLit,
    
    17 17
             mkByteStringCLit, mkFileEmbedLit,
    
    18 18
             mkDataLits, mkRODataLits,
    
    19
    -        mkStgWordCLit,
    
    20 19
     
    
    21 20
             -- CmmExpr
    
    22 21
             mkIntExpr, zeroExpr,
    
    ... ... @@ -211,22 +210,6 @@ mkRODataLits lbl lits
    211 210
         needsRelocation (CmmLabelOff _ _) = True
    
    212 211
         needsRelocation _                 = False
    
    213 212
     
    
    214
    -mkStgWordCLit :: Platform -> StgWord -> CmmLit
    
    215
    -mkStgWordCLit platform wd = CmmInt (fromStgWord wd) (wordWidth platform)
    
    216
    -
    
    217
    -packHalfWordsCLit :: Platform -> StgHalfWord -> StgHalfWord -> CmmLit
    
    218
    --- Make a single word literal in which the lower_half_word is
    
    219
    --- at the lower address, and the upper_half_word is at the
    
    220
    --- higher address
    
    221
    --- ToDo: consider using half-word lits instead
    
    222
    ---       but be careful: that's vulnerable when reversed
    
    223
    -packHalfWordsCLit platform lower_half_word upper_half_word
    
    224
    -   = case platformByteOrder platform of
    
    225
    -       BigEndian    -> mkWordCLit platform ((l `shiftL` halfWordSizeInBits platform) .|. u)
    
    226
    -       LittleEndian -> mkWordCLit platform (l .|. (u `shiftL` halfWordSizeInBits platform))
    
    227
    -    where l = fromStgHalfWord lower_half_word
    
    228
    -          u = fromStgHalfWord upper_half_word
    
    229
    -
    
    230 213
     ---------------------------------------------------
    
    231 214
     --
    
    232 215
     --      CmmExpr