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 _is_hidden = ik->is_hidden();
67 _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
68 _has_injected_fields = -1;
69 _implementor = NULL; // we will fill these lazily
70
71 // Ensure that the metadata wrapped by the ciMetadata is kept alive by GC.
72 // This is primarily useful for metadata which is considered as weak roots
73 // by the GC but need to be strong roots if reachable from a current compilation.
74 // InstanceKlass are created for both weak and strong metadata. Ensuring this metadata
75 // alive covers the cases where there are weak roots without performance cost.
76 oop holder = ik->klass_holder();
77 if (ik->class_loader_data()->has_class_mirror_holder()) {
78 // Though ciInstanceKlass records class loader oop, it's not enough to keep
79 // VM weak hidden and unsafe anonymous classes alive (loader == NULL). Klass holder should
80 // be used instead. It is enough to record a ciObject, since cached elements are never removed
81 // during ciObjectFactory lifetime. ciObjectFactory itself is created for
82 // every compilation and lives for the whole duration of the compilation.
83 assert(holder != NULL, "holder of hidden or unsafe anonymous class is the mirror which is never null");
84 (void)CURRENT_ENV->get_object(holder);
85 }
86
87 Thread *thread = Thread::current();
88 if (ciObjectFactory::is_initialized()) {
89 _loader = JNIHandles::make_local(thread, ik->class_loader());
90 _protection_domain = JNIHandles::make_local(thread,
91 ik->protection_domain());
92 _is_shared = false;
93 } else {
94 Handle h_loader(thread, ik->class_loader());
95 Handle h_protection_domain(thread, ik->protection_domain());
96 _loader = JNIHandles::make_global(h_loader);
97 _protection_domain = JNIHandles::make_global(h_protection_domain);
98 _is_shared = true;
99 }
|
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 _is_hidden = ik->is_hidden();
67 _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
68 _has_injected_fields = -1;
69 _implementor = NULL; // we will fill these lazily
70
71 // Ensure that the metadata wrapped by the ciMetadata is kept alive by GC.
72 // This is primarily useful for metadata which is considered as weak roots
73 // by the GC but need to be strong roots if reachable from a current compilation.
74 // InstanceKlass are created for both weak and strong metadata. Ensuring this metadata
75 // alive covers the cases where there are weak roots without performance cost.
76 oop holder = ik->klass_holder();
77 if (ik->class_loader_data()->has_class_mirror_holder()) {
78 // Though ciInstanceKlass records class loader oop, it's not enough to keep
79 // non-strong hidden classes and VM unsafe anonymous classes alive (loader == NULL). Klass holder should
80 // be used instead. It is enough to record a ciObject, since cached elements are never removed
81 // during ciObjectFactory lifetime. ciObjectFactory itself is created for
82 // every compilation and lives for the whole duration of the compilation.
83 assert(holder != NULL, "holder of hidden or unsafe anonymous class is the mirror which is never null");
84 (void)CURRENT_ENV->get_object(holder);
85 }
86
87 Thread *thread = Thread::current();
88 if (ciObjectFactory::is_initialized()) {
89 _loader = JNIHandles::make_local(thread, ik->class_loader());
90 _protection_domain = JNIHandles::make_local(thread,
91 ik->protection_domain());
92 _is_shared = false;
93 } else {
94 Handle h_loader(thread, ik->class_loader());
95 Handle h_protection_domain(thread, ik->protection_domain());
96 _loader = JNIHandles::make_global(h_loader);
97 _protection_domain = JNIHandles::make_global(h_protection_domain);
98 _is_shared = true;
99 }
|