Reduce lock contention in ExprNodeGenericFuncEvaluator and ShimLoader.

Originally contributed by @chenghao-intel.