hotspot/src/share/vm/oops/constantPool.cpp
changeset 31038 2fd2fdc6a70a
parent 29576 c223b0a9872e
child 31046 d01ad7a0ecb0
--- a/hotspot/src/share/vm/oops/constantPool.cpp	Fri May 15 19:23:11 2015 +0300
+++ b/hotspot/src/share/vm/oops/constantPool.cpp	Thu May 21 18:22:33 2015 +0300
@@ -67,7 +67,6 @@
   set_tags(NULL);
   set_cache(NULL);
   set_reference_map(NULL);
-  set_resolved_references(NULL);
   set_operands(NULL);
   set_pool_holder(NULL);
   set_flags(0);
@@ -104,10 +103,6 @@
   unreference_symbols();
 }
 
-objArrayOop ConstantPool::resolved_references() const {
-  return (objArrayOop)JNIHandles::resolve(_resolved_references);
-}
-
 // Create resolved_references array and mapping array for original cp indexes
 // The ldc bytecode was rewritten to have the resolved reference array index so need a way
 // to map it back for resolving and some unlikely miscellaneous uses.
@@ -136,30 +131,31 @@
 
     // Create Java array for holding resolved strings, methodHandles,
     // methodTypes, invokedynamic and invokehandle appendix objects, etc.
-    objArrayOop stom = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK);
-    Handle refs_handle (THREAD, (oop)stom);  // must handleize.
-    set_resolved_references(loader_data->add_handle(refs_handle));
+    objArrayOop obj_arr = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK);
+    pool_holder()->set_resolved_references(obj_arr);
   }
 }
 
+objArrayOop ConstantPool::resolved_references() const {
+  return pool_holder()->resolved_references();
+}
+
 // CDS support. Create a new resolved_references array.
 void ConstantPool::restore_unshareable_info(TRAPS) {
+  // restore the C++ vtable from the shared archive
+  restore_vtable();
+
+  if (pool_holder()->java_mirror() == NULL)  return;
 
   // Only create the new resolved references array if it hasn't been attempted before
-  if (resolved_references() != NULL) return;
-
-  // restore the C++ vtable from the shared archive
-  restore_vtable();
+  if (pool_holder()->resolved_references() != NULL) return;
 
   if (SystemDictionary::Object_klass_loaded()) {
     // Recreate the object array and add to ClassLoaderData.
     int map_length = resolved_reference_length();
     if (map_length > 0) {
-      objArrayOop stom = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK);
-      Handle refs_handle (THREAD, (oop)stom);  // must handleize.
-
-      ClassLoaderData* loader_data = pool_holder()->class_loader_data();
-      set_resolved_references(loader_data->add_handle(refs_handle));
+      objArrayOop resolved_references = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK);
+      pool_holder()->set_resolved_references(resolved_references);
     }
   }
 }
@@ -168,9 +164,8 @@
   // Resolved references are not in the shared archive.
   // Save the length for restoration.  It is not necessarily the same length
   // as reference_map.length() if invokedynamic is saved.
-  set_resolved_reference_length(
-    resolved_references() != NULL ? resolved_references()->length() : 0);
-  set_resolved_references(NULL);
+  objArrayOop resolved_references = pool_holder()->resolved_references();
+  set_resolved_reference_length(resolved_references != NULL ? resolved_references->length() : 0);
 }
 
 int ConstantPool::cp_to_object_index(int cp_index) {
@@ -1871,7 +1866,6 @@
     st->print_cr(" - holder: " INTPTR_FORMAT, pool_holder());
   }
   st->print_cr(" - cache: " INTPTR_FORMAT, cache());
-  st->print_cr(" - resolved_references: " INTPTR_FORMAT, (void *)resolved_references());
   st->print_cr(" - reference_map: " INTPTR_FORMAT, reference_map());
 
   for (int index = 1; index < length(); index++) {      // Index 0 is unused