Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce allocations by optimizing branching and black holes #5492

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Singleton BlackHole value
  • Loading branch information
ChrisPenner committed Nov 27, 2024
commit 700c33c9cd67f5fc194e858cb89f1b4d5136b8db
9 changes: 8 additions & 1 deletion unison-runtime/src/Unison/Runtime/Stack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ data GClosure comb
deriving stock (Show, Functor, Foldable, Traversable)
{- ORMOLU_ENABLE -}

-- Singleton black hole value to avoid allocation.
blackHole :: Closure
blackHole = Closure GBlackHole
{-# NOINLINE blackHole #-}

pattern PAp :: CombIx -> GCombInfo (RComb Val) -> Seg -> Closure
pattern PAp cix comb seg = Closure (GPAp cix comb seg)

Expand All @@ -295,7 +300,9 @@ pattern Captured k a seg = Closure (GCaptured k a seg)

pattern Foreign x = Closure (GForeign x)

pattern BlackHole = Closure GBlackHole
pattern BlackHole <- Closure GBlackHole
where
BlackHole = blackHole

pattern UnboxedTypeTag t <- Closure (GUnboxedTypeTag t)
where
Expand Down