comparison src/share/vm/classfile/classLoader.cpp @ 723:3ec1ff9307d6

6741757: minor ctw improvements Reviewed-by: kvn
author never
date Thu, 16 Apr 2009 21:25:29 -0700
parents a61af66fc99e
children bd02caa94611 6a93908f268f
comparison
equal deleted inserted replaced
722:a134d9824964 723:3ec1ff9307d6
1215 buffer[len-6] = 0; 1215 buffer[len-6] = 0;
1216 // If the file has a period after removing .class, it's not really a 1216 // If the file has a period after removing .class, it's not really a
1217 // valid class file. The class loader will check everything else. 1217 // valid class file. The class loader will check everything else.
1218 if (strchr(buffer, '.') == NULL) { 1218 if (strchr(buffer, '.') == NULL) {
1219 _compile_the_world_counter++; 1219 _compile_the_world_counter++;
1220 if (_compile_the_world_counter >= CompileTheWorldStartAt && _compile_the_world_counter <= CompileTheWorldStopAt) { 1220 if (_compile_the_world_counter > CompileTheWorldStopAt) return;
1221 // Construct name without extension 1221
1222 symbolHandle sym = oopFactory::new_symbol_handle(buffer, CHECK); 1222 // Construct name without extension
1223 // Use loader to load and initialize class 1223 symbolHandle sym = oopFactory::new_symbol_handle(buffer, CHECK);
1224 klassOop ik = SystemDictionary::resolve_or_null(sym, loader, Handle(), THREAD); 1224 // Use loader to load and initialize class
1225 instanceKlassHandle k (THREAD, ik); 1225 klassOop ik = SystemDictionary::resolve_or_null(sym, loader, Handle(), THREAD);
1226 if (k.not_null() && !HAS_PENDING_EXCEPTION) { 1226 instanceKlassHandle k (THREAD, ik);
1227 k->initialize(THREAD); 1227 if (k.not_null() && !HAS_PENDING_EXCEPTION) {
1228 k->initialize(THREAD);
1229 }
1230 bool exception_occurred = HAS_PENDING_EXCEPTION;
1231 CLEAR_PENDING_EXCEPTION;
1232 if (CompileTheWorldPreloadClasses && k.not_null()) {
1233 constantPoolKlass::preload_and_initialize_all_classes(k->constants(), THREAD);
1234 if (HAS_PENDING_EXCEPTION) {
1235 // If something went wrong in preloading we just ignore it
1236 CLEAR_PENDING_EXCEPTION;
1237 tty->print_cr("Preloading failed for (%d) %s", _compile_the_world_counter, buffer);
1228 } 1238 }
1229 bool exception_occurred = HAS_PENDING_EXCEPTION; 1239 }
1230 CLEAR_PENDING_EXCEPTION; 1240
1241 if (_compile_the_world_counter >= CompileTheWorldStartAt) {
1231 if (k.is_null() || (exception_occurred && !CompileTheWorldIgnoreInitErrors)) { 1242 if (k.is_null() || (exception_occurred && !CompileTheWorldIgnoreInitErrors)) {
1232 // If something went wrong (e.g. ExceptionInInitializerError) we skip this class 1243 // If something went wrong (e.g. ExceptionInInitializerError) we skip this class
1233 tty->print_cr("CompileTheWorld (%d) : Skipping %s", _compile_the_world_counter, buffer); 1244 tty->print_cr("CompileTheWorld (%d) : Skipping %s", _compile_the_world_counter, buffer);
1234 } else { 1245 } else {
1235 tty->print_cr("CompileTheWorld (%d) : %s", _compile_the_world_counter, buffer); 1246 tty->print_cr("CompileTheWorld (%d) : %s", _compile_the_world_counter, buffer);
1236 // Preload all classes to get around uncommon traps 1247 // Preload all classes to get around uncommon traps
1237 if (CompileTheWorldPreloadClasses) {
1238 constantPoolKlass::preload_and_initialize_all_classes(k->constants(), THREAD);
1239 if (HAS_PENDING_EXCEPTION) {
1240 // If something went wrong in preloading we just ignore it
1241 CLEAR_PENDING_EXCEPTION;
1242 tty->print_cr("Preloading failed for (%d) %s", _compile_the_world_counter, buffer);
1243 }
1244 }
1245 // Iterate over all methods in class 1248 // Iterate over all methods in class
1246 for (int n = 0; n < k->methods()->length(); n++) { 1249 for (int n = 0; n < k->methods()->length(); n++) {
1247 methodHandle m (THREAD, methodOop(k->methods()->obj_at(n))); 1250 methodHandle m (THREAD, methodOop(k->methods()->obj_at(n)));
1248 if (CompilationPolicy::canBeCompiled(m)) { 1251 if (CompilationPolicy::canBeCompiled(m)) {
1249 // Force compilation 1252 // Force compilation
1251 methodHandle(), 0, "CTW", THREAD); 1254 methodHandle(), 0, "CTW", THREAD);
1252 if (HAS_PENDING_EXCEPTION) { 1255 if (HAS_PENDING_EXCEPTION) {
1253 CLEAR_PENDING_EXCEPTION; 1256 CLEAR_PENDING_EXCEPTION;
1254 tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_counter, m->name()->as_C_string()); 1257 tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_counter, m->name()->as_C_string());
1255 } 1258 }
1256 if (TieredCompilation) { 1259 if (TieredCompilation) {
1257 // Clobber the first compile and force second tier compilation 1260 // Clobber the first compile and force second tier compilation
1258 m->clear_code(); 1261 nmethod* nm = m->code();
1259 CompileBroker::compile_method(m, InvocationEntryBci, 1262 if (nm != NULL) {
1260 methodHandle(), 0, "CTW", THREAD); 1263 // Throw out the code so that the code cache doesn't fill up
1261 if (HAS_PENDING_EXCEPTION) { 1264 nm->make_not_entrant();
1262 CLEAR_PENDING_EXCEPTION; 1265 m->clear_code();
1263 tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_counter, m->name()->as_C_string()); 1266 }
1267 CompileBroker::compile_method(m, InvocationEntryBci,
1268 methodHandle(), 0, "CTW", THREAD);
1269 if (HAS_PENDING_EXCEPTION) {
1270 CLEAR_PENDING_EXCEPTION;
1271 tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_counter, m->name()->as_C_string());
1272 }
1264 } 1273 }
1265 } 1274 }
1275
1276 nmethod* nm = m->code();
1277 if (nm != NULL) {
1278 // Throw out the code so that the code cache doesn't fill up
1279 nm->make_not_entrant();
1280 m->clear_code();
1266 } 1281 }
1267 } 1282 }
1268 } 1283 }
1269 } 1284 }
1270 } 1285 }