Wed, 25 Nov 2009 09:03:42 -0500
Merge
1.1 --- a/src/share/vm/classfile/systemDictionary.cpp Tue Nov 24 11:49:42 2009 -0800 1.2 +++ b/src/share/vm/classfile/systemDictionary.cpp Wed Nov 25 09:03:42 2009 -0500 1.3 @@ -99,6 +99,15 @@ 1.4 return java_lang_Class::parallelCapable(class_loader()); 1.5 } 1.6 // ---------------------------------------------------------------------------- 1.7 +// ParallelDefineClass flag does not apply to bootclass loader 1.8 +bool SystemDictionary::is_parallelDefine(Handle class_loader) { 1.9 + if (class_loader.is_null()) return false; 1.10 + if (AllowParallelDefineClass && java_lang_Class::parallelCapable(class_loader())) { 1.11 + return true; 1.12 + } 1.13 + return false; 1.14 +} 1.15 +// ---------------------------------------------------------------------------- 1.16 // Resolving of classes 1.17 1.18 // Forwards to resolve_or_null 1.19 @@ -724,13 +733,13 @@ 1.20 // Do actual loading 1.21 k = load_instance_class(name, class_loader, THREAD); 1.22 1.23 - // For UnsyncloadClass and AllowParallelDefineClass only: 1.24 + // For UnsyncloadClass only 1.25 // If they got a linkageError, check if a parallel class load succeeded. 1.26 // If it did, then for bytecode resolution the specification requires 1.27 // that we return the same result we did for the other thread, i.e. the 1.28 // successfully loaded instanceKlass 1.29 // Should not get here for classloaders that support parallelism 1.30 - // with the new cleaner mechanism 1.31 + // with the new cleaner mechanism, even with AllowParallelDefineClass 1.32 // Bootstrap goes through here to allow for an extra guarantee check 1.33 if (UnsyncloadClass || (class_loader.is_null())) { 1.34 if (k.is_null() && HAS_PENDING_EXCEPTION 1.35 @@ -1483,14 +1492,17 @@ 1.36 } 1.37 1.38 // Support parallel classloading 1.39 -// Initial implementation for bootstrap classloader 1.40 -// For custom class loaders that support parallel classloading, 1.41 +// All parallel class loaders, including bootstrap classloader 1.42 +// lock a placeholder entry for this class/class_loader pair 1.43 +// to allow parallel defines of different classes for this class loader 1.44 // With AllowParallelDefine flag==true, in case they do not synchronize around 1.45 // FindLoadedClass/DefineClass, calls, we check for parallel 1.46 // loading for them, wait if a defineClass is in progress 1.47 // and return the initial requestor's results 1.48 +// This flag does not apply to the bootstrap classloader. 1.49 // With AllowParallelDefine flag==false, call through to define_instance_class 1.50 // which will throw LinkageError: duplicate class definition. 1.51 +// False is the requested default. 1.52 // For better performance, the class loaders should synchronize 1.53 // findClass(), i.e. FindLoadedClass/DefineClassIfAbsent or they 1.54 // potentially waste time reading and parsing the bytestream. 1.55 @@ -1511,9 +1523,11 @@ 1.56 { 1.57 MutexLocker mu(SystemDictionary_lock, THREAD); 1.58 // First check if class already defined 1.59 - klassOop check = find_class(d_index, d_hash, name_h, class_loader); 1.60 - if (check != NULL) { 1.61 - return(instanceKlassHandle(THREAD, check)); 1.62 + if (UnsyncloadClass || (is_parallelDefine(class_loader))) { 1.63 + klassOop check = find_class(d_index, d_hash, name_h, class_loader); 1.64 + if (check != NULL) { 1.65 + return(instanceKlassHandle(THREAD, check)); 1.66 + } 1.67 } 1.68 1.69 // Acquire define token for this class/classloader 1.70 @@ -1529,7 +1543,7 @@ 1.71 // Only special cases allow parallel defines and can use other thread's results 1.72 // Other cases fall through, and may run into duplicate defines 1.73 // caught by finding an entry in the SystemDictionary 1.74 - if ((UnsyncloadClass || AllowParallelDefineClass) && (probe->instanceKlass() != NULL)) { 1.75 + if ((UnsyncloadClass || is_parallelDefine(class_loader)) && (probe->instanceKlass() != NULL)) { 1.76 probe->remove_seen_thread(THREAD, PlaceholderTable::DEFINE_CLASS); 1.77 placeholders()->find_and_remove(p_index, p_hash, name_h, class_loader, THREAD); 1.78 SystemDictionary_lock->notify_all();
2.1 --- a/src/share/vm/classfile/systemDictionary.hpp Tue Nov 24 11:49:42 2009 -0800 2.2 +++ b/src/share/vm/classfile/systemDictionary.hpp Wed Nov 25 09:03:42 2009 -0500 2.3 @@ -577,6 +577,7 @@ 2.4 static Handle compute_loader_lock_object(Handle class_loader, TRAPS); 2.5 static void check_loader_lock_contention(Handle loader_lock, TRAPS); 2.6 static bool is_parallelCapable(Handle class_loader); 2.7 + static bool is_parallelDefine(Handle class_loader); 2.8 2.9 static klassOop find_shared_class(symbolHandle class_name); 2.10
3.1 --- a/src/share/vm/runtime/arguments.cpp Tue Nov 24 11:49:42 2009 -0800 3.2 +++ b/src/share/vm/runtime/arguments.cpp Wed Nov 25 09:03:42 2009 -0500 3.3 @@ -1378,9 +1378,15 @@ 3.4 // or -Xms, then set it as fraction of the size of physical memory, 3.5 // respecting the maximum and minimum sizes of the heap. 3.6 if (FLAG_IS_DEFAULT(InitialHeapSize)) { 3.7 + julong reasonable_minimum = (julong)(OldSize + NewSize); 3.8 + 3.9 + reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize); 3.10 + 3.11 + reasonable_minimum = os::allocatable_physical_memory(reasonable_minimum); 3.12 + 3.13 julong reasonable_initial = phys_mem / InitialRAMFraction; 3.14 3.15 - reasonable_initial = MAX2(reasonable_initial, (julong)(OldSize + NewSize)); 3.16 + reasonable_initial = MAX2(reasonable_initial, reasonable_minimum); 3.17 reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize); 3.18 3.19 reasonable_initial = os::allocatable_physical_memory(reasonable_initial); 3.20 @@ -1388,14 +1394,10 @@ 3.21 if (PrintGCDetails && Verbose) { 3.22 // Cannot use gclog_or_tty yet. 3.23 tty->print_cr(" Initial heap size " SIZE_FORMAT, (uintx)reasonable_initial); 3.24 + tty->print_cr(" Minimum heap size " SIZE_FORMAT, (uintx)reasonable_minimum); 3.25 } 3.26 FLAG_SET_ERGO(uintx, InitialHeapSize, (uintx)reasonable_initial); 3.27 - 3.28 - // Subsequent ergonomics code may expect min_heap_size to be set 3.29 - // if InitialHeapSize is. Use whatever the current values are 3.30 - // for OldSize and NewSize, whether or not they were set on the 3.31 - // command line. 3.32 - set_min_heap_size(OldSize + NewSize); 3.33 + set_min_heap_size((uintx)reasonable_minimum); 3.34 } 3.35 } 3.36