// 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
* "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;
}
/*
return OK;
}
+#ifdef FEAT_PROFILE
static void
may_generate_prof_end(cctx_T *cctx, int prof_lnum)
{
cctx->ctx_lnum = save_lnum;
}
}
+#endif
/*
* Reserve space for a local variable.
// "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)
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);
compile_def_function(
ufunc_T *ufunc,
int check_return_type,
- int profiling,
+ int profiling UNUSED,
cctx_T *outer_cctx)
{
char_u *line = NULL;
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".
CLEAR_FIELD(cctx);
+#ifdef FEAT_PROFILE
cctx.ctx_profiling = profiling;
+#endif
cctx.ctx_ufunc = ufunc;
cctx.ctx_lnum = -1;
cctx.ctx_outer = outer_cctx;
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;
}
}
continue;
}
+#ifdef FEAT_PROFILE
if (cctx.ctx_profiling && cctx.ctx_lnum != prof_lnum)
{
may_generate_prof_end(&cctx, prof_lnum);
prof_lnum = cctx.ctx_lnum;
generate_instr(&cctx, ISN_PROF_START);
}
+#endif
// Some things can be recognized by the first character.
switch (*ea.cmd)
+ 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;
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)
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)
// 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;
++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.
case ISN_PROF_START:
case ISN_PROF_END:
{
+#ifdef FEAT_PROFILE
funccall_T cookie;
ufunc_T *cur_ufunc =
(((dfunc_T *)def_functions.ga_data)
}
else
func_line_end(&cookie);
+#endif
}
break;
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];