731 // Not necessarily sorted and not necessarily one-to-one. 732 CompressedLineNumberReadStream stream(compressed_linenumber_table()); 733 while (stream.read_pair()) { 734 if (stream.bci() == bci) { 735 // perfect match 736 return stream.line(); 737 } else { 738 // update best_bci/line 739 if (stream.bci() < bci && stream.bci() >= best_bci) { 740 best_bci = stream.bci(); 741 best_line = stream.line(); 742 } 743 } 744 } 745 } 746 return best_line; 747 } 748 749 750 bool Method::is_klass_loaded_by_klass_index(int klass_index) const { 751 if( constants()->tag_at(klass_index).is_unresolved_klass() || 752 constants()->tag_at(klass_index).is_unresolved_value_type() ) { 753 Thread *thread = Thread::current(); 754 Symbol* klass_name = constants()->klass_name_at(klass_index); 755 Handle loader(thread, method_holder()->class_loader()); 756 Handle prot (thread, method_holder()->protection_domain()); 757 return SystemDictionary::find(klass_name, loader, prot, thread) != NULL; 758 } else { 759 return true; 760 } 761 } 762 763 764 bool Method::is_klass_loaded(int refinfo_index, bool must_be_resolved) const { 765 int klass_index = constants()->klass_ref_index_at(refinfo_index); 766 if (must_be_resolved) { 767 // Make sure klass is resolved in constantpool. 768 if (constants()->tag_at(klass_index).is_unresolved_klass() || 769 constants()->tag_at(klass_index).is_unresolved_value_type()) { 770 return false; 771 } 772 } 773 return is_klass_loaded_by_klass_index(klass_index); 774 } 775 776 777 void Method::set_native_function(address function, bool post_event_flag) { 778 assert(function != NULL, "use clear_native_function to unregister natives"); 779 assert(!is_method_handle_intrinsic() || function == SharedRuntime::native_method_throw_unsatisfied_link_error_entry(), ""); 780 address* native_function = native_function_addr(); 781 782 // We can see racers trying to place the same native function into place. Once 783 // is plenty. 784 address current = *native_function; 785 if (current == function) return; 786 if (post_event_flag && JvmtiExport::should_post_native_method_bind() && 787 function != NULL) { 788 // native_method_throw_unsatisfied_link_error_entry() should only 789 // be passed when post_event_flag is false. | 731 // Not necessarily sorted and not necessarily one-to-one. 732 CompressedLineNumberReadStream stream(compressed_linenumber_table()); 733 while (stream.read_pair()) { 734 if (stream.bci() == bci) { 735 // perfect match 736 return stream.line(); 737 } else { 738 // update best_bci/line 739 if (stream.bci() < bci && stream.bci() >= best_bci) { 740 best_bci = stream.bci(); 741 best_line = stream.line(); 742 } 743 } 744 } 745 } 746 return best_line; 747 } 748 749 750 bool Method::is_klass_loaded_by_klass_index(int klass_index) const { 751 if( constants()->tag_at(klass_index).is_unresolved_klass()) { 752 Thread *thread = Thread::current(); 753 Symbol* klass_name = constants()->klass_name_at(klass_index); 754 Handle loader(thread, method_holder()->class_loader()); 755 Handle prot (thread, method_holder()->protection_domain()); 756 return SystemDictionary::find(klass_name, loader, prot, thread) != NULL; 757 } else { 758 return true; 759 } 760 } 761 762 763 bool Method::is_klass_loaded(int refinfo_index, bool must_be_resolved) const { 764 int klass_index = constants()->klass_ref_index_at(refinfo_index); 765 if (must_be_resolved) { 766 // Make sure klass is resolved in constantpool. 767 if (constants()->tag_at(klass_index).is_unresolved_klass()) { 768 return false; 769 } 770 } 771 return is_klass_loaded_by_klass_index(klass_index); 772 } 773 774 775 void Method::set_native_function(address function, bool post_event_flag) { 776 assert(function != NULL, "use clear_native_function to unregister natives"); 777 assert(!is_method_handle_intrinsic() || function == SharedRuntime::native_method_throw_unsatisfied_link_error_entry(), ""); 778 address* native_function = native_function_addr(); 779 780 // We can see racers trying to place the same native function into place. Once 781 // is plenty. 782 address current = *native_function; 783 if (current == function) return; 784 if (post_event_flag && JvmtiExport::should_post_native_method_bind() && 785 function != NULL) { 786 // native_method_throw_unsatisfied_link_error_entry() should only 787 // be passed when post_event_flag is false. |