diff libinterp/interp-core/jit-ir.h @ 15603:44272909d926

Stop JIT on interrupt * jit-ir.cc (jit_call::needs_release): Move to cc file and do not release artificial assigns. (jit_error_check::variable_to_strign): New function. (jit_error_check::print): Move to cc file and improve output. * jit-ir.h (jit_call::needs_release): Move to cc file. (jit_error_check::variable): New enum. (jit_error_check::variable_to_string): New declaration. (jit_error_check::jit_error_check): Add variable argument and new overload. (jit_error_check::check_variable, jit_error_check::has_check_for): New function. (jit_error_check::check_for): Ensure has_check_for is true. (jit_error_check::print): Move to cc file. (jit_error_check::check_alive): Always true if has_check_for is false. (jit_error_check::mvariable): New variable. * jit-typeinfo.cc (jit_typeinfo::jit_typeinfo): Initialize loctave_interrupt_state and fix name of cast to any. (jit_typeinfo::do_insert_interrupt_check): New function. * jit-typeinfo.h (jit_typeinfo::insert_interrupt_check): New function. (jit_typeinfo::do_insert_interrupt_check): New declaration. (jit_typeinfo::loctave_interrupt_state): New variable. * pt-jit.cc (jit_convert::visit_simple_for_command, jit_convert::visit_while_command): Check interrupt state. (jit_convert::create_check_impl): Specify var_error_state check. (jit_convert_llvm::visit): Generate var_interrupt error check. (jit_function_info::execute, jit_info::execute): Call octave_quit.
author Max Brister <max@2bass.com>
date Sun, 04 Nov 2012 21:11:33 -0700
parents f3e339aee38f
children e2de3c8882be
line wrap: on
line diff
--- a/libinterp/interp-core/jit-ir.h
+++ b/libinterp/interp-core/jit-ir.h
@@ -1176,10 +1176,7 @@
     return moperation.overload (argument_types ());
   }
 
-  virtual bool needs_release (void) const
-  {
-    return type () && jit_typeinfo::get_release (type ()).valid ();
-  }
+  virtual bool needs_release (void) const;
 
   virtual std::ostream& print (std::ostream& os, size_t indent = 0) const
   {
@@ -1212,27 +1209,47 @@
 jit_error_check : public jit_terminator
 {
 public:
-  jit_error_check (jit_call *acheck_for, jit_block *normal, jit_block *error)
-    : jit_terminator (2, error, normal, acheck_for) {}
+  // Which variable is the error check for?
+  enum variable
+    {
+      var_error_state,
+      var_interrupt
+    };
+
+  static std::string variable_to_string (variable v);
+
+  jit_error_check (variable var, jit_call *acheck_for, jit_block *normal,
+                   jit_block *error)
+    : jit_terminator (2, error, normal, acheck_for), mvariable (var) {}
+
+  jit_error_check (variable var, jit_block *normal, jit_block *error)
+    : jit_terminator (2, error, normal), mvariable (var) {}
+
+  variable check_variable (void) const { return mvariable; }
+
+  bool has_check_for (void) const
+  {
+    return argument_count () == 3;
+  }
 
   jit_call *check_for (void) const
   {
+    assert (has_check_for ());
     return static_cast<jit_call *> (argument (2));
   }
 
-  virtual std::ostream& print (std::ostream& os, size_t indent = 0) const
-  {
-    print_indent (os, indent) << "error_check " << *check_for () << ", ";
-    print_successor (os, 1) << ", ";
-    return print_successor (os, 0);
-  }
+  virtual std::ostream& print (std::ostream& os, size_t indent = 0) const;
 
   JIT_VALUE_ACCEPT;
 protected:
   virtual bool check_alive (size_t idx) const
   {
+    if (! has_check_for ())
+      return true;
     return idx == 1 ? true : check_for ()->can_error ();
   }
+private:
+  variable mvariable;
 };
 
 // for now only handles the 1D case