diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-05-06 14:52:53 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-12 21:41:43 -0400 |
commit | bfabf94f63b6644bd32982fd13ea0c8bca9aeae4 (patch) | |
tree | b185749a9676a57c226dab9681fa3c4ba0415dd3 /compiler/GHC/ByteCode | |
parent | da56ed41b62ab132db6d62637c11076985410b24 (diff) | |
download | haskell-bfabf94f63b6644bd32982fd13ea0c8bca9aeae4.tar.gz |
Replace CPP assertions with Haskell functions
There is no reason to use CPP. __LINE__ and __FILE__ macros are now
better replaced with GHC's CallStack. As a bonus, assert error messages
now contain more information (function name, column).
Here is the mapping table (HasCallStack omitted):
* ASSERT: assert :: Bool -> a -> a
* MASSERT: massert :: Bool -> m ()
* ASSERTM: assertM :: m Bool -> m ()
* ASSERT2: assertPpr :: Bool -> SDoc -> a -> a
* MASSERT2: massertPpr :: Bool -> SDoc -> m ()
* ASSERTM2: assertPprM :: m Bool -> SDoc -> m ()
Diffstat (limited to 'compiler/GHC/ByteCode')
-rw-r--r-- | compiler/GHC/ByteCode/Asm.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/ByteCode/Linker.hs | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/compiler/GHC/ByteCode/Asm.hs b/compiler/GHC/ByteCode/Asm.hs index 1f11938517..542a6b3635 100644 --- a/compiler/GHC/ByteCode/Asm.hs +++ b/compiler/GHC/ByteCode/Asm.hs @@ -34,7 +34,7 @@ import GHC.Types.Unique.DSet import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Utils.Misc +import GHC.Utils.Panic.Plain import GHC.Core.TyCon import GHC.Data.FastString @@ -202,7 +202,7 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm (final_insns, final_lits, final_ptrs) <- flip execStateT initial_state $ runAsm platform long_jumps env asm -- precomputed size should be equal to final size - ASSERT(n_insns == sizeSS final_insns) return () + massert (n_insns == sizeSS final_insns) let asm_insns = ssElts final_insns insns_arr = Array.listArray (0, fromIntegral n_insns - 1) asm_insns diff --git a/compiler/GHC/ByteCode/Linker.hs b/compiler/GHC/ByteCode/Linker.hs index 50bef7972e..9170da7710 100644 --- a/compiler/GHC/ByteCode/Linker.hs +++ b/compiler/GHC/ByteCode/Linker.hs @@ -39,8 +39,8 @@ import GHC.Data.FastString import GHC.Data.SizedSeq import GHC.Utils.Panic +import GHC.Utils.Panic.Plain import GHC.Utils.Outputable -import GHC.Utils.Misc import GHC.Types.Name import GHC.Types.Name.Env @@ -150,7 +150,7 @@ resolvePtr interp ie ce bco_ix breakarray ptr = case ptr of -> return (ResolvedBCOPtr (unsafeForeignRefToRemoteRef rhv)) | otherwise - -> ASSERT2(isExternalName nm, ppr nm) + -> assertPpr (isExternalName nm) (ppr nm) $ do let sym_to_find = nameToCLabel nm "closure" m <- lookupSymbol interp sym_to_find @@ -187,7 +187,7 @@ nameToCLabel :: Name -> String -> FastString nameToCLabel n suffix = mkFastString label where encodeZ = zString . zEncodeFS - (Module pkgKey modName) = ASSERT( isExternalName n ) nameModule n + (Module pkgKey modName) = assert (isExternalName n) $ nameModule n packagePart = encodeZ (unitFS pkgKey) modulePart = encodeZ (moduleNameFS modName) occPart = encodeZ (occNameFS (nameOccName n)) |