Mercurial > octave
changeset 27370:a2d3fa82b730
don't use stack to save and restore lvalue list value in evaluator (bug #56752)
* pt-eval.h, pt-eval.cc (tree_evaluator::m_lvalue_list): New variable.
Reduce the overhead of saving and resstoring the pointer to the current
lvalue_list in the evaluator by using a simple pointer instead of a
stack. The unwind_protect objects we use on the call stack already
provide the stack of values needed to save and restore the value of
the pointer to the current lvalue_list object.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 28 Aug 2019 21:38:34 -0400 |
parents | 5bf76ab4cce3 |
children | fcaecdbc8d8a |
files | libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-eval.h |
diffstat | 2 files changed, 15 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-eval.cc Wed Aug 28 16:15:08 2019 -0400 +++ b/libinterp/parse-tree/pt-eval.cc Wed Aug 28 21:38:34 2019 -0400 @@ -1206,7 +1206,7 @@ { Matrix retval; - const std::list<octave_lvalue> *lvalues = lvalue_list (); + const std::list<octave_lvalue> *lvalues = m_lvalue_list; if (! lvalues) return retval; @@ -1238,7 +1238,7 @@ bool tree_evaluator::isargout (int nargout, int iout) const { - const std::list<octave_lvalue> *lvalues = lvalue_list (); + const std::list<octave_lvalue> *lvalues = m_lvalue_list; if (iout >= std::max (nargout, 1)) return false; @@ -1263,7 +1263,7 @@ void tree_evaluator::isargout (int nargout, int nout, bool *isargout) const { - const std::list<octave_lvalue> *lvalues = lvalue_list (); + const std::list<octave_lvalue> *lvalues = m_lvalue_list; if (lvalues) { @@ -3148,10 +3148,8 @@ unwind_protect frame; - m_lvalue_list_stack.push (nullptr); - - frame.add_method (m_lvalue_list_stack, - &value_stack<const std::list<octave_lvalue>*>::pop); + frame.protect_var (m_lvalue_list); + m_lvalue_list = nullptr; string_vector anm = *p_arg_nm; first_args = convert_to_const_vector (al); @@ -3449,10 +3447,8 @@ unwind_protect frame; - m_lvalue_list_stack.push (nullptr); - - frame.add_method (m_lvalue_list_stack, - &value_stack<const std::list<octave_lvalue>*>::pop); + frame.protect_var (m_lvalue_list); + m_lvalue_list = nullptr; octave_idx_type nr = expr.length (); octave_idx_type nc = -1; @@ -3516,10 +3512,8 @@ std::list<octave_lvalue> lvalue_list = make_lvalue_list (lhs); - m_lvalue_list_stack.push (&lvalue_list); - - frame.add_method (m_lvalue_list_stack, - &value_stack<const std::list<octave_lvalue>*>::pop); + frame.protect_var (m_lvalue_list); + m_lvalue_list = &lvalue_list; octave_idx_type n_out = 0; @@ -3842,10 +3836,8 @@ std::list<octave_lvalue> lvalue_list; lvalue_list.push_back (ult); - m_lvalue_list_stack.push (&lvalue_list); - - frame.add_method (m_lvalue_list_stack, - &value_stack<const std::list<octave_lvalue>*>::pop); + frame.protect_var (m_lvalue_list); + m_lvalue_list = &lvalue_list; if (ult.numel () != 1) err_invalid_structure_assignment (); @@ -4578,10 +4570,8 @@ unwind_protect frame; - m_lvalue_list_stack.push (nullptr); - - frame.add_method (m_lvalue_list_stack, - &value_stack<const std::list<octave_lvalue>*>::pop); + frame.protect_var (m_lvalue_list); + m_lvalue_list = nullptr; if (rvalue && object && args->has_magic_end () && object->is_undefined ())
--- a/libinterp/parse-tree/pt-eval.h Wed Aug 28 16:15:08 2019 -0400 +++ b/libinterp/parse-tree/pt-eval.h Wed Aug 28 21:38:34 2019 -0400 @@ -131,7 +131,7 @@ tree_evaluator (interpreter& interp) : m_interpreter (interp), m_statement_context (SC_OTHER), m_result_type (RT_UNDEFINED), m_expr_result_value (), - m_expr_result_value_list (), m_lvalue_list_stack (), + m_expr_result_value_list (), m_lvalue_list (nullptr), m_nargout (0), m_autoload_map (), m_bp_table (*this), m_call_stack (*this), m_profiler (), m_debug_frame (0), m_debug_mode (false), m_quiet_breakpoint_flag (false), @@ -310,12 +310,6 @@ void isargout (int nargout, int nout, bool *isargout) const; - const std::list<octave_lvalue> * lvalue_list (void) const - { - return (m_lvalue_list_stack.empty () - ? nullptr : m_lvalue_list_stack.top ()); - } - void push_result (const octave_value& val) { m_result_type = RT_VALUE; @@ -827,7 +821,7 @@ octave_value m_expr_result_value; octave_value_list m_expr_result_value_list; - value_stack<const std::list<octave_lvalue>*> m_lvalue_list_stack; + const std::list<octave_lvalue> *m_lvalue_list; int m_nargout;