@@ -1112,6 +1112,10 @@ trait DebugInfo extends SAIOps {
11121112 def info (xs : Rep [_]* ): Rep [Unit ] = {
11131113 " info" .reflectCtrlWith[Unit ](xs : _* )
11141114 }
1115+
1116+ def infoWhen (envVar : Rep [String ], xs : Rep [_]* ): Rep [Unit ] = {
1117+ " infoWhen" .reflectCtrlWith[Unit ](envVar :: xs.toList: _* )
1118+ }
11151119}
11161120
11171121@ virtualize
@@ -1575,7 +1579,7 @@ trait StagedWasmEvaluator extends SAIOps
15751579 }
15761580 tailCall(thnK, ())
15771581 } else {
1578- info(s " Continue " )
1582+ info(s " Continue rest of the block " )
15791583 withBlock {
15801584 val control = makeControl(thnK, currentMCont)
15811585 ExploreTree .moveCursor(false , control)
@@ -1671,7 +1675,7 @@ trait StagedWasmEvaluator extends SAIOps
16711675 })
16721676 val newMKont : Rep [MCont [Unit ]] = currentMCont.prependCont(restK)
16731677 updateCurrentMCont(newMKont)
1674- info( s " Calling function at index " , index.toInt, " with call_indirect, stackSize =" , Stack .size)
1678+ infoWhen( " CALL " , s " Calling function at index " , index.toInt, " with call_indirect, stackSize =" , Stack .size)
16751679 val argsC = Stack .takeC(functy.inps)
16761680 val argsS = Stack .takeS(functy.inps)
16771681 Frames .pushFrameCallerC(functy.inps)
@@ -1686,7 +1690,7 @@ trait StagedWasmEvaluator extends SAIOps
16861690 compileCache(funcIndex)
16871691 } else {
16881692 def retK (ctx : Context ): Rep [Cont [Unit ]] = topFun((_ : Rep [Unit ]) => {
1689- info( s " Return from the function at $funcIndex, stackSize = " , Stack .size)
1693+ infoWhen( " CALL " , s " Exiting the function at $funcIndex, stackSize = " , Stack .size)
16901694 Frames .popFrameCalleeC(locals.size)
16911695 Frames .popFrameCalleeS(locals.size)
16921696 val offset = ctx.stackTypes.size - ty.out.size
@@ -1696,7 +1700,7 @@ trait StagedWasmEvaluator extends SAIOps
16961700 })
16971701
16981702 val func = topFun((_ : Rep [Unit ]) => {
1699- info( s " Entered the function at $funcIndex, stackSize = " , Stack .size)
1703+ infoWhen( " CALL " , s " Entered the function at $funcIndex, stackSize = " , Stack .size)
17001704 Frames .pushFrameCalleeC(locals.size)
17011705 Frames .pushFrameCalleeS(locals)
17021706 // the return instruction is also stack polymorphic
@@ -1718,14 +1722,14 @@ trait StagedWasmEvaluator extends SAIOps
17181722 val callee = evalFunc(ty, body, funcIndex, ty.inps, bodyLocals)
17191723 // Predef.println(s"[DEBUG] locals size: ${locals.size}")
17201724 withBlock {
1721- info( " Taking arguments from stack to call function at " , funcIndex)
1725+ infoWhen( " CALL " , s " Taking arguments from stack to call function at " , funcIndex)
17221726 val newCtx = ctx.take(ty.inps.size)
17231727 val argsC = Stack .takeC(ty.inps)
17241728 val argsS = Stack .takeS(ty.inps)
17251729 // We make a new trail by `restK`, since function creates a new block to escape
17261730 // (more or less like `return`)
17271731 val restK : Rep [Cont [Unit ]] = topFun((_ : Rep [Unit ]) => {
1728- info( s " Exiting the function at $funcIndex, stackSize = " , Stack .size)
1732+ infoWhen( " CALL " , s " Returning from the function at $funcIndex, stackSize = " , Stack .size)
17291733 Frames .popFrameCallerC(ty.inps.size)
17301734 Frames .popFrameCallerS(ty.inps.size)
17311735 eval(rest, kont, trail)(newCtx.copy(stackTypes = ty.out.reverse ++ ctx.stackTypes.drop(ty.inps.size)))
0 commit comments