Patch 8.2.2401
Problem: Build fails without +profiling feature.
Solution: Add #ifdefs.
Files: src/vim9compile.c, src/vim9execute.c, src/vim9.h, src/structs.h,
src/testdir/test_vim9_disassemble.vim
*** ../vim-8.2.2400/src/vim9compile.c 2021-01-24 12:53:30.780247041 +0100
--- src/vim9compile.c 2021-01-24 13:29:30.704432476 +0100
***************
*** 1699,1720 ****
* "profile" indicates profiling is to be done.
*/
int
! func_needs_compiling(ufunc_T *ufunc, int profile)
{
switch (ufunc->uf_def_status)
{
! case UF_NOT_COMPILED: return FALSE;
case UF_TO_BE_COMPILED: return TRUE;
case UF_COMPILED:
{
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
return profile ? dfunc->df_instr_prof == NULL
: dfunc->df_instr == NULL;
}
! case UF_COMPILING: return FALSE;
}
}
/*
--- 1699,1725 ----
* "profile" indicates profiling is to be done.
*/
int
! func_needs_compiling(ufunc_T *ufunc, int profile UNUSED)
{
switch (ufunc->uf_def_status)
{
! case UF_NOT_COMPILED: break;
case UF_TO_BE_COMPILED: return TRUE;
case UF_COMPILED:
{
+ #ifdef FEAT_PROFILE
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
return profile ? dfunc->df_instr_prof == NULL
: dfunc->df_instr == NULL;
+ #else
+ break;
+ #endif
}
! case UF_COMPILING: break;
}
+ return FALSE;
}
/*
***************
*** 2088,2093 ****
--- 2093,2099 ----
return OK;
}
+ #ifdef FEAT_PROFILE
static void
may_generate_prof_end(cctx_T *cctx, int prof_lnum)
{
***************
*** 2100,2105 ****
--- 2106,2112 ----
cctx->ctx_lnum = save_lnum;
}
}
+ #endif
/*
* Reserve space for a local variable.
***************
*** 7143,7151 ****
--- 7150,7160 ----
// "endwhile" jumps back here, one before when profiling
scope->se_u.se_while.ws_top_label = instr->ga_len;
+ #ifdef FEAT_PROFILE
if (cctx->ctx_profiling && ((isn_T *)instr->ga_data)[instr->ga_len - 1]
.isn_type == ISN_PROF_START)
--scope->se_u.se_while.ws_top_label;
+ #endif
// compile "expr"
if (compile_expr0(&p, cctx) == FAIL)
***************
*** 7178,7185 ****
--- 7187,7196 ----
cctx->ctx_scope = scope->se_outer;
unwind_locals(cctx, scope->se_local_count);
+ #ifdef FEAT_PROFILE
// count the endwhile before jumping
may_generate_prof_end(cctx, cctx->ctx_lnum);
+ #endif
// At end of ":for" scope jump back to the FOR instruction.
generate_JUMP(cctx, JUMP_ALWAYS, scope->se_u.se_while.ws_top_label);
***************
*** 7851,7857 ****
compile_def_function(
ufunc_T *ufunc,
int check_return_type,
! int profiling,
cctx_T *outer_cctx)
{
char_u *line = NULL;
--- 7862,7868 ----
compile_def_function(
ufunc_T *ufunc,
int check_return_type,
! int profiling UNUSED,
cctx_T *outer_cctx)
{
char_u *line = NULL;
***************
*** 7865,7871 ****
--- 7876,7884 ----
int save_estack_compiling = estack_compiling;
int do_estack_push;
int new_def_function = FALSE;
+ #ifdef FEAT_PROFILE
int prof_lnum = -1;
+ #endif
// When using a function that was compiled before: Free old instructions.
// The index is reused. Otherwise add a new entry in "def_functions".
***************
*** 7886,7892 ****
--- 7899,7907 ----
CLEAR_FIELD(cctx);
+ #ifdef FEAT_PROFILE
cctx.ctx_profiling = profiling;
+ #endif
cctx.ctx_ufunc = ufunc;
cctx.ctx_lnum = -1;
cctx.ctx_outer = outer_cctx;
***************
*** 7989,7995 ****
--- 8004,8012 ----
if (cctx.ctx_lnum >= ufunc->uf_lines.ga_len)
{
// beyond the last line
+ #ifdef FEAT_PROFILE
may_generate_prof_end(&cctx, prof_lnum);
+ #endif
break;
}
}
***************
*** 8005,8010 ****
--- 8022,8028 ----
continue;
}
+ #ifdef FEAT_PROFILE
if (cctx.ctx_profiling && cctx.ctx_lnum != prof_lnum)
{
may_generate_prof_end(&cctx, prof_lnum);
***************
*** 8012,8017 ****
--- 8030,8036 ----
prof_lnum = cctx.ctx_lnum;
generate_instr(&cctx, ISN_PROF_START);
}
+ #endif
// Some things can be recognized by the first character.
switch (*ea.cmd)
***************
*** 8376,8387 ****
--- 8395,8408 ----
+ ufunc->uf_dfunc_idx;
dfunc->df_deleted = FALSE;
dfunc->df_script_seq = current_sctx.sc_seq;
+ #ifdef FEAT_PROFILE
if (cctx.ctx_profiling)
{
dfunc->df_instr_prof = instr->ga_data;
dfunc->df_instr_prof_count = instr->ga_len;
}
else
+ #endif
{
dfunc->df_instr = instr->ga_data;
dfunc->df_instr_count = instr->ga_len;
*** ../vim-8.2.2400/src/vim9execute.c 2021-01-24 12:53:30.780247041 +0100
--- src/vim9execute.c 2021-01-24 13:29:55.520370754 +0100
***************
*** 645,651 ****
--- 645,655 ----
int error;
int idx;
int did_emsg_before = did_emsg;
+ #ifdef FEAT_PROFILE
int profiling = do_profiling == PROF_YES &&
ufunc->uf_profiling;
+ #else
+ # define profiling FALSE
+ #endif
if (func_needs_compiling(ufunc, profiling)
&& compile_def_function(ufunc, FALSE, profiling, NULL) == FAIL)
***************
*** 1131,1137 ****
--- 1135,1145 ----
int save_did_emsg_def = did_emsg_def;
int trylevel_at_start = trylevel;
int orig_funcdepth;
+ #ifdef FEAT_PROFILE
int profiling = do_profiling == PROF_YES &&
ufunc->uf_profiling;
+ #else
+ # define profiling FALSE
+ #endif
// Get pointer to item in the stack.
#define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx)
***************
*** 1158,1164 ****
// Check the function was really compiled.
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
! if ((profiling ? dfunc->df_instr_prof : dfunc->df_instr) == NULL)
{
iemsg("using call_def_function() on not compiled function");
return FAIL;
--- 1166,1176 ----
// Check the function was really compiled.
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
! if ((
! #ifdef FEAT_PROFILE
! profiling ? dfunc->df_instr_prof :
! #endif
! dfunc->df_instr) == NULL)
{
iemsg("using call_def_function() on not compiled function");
return FAIL;
***************
*** 1297,1303 ****
--- 1309,1319 ----
++ectx.ec_stack.ga_len;
}
+ #ifdef FEAT_PROFILE
ectx.ec_instr = profiling ? dfunc->df_instr_prof : dfunc->df_instr;
+ #else
+ ectx.ec_instr = dfunc->df_instr;
+ #endif
}
// Following errors are in the function, not the caller.
***************
*** 3501,3506 ****
--- 3517,3523 ----
case ISN_PROF_START:
case ISN_PROF_END:
{
+ #ifdef FEAT_PROFILE
funccall_T cookie;
ufunc_T *cur_ufunc =
(((dfunc_T *)def_functions.ga_data)
***************
*** 3515,3520 ****
--- 3532,3538 ----
}
else
func_line_end(&cookie);
+ #endif
}
break;
***************
*** 3715,3723 ****
--- 3733,3746 ----
msg((char *)ufunc->uf_name);
dfunc = ((dfunc_T *)def_functions.ga_data) + ufunc->uf_dfunc_idx;
+ #ifdef FEAT_PROFILE
instr = eap->forceit ? dfunc->df_instr_prof : dfunc->df_instr;
instr_count = eap->forceit ? dfunc->df_instr_prof_count
: dfunc->df_instr_count;
+ #else
+ instr = dfunc->df_instr;
+ instr_count = dfunc->df_instr_count;
+ #endif
for (current = 0; current < instr_count; ++current)
{
isn_T *iptr = &instr[current];
*** ../vim-8.2.2400/src/vim9.h 2021-01-24 12:53:30.780247041 +0100
--- src/vim9.h 2021-01-24 13:18:59.730157858 +0100
***************
*** 373,380 ****
// After compiling "df_instr" and/or "df_instr_prof" is not NULL.
isn_T *df_instr; // function body to be executed
int df_instr_count; // size of "df_instr"
! isn_T *df_instr_prof; // like "df_instr" with profiling
! int df_instr_prof_count; // size of "df_instr_prof"
int df_varcount; // number of local variables
int df_has_closure; // one if a closure was created
--- 373,382 ----
// After compiling "df_instr" and/or "df_instr_prof" is not NULL.
isn_T *df_instr; // function body to be executed
int df_instr_count; // size of "df_instr"
! #ifdef FEAT_PROFILE
! isn_T *df_instr_prof; // like "df_instr" with profiling
! int df_instr_prof_count; // size of "df_instr_prof"
! #endif
int df_varcount; // number of local variables
int df_has_closure; // one if a closure was created
*** ../vim-8.2.2400/src/structs.h 2021-01-24 12:53:30.780247041 +0100
--- src/structs.h 2021-01-24 13:27:16.040773091 +0100
***************
*** 1906,1911 ****
--- 1906,1916 ----
proftime_T pi_call_start;
} profinfo_T;
+ # else
+ typedef struct
+ {
+ int dummy;
+ } profinfo_T;
# endif
#else
// dummy typedefs for use in function prototypes
*** ../vim-8.2.2400/src/testdir/test_vim9_disassemble.vim 2021-01-24
12:53:30.784247042 +0100
--- src/testdir/test_vim9_disassemble.vim 2021-01-24 13:33:08.891898468
+0100
***************
*** 1848,1853 ****
--- 1848,1856 ----
enddef
def Test_profiled()
+ if !has('profile')
+ MissingFeature 'profile'
+ endif
var res = execute('disass! s:Profiled')
assert_match('<SNR>\d*_Profiled\_s*' ..
'echo "profiled"\_s*' ..
*** ../vim-8.2.2400/src/version.c 2021-01-24 12:53:30.784247042 +0100
--- src/version.c 2021-01-24 13:33:46.459808235 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2401,
/**/
--
Your fault: core dumped
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202101241234.10OCYmd92781423%40masaka.moolenaar.net.