From a78e986b294deb956bdac6bdf0ed476e31cbe902 Mon Sep 17 00:00:00 2001 From: Chris Penner Date: Tue, 15 Oct 2024 11:48:57 -0700 Subject: [PATCH] Fix bad arg serialization --- unison-runtime/src/Unison/Runtime/ANF.hs | 3 +++ unison-runtime/src/Unison/Runtime/Decompile.hs | 2 +- unison-runtime/src/Unison/Runtime/MCode.hs | 3 +-- unison-runtime/src/Unison/Runtime/MCode/Serialize.hs | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/unison-runtime/src/Unison/Runtime/ANF.hs b/unison-runtime/src/Unison/Runtime/ANF.hs index 48a91da074..61bd4ab662 100644 --- a/unison-runtime/src/Unison/Runtime/ANF.hs +++ b/unison-runtime/src/Unison/Runtime/ANF.hs @@ -1535,8 +1535,11 @@ type ANFD v = Compose (ANFM v) (Directed ()) data GroupRef = GR Reference Word64 deriving (Show) +-- | A value which is either unboxed or boxed. type UBValue = Either Word64 Value +-- | A list of either unboxed or boxed values. +-- Each slot is one of unboxed or boxed but not both. type ValList = [UBValue] data Value diff --git a/unison-runtime/src/Unison/Runtime/Decompile.hs b/unison-runtime/src/Unison/Runtime/Decompile.hs index b78ef25ca2..564c08e16b 100644 --- a/unison-runtime/src/Unison/Runtime/Decompile.hs +++ b/unison-runtime/src/Unison/Runtime/Decompile.hs @@ -164,7 +164,6 @@ decompile backref topTerms = \case -- Only match lists of boxed args. | ([], bs) <- partitionEithers vs -> apps' (con rf ct) <$> traverse (decompile backref topTerms) bs - (DataC rf _ _) -> err (BadData rf) $ bug "" (PApV (CIx rf rt k) _ (partitionEithers -> ([], bs))) | rf == Builtin "jumpCont" -> err Cont $ bug "" @@ -179,6 +178,7 @@ decompile backref topTerms = \case | otherwise -> err (UnkComb rf) $ ref () rf (PAp (CIx rf _ _) _ _) -> err (BadPAp rf) $ bug "" + (DataC rf _ _) -> err (BadData rf) $ bug "" BlackHole -> err Exn $ bug "" (Captured {}) -> err Cont $ bug "" (Foreign f) -> diff --git a/unison-runtime/src/Unison/Runtime/MCode.hs b/unison-runtime/src/Unison/Runtime/MCode.hs index da31af90c5..265efd163d 100644 --- a/unison-runtime/src/Unison/Runtime/MCode.hs +++ b/unison-runtime/src/Unison/Runtime/MCode.hs @@ -267,8 +267,7 @@ data Args | VArg2 !Int !Int | VArgR !Int !Int | VArgN {-# UNPACK #-} !(PrimArray Int) - | -- TODO: What do I do with this? - VArgV !Int + | VArgV !Int deriving (Show, Eq, Ord) argsToLists :: Args -> [Int] diff --git a/unison-runtime/src/Unison/Runtime/MCode/Serialize.hs b/unison-runtime/src/Unison/Runtime/MCode/Serialize.hs index 32460a0c31..89930aefc3 100644 --- a/unison-runtime/src/Unison/Runtime/MCode/Serialize.hs +++ b/unison-runtime/src/Unison/Runtime/MCode/Serialize.hs @@ -264,7 +264,7 @@ instance Tag ArgsT where putArgs :: (MonadPut m) => Args -> m () putArgs ZArgs = putTag ZArgsT putArgs (VArg1 i) = putTag Arg1T *> pInt i -putArgs (VArg2 i j) = putTag Arg1T *> pInt i *> pInt j +putArgs (VArg2 i j) = putTag Arg2T *> pInt i *> pInt j putArgs (VArgR i j) = putTag ArgRT *> pInt i *> pInt j putArgs (VArgN pa) = putTag ArgNT *> putIntArr pa putArgs (VArgV i) = putTag ArgVT *> pInt i