src/share/vm/compiler/compileBroker.cpp

Print this page
rev 2893 : 7121756: Improve C1 inlining policy by using profiling at call sites
Summary: profile based recompilation of methods with C1 with more inlining.
Reviewed-by:


1145     if (method_code != NULL) {
1146       if (compilation_is_complete(method, osr_bci, comp_level)) {
1147         return method_code;
1148       }
1149     }
1150     if (method->is_not_compilable(comp_level)) return NULL;
1151 
1152     if (UseCodeCacheFlushing) {
1153       nmethod* saved = CodeCache::find_and_remove_saved_code(method());
1154       if (saved != NULL) {
1155         method->set_code(method, saved);
1156         return saved;
1157       }
1158     }
1159 
1160   } else {
1161     // osr compilation
1162 #ifndef TIERED
1163     // seems like an assert of dubious value
1164     assert(comp_level == CompLevel_highest_tier,
1165            "all OSR compiles are assumed to be at a single compilation lavel");
1166 #endif // TIERED
1167     // We accept a higher level osr method
1168     nmethod* nm = method->lookup_osr_nmethod_for(osr_bci, comp_level, false);
1169     if (nm != NULL) return nm;
1170     if (method->is_not_osr_compilable()) return NULL;
1171   }
1172 
1173   assert(!HAS_PENDING_EXCEPTION, "No exception should be present");
1174   // some prerequisites that are compiler specific
1175   if (compiler(comp_level)->is_c2() || compiler(comp_level)->is_shark()) {
1176     method->constants()->resolve_string_constants(CHECK_0);
1177     // Resolve all classes seen in the signature of the method
1178     // we are compiling.
1179     methodOopDesc::load_signature_classes(method, CHECK_0);
1180   }
1181 
1182   // If the method is native, do the lookup in the thread requesting
1183   // the compilation. Native lookups can load code, which is not
1184   // permitted during compilation.
1185   //


1243 // CompileBroker::compilation_is_complete
1244 //
1245 // See if compilation of this method is already complete.
1246 bool CompileBroker::compilation_is_complete(methodHandle method,
1247                                             int          osr_bci,
1248                                             int          comp_level) {
1249   bool is_osr = (osr_bci != standard_entry_bci);
1250   if (is_osr) {
1251     if (method->is_not_osr_compilable()) {
1252       return true;
1253     } else {
1254       nmethod* result = method->lookup_osr_nmethod_for(osr_bci, comp_level, true);
1255       return (result != NULL);
1256     }
1257   } else {
1258     if (method->is_not_compilable(comp_level)) {
1259       return true;
1260     } else {
1261       nmethod* result = method->code();
1262       if (result == NULL) return false;





1263       return comp_level == result->comp_level();
1264     }
1265   }
1266 }
1267 
1268 
1269 // ------------------------------------------------------------------
1270 // CompileBroker::compilation_is_in_queue
1271 //
1272 // See if this compilation is already requested.
1273 //
1274 // Implementation note: there is only a single "is in queue" bit
1275 // for each method.  This means that the check below is overly
1276 // conservative in the sense that an osr compilation in the queue
1277 // will block a normal compilation from entering the queue (and vice
1278 // versa).  This can be remedied by a full queue search to disambiguate
1279 // cases.  If it is deemed profitible, this may be done.
1280 bool CompileBroker::compilation_is_in_queue(methodHandle method,
1281                                             int          osr_bci) {
1282   return method->queued_for_compilation();




1145     if (method_code != NULL) {
1146       if (compilation_is_complete(method, osr_bci, comp_level)) {
1147         return method_code;
1148       }
1149     }
1150     if (method->is_not_compilable(comp_level)) return NULL;
1151 
1152     if (UseCodeCacheFlushing) {
1153       nmethod* saved = CodeCache::find_and_remove_saved_code(method());
1154       if (saved != NULL) {
1155         method->set_code(method, saved);
1156         return saved;
1157       }
1158     }
1159 
1160   } else {
1161     // osr compilation
1162 #ifndef TIERED
1163     // seems like an assert of dubious value
1164     assert(comp_level == CompLevel_highest_tier,
1165            "all OSR compiles are assumed to be at a single compilation level");
1166 #endif // TIERED
1167     // We accept a higher level osr method
1168     nmethod* nm = method->lookup_osr_nmethod_for(osr_bci, comp_level, false);
1169     if (nm != NULL) return nm;
1170     if (method->is_not_osr_compilable()) return NULL;
1171   }
1172 
1173   assert(!HAS_PENDING_EXCEPTION, "No exception should be present");
1174   // some prerequisites that are compiler specific
1175   if (compiler(comp_level)->is_c2() || compiler(comp_level)->is_shark()) {
1176     method->constants()->resolve_string_constants(CHECK_0);
1177     // Resolve all classes seen in the signature of the method
1178     // we are compiling.
1179     methodOopDesc::load_signature_classes(method, CHECK_0);
1180   }
1181 
1182   // If the method is native, do the lookup in the thread requesting
1183   // the compilation. Native lookups can load code, which is not
1184   // permitted during compilation.
1185   //


1243 // CompileBroker::compilation_is_complete
1244 //
1245 // See if compilation of this method is already complete.
1246 bool CompileBroker::compilation_is_complete(methodHandle method,
1247                                             int          osr_bci,
1248                                             int          comp_level) {
1249   bool is_osr = (osr_bci != standard_entry_bci);
1250   if (is_osr) {
1251     if (method->is_not_osr_compilable()) {
1252       return true;
1253     } else {
1254       nmethod* result = method->lookup_osr_nmethod_for(osr_bci, comp_level, true);
1255       return (result != NULL);
1256     }
1257   } else {
1258     if (method->is_not_compilable(comp_level)) {
1259       return true;
1260     } else {
1261       nmethod* result = method->code();
1262       if (result == NULL) return false;
1263 #ifdef COMPILER1
1264       if (C1ProfileInlining && result->needs_recomp()) {
1265         return false;
1266       }
1267 #endif
1268       return comp_level == result->comp_level();
1269     }
1270   }
1271 }
1272 
1273 
1274 // ------------------------------------------------------------------
1275 // CompileBroker::compilation_is_in_queue
1276 //
1277 // See if this compilation is already requested.
1278 //
1279 // Implementation note: there is only a single "is in queue" bit
1280 // for each method.  This means that the check below is overly
1281 // conservative in the sense that an osr compilation in the queue
1282 // will block a normal compilation from entering the queue (and vice
1283 // versa).  This can be remedied by a full queue search to disambiguate
1284 // cases.  If it is deemed profitible, this may be done.
1285 bool CompileBroker::compilation_is_in_queue(methodHandle method,
1286                                             int          osr_bci) {
1287   return method->queued_for_compilation();