]> granicus.if.org Git - vim/commitdiff
patch 8.2.2401: build fails without +profiling feature v8.2.2401
authorBram Moolenaar <Bram@vim.org>
Sun, 24 Jan 2021 12:34:18 +0000 (13:34 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 24 Jan 2021 12:34:18 +0000 (13:34 +0100)
Problem:    Build fails without +profiling feature.
Solution:   Add #ifdefs.

src/structs.h
src/testdir/test_vim9_disassemble.vim
src/version.c
src/vim9.h
src/vim9compile.c
src/vim9execute.c

index b092b45bb0ecb91386fc0bce32e315f7236ee270..bd59656b7cbf0031202884b0feeb5ff0a1d64e5b 100644 (file)
@@ -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
index 9a3401fc32c34c2c633b35383bcc376761a282aa..97846a6f5f376dd13e66940b7c951e7eff49ea59 100644 (file)
@@ -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*' ..
index 41858baacfcdc7c3ad769f1a2458243b8a76056f..8786933fb23f0d61330194500986589e063c4f27 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2401,
 /**/
     2400,
 /**/
index 9446c15bf31d95f809ee689fc1a4bdd8a7020703..f8d51c5028ad1de1b836a33639a221c0bf68f18d 100644 (file)
@@ -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
index 5a7da1247a7eff912e8797506a73905f6e191668..32d9dea1eb1ae5f4451de557bb7873dc431d5aeb 100644 (file)
@@ -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;
+#else
+           break;
+#endif
        }
-       case UF_COMPILING: return FALSE;
+       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 prof_lnum)
        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 *cctx)
     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;
index e4948859f93a10b4bdff4adf7fedadfd11186f89..f640684c6eb7d75a031bee70de4dfeb6d542298a 100644 (file)
@@ -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];