< prev index next >

src/hotspot/share/oops/method.cpp

Print this page
rev 47400 : [mq]: cmpxchg_ptr
rev 47401 : [mq]: cmpxchg_if_null
rev 47404 : [mq]: load_ptr_acquire


 427   }
 428 
 429   methodHandle mh(m);
 430   MethodCounters* counters = MethodCounters::allocate(mh, THREAD);
 431   if (HAS_PENDING_EXCEPTION) {
 432     CompileBroker::log_metaspace_failure();
 433     ClassLoaderDataGraph::set_metaspace_oom(true);
 434     return NULL;   // return the exception (which is cleared)
 435   }
 436   if (!mh->init_method_counters(counters)) {
 437     MetadataFactory::free_metadata(mh->method_holder()->class_loader_data(), counters);
 438   }
 439 
 440   if (LogTouchedMethods) {
 441     mh->log_touched(CHECK_NULL);
 442   }
 443 
 444   return mh->method_counters();
 445 }
 446 





 447 void Method::cleanup_inline_caches() {
 448   // The current system doesn't use inline caches in the interpreter
 449   // => nothing to do (keep this method around for future use)
 450 }
 451 
 452 
 453 int Method::extra_stack_words() {
 454   // not an inline function, to avoid a header dependency on Interpreter
 455   return extra_stack_entries() * Interpreter::stackElementSize;
 456 }
 457 
 458 
 459 void Method::compute_size_of_parameters(Thread *thread) {
 460   ArgumentSizeComputer asc(signature());
 461   set_size_of_parameters(asc.size() + (is_static() ? 0 : 1));
 462 }
 463 
 464 BasicType Method::result_type() const {
 465   ResultTypeFinder rtf(signature());
 466   return rtf.type();


1092     assert(mh->_from_compiled_entry != NULL, "must be");
1093   } else {
1094     mh->set_adapter_entry(adapter);
1095     mh->_from_compiled_entry = adapter->get_c2i_entry();
1096   }
1097   return adapter->get_c2i_entry();
1098 }
1099 
1100 void Method::restore_unshareable_info(TRAPS) {
1101   assert(is_method() && is_valid_method(), "ensure C++ vtable is restored");
1102 
1103   // Since restore_unshareable_info can be called more than once for a method, don't
1104   // redo any work.
1105   if (adapter() == NULL) {
1106     methodHandle mh(THREAD, this);
1107     link_method(mh, CHECK);
1108   }
1109 }
1110 
1111 volatile address Method::from_compiled_entry_no_trampoline() const {
1112   nmethod *code = (nmethod *)OrderAccess::load_ptr_acquire(&_code);
1113   if (code) {
1114     return code->verified_entry_point();
1115   } else {
1116     return adapter()->get_c2i_entry();
1117   }
1118 }
1119 
1120 // The verified_code_entry() must be called when a invoke is resolved
1121 // on this method.
1122 
1123 // It returns the compiled code entry point, after asserting not null.
1124 // This function is called after potential safepoints so that nmethod
1125 // or adapter that it points to is still live and valid.
1126 // This function must not hit a safepoint!
1127 address Method::verified_code_entry() {
1128   debug_only(NoSafepointVerifier nsv;)
1129   assert(_from_compiled_entry != NULL, "must be set");
1130   return _from_compiled_entry;
1131 }
1132 
1133 // Check that if an nmethod ref exists, it has a backlink to this or no backlink at all
1134 // (could be racing a deopt).
1135 // Not inline to avoid circular ref.
1136 bool Method::check_code() const {
1137   // cached in a register or local.  There's a race on the value of the field.
1138   CompiledMethod *code = (CompiledMethod *)OrderAccess::load_ptr_acquire(&_code);
1139   return code == NULL || (code->method() == NULL) || (code->method() == (Method*)this && !code->is_osr_method());
1140 }
1141 
1142 // Install compiled code.  Instantly it can execute.
1143 void Method::set_code(const methodHandle& mh, CompiledMethod *code) {
1144   MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
1145   assert( code, "use clear_code to remove code" );
1146   assert( mh->check_code(), "" );
1147 
1148   guarantee(mh->adapter() != NULL, "Adapter blob must already exist!");
1149 
1150   // These writes must happen in this order, because the interpreter will
1151   // directly jump to from_interpreted_entry which jumps to an i2c adapter
1152   // which jumps to _from_compiled_entry.
1153   mh->_code = code;             // Assign before allowing compiled code to exec
1154 
1155   int comp_level = code->comp_level();
1156   // In theory there could be a race here. In practice it is unlikely
1157   // and not worth worrying about.
1158   if (comp_level > mh->highest_comp_level()) {




 427   }
 428 
 429   methodHandle mh(m);
 430   MethodCounters* counters = MethodCounters::allocate(mh, THREAD);
 431   if (HAS_PENDING_EXCEPTION) {
 432     CompileBroker::log_metaspace_failure();
 433     ClassLoaderDataGraph::set_metaspace_oom(true);
 434     return NULL;   // return the exception (which is cleared)
 435   }
 436   if (!mh->init_method_counters(counters)) {
 437     MetadataFactory::free_metadata(mh->method_holder()->class_loader_data(), counters);
 438   }
 439 
 440   if (LogTouchedMethods) {
 441     mh->log_touched(CHECK_NULL);
 442   }
 443 
 444   return mh->method_counters();
 445 }
 446 
 447 bool Method::init_method_counters(MethodCounters* counters) {
 448   // Try to install a pointer to MethodCounters, return true on success.
 449   return Atomic::cmpxchg_if_null(counters, &_method_counters);
 450 }
 451 
 452 void Method::cleanup_inline_caches() {
 453   // The current system doesn't use inline caches in the interpreter
 454   // => nothing to do (keep this method around for future use)
 455 }
 456 
 457 
 458 int Method::extra_stack_words() {
 459   // not an inline function, to avoid a header dependency on Interpreter
 460   return extra_stack_entries() * Interpreter::stackElementSize;
 461 }
 462 
 463 
 464 void Method::compute_size_of_parameters(Thread *thread) {
 465   ArgumentSizeComputer asc(signature());
 466   set_size_of_parameters(asc.size() + (is_static() ? 0 : 1));
 467 }
 468 
 469 BasicType Method::result_type() const {
 470   ResultTypeFinder rtf(signature());
 471   return rtf.type();


1097     assert(mh->_from_compiled_entry != NULL, "must be");
1098   } else {
1099     mh->set_adapter_entry(adapter);
1100     mh->_from_compiled_entry = adapter->get_c2i_entry();
1101   }
1102   return adapter->get_c2i_entry();
1103 }
1104 
1105 void Method::restore_unshareable_info(TRAPS) {
1106   assert(is_method() && is_valid_method(), "ensure C++ vtable is restored");
1107 
1108   // Since restore_unshareable_info can be called more than once for a method, don't
1109   // redo any work.
1110   if (adapter() == NULL) {
1111     methodHandle mh(THREAD, this);
1112     link_method(mh, CHECK);
1113   }
1114 }
1115 
1116 volatile address Method::from_compiled_entry_no_trampoline() const {
1117   CompiledMethod *code = OrderAccess::load_acquire(&_code);
1118   if (code) {
1119     return code->verified_entry_point();
1120   } else {
1121     return adapter()->get_c2i_entry();
1122   }
1123 }
1124 
1125 // The verified_code_entry() must be called when a invoke is resolved
1126 // on this method.
1127 
1128 // It returns the compiled code entry point, after asserting not null.
1129 // This function is called after potential safepoints so that nmethod
1130 // or adapter that it points to is still live and valid.
1131 // This function must not hit a safepoint!
1132 address Method::verified_code_entry() {
1133   debug_only(NoSafepointVerifier nsv;)
1134   assert(_from_compiled_entry != NULL, "must be set");
1135   return _from_compiled_entry;
1136 }
1137 
1138 // Check that if an nmethod ref exists, it has a backlink to this or no backlink at all
1139 // (could be racing a deopt).
1140 // Not inline to avoid circular ref.
1141 bool Method::check_code() const {
1142   // cached in a register or local.  There's a race on the value of the field.
1143   CompiledMethod *code = OrderAccess::load_acquire(&_code);
1144   return code == NULL || (code->method() == NULL) || (code->method() == (Method*)this && !code->is_osr_method());
1145 }
1146 
1147 // Install compiled code.  Instantly it can execute.
1148 void Method::set_code(const methodHandle& mh, CompiledMethod *code) {
1149   MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
1150   assert( code, "use clear_code to remove code" );
1151   assert( mh->check_code(), "" );
1152 
1153   guarantee(mh->adapter() != NULL, "Adapter blob must already exist!");
1154 
1155   // These writes must happen in this order, because the interpreter will
1156   // directly jump to from_interpreted_entry which jumps to an i2c adapter
1157   // which jumps to _from_compiled_entry.
1158   mh->_code = code;             // Assign before allowing compiled code to exec
1159 
1160   int comp_level = code->comp_level();
1161   // In theory there could be a race here. In practice it is unlikely
1162   // and not worth worrying about.
1163   if (comp_level > mh->highest_comp_level()) {


< prev index next >