Note [Making dictionary parameters strict]
The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? * Generally CBV is more efficient. * A datatype dictionary is always non-bottom and never takes much work to compute. E.g. a DFun from an instance decl always returns a dictionary record immediately. See DFunUnfolding in CoreSyn. See also Note [Recursive superclasses] in TcInstDcls. See #17758 for more background and perf numbers. Wrinkles: * A newtype dictionary is *not* always non-bottom. E.g. class C a where op :: a -> a instance C Int where op = error "urk" Now a value of type (C Int) is just a newtype wrapper (a cast) around the error thunk. Don't strictify these! * Strictifying DFuns risks destroying the invariant that DFuns never take much work to compute, so we don't do it. See Note [Do not strictify a DFun's parameter dictionaries] for details. * Although worker/wrapper *could* unbox strictly used dictionaries, we do not do so; see Note [Do not unbox class dictionaries]. The implementation is extremely simple: just make the strictness analyser strictify the demand on a dictionary binder in 'findBndrDmd' if the binder does not belong to a DFun.
References 2
- Do not strictify a DFun's parameter dictionaries GHC.Core.Opt.DmdAnal
- Do not unbox class dictionaries GHC.Core.Opt.WorkWrap.Utils
Referenced by 1
- GHC.Core.Opt.DmdAnal call site