Skip to content
  • Michal Terepeta's avatar
    Allow packing constructor fields · cca2d6b7
    Michal Terepeta authored and Ben Gamari's avatar Ben Gamari committed
    This is another step for fixing #13825 and is based on D38 by Simon
    Marlow.
    
    The change allows storing multiple constructor fields within the same
    word. This currently applies only to `Float`s, e.g.,
    ```
    data Foo = Foo {-# UNPACK #-} !Float {-# UNPACK #-} !Float
    ```
    on 64-bit arch, will now store both fields within the same constructor
    word. For `WordX/IntX` we'll need to introduce new primop types.
    
    Main changes:
    
    - We now use sizes in bytes when we compute the offsets for
      constructor fields in `StgCmmLayout` and introduce padding if
      necessary (word-sized fields are still word-aligned)
    
    - `ByteCodeGen` had to be updated to correctly construct the data
      types. This required some new bytecode instructions to allow pushing
      things that are not full words onto the stack (and updating
      `Interpreter.c`). Note that we only use the packed stuff when
      constructing data types (i.e., for `PACK`), in all other cases the
      behavior should not change.
    
    - `RtClosureInspect` was ...
    cca2d6b7