@@ -181,6 +181,16 @@ call_dfunc(int cdf_idx, partial_T *pt, int argcount_arg, ectx_T *ectx)
181181 return FAIL ;
182182 }
183183
184+ #ifdef FEAT_PROFILE
185+ // Profiling might be enabled/disabled along the way. This should not
186+ // fail, since the function was compiled before and toggling profiling
187+ // doesn't change any errors.
188+ if (func_needs_compiling (ufunc , PROFILING (ufunc ))
189+ && compile_def_function (ufunc , FALSE, PROFILING (ufunc ), NULL )
190+ == FAIL )
191+ return FAIL ;
192+ #endif
193+
184194 if (ufunc -> uf_va_name != NULL )
185195 {
186196 // Need to make a list out of the vararg arguments.
@@ -293,7 +303,7 @@ call_dfunc(int cdf_idx, partial_T *pt, int argcount_arg, ectx_T *ectx)
293303
294304 // Set execution state to the start of the called function.
295305 ectx -> ec_dfunc_idx = cdf_idx ;
296- ectx -> ec_instr = dfunc -> df_instr ;
306+ ectx -> ec_instr = INSTRUCTIONS ( dfunc ) ;
297307 entry = estack_push_ufunc (ufunc , 1 );
298308 if (entry != NULL )
299309 {
@@ -542,7 +552,7 @@ func_return(ectx_T *ectx)
542552 ectx -> ec_frame_idx = STACK_TV (ectx -> ec_frame_idx
543553 + STACK_FRAME_IDX_OFF )-> vval .v_number ;
544554 dfunc = ((dfunc_T * )def_functions .ga_data ) + ectx -> ec_dfunc_idx ;
545- ectx -> ec_instr = dfunc -> df_instr ;
555+ ectx -> ec_instr = INSTRUCTIONS ( dfunc ) ;
546556
547557 if (ret_idx > 0 )
548558 {
@@ -1103,6 +1113,7 @@ fill_partial_and_closure(partial_T *pt, ufunc_T *ufunc, ectx_T *ectx)
11031113 return OK ;
11041114}
11051115
1116+
11061117/*
11071118 * Call a "def" function from old Vim script.
11081119 * Return OK or FAIL.
@@ -1135,11 +1146,6 @@ call_def_function(
11351146 int save_did_emsg_def = did_emsg_def ;
11361147 int trylevel_at_start = trylevel ;
11371148 int orig_funcdepth ;
1138- #ifdef FEAT_PROFILE
1139- int profiling = do_profiling == PROF_YES && ufunc -> uf_profiling ;
1140- #else
1141- # define profiling FALSE
1142- #endif
11431149
11441150// Get pointer to item in the stack.
11451151#define STACK_TV (idx ) (((typval_T *)ectx.ec_stack.ga_data) + idx)
@@ -1152,8 +1158,8 @@ call_def_function(
11521158#define STACK_TV_VAR (idx ) (((typval_T *)ectx.ec_stack.ga_data) + ectx.ec_frame_idx + STACK_FRAME_SIZE + idx)
11531159
11541160 if (ufunc -> uf_def_status == UF_NOT_COMPILED
1155- || (func_needs_compiling (ufunc , profiling )
1156- && compile_def_function (ufunc , FALSE, profiling , NULL )
1161+ || (func_needs_compiling (ufunc , PROFILING ( ufunc ) )
1162+ && compile_def_function (ufunc , FALSE, PROFILING ( ufunc ) , NULL )
11571163 == FAIL ))
11581164 {
11591165 if (did_emsg_cumul + did_emsg == did_emsg_before )
@@ -1166,11 +1172,7 @@ call_def_function(
11661172 // Check the function was really compiled.
11671173 dfunc_T * dfunc = ((dfunc_T * )def_functions .ga_data )
11681174 + ufunc -> uf_dfunc_idx ;
1169- if ((
1170- #ifdef FEAT_PROFILE
1171- profiling ? dfunc -> df_instr_prof :
1172- #endif
1173- dfunc -> df_instr ) == NULL )
1175+ if (INSTRUCTIONS (dfunc ) == NULL )
11741176 {
11751177 iemsg ("using call_def_function() on not compiled function" );
11761178 return FAIL ;
@@ -1309,11 +1311,7 @@ call_def_function(
13091311 ++ ectx .ec_stack .ga_len ;
13101312 }
13111313
1312- #ifdef FEAT_PROFILE
1313- ectx .ec_instr = profiling ? dfunc -> df_instr_prof : dfunc -> df_instr ;
1314- #else
1315- ectx .ec_instr = dfunc -> df_instr ;
1316- #endif
1314+ ectx .ec_instr = INSTRUCTIONS (dfunc );
13171315 }
13181316
13191317 // Following errors are in the function, not the caller.
0 commit comments