Mercurial > hg > graal-jvmci-8
comparison src/share/vm/graal/graalEnv.cpp @ 3654:4123781869da
More handles, fixed broken cast.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 17 Nov 2011 00:28:31 +0100 |
parents | 6aef50c6d967 |
children | d24f157f2ba8 |
comparison
equal
deleted
inserted
replaced
3653:6aef50c6d967 | 3654:4123781869da |
---|---|
47 // ------------------------------------------------------------------ | 47 // ------------------------------------------------------------------ |
48 // ciEnv::check_klass_accessiblity | 48 // ciEnv::check_klass_accessiblity |
49 // | 49 // |
50 // Note: the logic of this method should mirror the logic of | 50 // Note: the logic of this method should mirror the logic of |
51 // constantPoolOopDesc::verify_constant_pool_resolve. | 51 // constantPoolOopDesc::verify_constant_pool_resolve. |
52 bool GraalEnv::check_klass_accessibility(klassOop accessing_klass, klassOop resolved_klass) { | 52 bool GraalEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass) { |
53 if (accessing_klass->klass_part()->oop_is_objArray()) { | 53 if (accessing_klass->oop_is_objArray()) { |
54 accessing_klass = ((objArrayKlass*)accessing_klass)->bottom_klass(); | 54 accessing_klass = objArrayKlass::cast(accessing_klass())->bottom_klass(); |
55 } | 55 } |
56 if (!accessing_klass->klass_part()->oop_is_instance()) { | 56 if (!accessing_klass->oop_is_instance()) { |
57 return true; | 57 return true; |
58 } | 58 } |
59 | 59 |
60 if (resolved_klass->klass_part()->oop_is_objArray()) { | 60 if (resolved_klass->oop_is_objArray()) { |
61 // Find the element klass, if this is an array. | 61 // Find the element klass, if this is an array. |
62 resolved_klass = objArrayKlass::cast(resolved_klass)->bottom_klass(); | 62 resolved_klass = objArrayKlass::cast(resolved_klass())->bottom_klass(); |
63 } | 63 } |
64 if (resolved_klass->klass_part()->oop_is_instance()) { | 64 if (resolved_klass->oop_is_instance()) { |
65 return Reflection::verify_class_access(accessing_klass, resolved_klass, true); | 65 return Reflection::verify_class_access(accessing_klass(), resolved_klass(), true); |
66 } | 66 } |
67 return true; | 67 return true; |
68 } | 68 } |
69 | 69 |
70 // ------------------------------------------------------------------ | 70 // ------------------------------------------------------------------ |
71 // ciEnv::get_klass_by_name_impl | 71 // ciEnv::get_klass_by_name_impl |
72 klassOop GraalEnv::get_klass_by_name_impl(KlassHandle accessing_klass, | 72 KlassHandle GraalEnv::get_klass_by_name_impl(KlassHandle accessing_klass, |
73 constantPoolHandle cpool, | 73 constantPoolHandle cpool, |
74 Symbol* sym, | 74 Symbol* sym, |
75 bool require_local) { | 75 bool require_local) { |
76 EXCEPTION_CONTEXT; | 76 EXCEPTION_CONTEXT; |
77 | 77 |
80 sym->byte_at(sym->utf8_length()-1) == ';') { | 80 sym->byte_at(sym->utf8_length()-1) == ';') { |
81 // This is a name from a signature. Strip off the trimmings. | 81 // This is a name from a signature. Strip off the trimmings. |
82 // Call recursive to keep scope of strippedsym. | 82 // Call recursive to keep scope of strippedsym. |
83 TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1, | 83 TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1, |
84 sym->utf8_length()-2, | 84 sym->utf8_length()-2, |
85 CHECK_NULL); | 85 CHECK_(KlassHandle())); |
86 return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local); | 86 return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local); |
87 } | 87 } |
88 | 88 |
89 Handle loader(THREAD, (oop)NULL); | 89 Handle loader(THREAD, (oop)NULL); |
90 Handle domain(THREAD, (oop)NULL); | 90 Handle domain(THREAD, (oop)NULL); |
97 { | 97 { |
98 ttyUnlocker ttyul; // release tty lock to avoid ordering problems | 98 ttyUnlocker ttyul; // release tty lock to avoid ordering problems |
99 MutexLocker ml(Compile_lock); | 99 MutexLocker ml(Compile_lock); |
100 klassOop kls; | 100 klassOop kls; |
101 if (!require_local) { | 101 if (!require_local) { |
102 kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, CHECK_NULL); | 102 kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, CHECK_(KlassHandle())); |
103 } else { | 103 } else { |
104 kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, CHECK_NULL); | 104 kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, CHECK_(KlassHandle())); |
105 } | 105 } |
106 found_klass = KlassHandle(THREAD, kls); | 106 found_klass = KlassHandle(THREAD, kls); |
107 } | 107 } |
108 | 108 |
109 // If we fail to find an array klass, look again for its element type. | 109 // If we fail to find an array klass, look again for its element type. |
116 (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) { | 116 (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) { |
117 // We have an unloaded array. | 117 // We have an unloaded array. |
118 // Build it on the fly if the element class exists. | 118 // Build it on the fly if the element class exists. |
119 TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1, | 119 TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1, |
120 sym->utf8_length()-1, | 120 sym->utf8_length()-1, |
121 CHECK_NULL); | 121 CHECK_(KlassHandle())); |
122 | 122 |
123 // Get element ciKlass recursively. | 123 // Get element ciKlass recursively. |
124 KlassHandle elem_klass = | 124 KlassHandle elem_klass = |
125 get_klass_by_name_impl(accessing_klass, | 125 get_klass_by_name_impl(accessing_klass, |
126 cpool, | 126 cpool, |
127 elem_sym, | 127 elem_sym, |
128 require_local); | 128 require_local); |
129 if (!elem_klass.is_null()) { | 129 if (!elem_klass.is_null()) { |
130 // Now make an array for it | 130 // Now make an array for it |
131 return elem_klass->array_klass(CHECK_NULL); | 131 return elem_klass->array_klass(CHECK_(KlassHandle())); |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 if (found_klass.is_null() && !cpool.is_null() && cpool->has_preresolution()) { | 135 if (found_klass.is_null() && !cpool.is_null() && cpool->has_preresolution()) { |
136 // Look inside the constant pool for pre-resolved class entries. | 136 // Look inside the constant pool for pre-resolved class entries. |
161 | 161 |
162 // ------------------------------------------------------------------ | 162 // ------------------------------------------------------------------ |
163 // ciEnv::get_klass_by_index_impl | 163 // ciEnv::get_klass_by_index_impl |
164 // | 164 // |
165 // Implementation of get_klass_by_index. | 165 // Implementation of get_klass_by_index. |
166 klassOop GraalEnv::get_klass_by_index_impl(constantPoolHandle cpool, | 166 KlassHandle GraalEnv::get_klass_by_index_impl(constantPoolHandle cpool, |
167 int index, | 167 int index, |
168 bool& is_accessible, | 168 bool& is_accessible, |
169 KlassHandle accessor) { | 169 KlassHandle accessor) { |
170 EXCEPTION_CONTEXT; | 170 EXCEPTION_CONTEXT; |
171 KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index)); | 171 KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index)); |
207 is_accessible = false; | 207 is_accessible = false; |
208 } else { | 208 } else { |
209 // Linked locally, and we must also check public/private, etc. | 209 // Linked locally, and we must also check public/private, etc. |
210 is_accessible = check_klass_accessibility(accessor(), k()); | 210 is_accessible = check_klass_accessibility(accessor(), k()); |
211 } | 211 } |
212 return k(); | 212 return k; |
213 } | 213 } |
214 | |
215 // Check for prior unloaded klass. The SystemDictionary's answers | |
216 // can vary over time but the compiler needs consistency. | |
217 Symbol* name = klass()->klass_part()->name(); | |
218 | 214 |
219 // It is known to be accessible, since it was found in the constant pool. | 215 // It is known to be accessible, since it was found in the constant pool. |
220 is_accessible = true; | 216 is_accessible = true; |
221 return klass(); | 217 return klass; |
222 } | 218 } |
223 | 219 |
224 // ------------------------------------------------------------------ | 220 // ------------------------------------------------------------------ |
225 // ciEnv::get_klass_by_index | 221 // ciEnv::get_klass_by_index |
226 // | 222 // |