Mercurial > octave
changeset 25380:61ba501d8f04 stable
back out changes attempting to automatically call handle class destructor
These changes proved to cause too much trouble for stable. Making
Octave call destructors for handle class objects will have to be done
on the default branch.
The following changesets on the stable branch were backed out:
changeset: b328ff3ce0f7
user: Piotr Held <pjheld@gmail.com>
date: Thu Nov 02 10:27:11 2017 -0700
summary: call delete method for handle class objects (bug #46497)
changeset: 2205c0ca02e7
parent: 0548e32e6b27
user: John W. Eaton <jwe@octave.org>
date: Fri May 11 16:46:27 2018 -0400
summary: improve test for handle class destructor
changeset: 97f1d513aaf6
parent: 2205c0ca02e7
user: John W. Eaton <jwe@octave.org>
date: Mon May 14 14:47:19 2018 -0400
summary: defer deletion of temporaries in argument lists (bug #53844)
changeset: 2f3a66d7cf8a
parent: c8f49ee7a687
user: John W. Eaton <jwe@octave.org>
date: Mon May 14 20:41:59 2018 -0400
summary: also preserve temporaries in indexing expressions (bug #53844)
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 15 May 2018 14:53:41 -0400 |
parents | 8e30ef611002 |
children | 072494014e76 2b0680bdb1ed |
files | libinterp/parse-tree/pt-arg-list.cc libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-eval.h test/bug-46497/bug-46497.tst test/bug-46497/class_bug46497.m test/bug-46497/module.mk test/module.mk |
diffstat | 7 files changed, 3 insertions(+), 137 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-arg-list.cc Tue May 15 11:46:25 2018 -0700 +++ b/libinterp/parse-tree/pt-arg-list.cc Tue May 15 14:53:41 2018 -0400 @@ -247,29 +247,12 @@ if (elt) { - bool is_assignment = elt->is_assignment_expression (); - octave_value tmp = tw->evaluate (elt); if (tmp.is_cs_list ()) args.push_back (tmp.list_value ()); else if (tmp.is_defined ()) - { - args.push_back (tmp); - - // Defer deletion of any temporary values until the end - // of the containing statement. That way destructors - // for temporary classdef handle objects will be called - // when it is safe to do so. - // - // FIXME: We could further limit this action to classdef - // handle objects, but we don't currently have an - // octave_value predicate for that so should add it on - // the default branch, not stable. - - if (! is_assignment) - tw->defer_deletion (tmp); - } + args.push_back (tmp); } else {
--- a/libinterp/parse-tree/pt-eval.cc Tue May 15 11:46:25 2018 -0700 +++ b/libinterp/parse-tree/pt-eval.cc Tue May 15 14:53:41 2018 -0400 @@ -81,7 +81,6 @@ m_result_type = RT_UNDEFINED; m_expr_result_value = octave_value (); m_expr_result_value_list = octave_value_list (); - m_deferred_delete_stack.clear (); m_lvalue_list_stack.clear (); m_nargout_stack.clear (); } @@ -1370,16 +1369,6 @@ if (base_expr_val.is_undefined ()) base_expr_val = evaluate (expr); - // Defer deletion of any temporary values until the end of the - // containing statement. That way destructors for temporary - // classdef handle objects will be called when it is safe to do so. - // - // FIXME: We could further limit this action to classdef handle - // objects, but we don't currently have an octave_value predicate for - // that so should add it on the default branch, not stable. - - defer_deletion (base_expr_val); - // If we are indexing an object or looking at something like // // classname.static_function (args, ...); @@ -2281,13 +2270,6 @@ cmd->accept (*this); else { - unwind_protect frame; - - frame.add_method (m_deferred_delete_stack, - &deferred_delete_stack::pop_frame); - - m_deferred_delete_stack.mark (); - if (m_echo_state) { size_t line = stmt.line ();
--- a/libinterp/parse-tree/pt-eval.h Tue May 15 11:46:25 2018 -0700 +++ b/libinterp/parse-tree/pt-eval.h Tue May 15 14:53:41 2018 -0400 @@ -67,54 +67,6 @@ ECHO_ALL = 4 }; - class deferred_delete_stack - { - public: - - deferred_delete_stack (void) = default; - - deferred_delete_stack (const deferred_delete_stack&) = default; - - deferred_delete_stack& operator = (const deferred_delete_stack&) = default; - - ~deferred_delete_stack (void) = default; - - // An undefined value on the stack marks the boundary of the - // current frame. - - void mark (void) { push (octave_value ()); } - - void push (const octave_value& val) { m_stack.push (val); } - - void pop_frame (void) - { - while (! m_stack.empty ()) - { - octave_value val = val_pop (); - - if (val.is_undefined ()) - break; - } - } - - void clear (void) - { - while (! m_stack.empty ()) - m_stack.pop (); - } - - private: - - std::stack<octave_value> m_stack; - - octave_value val_pop (void) - { - octave_value retval = m_stack.top (); - m_stack.pop (); - return retval; - } - }; - template <typename T> class value_stack { @@ -173,8 +125,8 @@ tree_evaluator (interpreter& interp) : m_interpreter (interp), m_result_type (RT_UNDEFINED), m_expr_result_value (), m_expr_result_value_list (), - m_deferred_delete_stack (), m_lvalue_list_stack (), - m_nargout_stack (), m_call_stack (interp), m_profiler (), + m_lvalue_list_stack (), m_nargout_stack (), + m_call_stack (interp), m_profiler (), m_max_recursion_depth (256), m_silent_functions (false), m_string_fill_char (' '), m_PS4 ("+ "), m_echo (ECHO_OFF), m_echo_state (false), m_echo_file_name (), m_echo_file_pos (1), @@ -315,11 +267,6 @@ // TRUE means we are evaluating some kind of looping construct. static bool in_loop_command; - void defer_deletion (const octave_value& val) - { - m_deferred_delete_stack.push (val); - } - Matrix ignored_fcn_outputs (void) const; bool isargout (int nargout, int iout) const; @@ -540,8 +487,6 @@ octave_value m_expr_result_value; octave_value_list m_expr_result_value_list; - deferred_delete_stack m_deferred_delete_stack; - value_stack<const std::list<octave_lvalue>*> m_lvalue_list_stack; value_stack<int> m_nargout_stack;
--- a/test/bug-46497/bug-46497.tst Tue May 15 11:46:25 2018 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -## Copyright (C) 2017 Piotr Held -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or -## (at your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -%!test -%! global __bug46497_global__ -%! __bug46497_global__ = "test_bug46497"; -%! a = class_bug46497 (13); -%! a = []; -%! assert(__bug46497_global__, struct ("myprop", 13, "status", "deleted"));
--- a/test/bug-46497/class_bug46497.m Tue May 15 11:46:25 2018 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -classdef class_bug46497 < handle - properties - myprop; - endproperties - methods - function obj = class_bug46497 (x) - obj.myprop = x; - endfunction - function delete (self) - global __bug46497_global__ - __bug46497_global__ = struct ("myprop", self.myprop, "status", "deleted"); - endfunction - endmethods -endclassdef
--- a/test/bug-46497/module.mk Tue May 15 11:46:25 2018 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -bug_46497_TEST_FILES = \ - %reldir%/bug-46497.tst \ - %reldir%/class_bug46497.m - -TEST_FILES += $(bug_46497_TEST_FILES)
--- a/test/module.mk Tue May 15 11:46:25 2018 -0700 +++ b/test/module.mk Tue May 15 14:53:41 2018 -0400 @@ -56,7 +56,6 @@ include %reldir%/bug-38691/module.mk include %reldir%/bug-41723/module.mk include %reldir%/bug-44940/module.mk -include %reldir%/bug-46497/module.mk include %reldir%/bug-46660/module.mk include %reldir%/bug-49379/module.mk include %reldir%/bug-50014/module.mk