6621621: HashMap front cache should be enabled only with AggressiveOpts
authorphh
Wed, 05 Dec 2007 09:02:00 -0800
changeset 191 314312979e7a
parent 190 e9a0a9dcd4f6
child 192 d66300cdf939
6621621: HashMap front cache should be enabled only with AggressiveOpts Reviewed-by: sbohne, xlu
hotspot/src/share/vm/classfile/vmSymbols.hpp
hotspot/src/share/vm/runtime/thread.cpp
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Dec 05 09:01:00 2007 -0800
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Dec 05 09:02:00 2007 -0800
@@ -96,10 +96,11 @@
   template(java_util_Vector,                          "java/util/Vector")                         \
   template(java_util_AbstractList,                    "java/util/AbstractList")                   \
   template(java_util_Hashtable,                       "java/util/Hashtable")                      \
+  template(java_util_HashMap,                         "java/util/HashMap")                        \
   template(java_lang_Compiler,                        "java/lang/Compiler")                       \
   template(sun_misc_Signal,                           "sun/misc/Signal")                          \
   template(java_lang_AssertionStatusDirectives,       "java/lang/AssertionStatusDirectives")      \
-  template(sun_jkernel_DownloadManager,               "sun/jkernel/DownloadManager")                 \
+  template(sun_jkernel_DownloadManager,               "sun/jkernel/DownloadManager")              \
   template(getBootClassPathEntryForClass_name,        "getBootClassPathEntryForClass")            \
                                                                                                   \
   /* class file format tags */                                                                    \
@@ -281,6 +282,7 @@
   template(park_event_name,                           "nativeParkEventPointer")                   \
   template(cache_field_name,                          "cache")                                    \
   template(value_name,                                "value")                                    \
+  template(frontCacheEnabled_name,                    "frontCacheEnabled")                        \
                                                                                                   \
   /* non-intrinsic name/signature pairs: */                                                       \
   template(register_method_name,                      "register")                                 \
--- a/hotspot/src/share/vm/runtime/thread.cpp	Wed Dec 05 09:01:00 2007 -0800
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Wed Dec 05 09:02:00 2007 -0800
@@ -2925,6 +2925,25 @@
       warning("java.lang.String not initialized");
     }
 
+    if (AggressiveOpts) {
+      // 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");
+#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);
+      }
+    }
+
     // Initialize java_lang.System (needed before creating the thread)
     if (InitializeJavaLangSystem) {
       initialize_class(vmSymbolHandles::java_lang_System(), CHECK_0);