# HG changeset patch # User John W. Eaton # Date 1493142740 14400 # Node ID c715a1aebbd555b490e1fb676da196074fe64c3d # Parent c452180ab6721f2f21fdc9ea5784e38328020cb3 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. diff -r c452180ab672 -r c715a1aebbd5 libinterp/corefcn/profiler.h --- 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 pe (profiler, *this); - -#define END_PROFILER_BLOCK \ - } // end of block => call pe's destructor - #endif diff -r c452180ab672 -r c715a1aebbd5 libinterp/octave-value/ov-builtin.cc --- 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 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; } diff -r c452180ab672 -r c715a1aebbd5 libinterp/octave-value/ov-mex-fcn.cc --- 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 block (profiler, *this); retval = call_mex (have_fmex, mex_fcn_ptr, args, nargout, this); - END_PROFILER_BLOCK - return retval; } diff -r c452180ab672 -r c715a1aebbd5 libinterp/octave-value/ov-usr-fcn.cc --- 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 + 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 + 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 ();