| 15 | namespace Executor { |
| 16 | |
| 17 | Executor::SavedThreadLocal::SavedThreadLocal( |
| 18 | Executor &Ex, Runtime::StackManager &StackMgr, |
| 19 | const Runtime::Instance::FunctionInstance &Func) noexcept { |
| 20 | // Prepare the execution context. |
| 21 | auto *ModInst = |
| 22 | const_cast<Runtime::Instance::ModuleInstance *>(Func.getModule()); |
| 23 | SavedThis = This; |
| 24 | This = &Ex; |
| 25 | |
| 26 | SavedExecutionContext = ExecutionContext; |
| 27 | ExecutionContext.StopToken = &Ex.StopToken; |
| 28 | ExecutionContext.Memories = ModInst->MemoryPtrs.data(); |
| 29 | ExecutionContext.Globals = ModInst->GlobalPtrs.data(); |
| 30 | if (Ex.Stat) { |
| 31 | ExecutionContext.InstrCount = &Ex.Stat->getInstrCountRef(); |
| 32 | ExecutionContext.CostTable = Ex.Stat->getCostTable().data(); |
| 33 | ExecutionContext.Gas = &Ex.Stat->getTotalCostRef(); |
| 34 | ExecutionContext.GasLimit = Ex.Stat->getCostLimit(); |
| 35 | } |
| 36 | |
| 37 | SavedCurrentStack = CurrentStack; |
| 38 | CurrentStack = &StackMgr; |
| 39 | } |
| 40 | |
| 41 | Executor::SavedThreadLocal::~SavedThreadLocal() noexcept { |
| 42 | CurrentStack = SavedCurrentStack; |
nothing calls this directly
no test coverage detected