< prev index next >

src/hotspot/share/ci/ciInstanceKlass.cpp

Print this page




  55   InstanceKlass* ik = get_instanceKlass();
  56 
  57   AccessFlags access_flags = ik->access_flags();
  58   _flags = ciFlags(access_flags);
  59   _has_finalizer = access_flags.has_finalizer();
  60   _has_subklass = flags().is_final() ? subklass_false : subklass_unknown;
  61   _init_state = ik->init_state();
  62   _nonstatic_field_size = ik->nonstatic_field_size();
  63   _has_nonstatic_fields = ik->has_nonstatic_fields();
  64   _has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods();
  65   _is_unsafe_anonymous = ik->is_unsafe_anonymous();
  66   _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
  67   _has_injected_fields = -1;
  68   _implementor = NULL; // we will fill these lazily
  69 
  70   // Ensure that the metadata wrapped by the ciMetadata is kept alive by GC.
  71   // This is primarily useful for metadata which is considered as weak roots
  72   // by the GC but need to be strong roots if reachable from a current compilation.
  73   // InstanceKlass are created for both weak and strong metadata.  Ensuring this metadata
  74   // alive covers the cases where there are weak roots without performance cost.
  75   oop holder = ik->holder_phantom();
  76   if (ik->is_unsafe_anonymous()) {
  77     // Though ciInstanceKlass records class loader oop, it's not enough to keep
  78     // VM unsafe anonymous classes alive (loader == NULL). Klass holder should
  79     // be used instead. It is enough to record a ciObject, since cached elements are never removed
  80     // during ciObjectFactory lifetime. ciObjectFactory itself is created for
  81     // every compilation and lives for the whole duration of the compilation.
  82     assert(holder != NULL, "holder of unsafe anonymous class is the mirror which is never null");
  83     (void)CURRENT_ENV->get_object(holder);
  84   }
  85 
  86   Thread *thread = Thread::current();
  87   if (ciObjectFactory::is_initialized()) {
  88     _loader = JNIHandles::make_local(thread, ik->class_loader());
  89     _protection_domain = JNIHandles::make_local(thread,
  90                                                 ik->protection_domain());
  91     _is_shared = false;
  92   } else {
  93     Handle h_loader(thread, ik->class_loader());
  94     Handle h_protection_domain(thread, ik->protection_domain());
  95     _loader = JNIHandles::make_global(h_loader);




  55   InstanceKlass* ik = get_instanceKlass();
  56 
  57   AccessFlags access_flags = ik->access_flags();
  58   _flags = ciFlags(access_flags);
  59   _has_finalizer = access_flags.has_finalizer();
  60   _has_subklass = flags().is_final() ? subklass_false : subklass_unknown;
  61   _init_state = ik->init_state();
  62   _nonstatic_field_size = ik->nonstatic_field_size();
  63   _has_nonstatic_fields = ik->has_nonstatic_fields();
  64   _has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods();
  65   _is_unsafe_anonymous = ik->is_unsafe_anonymous();
  66   _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
  67   _has_injected_fields = -1;
  68   _implementor = NULL; // we will fill these lazily
  69 
  70   // Ensure that the metadata wrapped by the ciMetadata is kept alive by GC.
  71   // This is primarily useful for metadata which is considered as weak roots
  72   // by the GC but need to be strong roots if reachable from a current compilation.
  73   // InstanceKlass are created for both weak and strong metadata.  Ensuring this metadata
  74   // alive covers the cases where there are weak roots without performance cost.
  75   oop holder = ik->klass_holder();
  76   if (ik->is_unsafe_anonymous()) {
  77     // Though ciInstanceKlass records class loader oop, it's not enough to keep
  78     // VM unsafe anonymous classes alive (loader == NULL). Klass holder should
  79     // be used instead. It is enough to record a ciObject, since cached elements are never removed
  80     // during ciObjectFactory lifetime. ciObjectFactory itself is created for
  81     // every compilation and lives for the whole duration of the compilation.
  82     assert(holder != NULL, "holder of unsafe anonymous class is the mirror which is never null");
  83     (void)CURRENT_ENV->get_object(holder);
  84   }
  85 
  86   Thread *thread = Thread::current();
  87   if (ciObjectFactory::is_initialized()) {
  88     _loader = JNIHandles::make_local(thread, ik->class_loader());
  89     _protection_domain = JNIHandles::make_local(thread,
  90                                                 ik->protection_domain());
  91     _is_shared = false;
  92   } else {
  93     Handle h_loader(thread, ik->class_loader());
  94     Handle h_protection_domain(thread, ik->protection_domain());
  95     _loader = JNIHandles::make_global(h_loader);


< prev index next >