Mercurial > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
15602:f3e339aee38f | 15603:44272909d926 |
---|---|
1174 const jit_function& overload (void) const | 1174 const jit_function& overload (void) const |
1175 { | 1175 { |
1176 return moperation.overload (argument_types ()); | 1176 return moperation.overload (argument_types ()); |
1177 } | 1177 } |
1178 | 1178 |
1179 virtual bool needs_release (void) const | 1179 virtual bool needs_release (void) const; |
1180 { | |
1181 return type () && jit_typeinfo::get_release (type ()).valid (); | |
1182 } | |
1183 | 1180 |
1184 virtual std::ostream& print (std::ostream& os, size_t indent = 0) const | 1181 virtual std::ostream& print (std::ostream& os, size_t indent = 0) const |
1185 { | 1182 { |
1186 print_indent (os, indent); | 1183 print_indent (os, indent); |
1187 | 1184 |
1210 // otherwise goto the error branch | 1207 // otherwise goto the error branch |
1211 class | 1208 class |
1212 jit_error_check : public jit_terminator | 1209 jit_error_check : public jit_terminator |
1213 { | 1210 { |
1214 public: | 1211 public: |
1215 jit_error_check (jit_call *acheck_for, jit_block *normal, jit_block *error) | 1212 // Which variable is the error check for? |
1216 : jit_terminator (2, error, normal, acheck_for) {} | 1213 enum variable |
1214 { | |
1215 var_error_state, | |
1216 var_interrupt | |
1217 }; | |
1218 | |
1219 static std::string variable_to_string (variable v); | |
1220 | |
1221 jit_error_check (variable var, jit_call *acheck_for, jit_block *normal, | |
1222 jit_block *error) | |
1223 : jit_terminator (2, error, normal, acheck_for), mvariable (var) {} | |
1224 | |
1225 jit_error_check (variable var, jit_block *normal, jit_block *error) | |
1226 : jit_terminator (2, error, normal), mvariable (var) {} | |
1227 | |
1228 variable check_variable (void) const { return mvariable; } | |
1229 | |
1230 bool has_check_for (void) const | |
1231 { | |
1232 return argument_count () == 3; | |
1233 } | |
1217 | 1234 |
1218 jit_call *check_for (void) const | 1235 jit_call *check_for (void) const |
1219 { | 1236 { |
1237 assert (has_check_for ()); | |
1220 return static_cast<jit_call *> (argument (2)); | 1238 return static_cast<jit_call *> (argument (2)); |
1221 } | 1239 } |
1222 | 1240 |
1223 virtual std::ostream& print (std::ostream& os, size_t indent = 0) const | 1241 virtual std::ostream& print (std::ostream& os, size_t indent = 0) const; |
1224 { | |
1225 print_indent (os, indent) << "error_check " << *check_for () << ", "; | |
1226 print_successor (os, 1) << ", "; | |
1227 return print_successor (os, 0); | |
1228 } | |
1229 | 1242 |
1230 JIT_VALUE_ACCEPT; | 1243 JIT_VALUE_ACCEPT; |
1231 protected: | 1244 protected: |
1232 virtual bool check_alive (size_t idx) const | 1245 virtual bool check_alive (size_t idx) const |
1233 { | 1246 { |
1247 if (! has_check_for ()) | |
1248 return true; | |
1234 return idx == 1 ? true : check_for ()->can_error (); | 1249 return idx == 1 ? true : check_for ()->can_error (); |
1235 } | 1250 } |
1251 private: | |
1252 variable mvariable; | |
1236 }; | 1253 }; |
1237 | 1254 |
1238 // for now only handles the 1D case | 1255 // for now only handles the 1D case |
1239 class | 1256 class |
1240 jit_magic_end : public jit_instruction | 1257 jit_magic_end : public jit_instruction |