52 _mark_for_deoptimization_status(not_marked), 53 _method(method), 54 _gc_data(NULL) 55 { 56 init_defaults(); 57 } 58 59 CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, int size, 60 int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, 61 OopMapSet* oop_maps, bool caller_must_gc_arguments) 62 : CodeBlob(name, type, CodeBlobLayout((address) this, size, header_size, cb), cb, 63 frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments), 64 _mark_for_deoptimization_status(not_marked), 65 _method(method), 66 _gc_data(NULL) 67 { 68 init_defaults(); 69 } 70 71 void CompiledMethod::init_defaults() { 72 _has_unsafe_access = 0; 73 _has_method_handle_invokes = 0; 74 _lazy_critical_native = 0; 75 _has_wide_vectors = 0; 76 } 77 78 bool CompiledMethod::is_method_handle_return(address return_pc) { 79 if (!has_method_handle_invokes()) return false; 80 PcDesc* pd = pc_desc_at(return_pc); 81 if (pd == NULL) 82 return false; 83 return pd->is_method_handle_invoke(); 84 } 85 86 // Returns a string version of the method state. 87 const char* CompiledMethod::state() const { 88 int state = get_state(); 89 switch (state) { 90 case not_installed: 91 return "not installed"; 675 Method* method = static_cast<Method*>(md); 676 if (!method->method_holder()->is_loader_alive()) { 677 Atomic::store(r->metadata_addr(), (Method*)NULL); 678 679 if (!r->metadata_is_immediate()) { 680 r->fix_metadata_relocation(); 681 } 682 } 683 } 684 break; 685 } 686 687 default: 688 break; 689 } 690 } 691 692 return true; 693 } 694 695 // Iterating over all nmethods, e.g. with the help of CodeCache::nmethods_do(fun) was found 696 // to not be inherently safe. There is a chance that fields are seen which are not properly 697 // initialized. This happens despite the fact that nmethods_do() asserts the CodeCache_lock 698 // to be held. 699 // To bundle knowledge about necessary checks in one place, this function was introduced. 700 // It is not claimed that these checks are sufficient, but they were found to be necessary. 701 bool CompiledMethod::nmethod_access_is_safe(nmethod* nm) { 702 Method* method = (nm == NULL) ? NULL : nm->method(); // nm->method() may be uninitialized, i.e. != NULL, but invalid 703 return (nm != NULL) && (method != NULL) && (method->signature() != NULL) && 704 !nm->is_zombie() && !nm->is_not_installed() && 705 os::is_readable_pointer(method) && 706 os::is_readable_pointer(method->constants()) && 707 os::is_readable_pointer(method->signature()); 708 } 709 710 address CompiledMethod::continuation_for_implicit_exception(address pc, bool for_div0_check) { 711 // Exception happened outside inline-cache check code => we are inside 712 // an active nmethod => use cpc to determine a return address 713 int exception_offset = pc - code_begin(); 714 int cont_offset = ImplicitExceptionTable(this).continuation_offset( exception_offset ); 715 #ifdef ASSERT 716 if (cont_offset == 0) { 717 Thread* thread = Thread::current(); 718 ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY 719 HandleMark hm(thread); 720 ResourceMark rm(thread); 721 CodeBlob* cb = CodeCache::find_blob(pc); 722 assert(cb != NULL && cb == this, ""); 723 ttyLocker ttyl; 724 tty->print_cr("implicit exception happened at " INTPTR_FORMAT, p2i(pc)); 725 print(); 726 method()->print_codes(); 727 print_code(); 728 print_pcs(); 729 } | 52 _mark_for_deoptimization_status(not_marked), 53 _method(method), 54 _gc_data(NULL) 55 { 56 init_defaults(); 57 } 58 59 CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, int size, 60 int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, 61 OopMapSet* oop_maps, bool caller_must_gc_arguments) 62 : CodeBlob(name, type, CodeBlobLayout((address) this, size, header_size, cb), cb, 63 frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments), 64 _mark_for_deoptimization_status(not_marked), 65 _method(method), 66 _gc_data(NULL) 67 { 68 init_defaults(); 69 } 70 71 void CompiledMethod::init_defaults() { 72 { // avoid uninitialized fields, even for short time periods 73 _is_far_code = false; 74 _scopes_data_begin = NULL; 75 _deopt_handler_begin = NULL; 76 _deopt_mh_handler_begin = NULL; 77 _exception_cache = NULL; 78 } 79 _has_unsafe_access = 0; 80 _has_method_handle_invokes = 0; 81 _lazy_critical_native = 0; 82 _has_wide_vectors = 0; 83 } 84 85 bool CompiledMethod::is_method_handle_return(address return_pc) { 86 if (!has_method_handle_invokes()) return false; 87 PcDesc* pd = pc_desc_at(return_pc); 88 if (pd == NULL) 89 return false; 90 return pd->is_method_handle_invoke(); 91 } 92 93 // Returns a string version of the method state. 94 const char* CompiledMethod::state() const { 95 int state = get_state(); 96 switch (state) { 97 case not_installed: 98 return "not installed"; 682 Method* method = static_cast<Method*>(md); 683 if (!method->method_holder()->is_loader_alive()) { 684 Atomic::store(r->metadata_addr(), (Method*)NULL); 685 686 if (!r->metadata_is_immediate()) { 687 r->fix_metadata_relocation(); 688 } 689 } 690 } 691 break; 692 } 693 694 default: 695 break; 696 } 697 } 698 699 return true; 700 } 701 702 address CompiledMethod::continuation_for_implicit_exception(address pc, bool for_div0_check) { 703 // Exception happened outside inline-cache check code => we are inside 704 // an active nmethod => use cpc to determine a return address 705 int exception_offset = pc - code_begin(); 706 int cont_offset = ImplicitExceptionTable(this).continuation_offset( exception_offset ); 707 #ifdef ASSERT 708 if (cont_offset == 0) { 709 Thread* thread = Thread::current(); 710 ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY 711 HandleMark hm(thread); 712 ResourceMark rm(thread); 713 CodeBlob* cb = CodeCache::find_blob(pc); 714 assert(cb != NULL && cb == this, ""); 715 ttyLocker ttyl; 716 tty->print_cr("implicit exception happened at " INTPTR_FORMAT, p2i(pc)); 717 print(); 718 method()->print_codes(); 719 print_code(); 720 print_pcs(); 721 } |