Fri, 13 Jun 2008 14:49:07 -0700
6714404: Add UseStringCache switch to enable String caching under AggressiveOpts
Summary: Poke String.stringCacheEnabled during vm initialization
Reviewed-by: never
1.1 --- a/src/share/vm/classfile/vmSymbols.hpp Tue Jun 10 11:14:27 2008 -0700 1.2 +++ b/src/share/vm/classfile/vmSymbols.hpp Fri Jun 13 14:49:07 2008 -0700 1.3 @@ -283,6 +283,7 @@ 1.4 template(cache_field_name, "cache") \ 1.5 template(value_name, "value") \ 1.6 template(frontCacheEnabled_name, "frontCacheEnabled") \ 1.7 + template(stringCacheEnabled_name, "stringCacheEnabled") \ 1.8 \ 1.9 /* non-intrinsic name/signature pairs: */ \ 1.10 template(register_method_name, "register") \
2.1 --- a/src/share/vm/runtime/globals.hpp Tue Jun 10 11:14:27 2008 -0700 2.2 +++ b/src/share/vm/runtime/globals.hpp Fri Jun 13 14:49:07 2008 -0700 2.3 @@ -2246,6 +2246,9 @@ 2.4 product(bool, AggressiveOpts, false, \ 2.5 "Enable aggressive optimizations - see arguments.cpp") \ 2.6 \ 2.7 + product(bool, UseStringCache, false, \ 2.8 + "Enable String cache capabilities on String.java") \ 2.9 + \ 2.10 /* statistics */ \ 2.11 develop(bool, UseVTune, false, \ 2.12 "enable support for Intel's VTune profiler") \
3.1 --- a/src/share/vm/runtime/thread.cpp Tue Jun 10 11:14:27 2008 -0700 3.2 +++ b/src/share/vm/runtime/thread.cpp Fri Jun 13 14:49:07 2008 -0700 3.3 @@ -2926,21 +2926,42 @@ 3.4 } 3.5 3.6 if (AggressiveOpts) { 3.7 - // Forcibly initialize java/util/HashMap and mutate the private 3.8 - // static final "frontCacheEnabled" field before we start creating instances 3.9 + { 3.10 + // Forcibly initialize java/util/HashMap and mutate the private 3.11 + // static final "frontCacheEnabled" field before we start creating instances 3.12 #ifdef ASSERT 3.13 - klassOop tmp_k = SystemDictionary::find(vmSymbolHandles::java_util_HashMap(), Handle(), Handle(), CHECK_0); 3.14 - assert(tmp_k == NULL, "java/util/HashMap should not be loaded yet"); 3.15 + klassOop tmp_k = SystemDictionary::find(vmSymbolHandles::java_util_HashMap(), Handle(), Handle(), CHECK_0); 3.16 + assert(tmp_k == NULL, "java/util/HashMap should not be loaded yet"); 3.17 #endif 3.18 - klassOop k_o = SystemDictionary::resolve_or_null(vmSymbolHandles::java_util_HashMap(), Handle(), Handle(), CHECK_0); 3.19 - KlassHandle k = KlassHandle(THREAD, k_o); 3.20 - guarantee(k.not_null(), "Must find java/util/HashMap"); 3.21 - instanceKlassHandle ik = instanceKlassHandle(THREAD, k()); 3.22 - ik->initialize(CHECK_0); 3.23 - fieldDescriptor fd; 3.24 - // Possible we might not find this field; if so, don't break 3.25 - if (ik->find_local_field(vmSymbols::frontCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) { 3.26 - k()->bool_field_put(fd.offset(), true); 3.27 + klassOop k_o = SystemDictionary::resolve_or_null(vmSymbolHandles::java_util_HashMap(), Handle(), Handle(), CHECK_0); 3.28 + KlassHandle k = KlassHandle(THREAD, k_o); 3.29 + guarantee(k.not_null(), "Must find java/util/HashMap"); 3.30 + instanceKlassHandle ik = instanceKlassHandle(THREAD, k()); 3.31 + ik->initialize(CHECK_0); 3.32 + fieldDescriptor fd; 3.33 + // Possible we might not find this field; if so, don't break 3.34 + if (ik->find_local_field(vmSymbols::frontCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) { 3.35 + k()->bool_field_put(fd.offset(), true); 3.36 + } 3.37 + } 3.38 + 3.39 + if (UseStringCache) { 3.40 + // Forcibly initialize java/lang/String and mutate the private 3.41 + // static final "stringCacheEnabled" field before we start creating instances 3.42 +#ifdef ASSERT 3.43 + klassOop tmp_k = SystemDictionary::find(vmSymbolHandles::java_lang_String(), Handle(), Handle(), CHECK_0); 3.44 + assert(tmp_k == NULL, "java/lang/String should not be loaded yet"); 3.45 +#endif 3.46 + klassOop k_o = SystemDictionary::resolve_or_null(vmSymbolHandles::java_lang_String(), Handle(), Handle(), CHECK_0); 3.47 + KlassHandle k = KlassHandle(THREAD, k_o); 3.48 + guarantee(k.not_null(), "Must find java/lang/String"); 3.49 + instanceKlassHandle ik = instanceKlassHandle(THREAD, k()); 3.50 + ik->initialize(CHECK_0); 3.51 + fieldDescriptor fd; 3.52 + // Possible we might not find this field; if so, don't break 3.53 + if (ik->find_local_field(vmSymbols::stringCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) { 3.54 + k()->bool_field_put(fd.offset(), true); 3.55 + } 3.56 } 3.57 } 3.58