# HG changeset patch # User John W. Eaton # Date 1701701534 18000 # Mon Dec 04 09:52:14 2023 -0500 # Branch stable # Node ID 435cfe35e3c602b172cf43f4da05af0cb195b747 # Parent 23b20195a0a49ef05f28eefaf0e94904d0cb8f80 disable building bytecode evaluator by default (bug #64977) * configure.ac (ENABLE_BYTECODE-EVALUATOR): Default to "no". Reverse sense of AC_ARG_ENABLE option for bytecode-evaluator. * call-stack.cc, call-stack.h, compile.cc, stack-frame.cc, stack-frame.h, ov-base-diag.h, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base-scalar.h, ov-base-sparse.h, ov-base.cc, ov-base.h, ov-cell.h, ov-classdef.h, ov-colon.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.cc, ov-fcn.h, ov-ref.cc, ov-ref.h, ov-struct.cc, ov-struct.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, pt-bytecode-vm-internal.h, pt-bytecode-vm.cc, pt-bytecode-vm.h, pt-bytecode-walk.cc, pt-bytecode-walk.h, pt-bytecode.h, pt-eval.cc, pt-eval.h, pt-tm-const.cc, pt-tm-const.h: Skip compilation of bytecode evaluator unless OCTAVE_ENABLE_BYTECODE_EVALUATOR is defined. * bytecode.tst, bytecode_disp.tst: Use "testif ENABLE_BYTECODE_EVALUATOR" to skip tests that require bytecode interpreter. diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -1412,11 +1412,11 @@ fi AC_C_BIGENDIAN() -ENABLE_BYTECODE_EVALUATOR=yes +ENABLE_BYTECODE_EVALUATOR=no AC_ARG_ENABLE([bytecode-evaluator], - [AS_HELP_STRING([--disable-bytecode-evaluator], - [don't compile *experimental* bytecode evaluator])], - [if test "$enableval" = no; then ENABLE_BYTECODE_EVALUATOR=no; fi], []) + [AS_HELP_STRING([--enable-bytecode-evaluator], + [compile *experimental* bytecode evaluator])], + [if test "$enableval" = yes; then ENABLE_BYTECODE_EVALUATOR=yes; fi], []) if test $ENABLE_BYTECODE_EVALUATOR = yes; then AC_DEFINE(OCTAVE_ENABLE_BYTECODE_EVALUATOR, 1, [Define to 1 to build experimental Virtual Machine evaluator.]) diff --git a/libinterp/corefcn/call-stack.cc b/libinterp/corefcn/call-stack.cc --- a/libinterp/corefcn/call-stack.cc +++ b/libinterp/corefcn/call-stack.cc @@ -30,7 +30,6 @@ #include "lo-regexp.h" #include "str-vec.h" -#include "pt-bytecode-vm.h" #include "builtin-defun-decls.h" #include "call-stack.h" #include "defun.h" @@ -42,6 +41,9 @@ #include "ov-fcn.h" #include "ov-usr-fcn.h" #include "pager.h" +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) +# include "pt-bytecode-vm.h" +#endif #include "stack-frame.h" #include "syminfo.h" #include "symrec.h" @@ -449,6 +451,7 @@ void call_stack::push (octave_user_scrip m_curr_frame = new_frame_idx; } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) void call_stack::push (vm &vm, octave_user_script *fcn, int nargout, int nargin) { @@ -513,6 +516,8 @@ void call_stack::push (vm &vm, octave_us m_curr_frame = new_frame_idx; } +#endif + void call_stack::push (octave_function *fcn) { std::size_t new_frame_idx; diff --git a/libinterp/corefcn/call-stack.h b/libinterp/corefcn/call-stack.h --- a/libinterp/corefcn/call-stack.h +++ b/libinterp/corefcn/call-stack.h @@ -49,7 +49,10 @@ OCTAVE_BEGIN_NAMESPACE(octave) class tree_evaluator; class symbol_info_list; class unwind_protect; + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) class vm; +#endif class OCTINTERP_API @@ -167,6 +170,8 @@ public: void push (octave_function *fcn); +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + void push (vm &vm, octave_user_function *fcn, int nargout, int nargin); void push (vm &vm, octave_user_script *fcn, int nargout, int nargin); @@ -174,6 +179,8 @@ public: void push (vm &vm, octave_user_function *fcn, int nargout, int nargin, const std::shared_ptr& closure_frames); +#endif + void set_location (int l, int c) { if (! m_cs.empty ()) diff --git a/libinterp/corefcn/compile.cc b/libinterp/corefcn/compile.cc --- a/libinterp/corefcn/compile.cc +++ b/libinterp/corefcn/compile.cc @@ -33,11 +33,15 @@ #include "variables.h" #include "interpreter.h" -#include "pt-bytecode-vm.h" -#include "pt-bytecode-walk.h" +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) +# include "pt-bytecode-vm.h" +# include "pt-bytecode-walk.h" +#endif OCTAVE_BEGIN_NAMESPACE(octave) +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + // If TRUE, use VM evaluator rather than tree walker. bool V__vm_enable__ = false; @@ -45,6 +49,8 @@ bool V__vm_enable__ = false; extern "C" void dummy_mark_1 (void); extern "C" void dummy_mark_2 (void); +#endif + DEFUN (__dummy_mark_1__, , , doc: /* -*- texinfo -*- @deftypefn {} {} __dummy_mark_1__ () @@ -57,9 +63,17 @@ point for @code{gdb}. @end deftypefn */) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + dummy_mark_1 (); return {}; + +#else + + err_disabled_feature ("__dummy_mark_1__", "byte-compiled functions"); + +#endif } DEFUN (__dummy_mark_2__, , , @@ -74,9 +88,17 @@ point for @code{gdb}. @end deftypefn */) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + dummy_mark_2 (); return {}; + +#else + + err_disabled_feature ("__dummy_mark_2__", "byte-compiled functions"); + +#endif } DEFUN (__vm_clear_cache__, , , @@ -87,9 +109,17 @@ Internal function. @end deftypefn */) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave::load_path::signal_clear_fcn_cache (); return octave_value {true}; + +#else + + err_disabled_feature ("__vm_clear_cache__", "byte-compiled functions"); + +#endif } DEFUN (__vm_print_trace__, , , @@ -109,9 +139,17 @@ The return value is true if a trace will @end deftypefn */) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + vm::m_trace_enabled = !vm::m_trace_enabled; return octave_value {vm::m_trace_enabled}; + +#else + + err_disabled_feature ("__vm_print_trace__", "byte-compiled functions"); + +#endif } DEFUN (__ref_count__, args, , @@ -145,6 +183,8 @@ Return true if the VM is executing the f @end deftypefn */) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + auto frame = interp.get_evaluator ().get_current_stack_frame (); if (!frame) error ("Invalid current frame"); @@ -156,6 +196,14 @@ Return true if the VM is executing the f bool bytecode_running = caller_frame->is_bytecode_fcn_frame (); return octave_value {bytecode_running}; + +#else + + octave_unused_parameter (interp); + + err_disabled_feature ("__vm_is_executing__", "byte-compiled functions"); + +#endif } DEFMETHOD (__vm_profile__, interp, args, , @@ -200,6 +248,8 @@ is not implemented yet. @end deftypefn */) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + int nargin = args.length (); auto &evaler = interp.get_evaluator (); @@ -270,6 +320,15 @@ is not implemented yet. print_usage (); return octave_value {true}; + +#else + + octave_unused_parameter (interp); + octave_unused_parameter (args); + + err_disabled_feature ("__vm_profile__", "byte-compiled functions"); + +#endif } DEFMETHOD (__vm_print_bytecode__, interp, args, , @@ -283,6 +342,8 @@ Prints the bytecode of a function name o @end deftypefn */) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + int nargin = args.length (); if (nargin != 1) @@ -345,6 +406,15 @@ Prints the bytecode of a function name o print_bytecode (bc); return octave_value {true}; + +#else + + octave_unused_parameter (interp); + octave_unused_parameter (args); + + err_disabled_feature ("__vm_print_bytecode__", "byte-compiled functions"); + +#endif } DEFMETHOD (__vm_is_compiled__, interp, args, , @@ -360,6 +430,8 @@ False otherwise. @end deftypefn */) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + int nargin = args.length (); if (nargin != 1) @@ -409,6 +481,15 @@ False otherwise. { return octave_value {false}; } + +#else + + octave_unused_parameter (interp); + octave_unused_parameter (args); + + err_disabled_feature ("__vm_is_compiled__", "byte-compiled functions"); + +#endif } DEFMETHOD (__vm_compile__, interp, args, , @@ -434,6 +515,8 @@ The @qcode{"clear"} option removes the b @end deftypefn */) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + int nargin = args.length (); if (! nargin) @@ -562,6 +645,15 @@ The @qcode{"clear"} option removes the b } return octave_value {true}; + +#else + + octave_unused_parameter (interp); + octave_unused_parameter (args); + + err_disabled_feature ("__vm_compile__", "byte-compiled functions"); + +#endif } DEFUN (__vm_enable__, args, nargout, @@ -593,8 +685,19 @@ by, e.g., @qcode{"clear all"}, or a modi @end deftypefn */) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + return set_internal_variable (V__vm_enable__, args, nargout, "__vm_enable__"); + +#else + + octave_unused_parameter (args); + octave_unused_parameter (nargout); + + err_disabled_feature ("__vm_enable__", "byte-compiled functions"); + +#endif } OCTAVE_END_NAMESPACE(octave) diff --git a/libinterp/corefcn/stack-frame.cc b/libinterp/corefcn/stack-frame.cc --- a/libinterp/corefcn/stack-frame.cc +++ b/libinterp/corefcn/stack-frame.cc @@ -49,13 +49,82 @@ #include "symrec.h" #include "symscope.h" #include "variables.h" -#include -#include "ov-ref.h" - -#include "pt-bytecode-vm.h" + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) +# include "ov-ref.h" +# include "pt-bytecode-vm.h" +#endif OCTAVE_BEGIN_NAMESPACE(octave) +// FIXME: There should probably be a display method for the script, +// fcn, and scope objects and the script and function objects should +// be responsible for displaying the scopes they contain. + +static void display_scope (std::ostream& os, const symbol_scope& scope) +{ + if (scope) + { + os << "scope: " << scope.name () << std::endl; + + if (scope.num_symbols () > 0) + { + os << "name (frame offset, data offset, storage class):" + << std::endl; + + std::list symbols = scope.symbol_list (); + + for (auto& sym : symbols) + { + os << " " << sym.name () << " (" << sym.frame_offset () + << ", " << sym.data_offset () << ", " << sym.storage_class () + << ")" << std::endl; + } + } + } +} + +class compiled_fcn_stack_frame; +class script_stack_frame; +class user_fcn_stack_frame; +class scope_stack_frame; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) +class bytecode_fcn_stack_frame; +#endif + +class stack_frame_walker +{ +protected: + + stack_frame_walker () { } + + virtual ~stack_frame_walker () = default; + +public: + + OCTAVE_DISABLE_COPY_MOVE (stack_frame_walker) + + virtual void + visit_compiled_fcn_stack_frame (compiled_fcn_stack_frame&) = 0; + + virtual void + visit_script_stack_frame (script_stack_frame&) = 0; + + virtual void + visit_user_fcn_stack_frame (user_fcn_stack_frame&) = 0; + + virtual void + visit_scope_stack_frame (scope_stack_frame&) = 0; + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + + virtual void + visit_bytecode_fcn_stack_frame (bytecode_fcn_stack_frame&) = 0; + +#endif +}; + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) // bytecode_fcn_stack_frame is for the VM. // @@ -1707,6 +1776,25 @@ private: int m_nargout; }; +void bytecode_fcn_stack_frame::display (bool) const +{ + std::ostream& os = octave_stdout; + + os << "-- [bytecode_fcn_stack_frame] (" << this << ") --" << std::endl; + + os << "fcn: " << m_fcn->name () + << " (" << m_fcn->type_name () << ")" << std::endl; + + display_scope (os, get_scope ()); +} + +void bytecode_fcn_stack_frame::accept (stack_frame_walker& sfw) +{ + sfw.visit_bytecode_fcn_stack_frame (*this); +} + +#endif + class compiled_fcn_stack_frame : public stack_frame { public: @@ -1780,12 +1868,20 @@ public: return m_static_link->varval (sym); } - octave_value& varref (const symbol_record& sym, bool deref_refs) + octave_value& varref (const symbol_record& sym +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , bool deref_refs +#endif + ) { // Look in closest stack frame that contains values (either the // top scope, or a user-defined function or script). - return m_static_link->varref (sym, deref_refs); + return m_static_link->varref (sym +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , deref_refs +#endif + ); } void mark_scope (const symbol_record& sym, scope_flags flag) @@ -1911,7 +2007,11 @@ public: octave_value varval (const symbol_record& sym) const; - octave_value& varref (const symbol_record& sym, bool deref_refs); + octave_value& varref (const symbol_record& sym +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , bool deref_refs +#endif + ); void mark_scope (const symbol_record& sym, scope_flags flag); @@ -2000,10 +2100,16 @@ public: void set_scope_flag (std::size_t data_offset, scope_flags flag) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + bool was_global = m_flags.at (data_offset) == scope_flags::GLOBAL; +#endif + m_flags.at (data_offset) = flag; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + bool is_global = flag == scope_flags::GLOBAL; // If the VM is running scripts it places octave_value_ref objects in @@ -2029,6 +2135,8 @@ public: m_values.at (data_offset) = cpy; } } + +#endif } octave_value get_auto_fcn_var (auto_var_type avt) const @@ -2056,7 +2164,11 @@ public: return m_values.at (data_offset); } - octave_value& varref (std::size_t data_offset, bool) + octave_value& varref (std::size_t data_offset +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , bool +#endif + ) { return m_values.at (data_offset); } @@ -2179,7 +2291,11 @@ public: octave_value varval (const symbol_record& sym) const; - octave_value& varref (const symbol_record& sym, bool deref_refs); + octave_value& varref (const symbol_record& sym +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , bool deref_refs +#endif + ); void mark_scope (const symbol_record& sym, scope_flags flag); @@ -2249,7 +2365,11 @@ public: octave_value varval (const symbol_record& sym) const; - octave_value& varref (const symbol_record& sym, bool deref_refs); + octave_value& varref (const symbol_record& sym +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , bool deref_refs +#endif + ); void mark_scope (const symbol_record& sym, scope_flags flag); @@ -2263,61 +2383,6 @@ private: symbol_scope m_scope; }; -// FIXME: There should probably be a display method for the script, -// fcn, and scope objects and the script and function objects should -// be responsible for displaying the scopes they contain. - -static void display_scope (std::ostream& os, const symbol_scope& scope) -{ - if (scope) - { - os << "scope: " << scope.name () << std::endl; - - if (scope.num_symbols () > 0) - { - os << "name (frame offset, data offset, storage class):" - << std::endl; - - std::list symbols = scope.symbol_list (); - - for (auto& sym : symbols) - { - os << " " << sym.name () << " (" << sym.frame_offset () - << ", " << sym.data_offset () << ", " << sym.storage_class () - << ")" << std::endl; - } - } - } -} - -class stack_frame_walker -{ -protected: - - stack_frame_walker () { } - - virtual ~stack_frame_walker () = default; - -public: - - OCTAVE_DISABLE_COPY_MOVE (stack_frame_walker) - - virtual void - visit_compiled_fcn_stack_frame (compiled_fcn_stack_frame&) = 0; - - virtual void - visit_script_stack_frame (script_stack_frame&) = 0; - - virtual void - visit_user_fcn_stack_frame (user_fcn_stack_frame&) = 0; - - virtual void - visit_scope_stack_frame (scope_stack_frame&) = 0; - - virtual void - visit_bytecode_fcn_stack_frame (bytecode_fcn_stack_frame&) = 0; -}; - class symbol_cleaner : public stack_frame_walker { public: @@ -2384,6 +2449,8 @@ public: alink->accept (*this); } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + void visit_bytecode_fcn_stack_frame (bytecode_fcn_stack_frame& frame) { clean_frame (frame); @@ -2394,6 +2461,8 @@ public: alink->accept (*this); } +#endif + private: void maybe_clear_symbol (stack_frame& frame, const symbol_record& sym) @@ -2634,6 +2703,8 @@ public: alink->accept (*this); } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + void visit_bytecode_fcn_stack_frame (bytecode_fcn_stack_frame& frame) { // For scripts, only collect symbol info in the outer most frame @@ -2646,6 +2717,8 @@ public: alink->accept (*this); } +#endif + private: typedef std::pair syminf_list_elt; @@ -2808,6 +2881,8 @@ stack_frame *stack_frame::create (tree_e return new scope_stack_frame (tw, scope, index, parent_link, static_link); } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + std::shared_ptr stack_frame::create_bytecode ( tree_evaluator& tw, octave_user_script *fcn, @@ -2932,6 +3007,8 @@ std::shared_ptr stack_frame } } +#endif + // This function is only implemented and should only be called for // user_fcn stack frames. Anything else indicates an error in the // implementation, but we'll simply warn if that happens. @@ -3180,7 +3257,11 @@ octave_value stack_frame::varval (std::s panic_impossible (); } -octave_value& stack_frame::varref (std::size_t, bool) +octave_value& stack_frame::varref (std::size_t +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , bool +#endif + ) { // This function should only be called for user_fcn_stack_frame or // scope_stack_frame objects. Anything else indicates an error in @@ -3813,7 +3894,11 @@ octave_value script_stack_frame::varval error ("internal error: invalid switch case"); } -octave_value& script_stack_frame::varref (const symbol_record& sym, bool deref_refs) +octave_value& script_stack_frame::varref (const symbol_record& sym +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , bool deref_refs +#endif + ) { std::size_t frame_offset; std::size_t data_offset; @@ -3836,7 +3921,11 @@ octave_value& script_stack_frame::varref switch (frame->get_scope_flag (data_offset)) { case LOCAL: - return frame->varref (data_offset, deref_refs); + return frame->varref (data_offset +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , deref_refs +#endif + ); case PERSISTENT: { @@ -4145,7 +4234,11 @@ octave_value user_fcn_stack_frame::varva error ("internal error: invalid switch case"); } -octave_value& user_fcn_stack_frame::varref (const symbol_record& sym, bool deref_refs) +octave_value& user_fcn_stack_frame::varref (const symbol_record& sym +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , bool deref_refs +#endif + ) { std::size_t frame_offset = sym.frame_offset (); std::size_t data_offset = sym.data_offset (); @@ -4167,7 +4260,11 @@ octave_value& user_fcn_stack_frame::varr switch (frame->get_scope_flag (data_offset)) { case LOCAL: - return frame->varref (data_offset, deref_refs); + return frame->varref (data_offset +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , deref_refs +#endif + ); case PERSISTENT: { @@ -4198,18 +4295,6 @@ void user_fcn_stack_frame::mark_scope (c set_scope_flag (data_offset, flag); } -void bytecode_fcn_stack_frame::display (bool) const -{ - std::ostream& os = octave_stdout; - - os << "-- [bytecode_fcn_stack_frame] (" << this << ") --" << std::endl; - - os << "fcn: " << m_fcn->name () - << " (" << m_fcn->type_name () << ")" << std::endl; - - display_scope (os, get_scope ()); -} - void user_fcn_stack_frame::display (bool follow) const { std::ostream& os = octave_stdout; @@ -4286,10 +4371,13 @@ octave_value scope_stack_frame::varval ( case LOCAL: { octave_value ov = m_values.at (data_offset); + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) if (ov.is_ref ()) return ov.ref_rep ()->deref (); - else - return ov; +#endif + + return ov; } case PERSISTENT: return m_scope.persistent_varval (data_offset); @@ -4301,7 +4389,11 @@ octave_value scope_stack_frame::varval ( error ("internal error: invalid switch case"); } -octave_value& scope_stack_frame::varref (const symbol_record& sym, bool deref_refs) +octave_value& scope_stack_frame::varref (const symbol_record& sym +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , bool deref_refs +#endif + ) { // There is no access link for scope frames, so the frame // offset must be zero. @@ -4316,10 +4408,13 @@ octave_value& scope_stack_frame::varref case LOCAL: { octave_value &ov = m_values.at (data_offset); + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) if (deref_refs && ov.is_ref ()) return ov.ref_rep ()->ref (); - else - return ov; +#endif + + return ov; } case PERSISTENT: return m_scope.persistent_varref (data_offset); @@ -4360,10 +4455,4 @@ void scope_stack_frame::accept (stack_fr sfw.visit_scope_stack_frame (*this); } -void bytecode_fcn_stack_frame::accept (stack_frame_walker& sfw) -{ - sfw.visit_bytecode_fcn_stack_frame (*this); -} - - OCTAVE_END_NAMESPACE(octave) diff --git a/libinterp/corefcn/stack-frame.h b/libinterp/corefcn/stack-frame.h --- a/libinterp/corefcn/stack-frame.h +++ b/libinterp/corefcn/stack-frame.h @@ -104,7 +104,10 @@ class symbol_info_list; class unwind_protect; class stack_frame_walker; + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) class vm; +#endif class stack_frame { @@ -183,6 +186,8 @@ public: const std::shared_ptr& parent_link, const std::shared_ptr& static_link); +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + // Bytecode function stackframe static std::shared_ptr create_bytecode (tree_evaluator& tw, @@ -211,6 +216,7 @@ public: const std::shared_ptr& parent_link, const std::shared_ptr& static_link, int nargout, int nargin); +#endif stack_frame (const stack_frame& elt) = default; @@ -491,9 +497,18 @@ public: return sym ? varval (sym) : octave_value (); } - virtual octave_value& varref (const symbol_record& sym, bool deref_refs = true) = 0; - virtual octave_value& varref (std::size_t data_offset, bool deref_refs = true); + virtual octave_value& varref (const symbol_record& sym +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , bool deref_refs = true +#endif + ) = 0; + + virtual octave_value& varref (std::size_t data_offset +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + , bool deref_refs = true +#endif + ); void assign (const symbol_record& sym, const octave_value& val) { @@ -624,6 +639,8 @@ public: bool is_closure_context () const { return m_is_closure_context; } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + // The VM needs to tell the bytecode stackframe that it unwinds so // that it can check whether to save the stack. virtual void vm_unwinds () {} @@ -633,6 +650,8 @@ public: virtual void vm_exit_script () {} virtual void vm_enter_nested () {} +#endif + protected: // Reference to the call stack that contains this frame. Global diff --git a/libinterp/octave-value/ov-base-diag.h b/libinterp/octave-value/ov-base-diag.h --- a/libinterp/octave-value/ov-base-diag.h +++ b/libinterp/octave-value/ov-base-diag.h @@ -247,11 +247,15 @@ public: OCTINTERP_API octave_value fast_elem_extract (octave_idx_type n) const; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave_base_value::vm_call_dispatch_type vm_dispatch_call () { return vm_call_dispatch_type::OCT_SUBSREF; } +#endif + protected: DMT m_matrix; diff --git a/libinterp/octave-value/ov-base-mat.cc b/libinterp/octave-value/ov-base-mat.cc --- a/libinterp/octave-value/ov-base-mat.cc +++ b/libinterp/octave-value/ov-base-mat.cc @@ -574,6 +574,30 @@ octave_base_matrix::fast_elem_extrac } template +bool +octave_base_matrix::fast_elem_insert (octave_idx_type n, + const octave_value& x) +{ + if (n < m_matrix.numel ()) + { + // Don't use builtin_type () here to avoid an extra VM call. + typedef typename MT::element_type ET; + const builtin_type_t btyp = class_to_btyp::btyp; + if (btyp == btyp_unknown) // Dead branch? + return false; + + // Set up the pointer to the proper place. + void *here = reinterpret_cast (&m_matrix(n)); + // Ask x to store there if it can. + return x.get_rep ().fast_elem_insert_self (here, btyp); + } + else + return false; +} + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + +template octave_value octave_base_matrix::checked_full_matrix_elem (octave_idx_type i) const { @@ -621,24 +645,4 @@ octave_base_matrix::vm_extract_forlo return arg.index_op (idx).storable_value (); } -template -bool -octave_base_matrix::fast_elem_insert (octave_idx_type n, - const octave_value& x) -{ - if (n < m_matrix.numel ()) - { - // Don't use builtin_type () here to avoid an extra VM call. - typedef typename MT::element_type ET; - const builtin_type_t btyp = class_to_btyp::btyp; - if (btyp == btyp_unknown) // Dead branch? - return false; - - // Set up the pointer to the proper place. - void *here = reinterpret_cast (&m_matrix(n)); - // Ask x to store there if it can. - return x.get_rep ().fast_elem_insert_self (here, btyp); - } - else - return false; -} +#endif diff --git a/libinterp/octave-value/ov-base-mat.h b/libinterp/octave-value/ov-base-mat.h --- a/libinterp/octave-value/ov-base-mat.h +++ b/libinterp/octave-value/ov-base-mat.h @@ -81,10 +81,14 @@ public: void maybe_economize () { m_matrix.maybe_economize (); } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + bool vm_need_storable_call () const { return true; } bool is_maybe_function () const { return false; } +#endif + // We don't need to override all three forms of subsref. The using // declaration will avoid warnings about partially-overloaded virtual // functions. @@ -212,6 +216,8 @@ public: // You should not use it anywhere else. const void * mex_get_data () const { return m_matrix.data (); } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + OCTINTERP_API octave_value vm_extract_forloop_value (octave_idx_type idx); @@ -226,6 +232,8 @@ public: return vm_call_dispatch_type::OCT_SUBSREF; } +#endif + protected: MT m_matrix; diff --git a/libinterp/octave-value/ov-base-scalar.cc b/libinterp/octave-value/ov-base-scalar.cc --- a/libinterp/octave-value/ov-base-scalar.cc +++ b/libinterp/octave-value/ov-base-scalar.cc @@ -69,14 +69,6 @@ octave_base_scalar::subsref (const s template octave_value -octave_base_scalar::vm_extract_forloop_value (octave_idx_type) -{ - return octave_value (scalar); -} - - -template -octave_value octave_base_scalar::subsasgn (const std::string& type, const std::list& idx, const octave_value& rhs) @@ -239,3 +231,14 @@ octave_base_scalar::fast_elem_insert else return false; } + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + +template +octave_value +octave_base_scalar::vm_extract_forloop_value (octave_idx_type) +{ + return octave_value (scalar); +} + +#endif diff --git a/libinterp/octave-value/ov-base-scalar.h b/libinterp/octave-value/ov-base-scalar.h --- a/libinterp/octave-value/ov-base-scalar.h +++ b/libinterp/octave-value/ov-base-scalar.h @@ -169,12 +169,14 @@ public: OCTINTERP_API octave_value fast_elem_extract (octave_idx_type n) const; + OCTINTERP_API bool + fast_elem_insert_self (void *where, builtin_type_t btyp) const; + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + OCTINTERP_API octave_value vm_extract_forloop_value (octave_idx_type idx); - OCTINTERP_API bool - fast_elem_insert_self (void *where, builtin_type_t btyp) const; - bool vm_need_dispatch_assign_rhs () { return false; } bool vm_need_dispatch_assign_lhs () { return false; } @@ -186,6 +188,8 @@ public: return vm_call_dispatch_type::OCT_SUBSREF; } +#endif + protected: // The value of this scalar. diff --git a/libinterp/octave-value/ov-base-sparse.h b/libinterp/octave-value/ov-base-sparse.h --- a/libinterp/octave-value/ov-base-sparse.h +++ b/libinterp/octave-value/ov-base-sparse.h @@ -242,11 +242,15 @@ public: OCTINTERP_API octave_value fast_elem_extract (octave_idx_type n) const; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave_base_value::vm_call_dispatch_type vm_dispatch_call () { return vm_call_dispatch_type::OCT_SUBSREF; } +#endif + protected: OCTINTERP_API octave_value diff --git a/libinterp/octave-value/ov-base.cc b/libinterp/octave-value/ov-base.cc --- a/libinterp/octave-value/ov-base.cc +++ b/libinterp/octave-value/ov-base.cc @@ -282,6 +282,8 @@ octave_base_value::index_vector (bool /* octave::err_invalid_index (nm.c_str ()); } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave_value octave_base_value::vm_extract_forloop_value (octave_idx_type idx) { @@ -300,6 +302,8 @@ octave_base_value::maybe_update_double ( return false; } +#endif + octave_value octave_base_value::simple_subsasgn (char type, octave_value_list& idx, const octave_value& rhs) @@ -962,6 +966,8 @@ octave_base_value::function_value (bool return nullptr; } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave_base_value::vm_call_dispatch_type octave_base_value::vm_dispatch_call () { @@ -987,6 +993,8 @@ octave_base_value::ref_rep () return nullptr; } +#endif + octave_user_function * octave_base_value::user_function_value (bool silent) { @@ -1449,6 +1457,20 @@ octave_base_value::fast_elem_extract (oc return octave_value (); } +bool +octave_base_value::fast_elem_insert (octave_idx_type, const octave_value&) +{ + return false; +} + +bool +octave_base_value::fast_elem_insert_self (void *, builtin_type_t) const +{ + return false; +} + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave_value octave_base_value::checked_full_matrix_elem (octave_idx_type) const { @@ -1461,17 +1483,7 @@ octave_base_value::checked_full_matrix_e err_wrong_type_arg ("octave_base_value::checked_full_matrix_elem (octave_idx_type, octave_idx_type)", type_name ()); } -bool -octave_base_value::fast_elem_insert (octave_idx_type, const octave_value&) -{ - return false; -} - -bool -octave_base_value::fast_elem_insert_self (void *, builtin_type_t) const -{ - return false; -} +#endif static octave_base_value * oct_conv_matrix_conv (const octave_base_value&) diff --git a/libinterp/octave-value/ov-base.h b/libinterp/octave-value/ov-base.h --- a/libinterp/octave-value/ov-base.h +++ b/libinterp/octave-value/ov-base.h @@ -78,9 +78,12 @@ class octave_user_script; class octave_user_code; class octave_fcn_handle; class octave_value_list; + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) class octave_value_ref; class octave_fcn_cache; class octave_value_vm; +#endif enum builtin_type_t { @@ -264,7 +267,10 @@ public: }; friend class octave_value; + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) friend class octave_value_vm; +#endif octave_base_value (); @@ -808,6 +814,8 @@ public: virtual octave_base_value * make_storable_value (); +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + virtual bool vm_need_storable_call () const { return false; } virtual bool vm_need_dispatch_assign_rhs () { return true; } @@ -842,6 +850,8 @@ public: virtual bool is_trivial_range () const { return false; }; +#endif + // Standard mappers. Register new ones here. enum unary_mapper_t { @@ -931,12 +941,16 @@ public: virtual bool fast_elem_insert_self (void *where, builtin_type_t btyp) const; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + virtual octave_value checked_full_matrix_elem (octave_idx_type i) const; virtual octave_value checked_full_matrix_elem (octave_idx_type i, octave_idx_type j) const; +#endif + protected: // This should only be called for derived types. diff --git a/libinterp/octave-value/ov-cell.h b/libinterp/octave-value/ov-cell.h --- a/libinterp/octave-value/ov-cell.h +++ b/libinterp/octave-value/ov-cell.h @@ -178,11 +178,15 @@ public: // You should not use it anywhere else. const void * mex_get_data () const; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave_base_value::vm_call_dispatch_type vm_dispatch_call () { return vm_call_dispatch_type::OCT_SUBSREF; } +#endif + octave_value_list simple_subsref (char type, octave_value_list& idx, int nargout); diff --git a/libinterp/octave-value/ov-classdef.h b/libinterp/octave-value/ov-classdef.h --- a/libinterp/octave-value/ov-classdef.h +++ b/libinterp/octave-value/ov-classdef.h @@ -230,11 +230,15 @@ public: OCTINTERP_API std::string file_name () const; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + vm_call_dispatch_type vm_dispatch_call () { return vm_call_dispatch_type::OCT_SUBSREF; } +#endif + private: octave::cdef_meta_object m_object; diff --git a/libinterp/octave-value/ov-colon.h b/libinterp/octave-value/ov-colon.h --- a/libinterp/octave-value/ov-colon.h +++ b/libinterp/octave-value/ov-colon.h @@ -76,11 +76,15 @@ public: OCTINTERP_API void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave_base_value::vm_call_dispatch_type vm_dispatch_call () { return vm_call_dispatch_type::OCT_SUBSREF; } +#endif + private: DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA diff --git a/libinterp/octave-value/ov-fcn-handle.cc b/libinterp/octave-value/ov-fcn-handle.cc --- a/libinterp/octave-value/ov-fcn-handle.cc +++ b/libinterp/octave-value/ov-fcn-handle.cc @@ -57,6 +57,9 @@ #include "pr-output.h" #include "pt-arg-list.h" #include "pt-assign.h" +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) +# include "pt-bytecode-walk.h" +#endif #include "pt-cmd.h" #include "pt-eval.h" #include "pt-exp.h" @@ -64,7 +67,6 @@ #include "pt-misc.h" #include "pt-pr-code.h" #include "pt-stmt.h" -#include "pt-bytecode-walk.h" #include "stack-frame.h" #include "syminfo.h" #include "symscope.h" @@ -230,6 +232,7 @@ public: friend bool is_equal_to (const simple_fcn_handle& fh1, const simple_fcn_handle& fh2); +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) octave_function * get_cached_fcn (const octave_value_list &args); @@ -237,13 +240,16 @@ public: get_cached_fcn (void *beg, void *end); bool has_function_cache () const; +#endif private: octave_value m_fcn; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) // Only used by the VM via get_cached_fcn() and has_function_cache() octave_fcn_cache m_cache; +#endif }; class scoped_fcn_handle : public base_fcn_handle @@ -314,6 +320,7 @@ public: friend bool is_equal_to (const scoped_fcn_handle& fh1, const scoped_fcn_handle& fh2); +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) octave_function * get_cached_fcn (void *, void *) { return m_fcn.function_value (); } @@ -322,6 +329,7 @@ public: bool has_function_cache () const { return true; } +#endif protected: @@ -707,6 +715,7 @@ public: bool parse (const std::string& fcn_text); +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) octave_function * get_cached_fcn (const octave_value_list&) { return m_fcn.function_value (); } @@ -719,6 +728,7 @@ public: octave_function *fn = m_fcn.function_value (); return fn ? fn->is_compiled () : false; } +#endif protected: @@ -771,8 +781,10 @@ public: return m_stack_context; } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) // Compile the underlying function to bytecode for the VM. void compile (); +#endif protected: @@ -991,6 +1003,8 @@ bool is_equal_to (const internal_fcn_han return false; } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + // FIXME: Find a way to avoid duplication of code in // simple_fcn_handle::call @@ -1208,6 +1222,8 @@ simple_fcn_handle::has_function_cache () } } +#endif + octave_value_list simple_fcn_handle::call (int nargout, const octave_value_list& args) { @@ -2086,8 +2102,10 @@ nested_fcn_handle::call (int nargout, co octave_user_function *oct_usr_fcn = m_fcn.user_function_value (); +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) if (octave::vm::maybe_compile_or_compiled (oct_usr_fcn)) return octave::vm::call (tw, nargout, args, oct_usr_fcn, m_stack_context); +#endif tw.push_stack_frame (oct_usr_fcn, m_stack_context); @@ -2976,8 +2994,10 @@ anonymous_fcn_handle::call (int nargout, octave_user_function *oct_usr_fcn = m_fcn.user_function_value (); +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) if (octave::vm::maybe_compile_or_compiled (oct_usr_fcn, &m_local_vars)) return octave::vm::call (tw, nargout, args, oct_usr_fcn); +#endif tw.push_stack_frame (oct_usr_fcn, m_local_vars, m_stack_context); @@ -2986,6 +3006,8 @@ anonymous_fcn_handle::call (int nargout, return oct_usr_fcn->execute (tw, nargout, args); } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + void anonymous_fcn_handle::compile () { octave_user_code *usr_code = user_function_value (); @@ -3001,6 +3023,8 @@ void anonymous_fcn_handle::compile () } } +#endif + octave_value anonymous_fcn_handle::workspace () const { octave_scalar_map local_vars_map; diff --git a/libinterp/octave-value/ov-fcn-handle.h b/libinterp/octave-value/ov-fcn-handle.h --- a/libinterp/octave-value/ov-fcn-handle.h +++ b/libinterp/octave-value/ov-fcn-handle.h @@ -377,6 +377,8 @@ public: friend bool is_equal_to (const octave_fcn_handle& fh1, const octave_fcn_handle& fh2); +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave_function * get_cached_fcn (void *beg, void *end) { return m_rep->get_cached_fcn (beg, end); } @@ -394,6 +396,9 @@ public: } void compile () { m_rep->compile (); } + +#endif + private: std::shared_ptr m_rep; diff --git a/libinterp/octave-value/ov-fcn.cc b/libinterp/octave-value/ov-fcn.cc --- a/libinterp/octave-value/ov-fcn.cc +++ b/libinterp/octave-value/ov-fcn.cc @@ -58,9 +58,11 @@ octave_value_list octave_function::call (octave::tree_evaluator& tw, int nargout, const octave_value_list& args) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) octave_user_function *usr = this->user_function_value(true); if (octave::vm::maybe_compile_or_compiled (usr)) return octave::vm::call (tw, nargout, args, usr); +#endif tw.push_stack_frame (this); @@ -69,6 +71,8 @@ octave_function::call (octave::tree_eval return execute (tw, nargout, args); } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + bool octave_fcn_cache::has_cached_function (void *pbeg, void *pend) const { @@ -264,3 +268,5 @@ call (octave::tree_evaluator& tw, //tw.final_index_error (ie, m_expr); } } + +#endif diff --git a/libinterp/octave-value/ov-fcn.h b/libinterp/octave-value/ov-fcn.h --- a/libinterp/octave-value/ov-fcn.h +++ b/libinterp/octave-value/ov-fcn.h @@ -48,6 +48,8 @@ OCTAVE_END_NAMESPACE(octave) // Functions. +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + // Class that holds a cached reference to a octave function // for use in the bytecode VM. class @@ -133,6 +135,7 @@ private: std::string m_fcn_name; }; +#endif class OCTINTERP_API @@ -322,6 +325,7 @@ public: execute (octave::tree_evaluator& tw, int nargout = 0, const octave_value_list& args = octave_value_list ()) = 0; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) vm_call_dispatch_type vm_dispatch_call () { return vm_call_dispatch_type::OCT_CALL; @@ -334,8 +338,9 @@ public: get_cached_fcn (const octave_value_list&) { return function_value (); } bool has_function_cache () const { return true; } +#endif -protected: + protected: octave_function (const std::string& nm, const std::string& ds = "") diff --git a/libinterp/octave-value/ov-ref.cc b/libinterp/octave-value/ov-ref.cc --- a/libinterp/octave-value/ov-ref.cc +++ b/libinterp/octave-value/ov-ref.cc @@ -27,10 +27,11 @@ # include "config.h" #endif +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + #include "ov.h" #include "ov-ref.h" - #include "interpreter.h" #include "interpreter-private.h" @@ -188,3 +189,5 @@ octave_value_ref_ptr::set_value (octave_ else *m_pov = val; } + +#endif diff --git a/libinterp/octave-value/ov-ref.h b/libinterp/octave-value/ov-ref.h --- a/libinterp/octave-value/ov-ref.h +++ b/libinterp/octave-value/ov-ref.h @@ -28,6 +28,8 @@ #include "octave-config.h" +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + #include "ov-base.h" #include "ovl.h" #include "symscope.h" @@ -184,3 +186,5 @@ private: }; #endif + +#endif diff --git a/libinterp/octave-value/ov-struct.cc b/libinterp/octave-value/ov-struct.cc --- a/libinterp/octave-value/ov-struct.cc +++ b/libinterp/octave-value/ov-struct.cc @@ -1119,6 +1119,8 @@ octave_struct::fast_elem_insert (octave_ return retval; } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave_value octave_struct::vm_extract_forloop_value (octave_idx_type counter) { @@ -1152,6 +1154,8 @@ octave_struct::vm_extract_forloop_value return arg.index_op (idx).storable_value (); } +#endif + DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_scalar_struct, "scalar struct", "struct"); diff --git a/libinterp/octave-value/ov-struct.h b/libinterp/octave-value/ov-struct.h --- a/libinterp/octave-value/ov-struct.h +++ b/libinterp/octave-value/ov-struct.h @@ -101,8 +101,12 @@ public: dim_vector dims () const { return m_map.dims (); } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave_value vm_extract_forloop_value (octave_idx_type idx); +#endif + std::size_t byte_size () const; // This is the number of elements in each field. The total number @@ -165,11 +169,15 @@ public: bool fast_elem_insert (octave_idx_type n, const octave_value& x); +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave_base_value::vm_call_dispatch_type vm_dispatch_call () { return vm_call_dispatch_type::OCT_SUBSREF; } +#endif + protected: // The associative array used to manage the structure data. @@ -295,11 +303,15 @@ public: bool fast_elem_insert_self (void *where, builtin_type_t btyp) const; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave_base_value::vm_call_dispatch_type vm_dispatch_call () { return vm_call_dispatch_type::OCT_SUBSREF; } +#endif + protected: // The associative array used to manage the structure data. diff --git a/libinterp/octave-value/ov-usr-fcn.cc b/libinterp/octave-value/ov-usr-fcn.cc --- a/libinterp/octave-value/ov-usr-fcn.cc +++ b/libinterp/octave-value/ov-usr-fcn.cc @@ -50,7 +50,10 @@ #include "pt-misc.h" #include "pt-pr-code.h" #include "pt-stmt.h" -#include "pt-bytecode-vm.h" +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) +# include "pt-bytecode-vm.h" +# include "pt-bytecode-walk.h" +#endif #include "pt-walk.h" #include "symtab.h" #include "interpreter-private.h" @@ -61,7 +64,6 @@ #include "profiler.h" #include "variables.h" #include "ov-fcn-handle.h" -#include "pt-bytecode-walk.h" // Whether to optimize subsasgn method calls. static bool Voptimize_subsasgn_calls = true; @@ -98,6 +100,8 @@ octave_user_code::get_file_info () m_file_name.c_str ()); } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + void octave_user_code::clear_bytecode () { @@ -112,6 +116,8 @@ octave_user_code::clear_bytecode () } } +#endif + std::string octave_user_code::get_code_line (std::size_t line) { @@ -198,6 +204,7 @@ octave_value_list octave_user_script::call (octave::tree_evaluator& tw, int nargout, const octave_value_list& args) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) if (octave::vm::maybe_compile_or_compiled (this)) { // Check that either: @@ -221,6 +228,7 @@ octave_user_script::call (octave::tree_e else warning ("Executing compiled scripts in the VM from an un-compiled function is not supported yet"); } +#endif tw.push_stack_frame (this); @@ -521,8 +529,10 @@ octave_value_list octave_user_function::call (octave::tree_evaluator& tw, int nargout, const octave_value_list& args) { +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) if (octave::vm::maybe_compile_or_compiled (this)) return octave::vm::call (tw, nargout, args, this); +#endif tw.push_stack_frame (this); diff --git a/libinterp/octave-value/ov-usr-fcn.h b/libinterp/octave-value/ov-usr-fcn.h --- a/libinterp/octave-value/ov-usr-fcn.h +++ b/libinterp/octave-value/ov-usr-fcn.h @@ -36,7 +36,9 @@ #include "ov-typeinfo.h" #include "symscope.h" #include "unwind-prot.h" -#include "pt-bytecode.h" +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) +# include "pt-bytecode.h" +#endif class string_vector; @@ -120,6 +122,7 @@ public: octave_value dump () const; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) void set_bytecode (octave::bytecode &bytecode) { m_bytecode = bytecode; @@ -133,12 +136,15 @@ public: bool compilation_failed () { return m_compilation_failed; } void set_compilation_failed (bool val) { m_compilation_failed = val; } +#endif protected: +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) bool m_compilation_failed = false; octave::bytecode m_bytecode; +#endif void get_file_info (); diff --git a/libinterp/octave-value/ov.cc b/libinterp/octave-value/ov.cc --- a/libinterp/octave-value/ov.cc +++ b/libinterp/octave-value/ov.cc @@ -1486,6 +1486,8 @@ octave_value::next_subsref (int nargout, return *this; } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + octave_value octave_value::maybe_as_trivial_range () { @@ -1501,6 +1503,8 @@ octave_value::maybe_as_trivial_range () return range.as_trivial_range (); } +#endif + octave_value octave_value::next_subsref (bool auto_add, const std::string& type, const std::list& idx, diff --git a/libinterp/octave-value/ov.h b/libinterp/octave-value/ov.h --- a/libinterp/octave-value/ov.h +++ b/libinterp/octave-value/ov.h @@ -48,10 +48,13 @@ OCTAVE_BEGIN_NAMESPACE(octave) class stack_frame; class type_info; +class scope_stack_frame; +class base_value_stack_frame; + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) class vm; class bytecode_fcn_stack_frame; -class scope_stack_frame; -class base_value_stack_frame; +#endif OCTAVE_END_NAMESPACE(octave) @@ -1543,6 +1546,8 @@ public: protected: +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + // Functions for use by the VM. friend class octave_value_ref; friend class octave_value_vm; @@ -1643,7 +1648,9 @@ protected: bool is_trivial_range () { return m_rep->is_trivial_range (); } -//! The real representation. +#endif + + //! The real representation. octave_base_value *m_rep; static OCTINTERP_API octave_base_value * nil_rep (); diff --git a/libinterp/parse-tree/pt-bytecode-vm-internal.h b/libinterp/parse-tree/pt-bytecode-vm-internal.h --- a/libinterp/parse-tree/pt-bytecode-vm-internal.h +++ b/libinterp/parse-tree/pt-bytecode-vm-internal.h @@ -28,6 +28,8 @@ #include "octave-config.h" +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + #define EXPAND_CSLIST_PUSH_N_OVL_ELEMENTS_TO_STACK(ovl,nargout) \ do {\ if (nargout <= 1)\ @@ -487,3 +489,5 @@ if (n_returns >= 0 && nargout > n_return #endif + +#endif diff --git a/libinterp/parse-tree/pt-bytecode-vm.cc b/libinterp/parse-tree/pt-bytecode-vm.cc --- a/libinterp/parse-tree/pt-bytecode-vm.cc +++ b/libinterp/parse-tree/pt-bytecode-vm.cc @@ -27,6 +27,8 @@ # include "config.h" #endif +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + #include #include @@ -8293,3 +8295,5 @@ extern "C" void dummy_mark_2 (void) { asm (""); } + +#endif diff --git a/libinterp/parse-tree/pt-bytecode-vm.h b/libinterp/parse-tree/pt-bytecode-vm.h --- a/libinterp/parse-tree/pt-bytecode-vm.h +++ b/libinterp/parse-tree/pt-bytecode-vm.h @@ -358,6 +358,10 @@ #include "octave-config.h" +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + +#include "octave-config.h" + #include #include #include @@ -643,3 +647,5 @@ opcodes_to_strings (std::vector -#include "octave-config.h" #include "pt-walk.h" #include "error.h" @@ -440,3 +443,5 @@ namespace octave } #endif + +#endif diff --git a/libinterp/parse-tree/pt-bytecode.h b/libinterp/parse-tree/pt-bytecode.h --- a/libinterp/parse-tree/pt-bytecode.h +++ b/libinterp/parse-tree/pt-bytecode.h @@ -26,6 +26,10 @@ #if ! defined (octave_pt_bytecode_h) #define octave_pt_bytecode_h 1 +#include "octave-config.h" + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + #include #include @@ -358,3 +362,5 @@ extern bool V__vm_enable__; OCTAVE_END_NAMESPACE(octave) #endif + +#endif diff --git a/libinterp/parse-tree/pt-eval.cc b/libinterp/parse-tree/pt-eval.cc --- a/libinterp/parse-tree/pt-eval.cc +++ b/libinterp/parse-tree/pt-eval.cc @@ -72,8 +72,10 @@ #include "unwind-prot.h" #include "utils.h" #include "variables.h" -#include "pt-bytecode-vm.h" -#include "pt-bytecode-walk.h" +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) +# include "pt-bytecode-vm.h" +# include "pt-bytecode-walk.h" +#endif OCTAVE_BEGIN_NAMESPACE(octave) @@ -1369,14 +1371,18 @@ tree_evaluator::reset_debug_state () || m_break_on_next_stmt || in_debug_repl ()); +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) update_vm_dbgprofecho_flag (); +#endif } void tree_evaluator::reset_debug_state (bool mode) { m_debug_mode = mode; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) update_vm_dbgprofecho_flag (); +#endif } void @@ -2472,6 +2478,8 @@ void tree_evaluator::push_stack_frame (o m_call_stack.push (fcn); } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + void tree_evaluator::push_stack_frame (vm &vm, octave_user_function *fcn, int nargout, int nargin) { m_call_stack.push (vm, fcn, nargout, nargin); @@ -2493,10 +2501,13 @@ void tree_evaluator::push_stack_frame (v void tree_evaluator::push_stack_frame (vm &vm, octave_user_code *fcn, int nargout, int nargin, const std::shared_ptr& closure_frames) { + CHECK_PANIC (fcn->is_user_function ()); m_call_stack.push (vm, static_cast (fcn), nargout, nargin, closure_frames); } +#endif + void tree_evaluator::pop_stack_frame () { m_call_stack.pop (); @@ -4998,7 +5009,10 @@ tree_evaluator::echo (const octave_value if (cleanup_pushed) maybe_set_echo_state (); - update_vm_dbgprofecho_flag (); // Since m_echo might have changed value we need to call this +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + // Since m_echo might have changed value we need to call this + update_vm_dbgprofecho_flag (); +#endif return octave_value (); } diff --git a/libinterp/parse-tree/pt-eval.h b/libinterp/parse-tree/pt-eval.h --- a/libinterp/parse-tree/pt-eval.h +++ b/libinterp/parse-tree/pt-eval.h @@ -61,7 +61,10 @@ class debugger; class interpreter; class push_parser; class unwind_protect; + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) class vm; +#endif // How to evaluate the code that the parse trees represent. @@ -69,7 +72,9 @@ class OCTINTERP_API tree_evaluator : pub { public: +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) friend class vm; +#endif enum echo_state { @@ -137,8 +142,11 @@ public: m_whos_line_format (" %la:5; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;\n"), m_silent_functions (false), m_string_fill_char (' '), m_PS4 ("+ "), m_dbstep_flag (0), m_break_on_next_stmt (false), m_echo (ECHO_OFF), - m_echo_state (false), m_echo_file_name (), m_vm_dbg_profile_echo (false), - m_vm_profiler_active (false), m_echo_file_pos (1), + m_echo_state (false), m_echo_file_name (), +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + m_vm_dbg_profile_echo (false), m_vm_profiler_active (false), +#endif + m_echo_file_pos (1), m_echo_files (), m_in_top_level_repl (false), m_server_mode (false), m_in_loop_command (false), m_breaking (0), m_continuing (0), m_returning (0), @@ -442,6 +450,8 @@ public: void push_stack_frame (octave_function *fcn); +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + void push_stack_frame (vm &vm, octave_user_function *fcn, int nargout, int nargin); void push_stack_frame (vm &vm, octave_user_script *fcn, int nargout, int nargin); @@ -450,6 +460,8 @@ public: void push_stack_frame (vm &vm, octave_user_code *fcn, int nargout, int nargin, const std::shared_ptr& closure_frames); +#endif + void pop_stack_frame (); std::shared_ptr pop_return_stack_frame (); @@ -841,7 +853,9 @@ public: int old_val = m_echo; m_echo = val; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) update_vm_dbgprofecho_flag (); +#endif return old_val; } @@ -869,6 +883,7 @@ public: m_echo_file_pos = pos; } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) void vm_set_profiler_active (bool val) { m_vm_profiler_active = val; @@ -876,8 +891,9 @@ public: } bool vm_dbgprofecho_flag () { return m_vm_dbg_profile_echo; } +#endif -private: + private: template void execute_range_loop (const range& rng, int line, @@ -992,6 +1008,8 @@ private: std::string m_echo_file_name; +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + // The VM needs to keep know if the evaluation is in a debug, echo or profiler // state. bool m_vm_dbg_profile_echo; // Set to true if either echo, dbg or vm profiler active @@ -1004,6 +1022,8 @@ private: m_vm_dbg_profile_echo = m_debug_mode || m_echo || m_vm_profiler_active; } +#endif + // Next line to echo, counting from 1. We use int here because the // parser does. It also initializes line and column numbers to the // invalid value -1 and that can cause trouble if cast to an diff --git a/libinterp/parse-tree/pt-tm-const.cc b/libinterp/parse-tree/pt-tm-const.cc --- a/libinterp/parse-tree/pt-tm-const.cc +++ b/libinterp/parse-tree/pt-tm-const.cc @@ -61,12 +61,16 @@ eval_error (const char *msg, const dim_v OCTAVE_BEGIN_NAMESPACE(octave) +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + tm_row_const::tm_row_const (const stack_element *beg, const stack_element *end) : tm_info (beg == end), m_values () { init (beg, end); } +#endif + void tm_row_const::cellify () { bool elt_changed = false; @@ -229,6 +233,8 @@ void tm_row_const::init (const tree_argu } } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + // FIXME: This function is mostly a duplicate of // // void tm_row_const::init (const tree_argument_list&, tree_evaluator&) @@ -304,6 +310,8 @@ tm_const::tm_const (const stack_element init (beg, end, row_lengths); } +#endif + octave_value tm_const::concat (char string_fill_char) const { if (m_tm_rows.empty ()) @@ -510,6 +518,8 @@ void tm_const::init (const tree_matrix& } } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) + // FIXME: This function is mostly a duplicate of both of the functions // // void tm_const::init (const tree_matrix&) @@ -765,6 +775,8 @@ void tm_const::init (const stack_element } } +#endif + octave_value tm_const::char_array_concat (char string_fill_char) const { char type = (m_all_dq_strings ? '"' : '\''); diff --git a/libinterp/parse-tree/pt-tm-const.h b/libinterp/parse-tree/pt-tm-const.h --- a/libinterp/parse-tree/pt-tm-const.h +++ b/libinterp/parse-tree/pt-tm-const.h @@ -46,7 +46,10 @@ OCTAVE_BEGIN_NAMESPACE(octave) class tree_evaluator; + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) union stack_element; +#endif // Evaluate tree_matrix objects and convert them to octave_value // arrays (full and sparse numeric, char, cell, struct, class and @@ -158,7 +161,9 @@ public: init (row, tw); } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) tm_row_const (const stack_element *beg, const stack_element *end); +#endif tm_row_const (const tm_row_const&) = default; @@ -185,7 +190,10 @@ private: void init_element (const octave_value&, bool&); void init (const tree_argument_list&, tree_evaluator& tw); + +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) void init (const stack_element *beg, const stack_element *end); +#endif }; class tm_const : public tm_info @@ -203,11 +211,13 @@ public: init (tm); } +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) tm_const (const stack_element *beg, const stack_element *end, octave_idx_type n_rows, tree_evaluator& tw); tm_const (const stack_element *beg, const stack_element *end, const std::vector& row_lengths, tree_evaluator& tw); +#endif OCTAVE_DISABLE_COPY_MOVE (tm_const) @@ -227,11 +237,13 @@ private: void init (const tree_matrix& tm); +#if defined (OCTAVE_ENABLE_BYTECODE_EVALUATOR) void init (const stack_element *beg, const stack_element *end, octave_idx_type row_length); void init (const stack_element *beg, const stack_element *end, const std::vector& row_lengths); +#endif octave_value char_array_concat (char string_fill_char) const; diff --git a/test/compile/bytecode.tst b/test/compile/bytecode.tst --- a/test/compile/bytecode.tst +++ b/test/compile/bytecode.tst @@ -32,7 +32,7 @@ %! clear classes ## Test binary expressions -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); % Disable the vm for the tree_walker run %! %! clear all % We want all compiled functions to be cleared so that we can run the tree_walker @@ -50,7 +50,7 @@ %! assert (__prog_output_assert__ (key)); ## Test subfunctions -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "2 2 2 11 30 10 30 5 0 0 double 1 2 1 2 double 30 11 5 0 0 double 1 2 1 2 double 11 11 12 13 1 1 double 14 1 1 double 11 11 5 13 1 1 double 14 1 1 double 11 3 3 3 2 2 2 313 ret32:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ret32:1 ret32:ret32:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 take32:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 1 18 59 64 "; @@ -69,7 +69,7 @@ %! assert (__prog_output_assert__ (key)); ## Test if:s -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "0 1 2 3 4 5 6 7 8 1 2 yay1 3 5 7 8 1 yay1 3 4 yay2 5 6 7 yay3 "; @@ -84,7 +84,7 @@ %! assert (__prog_output_assert__ (key)); ## Test for:s -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "1 2 3 4 4 1 3 5 5 1 4 4 4 3 2 1 1 0.200 0.300 0.400 0.400 0.300 0.200 0.100 0.000 0.000 NaN NaN NaN 1 4 2 2 16 4 3 3 256 3 2 1 double 1 3 size 2 size 1 2 4 size 2 size 1 double q size 1 size 1 w size 1 size 1 e size 1 size 1 char single single 5 1 11 2 12 key:a val:1 1val:1 key:b val:1 3val:2 4val:2 2key:c val:string "; @@ -99,7 +99,7 @@ %! assert (__prog_output_assert__ (key)); ## Test while -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "5 4 3 2 1 3 5 4 4 3 3 4 1 2 1 3 2 8 3 1 3 "; @@ -114,7 +114,7 @@ %! assert (__prog_output_assert__ (key)); ## Test assign -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "2 3 1 1 2 3 2 3 2 2 6 18 2.000000 2.000000 3.000000 4.000000 5.000000 1 4 double 729.000000 324.000000 182.250000 116.640000 4 1 double 37.000000 81.000000 54.000000 118.000000 2 2 double "; @@ -129,7 +129,7 @@ %! assert (__prog_output_assert__ (key)); ## Test unary -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "-1 4 1 2 3 4 1 3 2 4 0 0 "; @@ -144,7 +144,7 @@ %! assert (__prog_output_assert__ (key)); ## Test range -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "1 2 3 1 3 5 1 3 5 1 1.1 1.2 1.3 1.4 1 0.9 0.8 0.7 7 7 1 8 10 8 10 8 9 10 11 8 9 10 11 10 8 10 8 -10 -9 -8 -7 -10 -9 -8 -7 "; @@ -159,7 +159,7 @@ %! assert (__prog_output_assert__ (key)); ## Test multi assign -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "3 4 2 2 1 2 3 4 1 2 3 4 1 1 3 2 3 4 1 1 1 2 3 4 1 1 1 2 3 4 1 2 3 "; @@ -174,7 +174,7 @@ %! assert (__prog_output_assert__ (key)); ## Test subsasgn -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! clear functions % persistent variables in bytecode_subsasgn @@ -190,7 +190,7 @@ %! assert (__prog_output_assert__ (key), "bytecode_subsasgn failed compiled"); ## Test end -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "1 3 2 4 1 5 6 7 2 2 5 5 6 6 1 2 3 4 5 2 2 2 3 3 4 fs 2 3 1 foo oo "; @@ -205,7 +205,7 @@ %! assert (__prog_output_assert__ (key)); ## Test matrix -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "1 2 3 4 1 4 1 2 3 4 4 1 1 3 2 4 2 2 1 3 1 3 2 4 2 4 4 2 0 0 a b c d 7 15 10 22 2 2 30 1 1 1 2 3 4 2 4 6 8 3 6 9 12 4 8 12 16 4 4 1 1 1 0.0333333 0.0666667 0.1 0.133333 0.0666667 0.133333 0.2 0.266667 0.1 0.2 0.3 0.4 0.133333 0.266667 0.4 0.533333 4 4 1 0 0 1 2 2 30 1 1 10 14 14 20 2 2 0.0333333 0.0666667 0.1 0.133333 0.0666667 0.133333 0.2 0.266667 0.1 0.2 0.3 0.4 0.133333 0.266667 0.4 0.533333 4 4 2.5 -0.5 2 0 2 2 2 6 4 8 2 2 2 3 4 5 3 4 5 6 4 5 6 7 5 6 7 8 4 4 3 4 5 6 1 4 3 4 5 6 1 4 -1 0 1 2 1 4 2 4 6 8 1 4 0.5 1 1.5 2 1 4 0.5 1 1.5 2 1 4 1 4 9 16 1 4 1 1 1 1 1 4 1 1 1 1 1 4 1 4 27 256 1 4 1 2 3 4 2 4 6 8 3 6 9 12 4 8 12 16 4 4 1 0.5 0.333333 0.25 2 1 0.666667 0.5 3 1.5 1 0.75 4 2 1.33333 1 4 4 1 2 3 4 0.5 1 1.5 2 0.333333 0.666667 1 1.33333 0.25 0.5 0.75 1 4 4 1 4 27 256 4 1 qzwxeca s d zzxxccz x c 1 258 33264 258 1 33264 "; @@ -220,7 +220,7 @@ %! assert (__prog_output_assert__ (key)); ## Test return -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "2 baaar bääär baaaaz bääääz bååååz booz 1 1 2 1 1 1 2 1 silly silly "; @@ -235,7 +235,7 @@ %! assert (__prog_output_assert__ (key)); ## Test word list command -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "A B C QWE "; @@ -250,7 +250,7 @@ %! assert (__prog_output_assert__ (key)); ## Test do until -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "5 3 5 5 4 4 3 4 1 2 1 3 2 12 3 0 3 "; @@ -265,7 +265,7 @@ %! assert (__prog_output_assert__ (key)); ## Test cell -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "a b a b 1 2 b c b c 1 2 char b c c d b d c e 2 2 b d f h j l c e g i k m 6 2 1 2 2 3 1 3 2 4 1 3 1 2 1 3 2 4 2 2 double qwe 1 3 char 1 2 "; @@ -280,7 +280,7 @@ %! assert (__prog_output_assert__ (key)); ## Test varargin -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "2 3 1 2 1 1 1 1 1 2 3 4 1 4 4 0 0 0 1 2 3 4 1 3 4 2 3 4 1 3 3 2 2 3 4 1 4 4 1 0 0 1 0 0 0 2 1 1 1 1 2 3 4 1 3 4 2 3 4 1 3 3 2 2 3 4 1 4 4 1 2 1 2 4 1 2 0 0 2 1 nob 0 0 1 noa nob 0 0 0 2 1 2 4 1 2 3 4 3 3 2 1 0 "; @@ -308,7 +308,7 @@ %! assert (__prog_output_assert__ (key)); ## Test global variables -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "double 0 0 1 1 1 1 1 2 2 2 400 100 0 1 3 double 1 1 1 2 double 1 2 1 1 11 eclass:double 1 1 3 4 double 1 2 400 100 1 1 1 1 3 4 1 1 5 6 1 1 1 2 double 1 2 1 2 double 1 2 1 1 3 4 eclass:double 1 2 3 4 double 1 2 0 0 1 1 3 4 1 1 5 6 1 0 2 double 2 double 11 2 6 4 5 double 1 5 11 double 1 1 22 double 1 1 33 double 1 1 3 double 1 1 4 double 1 1 10 double 1 1 2 3 double 1 2 3 double 1 1 2 double 1 1 55 double 1 1 7 double 1 1 0 11 12 4 11 12 4 "; @@ -345,7 +345,7 @@ %! clear global q; ## Test switch -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "yay yay2 yay3 yay4 yay5 yay6 yay7 yay8 1 2 3 3 1 3 3 4 4 1 3 3 4 4 2 yoo 2 3 3 1:1 for-end:12:2 3:3 for-end:3breaking:4 "; @@ -360,7 +360,7 @@ %! assert (__prog_output_assert__ (key)); ## Test eval (dynamic stack frames) -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "3.000000 1.000000 1.000000 double 4.000000 1.000000 1.000000 double 4.000000 1.000000 1.000000 double 5.000000 4.000000 2.000000 3.000000 1.000000 1.000000 double 4.000000 1.000000 1.000000 double 4.000000 1.000000 1.000000 double 5.000000 4.000000 2.000000 1:11.000000 2:22.000000 3:33.000000 4:3.000000 5:22.000000 6:3.000000 7:3.000000 3 3 2 2 3.000000 3.000000 "; @@ -375,7 +375,7 @@ %! assert (__prog_output_assert__ (key)); ## Test evalin and assignin -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! % We want to test all combinations of compiled and uncompiled evalin_1 and 2. @@ -412,7 +412,7 @@ %! ## Test error messages -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! ## Interpreter reference %! __vm_enable__ (0, "local"); %! clear all @@ -459,7 +459,7 @@ %! 'operator \+: nonconformant arguments \(op1 is 1x3, op2 is 1x2\)'); ## Test try catch -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "yay yay2 yay3 ooo yay2 yay3 ooo2 ooo2 yay3 yay4 Nested error yay5 yay6 In catch yay7 qwe yay8 Error in subfunction yay9 'asd' undefined near line 87, column 11 yay10 operator *: nonconformant arguments (op1 is 1x2, op2 is 1x3) yay11 yoyo yay12 foo yay12 foo yay12 foo yay13 foo yay13 foo yay13 foo "; @@ -474,7 +474,7 @@ %! assert (__prog_output_assert__ (key)); ## Test unwind protect -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "yay1 yay2 yay3 e1 subyyay1 subyyay2 subyyay3 subyyay4 subyyay5 subyyay6 subyyay7 subyyay8 subyyay9 subyyay10 subyyay11 subyyay12 subyyay13 subyyay14 subyyay15 subyyay16 subyyay17 subyyay18 yay4 yay5 yay6 "; @@ -488,7 +488,7 @@ %! assert (__prog_output_assert__ (key)); ## Test persistant -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! clear functions % clear persistent variables in bytecode_persistant @@ -520,7 +520,7 @@ %! assert (__prog_output_assert__ (key)); ## Test structs -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "1 2 double 1 1 struct 3 4 "; @@ -534,7 +534,7 @@ %! assert (__prog_output_assert__ (key)); ## Test indexing chained objects and strange indexing -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "2 2 3 3 2 cell 1 1 3 3 2 3 22 double 33 3 4 matlab.lang.MemoizedFunction 2 "; @@ -548,7 +548,7 @@ %! assert (__prog_output_assert__ (key)); ## Test varargout -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "7 8 1 1 2 1 0 0 0 1 0 1 0 0 0 1 0 "; @@ -562,7 +562,7 @@ %! assert (__prog_output_assert__ (key)); ## Test inputname -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "a a b + 1 a a b b aa aa bb bb aa + 1 bb * 3 a + 1 b * 3 aa aa bb bb aa + 1 bb * 3 a a b b a + 1 b * 3 "; @@ -577,7 +577,7 @@ %! assert (__prog_output_assert__ (key)); ## Test ans -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "2 5 1 1 1 "; @@ -591,7 +591,7 @@ %! assert (__prog_output_assert__ (key)); ## Test using classdef -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! global cdef_foo_ctor_cnt; clear global cdef_foo_ctor_cnt; @@ -618,7 +618,7 @@ %! clear global __assert_printf__ ## Test anonymous function handles -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "1 2 12 3 4 4 4 1 2 3 1 2 3 1 2 1 2 11 12 11 12 1 4 4 1 1 1 2 1 2 1 2 3 1 2 3 1 3 1 3 9 0 1 fooo ~101 103 ~101 103 ~110 123 ~101 123 ~010 123 ~000 123 ~011 123 "; @@ -637,7 +637,7 @@ ## Test compling a function named differently from its ## m-file -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! clear all %! __vm_enable__ (1, "local"); %! __vm_compile__ wrongname_fn clear; @@ -646,14 +646,14 @@ %! assert (wrongname_fn (77) == 78); ## Test some misc stuff -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! clear all %! __vm_enable__ (1, "local"); %! %! bytecode_misc; % asserts inernally ## Leak check -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! clear all %! __vm_enable__ (1, "local"); %! @@ -667,7 +667,7 @@ %! assert (n_d == __ref_count__ (d)) ## Test scripts -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! __vm_enable__ (0, "local"); %! clear all %! key = "0 1 3 4 5 3 "; @@ -681,7 +681,7 @@ %! assert (__prog_output_assert__ (key)); ## Test nested functions. -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! global cdef_bar_cnt %! cdef_bar_cnt = 0; %! @@ -701,7 +701,7 @@ %! clear -global cdef_bar_alive_objs cdef_bar_cnt glb_d glb_e glb_f ## Test script interaction when called from top scope -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! %! __vm_enable__ (0, "local"); %! clear all @@ -788,7 +788,7 @@ %! clear bytecode_script_topscope_cli_fn ## Test save() and load() from scripts. -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! clear all %! %! for use_vm = [true, false] % Test with and without VM diff --git a/test/compile/shutup_operator_test/bytecode_disp.tst b/test/compile/shutup_operator_test/bytecode_disp.tst --- a/test/compile/shutup_operator_test/bytecode_disp.tst +++ b/test/compile/shutup_operator_test/bytecode_disp.tst @@ -4,7 +4,7 @@ ## in its own folder to not mess double up for the other ## tests. -%!test +%!testif ENABLE_BYTECODE_EVALUATOR %! % Overloading of class-methods seems to stick so we need to clear them since we overload %! % double's display. Is this a bug ??? %! clear classes