Nested()
enddef
+def ProfiledNestedProfiled()
+ var x = 0
+ def Nested(): any
+ return x
+ enddef
+ Nested()
+enddef
+
" Execute this near the end, profiling doesn't stop until Vim exists.
" This only tests that it works, not the profiling output.
def Test_xx_profile_with_lambda()
profile start Xprofile.log
profile func ProfiledWithLambda
ProfiledWithLambda()
+
profile func ProfiledNested
ProfiledNested()
+
+ # Also profile the nested function. Use a different function, although the
+ # contents is the same, to make sure it was not already compiled.
+ profile func *
+ ProfiledNestedProfiled()
+
+ profdel func *
+ profile pause
enddef
" Keep this last, it messes up highlighting.
char_u *lambda_name;
ufunc_T *ufunc;
int r = FAIL;
+ compiletype_T compile_type;
if (eap->forceit)
{
}
}
- if (func_needs_compiling(ufunc, COMPILE_TYPE(ufunc))
- && compile_def_function(ufunc, TRUE, COMPILE_TYPE(ufunc), cctx)
- == FAIL)
+ compile_type = COMPILE_TYPE(ufunc);
+#ifdef FEAT_PROFILE
+ // If the outer function is profiled, also compile the nested function for
+ // profiling.
+ if (cctx->ctx_compile_type == CT_PROFILE)
+ compile_type = CT_PROFILE;
+#endif
+ if (func_needs_compiling(ufunc, compile_type)
+ && compile_def_function(ufunc, TRUE, compile_type, cctx) == FAIL)
{
func_ptr_unref(ufunc);
goto theend;
#ifdef FEAT_PROFILE
// When the outer function is compiled for profiling, the nested function
// may be called without profiling. Compile it here in the right context.
- if (COMPILE_TYPE(ufunc) == CT_PROFILE
- && func_needs_compiling(ufunc, CT_NONE))
+ if (compile_type == CT_PROFILE && func_needs_compiling(ufunc, CT_NONE))
compile_def_function(ufunc, FALSE, CT_NONE, cctx);
#endif