src/share/vm/oops/method.cpp

Print this page




 877   // so making them eagerly shouldn't be too expensive.
 878   AdapterHandlerEntry* adapter = AdapterHandlerLibrary::get_adapter(mh);
 879   if (adapter == NULL ) {
 880     THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(), "out of space in CodeCache for adapters");
 881   }
 882 
 883   mh->set_adapter_entry(adapter);
 884   mh->_from_compiled_entry = adapter->get_c2i_entry();
 885   return adapter->get_c2i_entry();
 886 }
 887 
 888 // The verified_code_entry() must be called when a invoke is resolved
 889 // on this method.
 890 
 891 // It returns the compiled code entry point, after asserting not null.
 892 // This function is called after potential safepoints so that nmethod
 893 // or adapter that it points to is still live and valid.
 894 // This function must not hit a safepoint!
 895 address Method::verified_code_entry() {
 896   debug_only(No_Safepoint_Verifier nsv;)
 897   nmethod *code = (nmethod *)OrderAccess::load_ptr_acquire(&_code);
 898   if (code == NULL && UseCodeCacheFlushing) {
 899     nmethod *saved_code = CodeCache::reanimate_saved_code(this);
 900     if (saved_code != NULL) {
 901       methodHandle method(this);
 902       assert( ! saved_code->is_osr_method(), "should not get here for osr" );
 903       set_code( method, saved_code );
 904     }
 905   }
 906 
 907   assert(_from_compiled_entry != NULL, "must be set");
 908   return _from_compiled_entry;
 909 }
 910 
 911 // Check that if an nmethod ref exists, it has a backlink to this or no backlink at all
 912 // (could be racing a deopt).
 913 // Not inline to avoid circular ref.
 914 bool Method::check_code() const {
 915   // cached in a register or local.  There's a race on the value of the field.
 916   nmethod *code = (nmethod *)OrderAccess::load_ptr_acquire(&_code);
 917   return code == NULL || (code->method() == NULL) || (code->method() == (Method*)this && !code->is_osr_method());
 918 }
 919 
 920 // Install compiled code.  Instantly it can execute.
 921 void Method::set_code(methodHandle mh, nmethod *code) {
 922   assert( code, "use clear_code to remove code" );
 923   assert( mh->check_code(), "" );
 924 
 925   guarantee(mh->adapter() != NULL, "Adapter blob must already exist!");
 926 




 877   // so making them eagerly shouldn't be too expensive.
 878   AdapterHandlerEntry* adapter = AdapterHandlerLibrary::get_adapter(mh);
 879   if (adapter == NULL ) {
 880     THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(), "out of space in CodeCache for adapters");
 881   }
 882 
 883   mh->set_adapter_entry(adapter);
 884   mh->_from_compiled_entry = adapter->get_c2i_entry();
 885   return adapter->get_c2i_entry();
 886 }
 887 
 888 // The verified_code_entry() must be called when a invoke is resolved
 889 // on this method.
 890 
 891 // It returns the compiled code entry point, after asserting not null.
 892 // This function is called after potential safepoints so that nmethod
 893 // or adapter that it points to is still live and valid.
 894 // This function must not hit a safepoint!
 895 address Method::verified_code_entry() {
 896   debug_only(No_Safepoint_Verifier nsv;)










 897   assert(_from_compiled_entry != NULL, "must be set");
 898   return _from_compiled_entry;
 899 }
 900 
 901 // Check that if an nmethod ref exists, it has a backlink to this or no backlink at all
 902 // (could be racing a deopt).
 903 // Not inline to avoid circular ref.
 904 bool Method::check_code() const {
 905   // cached in a register or local.  There's a race on the value of the field.
 906   nmethod *code = (nmethod *)OrderAccess::load_ptr_acquire(&_code);
 907   return code == NULL || (code->method() == NULL) || (code->method() == (Method*)this && !code->is_osr_method());
 908 }
 909 
 910 // Install compiled code.  Instantly it can execute.
 911 void Method::set_code(methodHandle mh, nmethod *code) {
 912   assert( code, "use clear_code to remove code" );
 913   assert( mh->check_code(), "" );
 914 
 915   guarantee(mh->adapter() != NULL, "Adapter blob must already exist!");
 916