Skip to content

Commit f002a41

Browse files
committed
patch 8.2.2401: build fails without +profiling feature
Problem: Build fails without +profiling feature. Solution: Add #ifdefs.
1 parent b204990 commit f002a41

6 files changed

Lines changed: 63 additions & 7 deletions

File tree

src/structs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,6 +1906,11 @@ typedef struct {
19061906
proftime_T pi_call_start;
19071907
} profinfo_T;
19081908

1909+
# else
1910+
typedef struct
1911+
{
1912+
int dummy;
1913+
} profinfo_T;
19091914
# endif
19101915
#else
19111916
// dummy typedefs for use in function prototypes

src/testdir/test_vim9_disassemble.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,9 @@ def s:Profiled(): string
18481848
enddef
18491849

18501850
def Test_profiled()
1851+
if !has('profile')
1852+
MissingFeature 'profile'
1853+
endif
18511854
var res = execute('disass! s:Profiled')
18521855
assert_match('<SNR>\d*_Profiled\_s*' ..
18531856
'echo "profiled"\_s*' ..

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2401,
753755
/**/
754756
2400,
755757
/**/

src/vim9.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,10 @@ struct dfunc_S {
373373
// After compiling "df_instr" and/or "df_instr_prof" is not NULL.
374374
isn_T *df_instr; // function body to be executed
375375
int df_instr_count; // size of "df_instr"
376-
isn_T *df_instr_prof; // like "df_instr" with profiling
377-
int df_instr_prof_count; // size of "df_instr_prof"
376+
#ifdef FEAT_PROFILE
377+
isn_T *df_instr_prof; // like "df_instr" with profiling
378+
int df_instr_prof_count; // size of "df_instr_prof"
379+
#endif
378380

379381
int df_varcount; // number of local variables
380382
int df_has_closure; // one if a closure was created

src/vim9compile.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,22 +1699,27 @@ generate_BLOBAPPEND(cctx_T *cctx)
16991699
* "profile" indicates profiling is to be done.
17001700
*/
17011701
int
1702-
func_needs_compiling(ufunc_T *ufunc, int profile)
1702+
func_needs_compiling(ufunc_T *ufunc, int profile UNUSED)
17031703
{
17041704
switch (ufunc->uf_def_status)
17051705
{
1706-
case UF_NOT_COMPILED: return FALSE;
1706+
case UF_NOT_COMPILED: break;
17071707
case UF_TO_BE_COMPILED: return TRUE;
17081708
case UF_COMPILED:
17091709
{
1710+
#ifdef FEAT_PROFILE
17101711
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
17111712
+ ufunc->uf_dfunc_idx;
17121713

17131714
return profile ? dfunc->df_instr_prof == NULL
17141715
: dfunc->df_instr == NULL;
1716+
#else
1717+
break;
1718+
#endif
17151719
}
1716-
case UF_COMPILING: return FALSE;
1720+
case UF_COMPILING: break;
17171721
}
1722+
return FALSE;
17181723
}
17191724

17201725
/*
@@ -2088,6 +2093,7 @@ generate_undo_cmdmods(cctx_T *cctx)
20882093
return OK;
20892094
}
20902095

2096+
#ifdef FEAT_PROFILE
20912097
static void
20922098
may_generate_prof_end(cctx_T *cctx, int prof_lnum)
20932099
{
@@ -2100,6 +2106,7 @@ may_generate_prof_end(cctx_T *cctx, int prof_lnum)
21002106
cctx->ctx_lnum = save_lnum;
21012107
}
21022108
}
2109+
#endif
21032110

21042111
/*
21052112
* Reserve space for a local variable.
@@ -7143,9 +7150,11 @@ compile_while(char_u *arg, cctx_T *cctx)
71437150

71447151
// "endwhile" jumps back here, one before when profiling
71457152
scope->se_u.se_while.ws_top_label = instr->ga_len;
7153+
#ifdef FEAT_PROFILE
71467154
if (cctx->ctx_profiling && ((isn_T *)instr->ga_data)[instr->ga_len - 1]
71477155
.isn_type == ISN_PROF_START)
71487156
--scope->se_u.se_while.ws_top_label;
7157+
#endif
71497158

71507159
// compile "expr"
71517160
if (compile_expr0(&p, cctx) == FAIL)
@@ -7178,8 +7187,10 @@ compile_endwhile(char_u *arg, cctx_T *cctx)
71787187
cctx->ctx_scope = scope->se_outer;
71797188
unwind_locals(cctx, scope->se_local_count);
71807189

7190+
#ifdef FEAT_PROFILE
71817191
// count the endwhile before jumping
71827192
may_generate_prof_end(cctx, cctx->ctx_lnum);
7193+
#endif
71837194

71847195
// At end of ":for" scope jump back to the FOR instruction.
71857196
generate_JUMP(cctx, JUMP_ALWAYS, scope->se_u.se_while.ws_top_label);
@@ -7851,7 +7862,7 @@ add_def_function(ufunc_T *ufunc)
78517862
compile_def_function(
78527863
ufunc_T *ufunc,
78537864
int check_return_type,
7854-
int profiling,
7865+
int profiling UNUSED,
78557866
cctx_T *outer_cctx)
78567867
{
78577868
char_u *line = NULL;
@@ -7865,7 +7876,9 @@ compile_def_function(
78657876
int save_estack_compiling = estack_compiling;
78667877
int do_estack_push;
78677878
int new_def_function = FALSE;
7879+
#ifdef FEAT_PROFILE
78687880
int prof_lnum = -1;
7881+
#endif
78697882

78707883
// When using a function that was compiled before: Free old instructions.
78717884
// The index is reused. Otherwise add a new entry in "def_functions".
@@ -7886,7 +7899,9 @@ compile_def_function(
78867899

78877900
CLEAR_FIELD(cctx);
78887901

7902+
#ifdef FEAT_PROFILE
78897903
cctx.ctx_profiling = profiling;
7904+
#endif
78907905
cctx.ctx_ufunc = ufunc;
78917906
cctx.ctx_lnum = -1;
78927907
cctx.ctx_outer = outer_cctx;
@@ -7989,7 +8004,9 @@ compile_def_function(
79898004
if (cctx.ctx_lnum >= ufunc->uf_lines.ga_len)
79908005
{
79918006
// beyond the last line
8007+
#ifdef FEAT_PROFILE
79928008
may_generate_prof_end(&cctx, prof_lnum);
8009+
#endif
79938010
break;
79948011
}
79958012
}
@@ -8005,13 +8022,15 @@ compile_def_function(
80058022
continue;
80068023
}
80078024

8025+
#ifdef FEAT_PROFILE
80088026
if (cctx.ctx_profiling && cctx.ctx_lnum != prof_lnum)
80098027
{
80108028
may_generate_prof_end(&cctx, prof_lnum);
80118029

80128030
prof_lnum = cctx.ctx_lnum;
80138031
generate_instr(&cctx, ISN_PROF_START);
80148032
}
8033+
#endif
80158034

80168035
// Some things can be recognized by the first character.
80178036
switch (*ea.cmd)
@@ -8376,12 +8395,14 @@ compile_def_function(
83768395
+ ufunc->uf_dfunc_idx;
83778396
dfunc->df_deleted = FALSE;
83788397
dfunc->df_script_seq = current_sctx.sc_seq;
8398+
#ifdef FEAT_PROFILE
83798399
if (cctx.ctx_profiling)
83808400
{
83818401
dfunc->df_instr_prof = instr->ga_data;
83828402
dfunc->df_instr_prof_count = instr->ga_len;
83838403
}
83848404
else
8405+
#endif
83858406
{
83868407
dfunc->df_instr = instr->ga_data;
83878408
dfunc->df_instr_count = instr->ga_len;

src/vim9execute.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,11 @@ call_ufunc(
645645
int error;
646646
int idx;
647647
int did_emsg_before = did_emsg;
648+
#ifdef FEAT_PROFILE
648649
int profiling = do_profiling == PROF_YES && ufunc->uf_profiling;
650+
#else
651+
# define profiling FALSE
652+
#endif
649653

650654
if (func_needs_compiling(ufunc, profiling)
651655
&& compile_def_function(ufunc, FALSE, profiling, NULL) == FAIL)
@@ -1131,7 +1135,11 @@ call_def_function(
11311135
int save_did_emsg_def = did_emsg_def;
11321136
int trylevel_at_start = trylevel;
11331137
int orig_funcdepth;
1138+
#ifdef FEAT_PROFILE
11341139
int profiling = do_profiling == PROF_YES && ufunc->uf_profiling;
1140+
#else
1141+
# define profiling FALSE
1142+
#endif
11351143

11361144
// Get pointer to item in the stack.
11371145
#define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx)
@@ -1158,7 +1166,11 @@ call_def_function(
11581166
// Check the function was really compiled.
11591167
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
11601168
+ ufunc->uf_dfunc_idx;
1161-
if ((profiling ? dfunc->df_instr_prof : dfunc->df_instr) == NULL)
1169+
if ((
1170+
#ifdef FEAT_PROFILE
1171+
profiling ? dfunc->df_instr_prof :
1172+
#endif
1173+
dfunc->df_instr) == NULL)
11621174
{
11631175
iemsg("using call_def_function() on not compiled function");
11641176
return FAIL;
@@ -1297,7 +1309,11 @@ call_def_function(
12971309
++ectx.ec_stack.ga_len;
12981310
}
12991311

1312+
#ifdef FEAT_PROFILE
13001313
ectx.ec_instr = profiling ? dfunc->df_instr_prof : dfunc->df_instr;
1314+
#else
1315+
ectx.ec_instr = dfunc->df_instr;
1316+
#endif
13011317
}
13021318

13031319
// Following errors are in the function, not the caller.
@@ -3501,6 +3517,7 @@ call_def_function(
35013517
case ISN_PROF_START:
35023518
case ISN_PROF_END:
35033519
{
3520+
#ifdef FEAT_PROFILE
35043521
funccall_T cookie;
35053522
ufunc_T *cur_ufunc =
35063523
(((dfunc_T *)def_functions.ga_data)
@@ -3515,6 +3532,7 @@ call_def_function(
35153532
}
35163533
else
35173534
func_line_end(&cookie);
3535+
#endif
35183536
}
35193537
break;
35203538

@@ -3715,9 +3733,14 @@ ex_disassemble(exarg_T *eap)
37153733
msg((char *)ufunc->uf_name);
37163734

37173735
dfunc = ((dfunc_T *)def_functions.ga_data) + ufunc->uf_dfunc_idx;
3736+
#ifdef FEAT_PROFILE
37183737
instr = eap->forceit ? dfunc->df_instr_prof : dfunc->df_instr;
37193738
instr_count = eap->forceit ? dfunc->df_instr_prof_count
37203739
: dfunc->df_instr_count;
3740+
#else
3741+
instr = dfunc->df_instr;
3742+
instr_count = dfunc->df_instr_count;
3743+
#endif
37213744
for (current = 0; current < instr_count; ++current)
37223745
{
37233746
isn_T *iptr = &instr[current];

0 commit comments

Comments
 (0)