To: vim_dev@googlegroups.com Subject: Patch 8.2.3275 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3275 Problem: Optimizer can use hints about ga_grow() normally succeeding. Solution: Use GA_GROW_FAILS() and GA_GROW_OK() in several places. (Dominique Pellé, issue #8635) Files: src/arglist.c, src/macros.h, src/vim9execute.c, src/vim9compile.c *** ../vim-8.2.3274/src/arglist.c 2021-07-27 22:00:39.737712414 +0200 --- src/arglist.c 2021-08-02 18:22:03.292392069 +0200 *************** *** 148,154 **** return; alist_clear(al); ! if (ga_grow(&al->al_ga, count) == OK) { for (i = 0; i < count; ++i) { --- 148,154 ---- return; alist_clear(al); ! if (GA_GROW_OK(&al->al_ga, count)) { for (i = 0; i < count; ++i) { *************** *** 355,361 **** int old_argcount = ARGCOUNT; if (check_arglist_locked() != FAIL ! && ga_grow(&ALIST(curwin)->al_ga, count) == OK) { if (after < 0) after = 0; --- 355,361 ---- int old_argcount = ARGCOUNT; if (check_arglist_locked() != FAIL ! && GA_GROW_OK(&ALIST(curwin)->al_ga, count)) { if (after < 0) after = 0; *************** *** 599,605 **** garray_T *gap = &curwin->w_alist->al_ga; // ":argslocal": make a local copy of the global argument list. ! if (ga_grow(gap, GARGCOUNT) == OK) for (i = 0; i < GARGCOUNT; ++i) if (GARGLIST[i].ae_fname != NULL) { --- 599,605 ---- garray_T *gap = &curwin->w_alist->al_ga; // ":argslocal": make a local copy of the global argument list. ! if (GA_GROW_OK(gap, GARGCOUNT)) for (i = 0; i < GARGCOUNT; ++i) if (GARGLIST[i].ae_fname != NULL) { *** ../vim-8.2.3274/src/macros.h 2021-06-02 13:28:11.431120460 +0200 --- src/macros.h 2021-08-02 18:20:15.260631902 +0200 *************** *** 387,394 **** // Inline the condition for performance. #define CHECK_LIST_MATERIALIZE(l) if ((l)->lv_first == &range_list_item) range_list_materialize(l) ! // Inlined version of ga_grow(). Especially useful if "n" is a constant. ! #define GA_GROW(gap, n) (((gap)->ga_maxlen - (gap)->ga_len < n) ? ga_grow_inner((gap), (n)) : OK) #ifndef MIN # define MIN(a, b) ((a) < (b) ? (a) : (b)) --- 387,396 ---- // Inline the condition for performance. #define CHECK_LIST_MATERIALIZE(l) if ((l)->lv_first == &range_list_item) range_list_materialize(l) ! // Inlined version of ga_grow() with optimized condition that it fails. ! #define GA_GROW_FAILS(gap, n) unlikely((((gap)->ga_maxlen - (gap)->ga_len < n) ? ga_grow_inner((gap), (n)) : OK) == FAIL) ! // Inlined version of ga_grow() with optimized condition that it succeeds. ! #define GA_GROW_OK(gap, n) likely((((gap)->ga_maxlen - (gap)->ga_len < n) ? ga_grow_inner((gap), (n)) : OK) == OK) #ifndef MIN # define MIN(a, b) ((a) < (b) ? (a) : (b)) *** ../vim-8.2.3274/src/vim9execute.c 2021-08-02 18:07:15.190473826 +0200 --- src/vim9execute.c 2021-08-02 18:29:53.975365413 +0200 *************** *** 137,143 **** if (count > 0) ectx->ec_stack.ga_len -= count - 1; ! else if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) return FAIL; else ++ectx->ec_stack.ga_len; --- 137,143 ---- if (count > 0) ectx->ec_stack.ga_len -= count - 1; ! else if (GA_GROW_FAILS(&ectx->ec_stack, 1)) return FAIL; else ++ectx->ec_stack.ga_len; *************** *** 210,216 **** #ifdef FEAT_PROFILE if (do_profiling == PROF_YES) { ! if (likely(ga_grow(&profile_info_ga, 1) == OK)) { profinfo_T *info = ((profinfo_T *)profile_info_ga.ga_data) + profile_info_ga.ga_len; --- 210,216 ---- #ifdef FEAT_PROFILE if (do_profiling == PROF_YES) { ! if (GA_GROW_OK(&profile_info_ga, 1)) { profinfo_T *info = ((profinfo_T *)profile_info_ga.ga_data) + profile_info_ga.ga_len; *************** *** 289,296 **** // - if needed: a counter for number of closures created in // ectx->ec_funcrefs. varcount = dfunc->df_varcount + dfunc->df_has_closure; ! if (unlikely(ga_grow(&ectx->ec_stack, arg_to_add + STACK_FRAME_SIZE ! + varcount) == FAIL)) return FAIL; // If depth of calling is getting too high, don't execute the function. --- 289,295 ---- // - if needed: a counter for number of closures created in // ectx->ec_funcrefs. varcount = dfunc->df_varcount + dfunc->df_has_closure; ! if (GA_GROW_FAILS(&ectx->ec_stack, arg_to_add + STACK_FRAME_SIZE + varcount)) return FAIL; // If depth of calling is getting too high, don't execute the function. *************** *** 703,709 **** // Result replaces the arguments on the stack. if (argcount > 0) ectx->ec_stack.ga_len -= argcount - 1; ! else if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) return FAIL; else ++ectx->ec_stack.ga_len; --- 702,708 ---- // Result replaces the arguments on the stack. if (argcount > 0) ectx->ec_stack.ga_len -= argcount - 1; ! else if (GA_GROW_FAILS(&ectx->ec_stack, 1)) return FAIL; else ++ectx->ec_stack.ga_len; *************** *** 941,947 **** { // Make space for arguments from the partial, shift the "argcount" // arguments up. ! if (unlikely(ga_grow(&ectx->ec_stack, pt->pt_argc) == FAIL)) return FAIL; for (i = 1; i <= argcount; ++i) *STACK_TV_BOT(-i + pt->pt_argc) = *STACK_TV_BOT(-i); --- 940,946 ---- { // Make space for arguments from the partial, shift the "argcount" // arguments up. ! if (GA_GROW_FAILS(&ectx->ec_stack, pt->pt_argc)) return FAIL; for (i = 1; i <= argcount; ++i) *STACK_TV_BOT(-i + pt->pt_argc) = *STACK_TV_BOT(-i); *************** *** 1378,1384 **** // If this function returns and the closure is still being used, we // need to make a copy of the context (arguments and local variables). // Store a reference to the partial so we can handle that. ! if (unlikely(ga_grow(&ectx->ec_funcrefs, 1) == FAIL)) { vim_free(pt); return FAIL; --- 1377,1383 ---- // If this function returns and the closure is still being used, we // need to make a copy of the context (arguments and local variables). // Store a reference to the partial so we can handle that. ! if (GA_GROW_FAILS(&ectx->ec_funcrefs, 1)) { vim_free(pt); return FAIL; *************** *** 1511,1517 **** p = skipwhite(p); if (*p == '#') break; ! if (likely(ga_grow(&ga, 1) == OK)) ((char_u **)(ga.ga_data))[ga.ga_len++] = p; if (STRNCMP(p, "def ", 4) == 0) break; --- 1510,1516 ---- p = skipwhite(p); if (*p == '#') break; ! if (GA_GROW_OK(&ga, 1)) ((char_u **)(ga.ga_data))[ga.ga_len++] = p; if (STRNCMP(p, "def ", 4) == 0) break; *************** *** 1612,1618 **** { // Not inside try or need to return from current functions. // Push a dummy return value. ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; tv = STACK_TV_BOT(0); tv->v_type = VAR_NUMBER; --- 1611,1617 ---- { // Not inside try or need to return from current functions. // Push a dummy return value. ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; tv = STACK_TV_BOT(0); tv->v_type = VAR_NUMBER; *************** *** 1687,1693 **** int res; int save_flags = cmdmod.cmod_flags; ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; tv = STACK_TV_BOT(0); init_tv(tv); --- 1686,1692 ---- int res; int save_flags = cmdmod.cmod_flags; ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; tv = STACK_TV_BOT(0); init_tv(tv); *************** *** 1703,1709 **** // push typeval VAR_INSTR with instructions to be executed case ISN_INSTR: { ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; tv = STACK_TV_BOT(0); tv->vval.v_instr = ALLOC_ONE(instr_T); --- 1702,1708 ---- // push typeval VAR_INSTR with instructions to be executed case ISN_INSTR: { ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; tv = STACK_TV_BOT(0); tv->vval.v_instr = ALLOC_ONE(instr_T); *************** *** 1768,1774 **** clear_redir_lval(); redir_vname = 0; ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) { vim_free(res); goto theend; --- 1767,1773 ---- clear_redir_lval(); redir_vname = 0; ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) { vim_free(res); goto theend; *************** *** 1904,1910 **** p = tv_stringify(tv, buf); len = (int)STRLEN(p); ! if (unlikely(ga_grow(&ga, len + 2) == FAIL)) failed = TRUE; else { --- 1903,1909 ---- p = tv_stringify(tv, buf); len = (int)STRLEN(p); ! if (GA_GROW_FAILS(&ga, len + 2)) failed = TRUE; else { *************** *** 1955,1961 **** // load local variable or argument case ISN_LOAD: ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; copy_tv(STACK_TV_VAR(iptr->isn_arg.number), STACK_TV_BOT(0)); ++ectx->ec_stack.ga_len; --- 1954,1960 ---- // load local variable or argument case ISN_LOAD: ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; copy_tv(STACK_TV_VAR(iptr->isn_arg.number), STACK_TV_BOT(0)); ++ectx->ec_stack.ga_len; *************** *** 1963,1969 **** // load v: variable case ISN_LOADV: ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; copy_tv(get_vim_var_tv(iptr->isn_arg.number), STACK_TV_BOT(0)); ++ectx->ec_stack.ga_len; --- 1962,1968 ---- // load v: variable case ISN_LOADV: ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; copy_tv(get_vim_var_tv(iptr->isn_arg.number), STACK_TV_BOT(0)); ++ectx->ec_stack.ga_len; *************** *** 1979,1985 **** if (sv == NULL) goto theend; allocate_if_null(sv->sv_tv); ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; copy_tv(sv->sv_tv, STACK_TV_BOT(0)); ++ectx->ec_stack.ga_len; --- 1978,1984 ---- if (sv == NULL) goto theend; allocate_if_null(sv->sv_tv); ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; copy_tv(sv->sv_tv, STACK_TV_BOT(0)); ++ectx->ec_stack.ga_len; *************** *** 2002,2008 **** } else { ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; copy_tv(&di->di_tv, STACK_TV_BOT(0)); ++ectx->ec_stack.ga_len; --- 2001,2007 ---- } else { ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; copy_tv(&di->di_tv, STACK_TV_BOT(0)); ++ectx->ec_stack.ga_len; *************** *** 2052,2058 **** } else { ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; copy_tv(&di->di_tv, STACK_TV_BOT(0)); ++ectx->ec_stack.ga_len; --- 2051,2057 ---- } else { ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; copy_tv(&di->di_tv, STACK_TV_BOT(0)); ++ectx->ec_stack.ga_len; *************** *** 2065,2071 **** { char_u *name = iptr->isn_arg.string; ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; SOURCING_LNUM = iptr->isn_lnum; if (eval_variable(name, (int)STRLEN(name), --- 2064,2070 ---- { char_u *name = iptr->isn_arg.string; ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; SOURCING_LNUM = iptr->isn_lnum; if (eval_variable(name, (int)STRLEN(name), *************** *** 2092,2098 **** default: // Cannot reach here goto theend; } ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; tv = STACK_TV_BOT(0); tv->v_type = VAR_DICT; --- 2091,2097 ---- default: // Cannot reach here goto theend; } ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; tv = STACK_TV_BOT(0); tv->v_type = VAR_DICT; *************** *** 2111,2117 **** // This is not expected to fail, name is checked during // compilation: don't set SOURCING_LNUM. ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; if (eval_option(&name, &optval, TRUE) == FAIL) goto theend; --- 2110,2116 ---- // This is not expected to fail, name is checked during // compilation: don't set SOURCING_LNUM. ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; if (eval_option(&name, &optval, TRUE) == FAIL) goto theend; *************** *** 2126,2132 **** typval_T optval; char_u *name = iptr->isn_arg.string; ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; // name is always valid, checked when compiling (void)eval_env_var(&name, &optval, TRUE); --- 2125,2131 ---- typval_T optval; char_u *name = iptr->isn_arg.string; ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; // name is always valid, checked when compiling (void)eval_env_var(&name, &optval, TRUE); *************** *** 2137,2143 **** // load @register case ISN_LOADREG: ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; tv = STACK_TV_BOT(0); tv->v_type = VAR_STRING; --- 2136,2142 ---- // load @register case ISN_LOADREG: ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; tv = STACK_TV_BOT(0); tv->v_type = VAR_STRING; *************** *** 2572,2578 **** + iptr->isn_arg.outer.outer_idx; if (iptr->isn_type == ISN_LOADOUTER) { ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; copy_tv(tv, STACK_TV_BOT(0)); ++ectx->ec_stack.ga_len; --- 2571,2577 ---- + iptr->isn_arg.outer.outer_idx; if (iptr->isn_type == ISN_LOADOUTER) { ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; copy_tv(tv, STACK_TV_BOT(0)); ++ectx->ec_stack.ga_len; *************** *** 2760,2766 **** case ISN_PUSHFUNC: case ISN_PUSHCHANNEL: case ISN_PUSHJOB: ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; tv = STACK_TV_BOT(0); tv->v_lock = 0; --- 2759,2765 ---- case ISN_PUSHFUNC: case ISN_PUSHCHANNEL: case ISN_PUSHJOB: ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; tv = STACK_TV_BOT(0); tv->v_lock = 0; *************** *** 2885,2891 **** if (count > 0) ectx->ec_stack.ga_len -= 2 * count - 1; ! else if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; else ++ectx->ec_stack.ga_len; --- 2884,2890 ---- if (count > 0) ectx->ec_stack.ga_len -= 2 * count - 1; ! else if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; else ++ectx->ec_stack.ga_len; *************** *** 2967,2973 **** // return from a :def function call without a value case ISN_RETURN_VOID: ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; tv = STACK_TV_BOT(0); ++ectx->ec_stack.ga_len; --- 2966,2972 ---- // return from a :def function call without a value case ISN_RETURN_VOID: ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; tv = STACK_TV_BOT(0); ++ectx->ec_stack.ga_len; *************** *** 3009,3015 **** if (pt == NULL) goto theend; ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) { vim_free(pt); goto theend; --- 3008,3014 ---- if (pt == NULL) goto theend; ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) { vim_free(pt); goto theend; *************** *** 3104,3110 **** typval_T *idxtv = STACK_TV_VAR(iptr->isn_arg.forloop.for_idx); ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; if (ltv->v_type == VAR_LIST) { --- 3103,3109 ---- typval_T *idxtv = STACK_TV_VAR(iptr->isn_arg.forloop.for_idx); ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; if (ltv->v_type == VAR_LIST) { *************** *** 3211,3217 **** { trycmd_T *trycmd = NULL; ! if (unlikely(GA_GROW(&ectx->ec_trystack, 1) == FAIL)) goto theend; trycmd = ((trycmd_T *)ectx->ec_trystack.ga_data) + ectx->ec_trystack.ga_len; --- 3210,3216 ---- { trycmd_T *trycmd = NULL; ! if (GA_GROW_FAILS(&ectx->ec_trystack, 1)) goto theend; trycmd = ((trycmd_T *)ectx->ec_trystack.ga_data) + ectx->ec_trystack.ga_len; *************** *** 3236,3242 **** iemsg("Evaluating catch while current_exception is NULL"); goto theend; } ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; tv = STACK_TV_BOT(0); ++ectx->ec_stack.ga_len; --- 3235,3241 ---- iemsg("Evaluating catch while current_exception is NULL"); goto theend; } ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; tv = STACK_TV_BOT(0); ++ectx->ec_stack.ga_len; *************** *** 3895,3901 **** tv = STACK_TV_BOT(-1 - gi->gi_with_op); li = list_find(tv->vval.v_list, gi->gi_index); ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; ++ectx->ec_stack.ga_len; copy_tv(&li->li_tv, STACK_TV_BOT(-1)); --- 3894,3900 ---- tv = STACK_TV_BOT(-1 - gi->gi_with_op); li = list_find(tv->vval.v_list, gi->gi_index); ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; ++ectx->ec_stack.ga_len; copy_tv(&li->li_tv, STACK_TV_BOT(-1)); *************** *** 4130,4136 **** if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL) goto on_error; ! if (unlikely(GA_GROW(&ectx->ec_stack, 1) == FAIL)) goto theend; ++ectx->ec_stack.ga_len; tv = STACK_TV_BOT(-1); --- 4129,4135 ---- if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL) goto on_error; ! if (GA_GROW_FAILS(&ectx->ec_stack, 1)) goto theend; ++ectx->ec_stack.ga_len; tv = STACK_TV_BOT(-1); *************** *** 4232,4238 **** } CHECK_LIST_MATERIALIZE(l); ! if (unlikely(GA_GROW(&ectx->ec_stack, count - 1) == FAIL)) goto theend; ectx->ec_stack.ga_len += count - 1; --- 4231,4237 ---- } CHECK_LIST_MATERIALIZE(l); ! if (GA_GROW_FAILS(&ectx->ec_stack, count - 1)) goto theend; ectx->ec_stack.ga_len += count - 1; *************** *** 4506,4512 **** CLEAR_FIELD(ectx); ectx.ec_dfunc_idx = ufunc->uf_dfunc_idx; ga_init2(&ectx.ec_stack, sizeof(typval_T), 500); ! if (unlikely(ga_grow(&ectx.ec_stack, 20) == FAIL)) { funcdepth_decrement(); return FAIL; --- 4505,4511 ---- CLEAR_FIELD(ectx); ectx.ec_dfunc_idx = ufunc->uf_dfunc_idx; ga_init2(&ectx.ec_stack, sizeof(typval_T), 500); ! if (GA_GROW_FAILS(&ectx.ec_stack, 20)) { funcdepth_decrement(); return FAIL; *** ../vim-8.2.3274/src/vim9compile.c 2021-08-01 21:19:40.130538381 +0200 --- src/vim9compile.c 2021-08-02 18:27:23.787690554 +0200 *************** *** 548,554 **** isn_T *isn; RETURN_NULL_IF_SKIP(cctx); ! if (ga_grow(instr, 1) == FAIL) return NULL; isn = ((isn_T *)instr->ga_data) + instr->ga_len; isn->isn_type = isn_type; --- 548,554 ---- isn_T *isn; RETURN_NULL_IF_SKIP(cctx); ! if (GA_GROW_FAILS(instr, 1)) return NULL; isn = ((isn_T *)instr->ga_data) + instr->ga_len; isn->isn_type = isn_type; *************** *** 585,591 **** if ((isn = generate_instr(cctx, isn_type)) == NULL) return NULL; ! if (ga_grow(stack, 1) == FAIL) return NULL; ((type_T **)stack->ga_data)[stack->ga_len] = type == NULL ? &t_any : type; ++stack->ga_len; --- 585,591 ---- if ((isn = generate_instr(cctx, isn_type)) == NULL) return NULL; ! if (GA_GROW_FAILS(stack, 1)) return NULL; ((type_T **)stack->ga_data)[stack->ga_len] = type == NULL ? &t_any : type; ++stack->ga_len; *************** *** 1288,1294 **** isn->isn_arg.getitem.gi_with_op = with_op; // add the item type to the type stack ! if (ga_grow(stack, 1) == FAIL) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = item_type; ++stack->ga_len; --- 1288,1294 ---- isn->isn_arg.getitem.gi_with_op = with_op; // add the item type to the type stack ! if (GA_GROW_FAILS(stack, 1)) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = item_type; ++stack->ga_len; *************** *** 1590,1596 **** stack->ga_len -= count; // add the list type to the type stack ! if (ga_grow(stack, 1) == FAIL) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = type; ++stack->ga_len; --- 1590,1596 ---- stack->ga_len -= count; // add the list type to the type stack ! if (GA_GROW_FAILS(stack, 1)) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = type; ++stack->ga_len; *************** *** 1626,1632 **** stack->ga_len -= 2 * count; // add the dict type to the type stack ! if (ga_grow(stack, 1) == FAIL) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = type; ++stack->ga_len; --- 1626,1632 ---- stack->ga_len -= 2 * count; // add the dict type to the type stack ! if (GA_GROW_FAILS(stack, 1)) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = type; ++stack->ga_len; *************** *** 1654,1660 **** if (ufunc->uf_flags & FC_CLOSURE) cctx->ctx_ufunc->uf_flags |= FC_CLOSURE; ! if (ga_grow(stack, 1) == FAIL) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = ufunc->uf_func_type == NULL ? &t_func_any : ufunc->uf_func_type; --- 1654,1660 ---- if (ufunc->uf_flags & FC_CLOSURE) cctx->ctx_ufunc->uf_flags |= FC_CLOSURE; ! if (GA_GROW_FAILS(stack, 1)) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = ufunc->uf_func_type == NULL ? &t_func_any : ufunc->uf_func_type; *************** *** 1759,1765 **** return FAIL; isn->isn_arg.forloop.for_idx = loop_idx; ! if (ga_grow(stack, 1) == FAIL) return FAIL; // type doesn't matter, will be stored next ((type_T **)stack->ga_data)[stack->ga_len] = &t_any; --- 1759,1765 ---- return FAIL; isn->isn_arg.forloop.for_idx = loop_idx; ! if (GA_GROW_FAILS(stack, 1)) return FAIL; // type doesn't matter, will be stored next ((type_T **)stack->ga_data)[stack->ga_len] = &t_any; *************** *** 1841,1847 **** // Drop the argument types and push the return type. stack->ga_len -= argcount; ! if (ga_grow(stack, 1) == FAIL) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = internal_func_ret_type(func_idx, argcount, argtypes); --- 1841,1847 ---- // Drop the argument types and push the return type. stack->ga_len -= argcount; ! if (GA_GROW_FAILS(stack, 1)) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = internal_func_ret_type(func_idx, argcount, argtypes); *************** *** 2031,2037 **** } stack->ga_len -= argcount; // drop the arguments ! if (ga_grow(stack, 1) == FAIL) return FAIL; // add return value ((type_T **)stack->ga_data)[stack->ga_len] = ufunc->uf_ret_type; --- 2031,2037 ---- } stack->ga_len -= argcount; // drop the arguments ! if (GA_GROW_FAILS(stack, 1)) return FAIL; // add return value ((type_T **)stack->ga_data)[stack->ga_len] = ufunc->uf_ret_type; *************** *** 2056,2062 **** isn->isn_arg.ufunc.cuf_argcount = argcount; stack->ga_len -= argcount; // drop the arguments ! if (ga_grow(stack, 1) == FAIL) return FAIL; // add return value ((type_T **)stack->ga_data)[stack->ga_len] = &t_any; --- 2056,2062 ---- isn->isn_arg.ufunc.cuf_argcount = argcount; stack->ga_len -= argcount; // drop the arguments ! if (GA_GROW_FAILS(stack, 1)) return FAIL; // add return value ((type_T **)stack->ga_data)[stack->ga_len] = &t_any; *************** *** 2265,2271 **** return FAIL; isn->isn_arg.string = vim_strsave(line); ! if (ga_grow(stack, 1) == FAIL) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = &t_any; ++stack->ga_len; --- 2265,2271 ---- return FAIL; isn->isn_arg.string = vim_strsave(line); ! if (GA_GROW_FAILS(stack, 1)) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = &t_any; ++stack->ga_len; *************** *** 2297,2303 **** return FAIL; isn->isn_arg.string = range; ! if (ga_grow(stack, 1) == FAIL) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = &t_number; ++stack->ga_len; --- 2297,2303 ---- return FAIL; isn->isn_arg.string = range; ! if (GA_GROW_FAILS(stack, 1)) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = &t_number; ++stack->ga_len; *************** *** 2431,2437 **** return NULL; } ! if (ga_grow(&cctx->ctx_locals, 1) == FAIL) return NULL; lvar = ((lvar_T *)cctx->ctx_locals.ga_data) + cctx->ctx_locals.ga_len++; CLEAR_POINTER(lvar); --- 2431,2437 ---- return NULL; } ! if (GA_GROW_FAILS(&cctx->ctx_locals, 1)) return NULL; lvar = ((lvar_T *)cctx->ctx_locals.ga_data) + cctx->ctx_locals.ga_len++; CLEAR_POINTER(lvar); *************** *** 2448,2454 **** lvar->lv_type = type; // Remember the name for debugging. ! if (ga_grow(&dfunc->df_var_names, 1) == FAIL) return NULL; ((char_u **)dfunc->df_var_names.ga_data)[lvar->lv_idx] = vim_strsave(lvar->lv_name); --- 2448,2454 ---- lvar->lv_type = type; // Remember the name for debugging. ! if (GA_GROW_FAILS(&dfunc->df_var_names, 1)) return NULL; ((char_u **)dfunc->df_var_names.ga_data)[lvar->lv_idx] = vim_strsave(lvar->lv_name); *************** *** 3280,3286 **** trailing_error = *s != NUL; if (expr_res == FAIL || trailing_error ! || ga_grow(&cctx->ctx_instr, 1) == FAIL) { if (trailing_error) semsg(_(e_trailing_arg), s); --- 3280,3286 ---- trailing_error = *s != NUL; if (expr_res == FAIL || trailing_error ! || GA_GROW_FAILS(&cctx->ctx_instr, 1)) { if (trailing_error) semsg(_(e_trailing_arg), s); *************** *** 7034,7040 **** else { // variables are always initialized ! if (ga_grow(instr, 1) == FAIL) goto theend; switch (lhs.lhs_member_type->tt_type) { --- 7034,7040 ---- else { // variables are always initialized ! if (GA_GROW_FAILS(instr, 1)) goto theend; switch (lhs.lhs_member_type->tt_type) { *************** *** 7653,7659 **** // Move any CMDMOD instruction to after the jump if (((isn_T *)instr->ga_data)[instr->ga_len - 1].isn_type == ISN_CMDMOD) { ! if (ga_grow(instr, 1) == FAIL) return NULL; ((isn_T *)instr->ga_data)[instr->ga_len] = ((isn_T *)instr->ga_data)[instr->ga_len - 1]; --- 7653,7659 ---- // Move any CMDMOD instruction to after the jump if (((isn_T *)instr->ga_data)[instr->ga_len - 1].isn_type == ISN_CMDMOD) { ! if (GA_GROW_FAILS(instr, 1)) return NULL; ((isn_T *)instr->ga_data)[instr->ga_len] = ((isn_T *)instr->ga_data)[instr->ga_len - 1]; *************** *** 7999,8005 **** arg = skipwhite(arg + 1); // skip white after '[' // the list item is replaced by a number of items ! if (ga_grow(stack, var_count - 1) == FAIL) { drop_scope(cctx); return NULL; --- 7999,8005 ---- arg = skipwhite(arg + 1); // skip white after '[' // the list item is replaced by a number of items ! if (GA_GROW_FAILS(stack, var_count - 1)) { drop_scope(cctx); return NULL; *************** *** 9107,9113 **** trailing_error = *cmd != delimiter && *cmd != NUL; if (expr_res == FAIL || trailing_error ! || ga_grow(&cctx->ctx_instr, 1) == FAIL) { if (trailing_error) semsg(_(e_trailing_arg), cmd); --- 9107,9113 ---- trailing_error = *cmd != delimiter && *cmd != NUL; if (expr_res == FAIL || trailing_error ! || GA_GROW_FAILS(&cctx->ctx_instr, 1)) { if (trailing_error) semsg(_(e_trailing_arg), cmd); *************** *** 9267,9279 **** { // The first position is not used, so that a zero uf_dfunc_idx means it // wasn't set. ! if (ga_grow(&def_functions, 1) == FAIL) return FAIL; ++def_functions.ga_len; } // Add the function to "def_functions". ! if (ga_grow(&def_functions, 1) == FAIL) return FAIL; dfunc = ((dfunc_T *)def_functions.ga_data) + def_functions.ga_len; CLEAR_POINTER(dfunc); --- 9267,9279 ---- { // The first position is not used, so that a zero uf_dfunc_idx means it // wasn't set. ! if (GA_GROW_FAILS(&def_functions, 1)) return FAIL; ++def_functions.ga_len; } // Add the function to "def_functions". ! if (GA_GROW_FAILS(&def_functions, 1)) return FAIL; dfunc = ((dfunc_T *)def_functions.ga_data) + def_functions.ga_len; CLEAR_POINTER(dfunc); *** ../vim-8.2.3274/src/version.c 2021-08-02 18:07:15.190473826 +0200 --- src/version.c 2021-08-02 19:08:31.297987848 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3275, /**/ -- Not too long ago, a program was something you watched on TV... /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///