6714404: Add UseStringCache switch to enable String caching under AggressiveOpts
Summary: Poke String.stringCacheEnabled during vm initialization
Reviewed-by: never
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp Tue Jun 10 11:14:27 2008 -0700
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp Fri Jun 13 14:49:07 2008 -0700
@@ -283,6 +283,7 @@
template(cache_field_name, "cache") \
template(value_name, "value") \
template(frontCacheEnabled_name, "frontCacheEnabled") \
+ template(stringCacheEnabled_name, "stringCacheEnabled") \
\
/* non-intrinsic name/signature pairs: */ \
template(register_method_name, "register") \
--- a/hotspot/src/share/vm/runtime/globals.hpp Tue Jun 10 11:14:27 2008 -0700
+++ b/hotspot/src/share/vm/runtime/globals.hpp Fri Jun 13 14:49:07 2008 -0700
@@ -2246,6 +2246,9 @@
product(bool, AggressiveOpts, false, \
"Enable aggressive optimizations - see arguments.cpp") \
\
+ product(bool, UseStringCache, false, \
+ "Enable String cache capabilities on String.java") \
+ \
/* statistics */ \
develop(bool, UseVTune, false, \
"enable support for Intel's VTune profiler") \
--- a/hotspot/src/share/vm/runtime/thread.cpp Tue Jun 10 11:14:27 2008 -0700
+++ b/hotspot/src/share/vm/runtime/thread.cpp Fri Jun 13 14:49:07 2008 -0700
@@ -2926,21 +2926,42 @@
}
if (AggressiveOpts) {
- // Forcibly initialize java/util/HashMap and mutate the private
- // static final "frontCacheEnabled" field before we start creating instances
+ {
+ // Forcibly initialize java/util/HashMap and mutate the private
+ // static final "frontCacheEnabled" field before we start creating instances
#ifdef ASSERT
- klassOop tmp_k = SystemDictionary::find(vmSymbolHandles::java_util_HashMap(), Handle(), Handle(), CHECK_0);
- assert(tmp_k == NULL, "java/util/HashMap should not be loaded yet");
+ klassOop tmp_k = SystemDictionary::find(vmSymbolHandles::java_util_HashMap(), Handle(), Handle(), CHECK_0);
+ assert(tmp_k == NULL, "java/util/HashMap should not be loaded yet");
#endif
- klassOop k_o = SystemDictionary::resolve_or_null(vmSymbolHandles::java_util_HashMap(), Handle(), Handle(), CHECK_0);
- KlassHandle k = KlassHandle(THREAD, k_o);
- guarantee(k.not_null(), "Must find java/util/HashMap");
- instanceKlassHandle ik = instanceKlassHandle(THREAD, k());
- ik->initialize(CHECK_0);
- fieldDescriptor fd;
- // Possible we might not find this field; if so, don't break
- if (ik->find_local_field(vmSymbols::frontCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) {
- k()->bool_field_put(fd.offset(), true);
+ klassOop k_o = SystemDictionary::resolve_or_null(vmSymbolHandles::java_util_HashMap(), Handle(), Handle(), CHECK_0);
+ KlassHandle k = KlassHandle(THREAD, k_o);
+ guarantee(k.not_null(), "Must find java/util/HashMap");
+ instanceKlassHandle ik = instanceKlassHandle(THREAD, k());
+ ik->initialize(CHECK_0);
+ fieldDescriptor fd;
+ // Possible we might not find this field; if so, don't break
+ if (ik->find_local_field(vmSymbols::frontCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) {
+ k()->bool_field_put(fd.offset(), true);
+ }
+ }
+
+ if (UseStringCache) {
+ // Forcibly initialize java/lang/String and mutate the private
+ // static final "stringCacheEnabled" field before we start creating instances
+#ifdef ASSERT
+ klassOop tmp_k = SystemDictionary::find(vmSymbolHandles::java_lang_String(), Handle(), Handle(), CHECK_0);
+ assert(tmp_k == NULL, "java/lang/String should not be loaded yet");
+#endif
+ klassOop k_o = SystemDictionary::resolve_or_null(vmSymbolHandles::java_lang_String(), Handle(), Handle(), CHECK_0);
+ KlassHandle k = KlassHandle(THREAD, k_o);
+ guarantee(k.not_null(), "Must find java/lang/String");
+ instanceKlassHandle ik = instanceKlassHandle(THREAD, k());
+ ik->initialize(CHECK_0);
+ fieldDescriptor fd;
+ // Possible we might not find this field; if so, don't break
+ if (ik->find_local_field(vmSymbols::stringCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) {
+ k()->bool_field_put(fd.offset(), true);
+ }
}
}