comparison libinterp/interp-core/jit-ir.cc @ 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
696 return llvm::cast<llvm::TerminatorInst> (jit_value::to_llvm ()); 696 return llvm::cast<llvm::TerminatorInst> (jit_value::to_llvm ());
697 } 697 }
698 698
699 // -------------------- jit_call -------------------- 699 // -------------------- jit_call --------------------
700 bool 700 bool
701 jit_call::needs_release (void) const
702 {
703 if (type () && jit_typeinfo::get_release (type ()).valid ())
704 {
705 for (jit_use *use = first_use (); use; use = use->next ())
706 {
707 jit_assign *assign = dynamic_cast<jit_assign *> (use->user ());
708 if (assign && assign->artificial ())
709 return false;
710 }
711
712 return true;
713 }
714 return false;
715 }
716
717 bool
701 jit_call::infer (void) 718 jit_call::infer (void)
702 { 719 {
703 // FIXME: explain algorithm 720 // FIXME: explain algorithm
704 for (size_t i = 0; i < argument_count (); ++i) 721 for (size_t i = 0; i < argument_count (); ++i)
705 { 722 {
722 stash_type (infered); 739 stash_type (infered);
723 return true; 740 return true;
724 } 741 }
725 742
726 return false; 743 return false;
744 }
745
746 // -------------------- jit_error_check --------------------
747 std::string
748 jit_error_check::variable_to_string (variable v)
749 {
750 switch (v)
751 {
752 case var_error_state:
753 return "error_state";
754 case var_interrupt:
755 return "interrupt";
756 default:
757 panic_impossible ();
758 }
759 }
760
761 std::ostream&
762 jit_error_check::print (std::ostream& os, size_t indent) const
763 {
764 print_indent (os, indent) << "error_check " << variable_to_string (mvariable)
765 << ", ";
766
767 if (has_check_for ())
768 os << "<for> " << *check_for () << ", ";
769 print_successor (os << "<normal> ", 1) << ", ";
770 return print_successor (os << "<error> ", 0);
727 } 771 }
728 772
729 // -------------------- jit_magic_end -------------------- 773 // -------------------- jit_magic_end --------------------
730 jit_magic_end::context::context (jit_factory& factory, jit_value *avalue, 774 jit_magic_end::context::context (jit_factory& factory, jit_value *avalue,
731 size_t aindex, size_t acount) 775 size_t aindex, size_t acount)