From 276a77121044d746a0cc70c29e7691a1e306fa45 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Tue, 3 Dec 2024 20:38:41 +0100 Subject: [PATCH] libexpr: move thunk counter into eval state this is relative to the current state. why was it made global? Change-Id: I58b3ce0213e791a05ce9fd7a2cb2394b9454c653 --- lix/libexpr/eval.cc | 18 ++++++------------ lix/libexpr/eval.hh | 2 ++ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lix/libexpr/eval.cc b/lix/libexpr/eval.cc index c989dd0fb..070d02813 100644 --- a/lix/libexpr/eval.cc +++ b/lix/libexpr/eval.cc @@ -779,18 +779,10 @@ Value EvalMemory::newList(size_t size) } -unsigned long nrThunks = 0; - -static inline void mkThunk(Value & v, Env & env, Expr & expr) -{ - v.mkThunk(&env, expr); - nrThunks++; -} - - void EvalState::evalLazily(Expr & e, Value & v) { - mkThunk(v, builtins.env, e); + v.mkThunk(&builtins.env, e); + nrThunks++; } @@ -889,7 +881,8 @@ void EvalState::mkSingleDerivedPathString( Value * Expr::maybeThunk(EvalState & state, Env & env) { Value * v = state.mem.allocValue(); - mkThunk(*v, env, *this); + v->mkThunk(&env, *this); + state.nrThunks++; return v; } @@ -1088,7 +1081,8 @@ void ExprAttrs::eval(EvalState & state, Env & env, Value & v) Value * vAttr; if (hasOverrides && i.second.kind != AttrDef::Kind::Inherited) { vAttr = state.mem.allocValue(); - mkThunk(*vAttr, *i.second.chooseByKind(&env2, &env, inheritEnv), *i.second.e); + vAttr->mkThunk(i.second.chooseByKind(&env2, &env, inheritEnv), *i.second.e); + state.nrThunks++; } else vAttr = i.second.e->maybeThunk(state, *i.second.chooseByKind(&env2, &env, inheritEnv)); env2.values[displ++] = vAttr; diff --git a/lix/libexpr/eval.hh b/lix/libexpr/eval.hh index d42e3ff87..bed5aecce 100644 --- a/lix/libexpr/eval.hh +++ b/lix/libexpr/eval.hh @@ -780,6 +780,7 @@ private: unsigned long nrListConcats = 0; unsigned long nrPrimOpCalls = 0; unsigned long nrFunctionCalls = 0; + unsigned long nrThunks = 0; bool countCalls; @@ -794,6 +795,7 @@ private: using AttrSelects = std::map; AttrSelects attrSelects; + friend struct Expr; friend struct ExprOpUpdate; friend struct ExprOpConcatLists; friend struct ExprVar;