Skip to content

Commit d3a9594

Browse files
committed
add changelog
1 parent d6258a1 commit d3a9594

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Added
2+
- `generate-callstack` option: When enabled, the plugin replaces every occurrence of `PlutusTx.Trace.callStack` with a `BuiltinString` containing the callstack at that relative point. Enabling this option incurs execution-cost overhead: it adds an extra callstack argument to all user-defined functions, and every time they are invoked it requires having extra application node for providing the current callstack. When `gennerate-callstack` is not enabled, `PlutusTx.Trace.callStack` is string "<CallStack>".
3+
4+

plutus-tx-plugin/src/PlutusTx/Compiler/Expr.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,13 +613,13 @@ ourselves before we start.
613613
-}
614614

615615
-- | Apply callstack to given term if given 'GHC.Var' requires callstack to be applied.
616-
applyCallStack
616+
applyCallStackWhenNeeded
617617
:: MonadState CompileState m
618618
=> GHC.Var
619619
-> PIRTerm PLC.DefaultUni PLC.DefaultFun
620620
-> m (PIRTerm PLC.DefaultUni PLC.DefaultFun)
621-
applyCallStack currVar t = do
622-
csFuns <- gets csNeedsCallStack
621+
applyCallStackWhenNeeded currVar t = do
622+
csFuns <- gets csCallStackDeps
623623
if Set.member (LexName $ GHC.varName currVar) csFuns
624624
then do
625625
lastCs <- lastCallStackName
@@ -651,7 +651,7 @@ lookupTerm
651651
-> m (Maybe (PIRTerm PLC.DefaultUni PLC.DefaultFun))
652652
lookupTerm var =
653653
PIR.lookupTerm (LexName $ GHC.varName var)
654-
>>= traverse (applyCallStack var)
654+
>>= traverse (applyCallStackWhenNeeded var)
655655

656656
hoistExpr
657657
:: CompilingDefault uni fun m ann
@@ -744,7 +744,7 @@ hoistExpr var t = do
744744
PIR.modifyTermDef lexName (const $ PIR.Def var'' (t', PIR.NonStrict))
745745

746746
-- Apply callstack.
747-
applyCallStack var $ PIR.mkVar var''
747+
applyCallStackWhenNeeded var $ PIR.mkVar var''
748748

749749
maybeProfileRhs
750750
:: (CompilingDefault uni fun m ann) => PLCVar uni -> PIRTerm uni fun -> m (PIRTerm uni fun)

plutus-tx-plugin/src/PlutusTx/Compiler/Types.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
{-# LANGUAGE DataKinds #-}
44
{-# LANGUAGE FlexibleContexts #-}
55
{-# LANGUAGE FlexibleInstances #-}
6-
{-# LANGUAGE OverloadedStrings #-}
76
{-# LANGUAGE Rank2Types #-}
87
{-# LANGUAGE TypeFamilies #-}
98
{-# LANGUAGE TypeOperators #-}
@@ -84,7 +83,7 @@ data CompileState = CompileState
8483
{- ^ The callstack variables bound at the current state. The first element represents the
8584
most recent callstack.
8685
-}
87-
, csNeedsCallStack :: Set LexName
86+
, csCallStackDeps :: Set LexName
8887
{- ^ Set of names that requires callstack. A name being in this set indicates that their
8988
corresponding term is modified to have extra string argument and need to apply callstack
9089
before using the function.
@@ -100,8 +99,8 @@ lastCallStackName = do
10099

101100
insertCallStackDeps :: MonadState CompileState m => LexName -> m ()
102101
insertCallStackDeps name =
103-
modify' $ \compileState@(CompileState {csNeedsCallStack = fns}) ->
104-
compileState {csNeedsCallStack = Set.insert name fns}
102+
modify' $ \compileState@(CompileState {csCallStackDeps = fns}) ->
103+
compileState {csCallStackDeps = Set.insert name fns}
105104

106105
-- | Verbosity level of the Plutus Tx compiler.
107106
data Verbosity

0 commit comments

Comments
 (0)