summaryrefslogtreecommitdiffstats
path: root/src/userfunc.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-01-24 12:53:53 +0100
committerBram Moolenaar <Bram@vim.org>2021-01-24 12:53:53 +0100
commitb204990346ca857802b174afe8a7fbb05e4f318e (patch)
tree6660d87cac14e978841c1eaf55994bf8a85f84a9 /src/userfunc.c
parent7cf0c114d690c91ac88c92a1a6f1b1935cb6410f (diff)
patch 8.2.2400: Vim9: compiled functions are not profiledv8.2.2400
Problem: Vim9: compiled functions are not profiled. Solution: Add initial changes to profile compiled functions. Fix that a script-local function was hard to debug.
Diffstat (limited to 'src/userfunc.c')
-rw-r--r--src/userfunc.c56
1 files changed, 19 insertions, 37 deletions
diff --git a/src/userfunc.c b/src/userfunc.c
index 5372260d6d..9216685823 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -1601,12 +1601,14 @@ call_user_func(
char_u numbuf[NUMBUFLEN];
char_u *name;
#ifdef FEAT_PROFILE
- proftime_T wait_start;
- proftime_T call_start;
- int started_profiling = FALSE;
+ profinfo_T profile_info;
#endif
ESTACK_CHECK_DECLARATION
+#ifdef FEAT_PROFILE
+ CLEAR_FIELD(profile_info);
+#endif
+
// If depth of calling is getting too high, don't execute the function.
if (funcdepth_increment() == FAIL)
{
@@ -1635,8 +1637,16 @@ call_user_func(
if (fp->uf_def_status != UF_NOT_COMPILED)
{
// Execute the function, possibly compiling it first.
+#ifdef FEAT_PROFILE
+ profile_may_start_func(&profile_info, fp, fc);
+#endif
call_def_function(fp, argcount, argvars, funcexe->partial, rettv);
funcdepth_decrement();
+#ifdef FEAT_PROFILE
+ if (do_profiling == PROF_YES && (fp->uf_profiling
+ || (fc->caller != NULL && fc->caller->func->uf_profiling)))
+ profile_may_end_func(&profile_info, fp, fc);
+#endif
current_funccal = fc->caller;
free_funccal(fc);
return;
@@ -1849,22 +1859,7 @@ call_user_func(
--no_wait_return;
}
#ifdef FEAT_PROFILE
- if (do_profiling == PROF_YES)
- {
- if (!fp->uf_profiling && has_profiling(FALSE, fp->uf_name, NULL))
- {
- started_profiling = TRUE;
- func_do_profile(fp);
- }
- if (fp->uf_profiling
- || (fc->caller != NULL && fc->caller->func->uf_profiling))
- {
- ++fp->uf_tm_count;
- profile_start(&call_start);
- profile_zero(&fp->uf_tm_children);
- }
- script_prof_save(&wait_start);
- }
+ profile_may_start_func(&profile_info, fp, fc);
#endif
save_current_sctx = current_sctx;
@@ -1902,20 +1897,7 @@ call_user_func(
#ifdef FEAT_PROFILE
if (do_profiling == PROF_YES && (fp->uf_profiling
|| (fc->caller != NULL && fc->caller->func->uf_profiling)))
- {
- profile_end(&call_start);
- profile_sub_wait(&wait_start, &call_start);
- profile_add(&fp->uf_tm_total, &call_start);
- profile_self(&fp->uf_tm_self, &call_start, &fp->uf_tm_children);
- if (fc->caller != NULL && fc->caller->func->uf_profiling)
- {
- profile_add(&fc->caller->func->uf_tm_children, &call_start);
- profile_add(&fc->caller->func->uf_tml_children, &call_start);
- }
- if (started_profiling)
- // make a ":profdel func" stop profiling the function
- fp->uf_profiling = FALSE;
- }
+ profile_may_end_func(&profile_info, fp, fc);
#endif
// when being verbose, mention the return value
@@ -1964,7 +1946,7 @@ call_user_func(
current_sctx = save_current_sctx;
#ifdef FEAT_PROFILE
if (do_profiling == PROF_YES)
- script_prof_restore(&wait_start);
+ script_prof_restore(&profile_info.pi_wait_start);
#endif
if (using_sandbox)
--sandbox;
@@ -3982,7 +3964,7 @@ ex_function(exarg_T *eap)
/*
* :defcompile - compile all :def functions in the current script that need to
- * be compiled. Except dead functions.
+ * be compiled. Except dead functions. Doesn't do profiling.
*/
void
ex_defcompile(exarg_T *eap UNUSED)
@@ -4002,7 +3984,7 @@ ex_defcompile(exarg_T *eap UNUSED)
&& ufunc->uf_def_status == UF_TO_BE_COMPILED
&& (ufunc->uf_flags & FC_DEAD) == 0)
{
- compile_def_function(ufunc, FALSE, NULL);
+ compile_def_function(ufunc, FALSE, FALSE, NULL);
if (func_hashtab.ht_changed != changed)
{
@@ -4698,7 +4680,7 @@ get_func_line(
SOURCING_LNUM = fcp->linenr;
#ifdef FEAT_PROFILE
if (do_profiling == PROF_YES)
- func_line_start(cookie);
+ func_line_start(cookie, SOURCING_LNUM);
#endif
}
}