Mercurial > octave
changeset 23436:c715a1aebbd5
eliminate remains of BEGIN_PROFILER_BLOCK and END_PROFILER_BLOCK macros
* profiler.h (BEGIN_PROFILER_BLOCK, END_PROFILER_BLOCK): Delete macros.
* ov-builtin.cc, ov-mex-fcn.cc, ov-usr-fcn.cc: Eliminate remaining use
of BEGIN_PROFILER_BLOCK and END_PROFILER_BLOCK macros.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 25 Apr 2017 13:52:20 -0400 |
parents | c452180ab672 |
children | 442fe5b5afb5 |
files | libinterp/corefcn/profiler.h libinterp/octave-value/ov-builtin.cc libinterp/octave-value/ov-mex-fcn.cc libinterp/octave-value/ov-usr-fcn.cc |
diffstat | 4 files changed, 30 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/profiler.h Fri Apr 21 18:07:40 2017 -0400 +++ b/libinterp/corefcn/profiler.h Tue Apr 25 13:52:20 2017 -0400 @@ -212,13 +212,4 @@ // The instance used. extern OCTINTERP_API profile_data_accumulator profiler; -// Helper macro to profile a block of code. - -#define BEGIN_PROFILER_BLOCK(classname) \ - { \ - profile_data_accumulator::enter<classname> pe (profiler, *this); - -#define END_PROFILER_BLOCK \ - } // end of block => call pe's destructor - #endif
--- a/libinterp/octave-value/ov-builtin.cc Fri Apr 21 18:07:40 2017 -0400 +++ b/libinterp/octave-value/ov-builtin.cc Tue Apr 25 13:52:20 2017 -0400 @@ -121,23 +121,29 @@ curr_lvalue_list = lvalue_list; } - BEGIN_PROFILER_BLOCK (octave_builtin) + profile_data_accumulator::enter<octave_builtin> block (profiler, *this); retval = (*f) (args, nargout); + // Do not allow null values to be returned from functions. // FIXME: perhaps true builtins should be allowed? + retval.make_storable_values (); + // Fix the case of a single undefined value. // This happens when a compiled function uses + // // octave_value retval; + // // instead of + // // octave_value_list retval; + // // the idiom is very common, so we solve that here. + if (retval.length () == 1 && retval.xelem (0).is_undefined ()) retval.clear (); - END_PROFILER_BLOCK - return retval; }
--- a/libinterp/octave-value/ov-mex-fcn.cc Fri Apr 21 18:07:40 2017 -0400 +++ b/libinterp/octave-value/ov-mex-fcn.cc Tue Apr 25 13:52:20 2017 -0400 @@ -142,11 +142,9 @@ frame.add_fcn (octave::call_stack::pop); - BEGIN_PROFILER_BLOCK (octave_mex_function) + profile_data_accumulator::enter<octave_mex_function> block (profiler, *this); retval = call_mex (have_fmex, mex_fcn_ptr, args, nargout, this); - END_PROFILER_BLOCK - return retval; }
--- a/libinterp/octave-value/ov-usr-fcn.cc Fri Apr 21 18:07:40 2017 -0400 +++ b/libinterp/octave-value/ov-usr-fcn.cc Tue Apr 25 13:52:20 2017 -0400 @@ -148,14 +148,13 @@ frame.protect_var (octave::tree_evaluator::statement_context); octave::tree_evaluator::statement_context = octave::tree_evaluator::script; - BEGIN_PROFILER_BLOCK (octave_user_script) + profile_data_accumulator::enter<octave_user_script> + block (profiler, *this); octave::tree_evaluator *tw = octave::current_evaluator; cmd_list->accept (*tw); - END_PROFILER_BLOCK - if (octave::tree_return_command::returning) octave::tree_return_command::returning = 0; @@ -592,27 +591,28 @@ frame.protect_var (octave::tree_evaluator::statement_context); octave::tree_evaluator::statement_context = octave::tree_evaluator::function; - BEGIN_PROFILER_BLOCK (octave_user_function) + { + profile_data_accumulator::enter<octave_user_function> + block (profiler, *this); - if (is_special_expr ()) - { - assert (cmd_list->length () == 1); + if (is_special_expr ()) + { + assert (cmd_list->length () == 1); - octave::tree_statement *stmt = cmd_list->front (); - - octave::tree_expression *expr = stmt->expression (); + octave::tree_statement *stmt = cmd_list->front (); - if (expr) - { - octave::call_stack::set_location (stmt->line (), stmt->column ()); + octave::tree_expression *expr = stmt->expression (); + + if (expr) + { + octave::call_stack::set_location (stmt->line (), stmt->column ()); - retval = tw->evaluate_n (expr, nargout, lvalue_list); - } - } - else - cmd_list->accept (*tw); - - END_PROFILER_BLOCK + retval = tw->evaluate_n (expr, nargout, lvalue_list); + } + } + else + cmd_list->accept (*tw); + } if (echo_commands) print_code_function_trailer ();