Skip to content

Commit 8de10dc

Browse files
committed
Merge remote-tracking branch 'origin/master' into release
2 parents adc169e + 59a999a commit 8de10dc

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

booster/library/Booster/Log.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module Booster.Log (
1919
jsonLogger,
2020
textLogger,
2121
withContext,
22+
withContext_,
2223
withContexts,
2324
withKorePatternContext,
2425
withPatternContext,

booster/library/Booster/Pattern/ApplyEquations.hs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import Booster.Prettyprinter (renderOneLineText)
6767
import Booster.SMT.Interface qualified as SMT
6868
import Booster.Syntax.Json.Externalise (externaliseTerm)
6969
import Booster.Util (Bound (..))
70+
import Kore.JsonRpc.Types.ContextLog (CLContext (CLWithId), IdContext (CtxCached))
7071
import Kore.Util (showHashHex)
7172

7273
newtype EquationT io a
@@ -165,6 +166,10 @@ instance Monoid SimplifierCache where
165166
data CacheTag = LLVM | Equations
166167
deriving stock (Show)
167168

169+
instance ContextFor CacheTag where
170+
withContextFor t =
171+
withContext_ (CLWithId . CtxCached $ Text.toLower $ Text.pack $ show t)
172+
168173
data EquationMetadata = EquationMetadata
169174
{ location :: Maybe Location
170175
, label :: Maybe Label
@@ -351,7 +356,7 @@ llvmSimplify term = do
351356
where
352357
evalLlvm definition api cb t@(Term attributes _)
353358
| attributes.isEvaluated = pure t
354-
| isConcrete t && attributes.canBeEvaluated = withContext CtxLlvm $ do
359+
| isConcrete t && attributes.canBeEvaluated = withContext CtxLlvm . withTermContext t $ do
355360
LLVM.simplifyTerm api definition t (sortOfTerm t)
356361
>>= \case
357362
Left (LlvmError e) -> do
@@ -531,10 +536,11 @@ cached cacheTag cb t@(Term attributes _)
531536
Just cachedTerm -> do
532537
when (t /= cachedTerm) $ do
533538
setChanged
534-
withContext CtxSuccess $
535-
withContext CtxCached $
536-
withTermContext cachedTerm $
537-
pure ()
539+
withTermContext t $
540+
withContext CtxSuccess $
541+
withContextFor cacheTag $
542+
withTermContext cachedTerm $
543+
pure ()
538544
pure cachedTerm
539545

540546
elseApply :: (Monad m, Eq b) => (b -> m b) -> (b -> m b) -> b -> m b

kore-rpc-types/src/Kore/JsonRpc/Types/ContextLog.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ data SimpleContext
3434
| CtxConstraint
3535
| CtxSMT
3636
| CtxLlvm
37-
| CtxCached
3837
| -- results
3938
CtxFailure
4039
| CtxIndeterminate
@@ -76,6 +75,7 @@ data IdContext
7675
| -- entities with name
7776
CtxHook Text
7877
| CtxRequest Text
78+
| CtxCached Text
7979
deriving stock (Eq, Ord)
8080

8181
instance Show IdContext where
@@ -86,6 +86,7 @@ instance Show IdContext where
8686
show (CtxTerm uid) = "term " <> show uid
8787
show (CtxHook name) = "hook " <> unpack name
8888
show (CtxRequest name) = "request " <> unpack name
89+
show (CtxCached name) = "cached " <> unpack name
8990

9091
getUniqueId :: IdContext -> Maybe UniqueId
9192
getUniqueId = \case

0 commit comments

Comments
 (0)