comparison src/share/vm/classfile/classLoader.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents d2a62e0f25eb
children e522a00b91aa 6cb0d32b828b
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
1 /* 1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
35 #include "interpreter/oopMapCache.hpp" 35 #include "interpreter/oopMapCache.hpp"
36 #include "memory/allocation.inline.hpp" 36 #include "memory/allocation.inline.hpp"
37 #include "memory/generation.hpp" 37 #include "memory/generation.hpp"
38 #include "memory/oopFactory.hpp" 38 #include "memory/oopFactory.hpp"
39 #include "memory/universe.inline.hpp" 39 #include "memory/universe.inline.hpp"
40 #include "oops/constantPoolKlass.hpp"
41 #include "oops/instanceKlass.hpp" 40 #include "oops/instanceKlass.hpp"
42 #include "oops/instanceRefKlass.hpp" 41 #include "oops/instanceRefKlass.hpp"
43 #include "oops/oop.inline.hpp" 42 #include "oops/oop.inline.hpp"
44 #include "oops/symbol.hpp" 43 #include "oops/symbol.hpp"
45 #include "prims/jvm_misc.hpp" 44 #include "prims/jvm_misc.hpp"
902 e = e->next(); 901 e = e->next();
903 ++classpath_index; 902 ++classpath_index;
904 } 903 }
905 } 904 }
906 905
907 instanceKlassHandle h(THREAD, klassOop(NULL)); 906 instanceKlassHandle h;
908 if (stream != NULL) { 907 if (stream != NULL) {
909 908
910 // class file found, parse it 909 // class file found, parse it
911 ClassFileParser parser(stream); 910 ClassFileParser parser(stream);
912 Handle class_loader; 911 Handle class_loader;
1190 } 1189 }
1191 if (HAS_PENDING_EXCEPTION) { 1190 if (HAS_PENDING_EXCEPTION) {
1192 if (PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())) { 1191 if (PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())) {
1193 CLEAR_PENDING_EXCEPTION; 1192 CLEAR_PENDING_EXCEPTION;
1194 tty->print_cr("\nCompileTheWorld : Ran out of memory\n"); 1193 tty->print_cr("\nCompileTheWorld : Ran out of memory\n");
1195 size_t used = Universe::heap()->permanent_used(); 1194 tty->print_cr("Increase class metadata storage if a limit was set");
1196 size_t capacity = Universe::heap()->permanent_capacity();
1197 tty->print_cr("Permanent generation used %dK of %dK", used/K, capacity/K);
1198 tty->print_cr("Increase size by setting e.g. -XX:MaxPermSize=%dK\n", capacity*2/K);
1199 } else { 1195 } else {
1200 tty->print_cr("\nCompileTheWorld : Unexpected exception occurred\n"); 1196 tty->print_cr("\nCompileTheWorld : Unexpected exception occurred\n");
1201 } 1197 }
1202 } 1198 }
1203 } 1199 }
1316 if (_compile_the_world_counter > CompileTheWorldStopAt) return; 1312 if (_compile_the_world_counter > CompileTheWorldStopAt) return;
1317 1313
1318 // Construct name without extension 1314 // Construct name without extension
1319 TempNewSymbol sym = SymbolTable::new_symbol(buffer, CHECK); 1315 TempNewSymbol sym = SymbolTable::new_symbol(buffer, CHECK);
1320 // Use loader to load and initialize class 1316 // Use loader to load and initialize class
1321 klassOop ik = SystemDictionary::resolve_or_null(sym, loader, Handle(), THREAD); 1317 Klass* ik = SystemDictionary::resolve_or_null(sym, loader, Handle(), THREAD);
1322 instanceKlassHandle k (THREAD, ik); 1318 instanceKlassHandle k (THREAD, ik);
1323 if (k.not_null() && !HAS_PENDING_EXCEPTION) { 1319 if (k.not_null() && !HAS_PENDING_EXCEPTION) {
1324 k->initialize(THREAD); 1320 k->initialize(THREAD);
1325 } 1321 }
1326 bool exception_occurred = HAS_PENDING_EXCEPTION; 1322 bool exception_occurred = HAS_PENDING_EXCEPTION;
1327 clear_pending_exception_if_not_oom(CHECK); 1323 clear_pending_exception_if_not_oom(CHECK);
1328 if (CompileTheWorldPreloadClasses && k.not_null()) { 1324 if (CompileTheWorldPreloadClasses && k.not_null()) {
1329 constantPoolKlass::preload_and_initialize_all_classes(k->constants(), THREAD); 1325 ConstantPool::preload_and_initialize_all_classes(k->constants(), THREAD);
1330 if (HAS_PENDING_EXCEPTION) { 1326 if (HAS_PENDING_EXCEPTION) {
1331 // If something went wrong in preloading we just ignore it 1327 // If something went wrong in preloading we just ignore it
1332 clear_pending_exception_if_not_oom(CHECK); 1328 clear_pending_exception_if_not_oom(CHECK);
1333 tty->print_cr("Preloading failed for (%d) %s", _compile_the_world_counter, buffer); 1329 tty->print_cr("Preloading failed for (%d) %s", _compile_the_world_counter, buffer);
1334 } 1330 }
1341 } else { 1337 } else {
1342 tty->print_cr("CompileTheWorld (%d) : %s", _compile_the_world_counter, buffer); 1338 tty->print_cr("CompileTheWorld (%d) : %s", _compile_the_world_counter, buffer);
1343 // Preload all classes to get around uncommon traps 1339 // Preload all classes to get around uncommon traps
1344 // Iterate over all methods in class 1340 // Iterate over all methods in class
1345 for (int n = 0; n < k->methods()->length(); n++) { 1341 for (int n = 0; n < k->methods()->length(); n++) {
1346 methodHandle m (THREAD, methodOop(k->methods()->obj_at(n))); 1342 methodHandle m (THREAD, k->methods()->at(n));
1347 if (CompilationPolicy::can_be_compiled(m)) { 1343 if (CompilationPolicy::can_be_compiled(m)) {
1348 1344
1349 if (++_codecache_sweep_counter == CompileTheWorldSafepointInterval) { 1345 if (++_codecache_sweep_counter == CompileTheWorldSafepointInterval) {
1350 // Give sweeper a chance to keep up with CTW 1346 // Give sweeper a chance to keep up with CTW
1351 VM_ForceSafepoint op; 1347 VM_ForceSafepoint op;