Consume prelude v7.3.1: share the unit singleton (@inline unit never) - #258
Merged
Conversation
) Dissolving the alias multiplied the Always target's use sites right before Always pasted its body into every one of them, duplicating the body (a lifted foreign's lambda, for example) across all alias use sites. The top-level inliner now declines the bare-Ref tier when the target carries @inline always, so the alias stays the single materialization point and the body pastes into it once. The top-level Always decision is also keyed by name (policyAlways) rather than the RHS root annotation, so a binding that merely received an always-annotated body during an earlier paste does not itself turn unconditionally inlinable one fixpoint round later; the local rules keep reading the root annotation.
With `@inline unit never`, the `Data_Unit_foreign.unit` accessor is no
longer folded into each use site; it becomes a single shared binding
(`local Data_Unit_unit = Data_Unit_foreign.unit`) that call sites
reference by name. Ten golden.lua move to this shape; the linked output
still holds exactly one `{}` for unit (the one inside the hoisted foreign
table), and every eval/golden.txt oracle is byte-identical, so runtime
behaviour is unchanged. The remaining golden.ir churn is the prelude
source path moving to the v7.3.1 commit.
Refs #176
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Picks up prelude v7.3.1 via the package set (
psc-0.15.15-20260712-2). The fork flipsData.Unit.unitfrom@inline unit alwaystonever, which pins theunit = {}foreign singleton to one shared binding instead of letting the accessor fold into every use site. This is the compiler-side half of #176: the fork edit and release landed separately, and this PR just repoints the golden set and accepts the resulting churn.What moves
test/ps/spago.yaml+test/ps/spago.lock: the set URL moves topsc-0.15.15-20260712-2, and prelude re-resolves to the v7.3.1 commit.golden.luachange shape: wherealwaysfolded the accessor into each site,neverkeeps a singlelocal Data_Unit_unit = Data_Unit_foreign.unitand references it by name:local Data_Unit_foreign = { unit = {} } +local Data_Unit_unit = Data_Unit_foreign.unit ... -return { main = Effect_applicativeEffect.pure(Data_Unit_foreign.unit) } +return { main = Effect_applicativeEffect.pure(Data_Unit_unit) }golden.irchurn is the prelude source path moving to the v7.3.1 commit.Why it is safe
eval/golden.txtoracle is byte-identical, so runtime output does not change. That includes theArray Unitprinting class (Arrays of typeArray Unitare always empty #23), which still printsunit / unit / unit / 3.{}for unit, inside the hoisted foreign table. The total{}count across the goldens is unchanged.@inline unit alwaystonever— inlining unit duplicates the singleton allocation #176 asked for, not a behavioural change. No new test is needed: unit is exercised corpus-wide, and Foreign table-constructor exports are duplicated per use site (fresh identity and allocation per copy) #175'sGolden.ForeignSharingeval golden already guards the sharing invariant.Refs #176