39 // ciInstanceKlass
40 //
41 // This class represents a Klass* in the HotSpot virtual machine
42 // whose Klass part in an InstanceKlass.
43
44
45 // ------------------------------------------------------------------
46 // ciInstanceKlass::ciInstanceKlass
47 //
48 // Loaded instance klass.
49 ciInstanceKlass::ciInstanceKlass(Klass* k) :
50 ciKlass(k)
51 {
52 assert(get_Klass()->is_instance_klass(), "wrong type");
53 assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
54 InstanceKlass* ik = get_instanceKlass();
55
56 AccessFlags access_flags = ik->access_flags();
57 _flags = ciFlags(access_flags);
58 _has_finalizer = access_flags.has_finalizer();
59 _has_subklass = ik->subklass() != NULL;
60 _init_state = ik->init_state();
61 _nonstatic_field_size = ik->nonstatic_field_size();
62 _has_nonstatic_fields = ik->has_nonstatic_fields();
63 _has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods();
64 _is_unsafe_anonymous = ik->is_unsafe_anonymous();
65 _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
66 _has_injected_fields = -1;
67 _implementor = NULL; // we will fill these lazily
68
69 // Ensure that the metadata wrapped by the ciMetadata is kept alive by GC.
70 // This is primarily useful for metadata which is considered as weak roots
71 // by the GC but need to be strong roots if reachable from a current compilation.
72 // InstanceKlass are created for both weak and strong metadata. Ensuring this metadata
73 // alive covers the cases where there are weak roots without performance cost.
74 oop holder = ik->holder_phantom();
75 if (ik->is_unsafe_anonymous()) {
76 // Though ciInstanceKlass records class loader oop, it's not enough to keep
77 // VM unsafe anonymous classes alive (loader == NULL). Klass holder should
78 // be used instead. It is enough to record a ciObject, since cached elements are never removed
|
39 // ciInstanceKlass
40 //
41 // This class represents a Klass* in the HotSpot virtual machine
42 // whose Klass part in an InstanceKlass.
43
44
45 // ------------------------------------------------------------------
46 // ciInstanceKlass::ciInstanceKlass
47 //
48 // Loaded instance klass.
49 ciInstanceKlass::ciInstanceKlass(Klass* k) :
50 ciKlass(k)
51 {
52 assert(get_Klass()->is_instance_klass(), "wrong type");
53 assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
54 InstanceKlass* ik = get_instanceKlass();
55
56 AccessFlags access_flags = ik->access_flags();
57 _flags = ciFlags(access_flags);
58 _has_finalizer = access_flags.has_finalizer();
59 _has_subklass = flags().is_final() ? subklass_false : subklass_unknown;
60 _init_state = ik->init_state();
61 _nonstatic_field_size = ik->nonstatic_field_size();
62 _has_nonstatic_fields = ik->has_nonstatic_fields();
63 _has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods();
64 _is_unsafe_anonymous = ik->is_unsafe_anonymous();
65 _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
66 _has_injected_fields = -1;
67 _implementor = NULL; // we will fill these lazily
68
69 // Ensure that the metadata wrapped by the ciMetadata is kept alive by GC.
70 // This is primarily useful for metadata which is considered as weak roots
71 // by the GC but need to be strong roots if reachable from a current compilation.
72 // InstanceKlass are created for both weak and strong metadata. Ensuring this metadata
73 // alive covers the cases where there are weak roots without performance cost.
74 oop holder = ik->holder_phantom();
75 if (ik->is_unsafe_anonymous()) {
76 // Though ciInstanceKlass records class loader oop, it's not enough to keep
77 // VM unsafe anonymous classes alive (loader == NULL). Klass holder should
78 // be used instead. It is enough to record a ciObject, since cached elements are never removed
|
129 _java_mirror = NULL;
130 _field_cache = NULL;
131 }
132
133
134
135 // ------------------------------------------------------------------
136 // ciInstanceKlass::compute_shared_is_initialized
137 void ciInstanceKlass::compute_shared_init_state() {
138 GUARDED_VM_ENTRY(
139 InstanceKlass* ik = get_instanceKlass();
140 _init_state = ik->init_state();
141 )
142 }
143
144 // ------------------------------------------------------------------
145 // ciInstanceKlass::compute_shared_has_subklass
146 bool ciInstanceKlass::compute_shared_has_subklass() {
147 GUARDED_VM_ENTRY(
148 InstanceKlass* ik = get_instanceKlass();
149 _has_subklass = ik->subklass() != NULL;
150 return _has_subklass;
151 )
152 }
153
154 // ------------------------------------------------------------------
155 // ciInstanceKlass::loader
156 oop ciInstanceKlass::loader() {
157 ASSERT_IN_VM;
158 return JNIHandles::resolve(_loader);
159 }
160
161 // ------------------------------------------------------------------
162 // ciInstanceKlass::loader_handle
163 jobject ciInstanceKlass::loader_handle() {
164 return _loader;
165 }
166
167 // ------------------------------------------------------------------
168 // ciInstanceKlass::protection_domain
169 oop ciInstanceKlass::protection_domain() {
|
129 _java_mirror = NULL;
130 _field_cache = NULL;
131 }
132
133
134
135 // ------------------------------------------------------------------
136 // ciInstanceKlass::compute_shared_is_initialized
137 void ciInstanceKlass::compute_shared_init_state() {
138 GUARDED_VM_ENTRY(
139 InstanceKlass* ik = get_instanceKlass();
140 _init_state = ik->init_state();
141 )
142 }
143
144 // ------------------------------------------------------------------
145 // ciInstanceKlass::compute_shared_has_subklass
146 bool ciInstanceKlass::compute_shared_has_subklass() {
147 GUARDED_VM_ENTRY(
148 InstanceKlass* ik = get_instanceKlass();
149 _has_subklass = ik->subklass() != NULL ? subklass_true : subklass_false;
150 return _has_subklass == subklass_true;
151 )
152 }
153
154 // ------------------------------------------------------------------
155 // ciInstanceKlass::loader
156 oop ciInstanceKlass::loader() {
157 ASSERT_IN_VM;
158 return JNIHandles::resolve(_loader);
159 }
160
161 // ------------------------------------------------------------------
162 // ciInstanceKlass::loader_handle
163 jobject ciInstanceKlass::loader_handle() {
164 return _loader;
165 }
166
167 // ------------------------------------------------------------------
168 // ciInstanceKlass::protection_domain
169 oop ciInstanceKlass::protection_domain() {
|
565 // Find a method in this klass.
566 ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) {
567 VM_ENTRY_MARK;
568 InstanceKlass* k = get_instanceKlass();
569 Symbol* name_sym = name->get_symbol();
570 Symbol* sig_sym= signature->get_symbol();
571
572 Method* m = k->find_method(name_sym, sig_sym);
573 if (m == NULL) return NULL;
574
575 return CURRENT_THREAD_ENV->get_method(m);
576 }
577
578 // ------------------------------------------------------------------
579 // ciInstanceKlass::is_leaf_type
580 bool ciInstanceKlass::is_leaf_type() {
581 assert(is_loaded(), "must be loaded");
582 if (is_shared()) {
583 return is_final(); // approximately correct
584 } else {
585 return !_has_subklass && (nof_implementors() == 0);
586 }
587 }
588
589 // ------------------------------------------------------------------
590 // ciInstanceKlass::implementor
591 //
592 // Report an implementor of this interface.
593 // Note that there are various races here, since my copy
594 // of _nof_implementors might be out of date with respect
595 // to results returned by InstanceKlass::implementor.
596 // This is OK, since any dependencies we decide to assert
597 // will be checked later under the Compile_lock.
598 ciInstanceKlass* ciInstanceKlass::implementor() {
599 ciInstanceKlass* impl = _implementor;
600 if (impl == NULL) {
601 // Go into the VM to fetch the implementor.
602 {
603 VM_ENTRY_MARK;
604 MutexLocker ml(Compile_lock);
|
565 // Find a method in this klass.
566 ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) {
567 VM_ENTRY_MARK;
568 InstanceKlass* k = get_instanceKlass();
569 Symbol* name_sym = name->get_symbol();
570 Symbol* sig_sym= signature->get_symbol();
571
572 Method* m = k->find_method(name_sym, sig_sym);
573 if (m == NULL) return NULL;
574
575 return CURRENT_THREAD_ENV->get_method(m);
576 }
577
578 // ------------------------------------------------------------------
579 // ciInstanceKlass::is_leaf_type
580 bool ciInstanceKlass::is_leaf_type() {
581 assert(is_loaded(), "must be loaded");
582 if (is_shared()) {
583 return is_final(); // approximately correct
584 } else {
585 return !has_subklass() && (nof_implementors() == 0);
586 }
587 }
588
589 // ------------------------------------------------------------------
590 // ciInstanceKlass::implementor
591 //
592 // Report an implementor of this interface.
593 // Note that there are various races here, since my copy
594 // of _nof_implementors might be out of date with respect
595 // to results returned by InstanceKlass::implementor.
596 // This is OK, since any dependencies we decide to assert
597 // will be checked later under the Compile_lock.
598 ciInstanceKlass* ciInstanceKlass::implementor() {
599 ciInstanceKlass* impl = _implementor;
600 if (impl == NULL) {
601 // Go into the VM to fetch the implementor.
602 {
603 VM_ENTRY_MARK;
604 MutexLocker ml(Compile_lock);
|