mirror of
https://github.com/NixOS/nix.git
synced 2025-11-10 12:36:01 +01:00
Merge pull request #13219 from xokdvium/eval-profiler
libexpr: Add `EvalProfiler` and use it for `FunctionCallTrace`
This commit is contained in:
commit
638b7ec6c5
8 changed files with 202 additions and 13 deletions
|
|
@ -372,6 +372,10 @@ EvalState::EvalState(
|
|||
);
|
||||
|
||||
createBaseEnv(settings);
|
||||
|
||||
/* Register function call tracer. */
|
||||
if (settings.traceFunctionCalls)
|
||||
profiler.addProfiler(make_ref<FunctionCallTrace>());
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1526,9 +1530,14 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
|
|||
{
|
||||
auto _level = addCallDepth(pos);
|
||||
|
||||
auto trace = settings.traceFunctionCalls
|
||||
? std::make_unique<FunctionCallTrace>(positions[pos])
|
||||
: nullptr;
|
||||
auto neededHooks = profiler.getNeededHooks();
|
||||
if (neededHooks.test(EvalProfiler::preFunctionCall)) [[unlikely]]
|
||||
profiler.preFunctionCallHook(*this, fun, args, pos);
|
||||
|
||||
Finally traceExit_{[&](){
|
||||
if (profiler.getNeededHooks().test(EvalProfiler::postFunctionCall)) [[unlikely]]
|
||||
profiler.postFunctionCallHook(*this, fun, args, pos);
|
||||
}};
|
||||
|
||||
forceValue(fun, pos);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue