[Git][ghc/ghc][wip/ghc-9.10] JS: correctly handle RUBBISH literals (#24664)
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Thu Apr 25 16:56:35 UTC 2024
Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC
Commits:
bb67e8d5 by Sylvain Henry at 2024-04-25T12:56:03-04:00
JS: correctly handle RUBBISH literals (#24664)
(cherry picked from commit daeda83478d5b800d29661408dd67cc4b23df374)
- - - - -
1 changed file:
- compiler/GHC/StgToJS/Literal.hs
Changes:
=====================================
compiler/GHC/StgToJS/Literal.hs
=====================================
@@ -22,6 +22,7 @@ import GHC.StgToJS.Symbols
import GHC.Data.FastString
import GHC.Types.Literal
import GHC.Types.Basic
+import GHC.Types.RepType
import GHC.Utils.Misc
import GHC.Utils.Panic
import GHC.Utils.Outputable
@@ -68,7 +69,27 @@ genLit = \case
| otherwise -> return [ toJExpr (global (mkRawSymbol True name))
, ValExpr (JInt 0)
]
- LitRubbish {} -> return [ null_ ]
+ LitRubbish _ rr_ty ->
+ -- Generate appropriate rubbish literals, otherwise it might trip up the
+ -- code generator when a primop is applied to a rubbish literal (see #24664)
+ let reps = runtimeRepPrimRep (text "GHC.StgToJS.Literal.genLit") rr_ty
+ rub = \case
+ BoxedRep _ -> [ null_ ]
+ AddrRep -> [ null_, ValExpr (JInt 0) ]
+ WordRep -> [ ValExpr (JInt 0) ]
+ Word8Rep -> [ ValExpr (JInt 0) ]
+ Word16Rep -> [ ValExpr (JInt 0) ]
+ Word32Rep -> [ ValExpr (JInt 0) ]
+ Word64Rep -> [ ValExpr (JInt 0), ValExpr (JInt 0) ]
+ IntRep -> [ ValExpr (JInt 0) ]
+ Int8Rep -> [ ValExpr (JInt 0) ]
+ Int16Rep -> [ ValExpr (JInt 0) ]
+ Int32Rep -> [ ValExpr (JInt 0) ]
+ Int64Rep -> [ ValExpr (JInt 0), ValExpr (JInt 0) ]
+ DoubleRep -> [ ValExpr (JInt 0) ]
+ FloatRep -> [ ValExpr (JInt 0) ]
+ VecRep _ _ -> panic "GHC.StgToJS.Literal.genLit: VecRep unsupported"
+ in return (concatMap rub reps)
-- | generate a literal for the static init tables
genStaticLit :: Literal -> G [StaticLit]
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bb67e8d5678a4a6a7d54606b623141bc44ef3b8d
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bb67e8d5678a4a6a7d54606b623141bc44ef3b8d
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/20240425/7052189b/attachment-0001.html>
More information about the ghc-commits
mailing list