hotspot/src/share/vm/oops/cpCache.cpp
changeset 28019 a6303ff71902
parent 25354 f6762819b488
child 29081 c61eb4914428
equal deleted inserted replaced
28017:84009002b566 28019:a6303ff71902
   285   // Competing writers must acquire exclusive access via a lock.
   285   // Competing writers must acquire exclusive access via a lock.
   286   // A losing writer waits on the lock until the winner writes f1 and leaves
   286   // A losing writer waits on the lock until the winner writes f1 and leaves
   287   // the lock, so that when the losing writer returns, he can use the linked
   287   // the lock, so that when the losing writer returns, he can use the linked
   288   // cache entry.
   288   // cache entry.
   289 
   289 
   290   // Use the lock from the metaspace for this, which cannot stop for safepoint.
   290   objArrayHandle resolved_references = cpool->resolved_references();
   291   Mutex* metaspace_lock = cpool->pool_holder()->class_loader_data()->metaspace_lock();
   291   // Use the resolved_references() lock for this cpCache entry.
   292   MutexLockerEx ml(metaspace_lock,  Mutex::_no_safepoint_check_flag);
   292   // resolved_references are created for all classes with Invokedynamic, MethodHandle
       
   293   // or MethodType constant pool cache entries.
       
   294   assert(resolved_references() != NULL,
       
   295          "a resolved_references array should have been created for this class");
       
   296   ObjectLocker ol(resolved_references, Thread::current());
   293   if (!is_f1_null()) {
   297   if (!is_f1_null()) {
   294     return;
   298     return;
   295   }
   299   }
   296 
   300 
   297   const methodHandle adapter = call_info.resolved_method();
   301   const methodHandle adapter = call_info.resolved_method();
   334   // not '(Ljava/lang/String;)Ljava/util/List;'.
   338   // not '(Ljava/lang/String;)Ljava/util/List;'.
   335   // The fact that String and List are involved is encoded in the MethodType in refs[f2].
   339   // The fact that String and List are involved is encoded in the MethodType in refs[f2].
   336   // This allows us to create fewer Methods, while keeping type safety.
   340   // This allows us to create fewer Methods, while keeping type safety.
   337   //
   341   //
   338 
   342 
   339   objArrayHandle resolved_references = cpool->resolved_references();
       
   340   // Store appendix, if any.
   343   // Store appendix, if any.
   341   if (has_appendix) {
   344   if (has_appendix) {
   342     const int appendix_index = f2_as_index() + _indy_resolved_references_appendix_offset;
   345     const int appendix_index = f2_as_index() + _indy_resolved_references_appendix_offset;
   343     assert(appendix_index >= 0 && appendix_index < resolved_references->length(), "oob");
   346     assert(appendix_index >= 0 && appendix_index < resolved_references->length(), "oob");
   344     assert(resolved_references->obj_at(appendix_index) == NULL, "init just once");
   347     assert(resolved_references->obj_at(appendix_index) == NULL, "init just once");