Mercurial > vim
changeset 23719:1a7c2685d780 v8.2.2401
patch 8.2.2401: build fails without +profiling feature
Commit: https://github.com/vim/vim/commit/f002a41d127d49cfe5a59819d1498bc0ff8b594a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 24 13:34:18 2021 +0100
patch 8.2.2401: build fails without +profiling feature
Problem: Build fails without +profiling feature.
Solution: Add #ifdefs.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 24 Jan 2021 13:45:04 +0100 |
parents | cb609d495c3c |
children | 8c3997ad6088 |
files | src/structs.h src/testdir/test_vim9_disassemble.vim src/version.c src/vim9.h src/vim9compile.c src/vim9execute.c |
diffstat | 6 files changed, 65 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/structs.h +++ b/src/structs.h @@ -1906,6 +1906,11 @@ typedef struct { proftime_T pi_call_start; } profinfo_T; +# else +typedef struct +{ + int dummy; +} profinfo_T; # endif #else // dummy typedefs for use in function prototypes
--- a/src/testdir/test_vim9_disassemble.vim +++ b/src/testdir/test_vim9_disassemble.vim @@ -1848,6 +1848,9 @@ def s:Profiled(): string 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*' ..
--- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2401, +/**/ 2400, /**/ 2399,
--- a/src/vim9.h +++ b/src/vim9.h @@ -373,8 +373,10 @@ struct dfunc_S { // 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" +#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
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -1699,22 +1699,27 @@ generate_BLOBAPPEND(cctx_T *cctx) * "profile" indicates profiling is to be done. */ int -func_needs_compiling(ufunc_T *ufunc, int profile) +func_needs_compiling(ufunc_T *ufunc, int profile UNUSED) { switch (ufunc->uf_def_status) { - case UF_NOT_COMPILED: return FALSE; + 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; - } - case UF_COMPILING: return FALSE; - } +#else + break; +#endif + } + case UF_COMPILING: break; + } + return FALSE; } /* @@ -2088,6 +2093,7 @@ generate_undo_cmdmods(cctx_T *cctx) return OK; } +#ifdef FEAT_PROFILE static void may_generate_prof_end(cctx_T *cctx, int prof_lnum) { @@ -2100,6 +2106,7 @@ may_generate_prof_end(cctx_T *cctx, int cctx->ctx_lnum = save_lnum; } } +#endif /* * Reserve space for a local variable. @@ -7143,9 +7150,11 @@ compile_while(char_u *arg, cctx_T *cctx) // "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,8 +7187,10 @@ compile_endwhile(char_u *arg, cctx_T *cc 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,7 +7862,7 @@ add_def_function(ufunc_T *ufunc) compile_def_function( ufunc_T *ufunc, int check_return_type, - int profiling, + int profiling UNUSED, cctx_T *outer_cctx) { char_u *line = NULL; @@ -7865,7 +7876,9 @@ compile_def_function( 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,7 +7899,9 @@ compile_def_function( 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,7 +8004,9 @@ compile_def_function( 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,6 +8022,7 @@ compile_def_function( continue; } +#ifdef FEAT_PROFILE if (cctx.ctx_profiling && cctx.ctx_lnum != prof_lnum) { may_generate_prof_end(&cctx, prof_lnum); @@ -8012,6 +8030,7 @@ compile_def_function( 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,12 +8395,14 @@ nextline: + 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;
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -645,7 +645,11 @@ call_ufunc( 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,7 +1135,11 @@ call_def_function( 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,7 +1166,11 @@ call_def_function( // 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) + 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,7 +1309,11 @@ call_def_function( ++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,6 +3517,7 @@ call_def_function( 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,6 +3532,7 @@ call_def_function( } else func_line_end(&cookie); +#endif } break; @@ -3715,9 +3733,14 @@ ex_disassemble(exarg_T *eap) 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];