[commit: ghc] master: Allow packing constructor fields (cca2d6b)

git at git.haskell.org git at git.haskell.org
Mon Oct 30 01:51:37 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/cca2d6b78f97bfb79bef4dc3f75d6c4d15b94680/ghc

>---------------------------------------------------------------

commit cca2d6b78f97bfb79bef4dc3f75d6c4d15b94680
Author: Michal Terepeta <michal.terepeta at gmail.com>
Date:   Sun Oct 29 20:49:32 2017 -0400

    Allow packing constructor fields
    
    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 changed to handle the new layout when
      extracting subterms. This seems to be used by things like `:print`.
      I've also added a test for this.
    
    - I deviated slightly from Simon's approach and use `PrimRep` instead
      of `ArgRep` for computing the size of fields.  This seemed more
      natural and in the future we'll probably want to introduce new
      primitive types (e.g., `Int8#`) and `PrimRep` seems like a better
      place to do that (where we already have `Int64Rep` for example).
      `ArgRep` on the other hand seems to be more focused on calling
      functions.
    
    Signed-off-by: Michal Terepeta <michal.terepeta at gmail.com>
    
    Test Plan: ./validate
    
    Reviewers: bgamari, simonmar, austin, hvr, goldfire, erikd
    
    Reviewed By: bgamari
    
    Subscribers: maoe, rwbarton, thomie
    
    GHC Trac Issues: #13825
    
    Differential Revision: https://phabricator.haskell.org/D3809


>---------------------------------------------------------------

cca2d6b78f97bfb79bef4dc3f75d6c4d15b94680
 compiler/cmm/CmmCallConv.hs                        |   5 +-
 compiler/cmm/SMRep.hs                              |   9 +-
 compiler/codeGen/StgCmmBind.hs                     |   2 +-
 compiler/codeGen/StgCmmCon.hs                      |  15 ++-
 compiler/codeGen/StgCmmHeap.hs                     |  15 +--
 compiler/codeGen/StgCmmLayout.hs                   |  93 ++++++++++++++---
 compiler/coreSyn/CoreLint.hs                       |   4 +-
 compiler/ghci/ByteCodeAsm.hs                       |  15 +++
 compiler/ghci/ByteCodeGen.hs                       |  84 +++++++++++----
 compiler/ghci/ByteCodeInstr.hs                     |  52 ++++++++-
 compiler/ghci/RtClosureInspect.hs                  |  89 ++++++++++------
 compiler/main/Constants.hs                         |   4 +
 compiler/types/TyCon.hs                            |  35 ++++---
 includes/rts/Bytecodes.h                           | 116 ++++++++++++---------
 includes/stg/Types.h                               |   4 +
 rts/Disassembler.c                                 |  47 ++++++++-
 rts/Interpreter.c                                  |  81 ++++++++++++++
 testsuite/tests/codeGen/should_run/T13825-unit.hs  |  78 ++++++++++++++
 testsuite/tests/codeGen/should_run/all.T           |   4 +
 .../tests/ghci.debugger/scripts/T13825-debugger.hs |  33 ++++++
 .../ghci.debugger/scripts/T13825-debugger.script   |   7 ++
 .../ghci.debugger/scripts/T13825-debugger.stdout   |   8 ++
 testsuite/tests/ghci.debugger/scripts/all.T        |   1 +
 testsuite/tests/ghci/should_run/T13825-ghci.hs     |  38 +++++++
 testsuite/tests/ghci/should_run/T13825-ghci.script |  13 +++
 testsuite/tests/ghci/should_run/T13825-ghci.stdout |   4 +
 testsuite/tests/ghci/should_run/all.T              |   1 +
 .../tests/primops/should_run/T13825-compile.hs     |  66 ++++++++++++
 .../tests/primops/should_run/T13825-compile.stdout |   3 +
 testsuite/tests/primops/should_run/all.T           |   1 +
 30 files changed, 768 insertions(+), 159 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc cca2d6b78f97bfb79bef4dc3f75d6c4d15b94680


More information about the ghc-commits mailing list