Sebastian Graf pushed to branch wip/sg/first-class-strict at Glasgow Haskell Compiler / GHC
Commits:
8fadf2e0 by I-Al-Istannen at 2026-06-27T12:09:51+02:00
Strict: add the wired-in unlifted box type
Adds the wired-in type Strict :: Type -> UnliftedType with its single
strict constructor MkStrict, an evaluated-and-properly-tagged box for strict
fields, and the isStrictTy predicate. See Note [The Strict type].
Co-authored-by: Sebastian Graf
- - - - -
1f961f09 by I-Al-Istannen at 2026-06-27T12:09:52+02:00
Strict: make demand analysis and CPR transparent to the box
Demand and CPR analysis look through Strict/MkStrict so that a product
demand on Strict a is passed to the wrapped field and CPR information flows
likewise, and exprIsTrivial / unfolding sizing treat MkStrict on a value as
trivial. Accepts the resulting signature churn in the test suite.
Co-authored-by: Sebastian Graf
- - - - -
8a89b9ef by I-Al-Istannen at 2026-06-27T12:09:52+02:00
Strict: unbox strict arguments through the box in worker/wrapper
Worker/wrapper marks each strictified worker argument with Strict, so the
wrapper passes an evaluated value and the worker need not re-force it, and
unboxes the wrapped type when profitable.
Co-authored-by: Sebastian Graf
- - - - -
0eaa66ed by I-Al-Istannen at 2026-06-27T12:09:52+02:00
Desugar: only reconstruct constructor fields used by the body
Co-authored-by: Sebastian Graf
- - - - -
4165000f by I-Al-Istannen at 2026-06-27T12:09:52+02:00
CorePrep: erase MkStrict via a representational cast
MkStrict is erased in CorePrep: a producer becomes the field cast to
Strict a with a heterogeneous representational coercion, forcing the field
first when it is not already a value; a consumer match becomes the scrutinee
cast back. Core Lint tolerates the resulting out-of-scope type variables and
the Strict coercion. See Note [The Strict type].
Co-authored-by: Sebastian Graf
- - - - -
7d62101e by I-Al-Istannen at 2026-06-27T12:09:52+02:00
Strict: STG representation and code generation
Treats Strict a as a single unlifted heap pointer through RepType,
unarisation, STG lint, tag inference and StgToCmm: an unlifted box is already
evaluated and properly tagged, so it is returned directly unless applied as a
function. An STG Lint check flags an evaluated binder lowered to an updatable
indirection.
Co-authored-by: Sebastian Graf
- - - - -
335c17b6 by Sebastian Graf at 2026-06-27T12:09:52+02:00
Strict: add a should_run test for the strict-field machinery
StrictBox exercises a strict value field built from a thunk (forced to an
evaluated, properly-tagged value), a strict field of function type that is
applied, worker/wrapper unboxing of a strict argument, and a strict field
holding another boxed value. Run with -dtag-inference-checks so that a strict
field that is not properly tagged aborts at runtime.
- - - - -
64 changed files:
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/PrimOps/Casts.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/DataCon.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/CprAnal.hs
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/WorkWrap/Utils.hs
- compiler/GHC/Core/SimpleOpt.hs
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/Core/Unfold.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/CoreToStg.hs
- compiler/GHC/CoreToStg/Prep.hs
- compiler/GHC/Driver/Config/Core/Lint.hs
- compiler/GHC/Driver/Config/Core/Lint/Interactive.hs
- compiler/GHC/Driver/Config/CoreToStg/Prep.hs
- compiler/GHC/Driver/Main/Interactive.hs
- compiler/GHC/Driver/Main/Passes.hs
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/HsToCore/Match/Literal.hs
- compiler/GHC/HsToCore/Pmc/Solver/Types.hs
- compiler/GHC/HsToCore/Utils.hs
- compiler/GHC/Stg/Lint.hs
- compiler/GHC/Stg/Unarise.hs
- compiler/GHC/StgToCmm/Closure.hs
- compiler/GHC/StgToCmm/Expr.hs
- compiler/GHC/StgToCmm/TagCheck.hs
- compiler/GHC/Types/Id/Make.hs
- compiler/GHC/Types/RepType.hs
- libraries/ghc-internal/src/GHC/Internal/Types.hs
- testsuite/tests/backpack/cabal/bkpcabal08/bkpcabal08.stdout
- testsuite/tests/codeGen/should_compile/T25166.stdout-ws-64
- + testsuite/tests/codeGen/should_run/StrictBox.hs
- + testsuite/tests/codeGen/should_run/StrictBox.stdout
- testsuite/tests/codeGen/should_run/all.T
- testsuite/tests/core-to-stg/T24124.stderr
- testsuite/tests/cpranal/should_compile/T18109.stderr
- testsuite/tests/cpranal/should_compile/T18174.stderr
- testsuite/tests/dmdanal/should_compile/T10482.stderr
- testsuite/tests/dmdanal/should_compile/T10482a.stderr
- testsuite/tests/dmdanal/sigs/T16197b.stderr
- testsuite/tests/dmdanal/sigs/T16859.stderr
- testsuite/tests/dmdanal/sigs/T17932.stderr
- testsuite/tests/dmdanal/sigs/T22241.stderr
- testsuite/tests/ghci.debugger/scripts/T13825-debugger.stdout
- testsuite/tests/ghci.debugger/scripts/print007.stdout
- testsuite/tests/ghci.debugger/scripts/print022.stdout
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-prim-exports.stdout
- + testsuite/tests/perf/should_run/StrictBuilderFusion.hs
- + testsuite/tests/perf/should_run/StrictBuilderFusion.stdout
- testsuite/tests/perf/should_run/all.T
- testsuite/tests/profiling/should_compile/prof-late-cc3.stderr
- testsuite/tests/simplCore/should_compile/T18013.stderr
- testsuite/tests/simplCore/should_compile/T22309.stderr
- testsuite/tests/simplCore/should_compile/T24359a.stderr
- testsuite/tests/simplCore/should_compile/T26615.stderr
- testsuite/tests/simplCore/should_compile/T4081.stderr
- testsuite/tests/simplStg/should_compile/T15226b.stderr
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f47fb1b36c37cfe259548779371219f...
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f47fb1b36c37cfe259548779371219f...
You're receiving this email because of your account on gitlab.haskell.org.