comparison src/vim9execute.c @ 23725:f98692ae09a0 v8.2.2404

patch 8.2.2404: Vim9: profiling try/catch not correct Commit: https://github.com/vim/vim/commit/107e9cecf72928b4aaaf08b73bf2d191924ab695 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 24 20:52:00 2021 +0100 patch 8.2.2404: Vim9: profiling try/catch not correct Problem: Vim9: profiling try/catch not correct. Solution: Add profile instructions. Fix that "entry" did not rethrow an excpetion.
author Bram Moolenaar <Bram@vim.org>
date Sun, 24 Jan 2021 21:00:04 +0100
parents 1a7c2685d780
children 7caffd835aa1
comparison
equal deleted inserted replaced
23724:85e6fa8b86f7 23725:f98692ae09a0
2611 { 2611 {
2612 garray_T *trystack = &ectx.ec_trystack; 2612 garray_T *trystack = &ectx.ec_trystack;
2613 2613
2614 if (trystack->ga_len > 0) 2614 if (trystack->ga_len > 0)
2615 { 2615 {
2616 trycmd_T *trycmd = NULL; 2616 trycmd_T *trycmd;
2617 2617
2618 --trystack->ga_len; 2618 --trystack->ga_len;
2619 --trylevel; 2619 --trylevel;
2620 ectx.ec_in_catch = FALSE; 2620 ectx.ec_in_catch = FALSE;
2621 trycmd = ((trycmd_T *)trystack->ga_data) 2621 trycmd = ((trycmd_T *)trystack->ga_data)
2633 } 2633 }
2634 } 2634 }
2635 break; 2635 break;
2636 2636
2637 case ISN_THROW: 2637 case ISN_THROW:
2638 if (ectx.ec_trystack.ga_len == 0 && trylevel == 0 2638 {
2639 && emsg_silent) 2639 garray_T *trystack = &ectx.ec_trystack;
2640 { 2640
2641 // throwing an exception while using "silent!" causes the 2641 if (trystack->ga_len == 0 && trylevel == 0 && emsg_silent)
2642 // function to abort but not display an error. 2642 {
2643 tv = STACK_TV_BOT(-1); 2643 // throwing an exception while using "silent!" causes
2644 clear_tv(tv); 2644 // the function to abort but not display an error.
2645 tv->v_type = VAR_NUMBER; 2645 tv = STACK_TV_BOT(-1);
2646 tv->vval.v_number = 0; 2646 clear_tv(tv);
2647 goto done; 2647 tv->v_type = VAR_NUMBER;
2648 } 2648 tv->vval.v_number = 0;
2649 --ectx.ec_stack.ga_len; 2649 goto done;
2650 tv = STACK_TV_BOT(0); 2650 }
2651 if (tv->vval.v_string == NULL 2651 --ectx.ec_stack.ga_len;
2652 tv = STACK_TV_BOT(0);
2653 if (tv->vval.v_string == NULL
2652 || *skipwhite(tv->vval.v_string) == NUL) 2654 || *skipwhite(tv->vval.v_string) == NUL)
2653 { 2655 {
2654 vim_free(tv->vval.v_string); 2656 vim_free(tv->vval.v_string);
2655 SOURCING_LNUM = iptr->isn_lnum; 2657 SOURCING_LNUM = iptr->isn_lnum;
2656 emsg(_(e_throw_with_empty_string)); 2658 emsg(_(e_throw_with_empty_string));
2657 goto failed; 2659 goto failed;
2658 } 2660 }
2659 2661
2660 if (throw_exception(tv->vval.v_string, ET_USER, NULL) == FAIL) 2662 // Inside a "catch" we need to first discard the caught
2661 { 2663 // exception.
2662 vim_free(tv->vval.v_string); 2664 if (trystack->ga_len > 0)
2663 goto failed; 2665 {
2664 } 2666 trycmd_T *trycmd = ((trycmd_T *)trystack->ga_data)
2665 did_throw = TRUE; 2667 + trystack->ga_len - 1;
2668 if (trycmd->tcd_caught && current_exception != NULL)
2669 {
2670 // discard the exception
2671 if (caught_stack == current_exception)
2672 caught_stack = caught_stack->caught;
2673 discard_current_exception();
2674 trycmd->tcd_caught = FALSE;
2675 }
2676 }
2677
2678 if (throw_exception(tv->vval.v_string, ET_USER, NULL)
2679 == FAIL)
2680 {
2681 vim_free(tv->vval.v_string);
2682 goto failed;
2683 }
2684 did_throw = TRUE;
2685 }
2666 break; 2686 break;
2667 2687
2668 // compare with special values 2688 // compare with special values
2669 case ISN_COMPAREBOOL: 2689 case ISN_COMPAREBOOL:
2670 case ISN_COMPARESPECIAL: 2690 case ISN_COMPARESPECIAL: