hotspot/src/share/vm/oops/constantPool.cpp
changeset 31046 d01ad7a0ecb0
parent 31038 2fd2fdc6a70a
child 31592 43f48e165466
equal deleted inserted replaced
31045:31769e6e8293 31046:d01ad7a0ecb0
    65 ConstantPool::ConstantPool(Array<u1>* tags) {
    65 ConstantPool::ConstantPool(Array<u1>* tags) {
    66   set_length(tags->length());
    66   set_length(tags->length());
    67   set_tags(NULL);
    67   set_tags(NULL);
    68   set_cache(NULL);
    68   set_cache(NULL);
    69   set_reference_map(NULL);
    69   set_reference_map(NULL);
       
    70   set_resolved_references(NULL);
    70   set_operands(NULL);
    71   set_operands(NULL);
    71   set_pool_holder(NULL);
    72   set_pool_holder(NULL);
    72   set_flags(0);
    73   set_flags(0);
    73 
    74 
    74   // only set to non-zero if constant pool is merged by RedefineClasses
    75   // only set to non-zero if constant pool is merged by RedefineClasses
    99 }
   100 }
   100 
   101 
   101 void ConstantPool::release_C_heap_structures() {
   102 void ConstantPool::release_C_heap_structures() {
   102   // walk constant pool and decrement symbol reference counts
   103   // walk constant pool and decrement symbol reference counts
   103   unreference_symbols();
   104   unreference_symbols();
       
   105 }
       
   106 
       
   107 objArrayOop ConstantPool::resolved_references() const {
       
   108   return (objArrayOop)JNIHandles::resolve(_resolved_references);
   104 }
   109 }
   105 
   110 
   106 // Create resolved_references array and mapping array for original cp indexes
   111 // Create resolved_references array and mapping array for original cp indexes
   107 // The ldc bytecode was rewritten to have the resolved reference array index so need a way
   112 // The ldc bytecode was rewritten to have the resolved reference array index so need a way
   108 // to map it back for resolving and some unlikely miscellaneous uses.
   113 // to map it back for resolving and some unlikely miscellaneous uses.
   129       set_reference_map(om);
   134       set_reference_map(om);
   130     }
   135     }
   131 
   136 
   132     // Create Java array for holding resolved strings, methodHandles,
   137     // Create Java array for holding resolved strings, methodHandles,
   133     // methodTypes, invokedynamic and invokehandle appendix objects, etc.
   138     // methodTypes, invokedynamic and invokehandle appendix objects, etc.
   134     objArrayOop obj_arr = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK);
   139     objArrayOop stom = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK);
   135     pool_holder()->set_resolved_references(obj_arr);
   140     Handle refs_handle (THREAD, (oop)stom);  // must handleize.
   136   }
   141     set_resolved_references(loader_data->add_handle(refs_handle));
   137 }
   142   }
   138 
       
   139 objArrayOop ConstantPool::resolved_references() const {
       
   140   return pool_holder()->resolved_references();
       
   141 }
   143 }
   142 
   144 
   143 // CDS support. Create a new resolved_references array.
   145 // CDS support. Create a new resolved_references array.
   144 void ConstantPool::restore_unshareable_info(TRAPS) {
   146 void ConstantPool::restore_unshareable_info(TRAPS) {
       
   147 
       
   148   // Only create the new resolved references array if it hasn't been attempted before
       
   149   if (resolved_references() != NULL) return;
       
   150 
   145   // restore the C++ vtable from the shared archive
   151   // restore the C++ vtable from the shared archive
   146   restore_vtable();
   152   restore_vtable();
   147 
       
   148   if (pool_holder()->java_mirror() == NULL)  return;
       
   149 
       
   150   // Only create the new resolved references array if it hasn't been attempted before
       
   151   if (pool_holder()->resolved_references() != NULL) return;
       
   152 
   153 
   153   if (SystemDictionary::Object_klass_loaded()) {
   154   if (SystemDictionary::Object_klass_loaded()) {
   154     // Recreate the object array and add to ClassLoaderData.
   155     // Recreate the object array and add to ClassLoaderData.
   155     int map_length = resolved_reference_length();
   156     int map_length = resolved_reference_length();
   156     if (map_length > 0) {
   157     if (map_length > 0) {
   157       objArrayOop resolved_references = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK);
   158       objArrayOop stom = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK);
   158       pool_holder()->set_resolved_references(resolved_references);
   159       Handle refs_handle (THREAD, (oop)stom);  // must handleize.
       
   160 
       
   161       ClassLoaderData* loader_data = pool_holder()->class_loader_data();
       
   162       set_resolved_references(loader_data->add_handle(refs_handle));
   159     }
   163     }
   160   }
   164   }
   161 }
   165 }
   162 
   166 
   163 void ConstantPool::remove_unshareable_info() {
   167 void ConstantPool::remove_unshareable_info() {
   164   // Resolved references are not in the shared archive.
   168   // Resolved references are not in the shared archive.
   165   // Save the length for restoration.  It is not necessarily the same length
   169   // Save the length for restoration.  It is not necessarily the same length
   166   // as reference_map.length() if invokedynamic is saved.
   170   // as reference_map.length() if invokedynamic is saved.
   167   objArrayOop resolved_references = pool_holder()->resolved_references();
   171   set_resolved_reference_length(
   168   set_resolved_reference_length(resolved_references != NULL ? resolved_references->length() : 0);
   172     resolved_references() != NULL ? resolved_references()->length() : 0);
       
   173   set_resolved_references(NULL);
   169 }
   174 }
   170 
   175 
   171 int ConstantPool::cp_to_object_index(int cp_index) {
   176 int ConstantPool::cp_to_object_index(int cp_index) {
   172   // this is harder don't do this so much.
   177   // this is harder don't do this so much.
   173   int i = reference_map()->find(cp_index);
   178   int i = reference_map()->find(cp_index);
  1864   }
  1869   }
  1865   if (pool_holder() != NULL) {
  1870   if (pool_holder() != NULL) {
  1866     st->print_cr(" - holder: " INTPTR_FORMAT, pool_holder());
  1871     st->print_cr(" - holder: " INTPTR_FORMAT, pool_holder());
  1867   }
  1872   }
  1868   st->print_cr(" - cache: " INTPTR_FORMAT, cache());
  1873   st->print_cr(" - cache: " INTPTR_FORMAT, cache());
       
  1874   st->print_cr(" - resolved_references: " INTPTR_FORMAT, (void *)resolved_references());
  1869   st->print_cr(" - reference_map: " INTPTR_FORMAT, reference_map());
  1875   st->print_cr(" - reference_map: " INTPTR_FORMAT, reference_map());
  1870 
  1876 
  1871   for (int index = 1; index < length(); index++) {      // Index 0 is unused
  1877   for (int index = 1; index < length(); index++) {      // Index 0 is unused
  1872     ((ConstantPool*)this)->print_entry_on(index, st);
  1878     ((ConstantPool*)this)->print_entry_on(index, st);
  1873     switch (tag_at(index).value()) {
  1879     switch (tag_at(index).value()) {