Hide FunctionCallTrace constructor/destructor
This prevents them from being inlined. On gcc 9, this reduces the stack size needed for nix-instantiate '<nixpkgs>' -A texlive.combined.scheme-full --dry-run from 12.9 MiB to 4.8 MiB. (cherry picked from commit cb90e382b5b6e177ea902b3909fd1897643ae3cd)
This commit is contained in:
parent
c94fd5f51a
commit
f84c3f9d65
3 changed files with 20 additions and 15 deletions
|
@ -1096,9 +1096,7 @@ void EvalState::callPrimOp(Value & fun, Value & arg, Value & v, const Pos & pos)
|
||||||
|
|
||||||
void EvalState::callFunction(Value & fun, Value & arg, Value & v, const Pos & pos)
|
void EvalState::callFunction(Value & fun, Value & arg, Value & v, const Pos & pos)
|
||||||
{
|
{
|
||||||
std::unique_ptr<FunctionCallTrace> trace;
|
auto trace = evalSettings.traceFunctionCalls ? std::make_unique<FunctionCallTrace>(pos) : nullptr;
|
||||||
if (evalSettings.traceFunctionCalls)
|
|
||||||
trace = std::make_unique<FunctionCallTrace>(pos);
|
|
||||||
|
|
||||||
forceValue(fun, pos);
|
forceValue(fun, pos);
|
||||||
|
|
||||||
|
|
17
src/libexpr/function-trace.cc
Normal file
17
src/libexpr/function-trace.cc
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#include "function-trace.hh"
|
||||||
|
|
||||||
|
namespace nix {
|
||||||
|
|
||||||
|
FunctionCallTrace::FunctionCallTrace(const Pos & pos) : pos(pos) {
|
||||||
|
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
|
||||||
|
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
|
||||||
|
printMsg(lvlInfo, "function-trace entered %1% at %2%", pos, ns.count());
|
||||||
|
}
|
||||||
|
|
||||||
|
FunctionCallTrace::~FunctionCallTrace() {
|
||||||
|
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
|
||||||
|
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
|
||||||
|
printMsg(lvlInfo, "function-trace exited %1% at %2%", pos, ns.count());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,17 +8,7 @@ namespace nix {
|
||||||
struct FunctionCallTrace
|
struct FunctionCallTrace
|
||||||
{
|
{
|
||||||
const Pos & pos;
|
const Pos & pos;
|
||||||
|
FunctionCallTrace(const Pos & pos);
|
||||||
FunctionCallTrace(const Pos & pos) : pos(pos) {
|
~FunctionCallTrace();
|
||||||
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
|
|
||||||
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
|
|
||||||
printMsg(lvlInfo, "function-trace entered %1% at %2%", pos, ns.count());
|
|
||||||
}
|
|
||||||
|
|
||||||
~FunctionCallTrace() {
|
|
||||||
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
|
|
||||||
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
|
|
||||||
printMsg(lvlInfo, "function-trace exited %1% at %2%", pos, ns.count());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue