[Git][ghc/ghc][wip/ghci-primcall] 18 commits: Add support for sized literals in the bytecode interpreter.

Luite Stegeman (@luite) gitlab at gitlab.haskell.org
Sun Jan 8 05:26:18 UTC 2023



Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC


Commits:
28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00
Add support for sized literals in the bytecode interpreter.

The bytecode interpreter only has branching instructions for
word-sized values. These are used for pattern matching.
Branching instructions for other types (e.g. Int16# or Word8#)
weren't needed, since unoptimized Core or STG never requires
branching on types like this.

It's now possible for optimized STG to reach the bytecode
generator (e.g. fat interface files or certain compiler flag
combinations), which requires dealing with various sized
literals in branches.

This patch improves support for generating bytecode from
optimized STG by adding the following new bytecode
instructions:

    TESTLT_I64
    TESTEQ_I64
    TESTLT_I32
    TESTEQ_I32
    TESTLT_I16
    TESTEQ_I16
    TESTLT_I8
    TESTEQ_I8
    TESTLT_W64
    TESTEQ_W64
    TESTLT_W32
    TESTEQ_W32
    TESTLT_W16
    TESTEQ_W16
    TESTLT_W8
    TESTEQ_W8

Fixes #21945

- - - - -
ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00
Only store Name in FunRhs rather than Id with knot-tied fields

All the issues here have been caused by #18758.
The goal of the ticket is to be able to talk about things like
`LTyClDecl GhcTc`. In the case of HsMatchContext,
the correct "context" is whatever we want, and in fact storing just a
`Name` is sufficient and correct context, even if the rest of the AST is
storing typechecker Ids.

So this reverts (#20415, !5579) which intended to get closed to #18758 but
didn't really and introduced a few subtle bugs.

Printing of an error message in #22695 would just hang, because we would
attempt to print the `Id` in debug mode to assertain whether it was
empty or not. Printing the Name is fine for the error message.

Another consequence is that when `-dppr-debug` was enabled the compiler would
hang because the debug printing of the Id would try and print fields
which were not populated yet.

This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add
a workaround for the `checkArgs` function which was probably a very
similar bug to #22695.

Fixes #22695

- - - - -
c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00
ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3

Fixes #22599

- - - - -
0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00
darwin ci: Explicitly pass desired build triple to configure

On the zw3rk machines for some reason the build machine was inferred to
be arm64. Setting the build triple appropiately resolve this confusion
and we produce x86 binaries.

- - - - -
2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00
rts: MUT_VAR is not a StgMutArrPtrs

There was previously a comment claiming that the MUT_VAR closure type
had the layout of StgMutArrPtrs.
- - - - -
6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00
Make FloatIn robust to shadowing

This MR fixes #22622. See the new
  Note [Shadowing and name capture]

I did a bit of refactoring in sepBindsByDropPoint too.

The bug doesn't manifest in HEAD, but it did show up in 9.4,
so we should backport this patch to 9.4

- - - - -
a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00
T10955: Set DYLD_LIBRARY_PATH for darwin

The correct path to direct the dynamic linker on darwin is
DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX
using LD_LIBRARY_PATH seems to have stopped working.

For more reading see:

https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s

- - - - -
73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00
Skip T18623 on darwin (to add to the long list of OSs)

On recent versions of OSX, running `ulimit -v` results in

```
ulimit: setrlimit failed: invalid argument
```

Time is too short to work out what random stuff Apple has been doing
with ulimit, so just skip the test like we do for other platforms.

- - - - -
8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00
Pass -Wl,-no_fixup_chains to ld64 when appropiate

Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default.
This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we
explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on
darwin. This results in a warning of the form:

ld: warning: -undefined dynamic_lookup may not work with chained fixups

The manual explains the incompatible nature of these two flags:

     -undefined treatment
             Specifies how undefined symbols are to be treated. Options are: error, warning,
             suppress, or dynamic_lookup.  The default is error. Note: dynamic_lookup that
             depends on lazy binding will not work with chained fixups.

A relevant ticket is #22429

Here are also a few other links which are relevant to the issue:

Official comment: https://developer.apple.com/forums/thread/719961

More relevant links:

https://openradar.appspot.com/radar?id=5536824084660224

https://github.com/python/cpython/issues/97524

Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas    e-notes

- - - - -
fdba0a60 by Luite Stegeman at 2023-01-08T14:23:54+09:00
Add PrimCallConv suppport to GHCi

- - - - -
9c9fc6af by Luite Stegeman at 2023-01-08T14:23:54+09:00
make bytecode assembler assertion failures more descriptive

- - - - -
699de3e5 by Luite Stegeman at 2023-01-08T14:23:54+09:00
fix typo in testcase

- - - - -
63d009b9 by Luite Stegeman at 2023-01-08T14:23:54+09:00
fix whitespace

- - - - -
486906fe by Luite Stegeman at 2023-01-08T14:23:55+09:00
fix GHCiPrimCall expected output

- - - - -
b9dcc607 by Luite Stegeman at 2023-01-08T14:23:55+09:00
add GHCiPrimCall expected test output for wordsize 32

- - - - -
5e31366d by Luite Stegeman at 2023-01-08T14:23:55+09:00
re-enable some disabled testcases in GHCiPrimCall test

- - - - -
a054e549 by Luite Stegeman at 2023-01-08T14:23:55+09:00
add type sig again

- - - - -
0a6347fc by Luite Stegeman at 2023-01-08T14:23:55+09:00
correct GHCiPrimCall word size 32 expected result

- - - - -


30 changed files:

- .gitlab/ci.sh
- .gitlab/darwin/toolchain.nix
- .gitlab/gen_ci.hs
- .gitlab/jobs.yaml
- compiler/GHC/ByteCode/Asm.hs
- compiler/GHC/ByteCode/Instr.hs
- compiler/GHC/ByteCode/Types.hs
- compiler/GHC/Cmm/CallConv.hs
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/Core/Opt/FloatIn.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/StgToByteCode.hs
- compiler/GHC/StgToCmm/Foreign.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Arrow.hs
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Gen/Match.hs-boot
- compiler/GHC/Tc/TyCl/PatSyn.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/Language/Haskell/Syntax/Expr.hs
- configure.ac
- + m4/fp_ld_no_fixup_chains.m4
- rts/Disassembler.c
- rts/Interpreter.c
- rts/RtsSymbols.c
- rts/StgMiscClosures.cmm


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee171e8b127a7f11aedbfe45e284f08636588dec...0a6347fc57013d1a3edccdf4a801cb2e4a230836

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee171e8b127a7f11aedbfe45e284f08636588dec...0a6347fc57013d1a3edccdf4a801cb2e4a230836
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230108/f1f90c2a/attachment-0001.html>


More information about the ghc-commits mailing list