diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-10-13 19:20:28 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-10-15 21:58:27 -0400 |
commit | cc536288c32df9c4b9f37020b76348f58a57b3cb (patch) | |
tree | e3072e960fb0a29163decf4554471274790c99c1 /compiler/GHC/ByteCode | |
parent | ae146b536445d20ef9983ff0e38ce1beaec6f321 (diff) | |
download | haskell-cc536288c32df9c4b9f37020b76348f58a57b3cb.tar.gz |
compiler/ByteCode: Allow 2^32 local labels
This widens LocalLabel to 2^16, avoiding the crash observed in #14334.
Closes #14334.
Diffstat (limited to 'compiler/GHC/ByteCode')
-rw-r--r-- | compiler/GHC/ByteCode/Asm.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/ByteCode/Instr.hs | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/compiler/GHC/ByteCode/Asm.hs b/compiler/GHC/ByteCode/Asm.hs index b59748bc92..c344823ccb 100644 --- a/compiler/GHC/ByteCode/Asm.hs +++ b/compiler/GHC/ByteCode/Asm.hs @@ -179,7 +179,9 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm -- this BCO to be long. (n_insns0, lbl_map0) = inspectAsm platform False initial_offset asm ((n_insns, lbl_map), long_jumps) - | isLarge n_insns0 = (inspectAsm platform True initial_offset asm, True) + | isLarge (fromIntegral $ Map.size lbl_map0) + || isLarge n_insns0 + = (inspectAsm platform True initial_offset asm, True) | otherwise = ((n_insns0, lbl_map0), False) env :: LocalLabel -> Word diff --git a/compiler/GHC/ByteCode/Instr.hs b/compiler/GHC/ByteCode/Instr.hs index aecc7c9181..bc9b114573 100644 --- a/compiler/GHC/ByteCode/Instr.hs +++ b/compiler/GHC/ByteCode/Instr.hs @@ -50,7 +50,8 @@ data ProtoBCO a protoBCOFFIs :: [FFIInfo] } -newtype LocalLabel = LocalLabel { getLocalLabel :: Word16 } +-- | A local block label (e.g. identifying a case alternative). +newtype LocalLabel = LocalLabel { getLocalLabel :: Word32 } deriving (Eq, Ord) instance Outputable LocalLabel where |