Skip to content

More precise [llvm]/[cached *] log context #3957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions booster/library/Booster/Log.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Booster.Log (
jsonLogger,
textLogger,
withContext,
withContext_,
withContexts,
withKorePatternContext,
withPatternContext,
Expand Down
16 changes: 11 additions & 5 deletions booster/library/Booster/Pattern/ApplyEquations.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import Booster.Prettyprinter (renderOneLineText)
import Booster.SMT.Interface qualified as SMT
import Booster.Syntax.Json.Externalise (externaliseTerm)
import Booster.Util (Bound (..))
import Kore.JsonRpc.Types.ContextLog (CLContext (CLWithId), IdContext (CtxCached))
import Kore.Util (showHashHex)

newtype EquationT io a
Expand Down Expand Up @@ -165,6 +166,10 @@ instance Monoid SimplifierCache where
data CacheTag = LLVM | Equations
deriving stock (Show)

instance ContextFor CacheTag where
withContextFor t =
withContext_ (CLWithId . CtxCached $ Text.toLower $ Text.pack $ show t)

data EquationMetadata = EquationMetadata
{ location :: Maybe Location
, label :: Maybe Label
Expand Down Expand Up @@ -351,7 +356,7 @@ llvmSimplify term = do
where
evalLlvm definition api cb t@(Term attributes _)
| attributes.isEvaluated = pure t
| isConcrete t && attributes.canBeEvaluated = withContext CtxLlvm $ do
| isConcrete t && attributes.canBeEvaluated = withContext CtxLlvm . withTermContext t $ do
LLVM.simplifyTerm api definition t (sortOfTerm t)
>>= \case
Left (LlvmError e) -> do
Expand Down Expand Up @@ -531,10 +536,11 @@ cached cacheTag cb t@(Term attributes _)
Just cachedTerm -> do
when (t /= cachedTerm) $ do
setChanged
withContext CtxSuccess $
withContext CtxCached $
withTermContext cachedTerm $
pure ()
withTermContext t $
withContext CtxSuccess $
withContextFor cacheTag $
withTermContext cachedTerm $
pure ()
pure cachedTerm

elseApply :: (Monad m, Eq b) => (b -> m b) -> (b -> m b) -> b -> m b
Expand Down
3 changes: 2 additions & 1 deletion kore-rpc-types/src/Kore/JsonRpc/Types/ContextLog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ data SimpleContext
| CtxConstraint
| CtxSMT
| CtxLlvm
| CtxCached
| -- results
CtxFailure
| CtxIndeterminate
Expand Down Expand Up @@ -76,6 +75,7 @@ data IdContext
| -- entities with name
CtxHook Text
| CtxRequest Text
| CtxCached Text
deriving stock (Eq, Ord)

instance Show IdContext where
Expand All @@ -86,6 +86,7 @@ instance Show IdContext where
show (CtxTerm uid) = "term " <> show uid
show (CtxHook name) = "hook " <> unpack name
show (CtxRequest name) = "request " <> unpack name
show (CtxCached name) = "cached " <> unpack name

getUniqueId :: IdContext -> Maybe UniqueId
getUniqueId = \case
Expand Down
Loading