diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-07-11 20:22:30 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-11 20:22:30 +0200 |
commit | ffcfddc759e583471a1ed55e0938d042bf68c507 (patch) | |
tree | a95c6cf4c4e1f75de9a183312c6d0d0f968e849d /src/vim9compile.c | |
parent | c72bdd28ac5fe079825155930af8e792580139bb (diff) | |
download | vim-git-ffcfddc759e583471a1ed55e0938d042bf68c507.tar.gz |
patch 8.2.3151: Vim9: profiling fails if nested function is also profiledv8.2.3151
Problem: Vim9: profiling fails if nested function is also profiled.
Solution: Use the compile type from the outer function. (closes #8543)
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r-- | src/vim9compile.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c index 15c8ef6a8..d25183f19 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -5570,6 +5570,7 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx) char_u *lambda_name; ufunc_T *ufunc; int r = FAIL; + compiletype_T compile_type; if (eap->forceit) { @@ -5636,9 +5637,15 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx) } } - 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; @@ -5647,8 +5654,7 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx) #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 |