< prev index next >

src/hotspot/share/oops/method.cpp

Print this page




1230     assert(mh->_from_compiled_entry != NULL, "must be");
1231   } else {
1232     mh->set_adapter_entry(adapter);
1233     mh->_from_compiled_entry = adapter->get_c2i_entry();
1234   }
1235   return adapter->get_c2i_entry();
1236 }
1237 
1238 void Method::restore_unshareable_info(TRAPS) {
1239   assert(is_method() && is_valid_method(this), "ensure C++ vtable is restored");
1240 
1241   // Since restore_unshareable_info can be called more than once for a method, don't
1242   // redo any work.
1243   if (adapter() == NULL) {
1244     methodHandle mh(THREAD, this);
1245     link_method(mh, CHECK);
1246   }
1247 }
1248 
1249 address Method::from_compiled_entry_no_trampoline() const {
1250   CompiledMethod *code = OrderAccess::load_acquire(&_code);
1251   if (code) {
1252     return code->verified_entry_point();
1253   } else {
1254     return adapter()->get_c2i_entry();
1255   }
1256 }
1257 
1258 // The verified_code_entry() must be called when a invoke is resolved
1259 // on this method.
1260 
1261 // It returns the compiled code entry point, after asserting not null.
1262 // This function is called after potential safepoints so that nmethod
1263 // or adapter that it points to is still live and valid.
1264 // This function must not hit a safepoint!
1265 address Method::verified_code_entry() {
1266   debug_only(NoSafepointVerifier nsv;)
1267   assert(_from_compiled_entry != NULL, "must be set");
1268   return _from_compiled_entry;
1269 }
1270 
1271 // Check that if an nmethod ref exists, it has a backlink to this or no backlink at all
1272 // (could be racing a deopt).
1273 // Not inline to avoid circular ref.
1274 bool Method::check_code() const {
1275   // cached in a register or local.  There's a race on the value of the field.
1276   CompiledMethod *code = OrderAccess::load_acquire(&_code);
1277   return code == NULL || (code->method() == NULL) || (code->method() == (Method*)this && !code->is_osr_method());
1278 }
1279 
1280 // Install compiled code.  Instantly it can execute.
1281 void Method::set_code(const methodHandle& mh, CompiledMethod *code) {
1282   assert_lock_strong(CompiledMethod_lock);
1283   assert( code, "use clear_code to remove code" );
1284   assert( mh->check_code(), "" );
1285 
1286   guarantee(mh->adapter() != NULL, "Adapter blob must already exist!");
1287 
1288   // These writes must happen in this order, because the interpreter will
1289   // directly jump to from_interpreted_entry which jumps to an i2c adapter
1290   // which jumps to _from_compiled_entry.
1291   mh->_code = code;             // Assign before allowing compiled code to exec
1292 
1293   int comp_level = code->comp_level();
1294   // In theory there could be a race here. In practice it is unlikely
1295   // and not worth worrying about.
1296   if (comp_level > mh->highest_comp_level()) {




1230     assert(mh->_from_compiled_entry != NULL, "must be");
1231   } else {
1232     mh->set_adapter_entry(adapter);
1233     mh->_from_compiled_entry = adapter->get_c2i_entry();
1234   }
1235   return adapter->get_c2i_entry();
1236 }
1237 
1238 void Method::restore_unshareable_info(TRAPS) {
1239   assert(is_method() && is_valid_method(this), "ensure C++ vtable is restored");
1240 
1241   // Since restore_unshareable_info can be called more than once for a method, don't
1242   // redo any work.
1243   if (adapter() == NULL) {
1244     methodHandle mh(THREAD, this);
1245     link_method(mh, CHECK);
1246   }
1247 }
1248 
1249 address Method::from_compiled_entry_no_trampoline() const {
1250   CompiledMethod *code = Atomic::load_acquire(&_code);
1251   if (code) {
1252     return code->verified_entry_point();
1253   } else {
1254     return adapter()->get_c2i_entry();
1255   }
1256 }
1257 
1258 // The verified_code_entry() must be called when a invoke is resolved
1259 // on this method.
1260 
1261 // It returns the compiled code entry point, after asserting not null.
1262 // This function is called after potential safepoints so that nmethod
1263 // or adapter that it points to is still live and valid.
1264 // This function must not hit a safepoint!
1265 address Method::verified_code_entry() {
1266   debug_only(NoSafepointVerifier nsv;)
1267   assert(_from_compiled_entry != NULL, "must be set");
1268   return _from_compiled_entry;
1269 }
1270 
1271 // Check that if an nmethod ref exists, it has a backlink to this or no backlink at all
1272 // (could be racing a deopt).
1273 // Not inline to avoid circular ref.
1274 bool Method::check_code() const {
1275   // cached in a register or local.  There's a race on the value of the field.
1276   CompiledMethod *code = Atomic::load_acquire(&_code);
1277   return code == NULL || (code->method() == NULL) || (code->method() == (Method*)this && !code->is_osr_method());
1278 }
1279 
1280 // Install compiled code.  Instantly it can execute.
1281 void Method::set_code(const methodHandle& mh, CompiledMethod *code) {
1282   assert_lock_strong(CompiledMethod_lock);
1283   assert( code, "use clear_code to remove code" );
1284   assert( mh->check_code(), "" );
1285 
1286   guarantee(mh->adapter() != NULL, "Adapter blob must already exist!");
1287 
1288   // These writes must happen in this order, because the interpreter will
1289   // directly jump to from_interpreted_entry which jumps to an i2c adapter
1290   // which jumps to _from_compiled_entry.
1291   mh->_code = code;             // Assign before allowing compiled code to exec
1292 
1293   int comp_level = code->comp_level();
1294   // In theory there could be a race here. In practice it is unlikely
1295   // and not worth worrying about.
1296   if (comp_level > mh->highest_comp_level()) {


< prev index next >