Mercurial > hg > graal-jvmci-8
comparison src/share/vm/graal/graalCompiler.cpp @ 13375:e8c4a6ea3f77
cleaned up VMToCompiler.createResolvedJavaType
author | twisti |
---|---|
date | Tue, 17 Dec 2013 20:58:58 -0800 |
parents | 430c9f08728d |
children | 606959535fd4 |
comparison
equal
deleted
inserted
replaced
13374:ad187607b784 | 13375:e8c4a6ea3f77 |
---|---|
217 // Print compilation timers and statistics | 217 // Print compilation timers and statistics |
218 void GraalCompiler::print_timers() { | 218 void GraalCompiler::print_timers() { |
219 TRACE_graal_1("GraalCompiler::print_timers"); | 219 TRACE_graal_1("GraalCompiler::print_timers"); |
220 } | 220 } |
221 | 221 |
222 Handle GraalCompiler::get_JavaType(Symbol* klass_name, TRAPS) { | |
223 return VMToCompiler::createUnresolvedJavaType(java_lang_String::create_from_symbol(klass_name, THREAD), THREAD); | |
224 } | |
225 | |
226 Handle GraalCompiler::get_JavaTypeFromSignature(Symbol* signature, KlassHandle loading_klass, TRAPS) { | 222 Handle GraalCompiler::get_JavaTypeFromSignature(Symbol* signature, KlassHandle loading_klass, TRAPS) { |
227 | |
228 BasicType field_type = FieldType::basic_type(signature); | 223 BasicType field_type = FieldType::basic_type(signature); |
229 // If the field is a pointer type, get the klass of the | 224 // If the field is a pointer type, get the klass of the |
230 // field. | 225 // field. |
231 if (field_type == T_OBJECT || field_type == T_ARRAY) { | 226 if (field_type == T_OBJECT || field_type == T_ARRAY) { |
232 KlassHandle handle = GraalEnv::get_klass_by_name(loading_klass, signature, false); | 227 KlassHandle klass = GraalEnv::get_klass_by_name(loading_klass, signature, false); |
233 if (handle.is_null()) { | 228 if (klass.is_null()) { |
234 return get_JavaType(signature, CHECK_NH); | 229 Handle signature_string = java_lang_String::create_from_symbol(signature, CHECK_NH); |
230 return VMToCompiler::createUnresolvedJavaType(signature_string, CHECK_NH); | |
235 } else { | 231 } else { |
236 return get_JavaType(handle, CHECK_NH); | 232 return createHotSpotResolvedObjectType(klass, CHECK_NH); |
237 } | 233 } |
238 } else { | 234 } else { |
239 return VMToCompiler::createPrimitiveJavaType(field_type, CHECK_NH); | 235 return VMToCompiler::createPrimitiveJavaType(field_type, CHECK_NH); |
240 } | 236 } |
241 } | 237 } |
254 MonitorLockerEx ml(cp->lock()); | 250 MonitorLockerEx ml(cp->lock()); |
255 constantTag tag = cp->tag_at(index); | 251 constantTag tag = cp->tag_at(index); |
256 if (tag.is_klass()) { | 252 if (tag.is_klass()) { |
257 // The klass has been inserted into the constant pool | 253 // The klass has been inserted into the constant pool |
258 // very recently. | 254 // very recently. |
259 return GraalCompiler::get_JavaType(cp->resolved_klass_at(index), CHECK_NH); | 255 return GraalCompiler::createHotSpotResolvedObjectType(cp->resolved_klass_at(index), CHECK_NH); |
260 } else if (tag.is_symbol()) { | 256 } else if (tag.is_symbol()) { |
261 klass_name = cp->symbol_at(index); | 257 klass_name = cp->symbol_at(index); |
262 } else { | 258 } else { |
263 assert(cp->tag_at(index).is_unresolved_klass(), "wrong tag"); | 259 assert(cp->tag_at(index).is_unresolved_klass(), "wrong tag"); |
264 klass_name = cp->unresolved_klass_at(index); | 260 klass_name = cp->unresolved_klass_at(index); |
265 } | 261 } |
266 } | 262 } |
267 return GraalCompiler::get_JavaType(klass_name, CHECK_NH); | 263 Handle klass_name_string = java_lang_String::create_from_symbol(klass_name, CHECK_NH); |
264 return VMToCompiler::createUnresolvedJavaType(klass_name_string, CHECK_NH); | |
268 } else { | 265 } else { |
269 return GraalCompiler::get_JavaType(klass, CHECK_NH); | 266 return GraalCompiler::createHotSpotResolvedObjectType(klass, CHECK_NH); |
270 } | 267 } |
271 } | |
272 | |
273 Handle GraalCompiler::get_JavaType(KlassHandle klass, TRAPS) { | |
274 Handle name = java_lang_String::create_from_symbol(klass->name(), THREAD); | |
275 return createHotSpotResolvedObjectType(klass, name, CHECK_NH); | |
276 } | 268 } |
277 | 269 |
278 Handle GraalCompiler::get_JavaField(int offset, int flags, Symbol* field_name, Handle field_holder, Handle field_type, TRAPS) { | 270 Handle GraalCompiler::get_JavaField(int offset, int flags, Symbol* field_name, Handle field_holder, Handle field_type, TRAPS) { |
279 Handle name = java_lang_String::create_from_symbol(field_name, CHECK_NH); | 271 Handle name = java_lang_String::create_from_symbol(field_name, CHECK_NH); |
280 return VMToCompiler::createJavaField(field_holder, name, field_type, offset, flags, false, CHECK_NH); | 272 return VMToCompiler::createJavaField(field_holder, name, field_type, offset, flags, false, CHECK_NH); |
281 } | 273 } |
282 | 274 |
283 Handle GraalCompiler::createHotSpotResolvedObjectType(KlassHandle klass, Handle name, TRAPS) { | 275 Handle GraalCompiler::createHotSpotResolvedObjectType(KlassHandle klass, TRAPS) { |
284 oop java_class = klass->java_mirror(); | 276 oop java_class = klass->java_mirror(); |
285 oop graal_mirror = java_lang_Class::graal_mirror(java_class); | 277 oop graal_mirror = java_lang_Class::graal_mirror(java_class); |
286 if (graal_mirror != NULL) { | 278 if (graal_mirror != NULL) { |
287 assert(graal_mirror->is_a(HotSpotResolvedObjectType::klass()), "unexpected class..."); | 279 assert(graal_mirror->is_a(HotSpotResolvedObjectType::klass()), "unexpected class..."); |
288 return graal_mirror; | 280 return graal_mirror; |
289 } | 281 } |
290 | 282 return VMToCompiler::createResolvedJavaType(java_class, CHECK_NH); |
291 Handle simpleName = name; | |
292 if (klass->oop_is_instance()) { | |
293 ResourceMark rm; | |
294 InstanceKlass* ik = (InstanceKlass*) klass(); | |
295 name = java_lang_String::create_from_str(ik->signature_name(), CHECK_NH); | |
296 } | |
297 | |
298 int sizeOrSpecies; | |
299 if (klass->is_interface()) { | |
300 sizeOrSpecies = (int) 0x80000000; // see HotSpotResolvedObjectType.INTERFACE_SPECIES_VALUE | |
301 } else if (klass->oop_is_array()) { | |
302 sizeOrSpecies = (int) 0x7fffffff; // see HotSpotResolvedObjectType.ARRAY_SPECIES_VALUE | |
303 } else { | |
304 sizeOrSpecies = InstanceKlass::cast(klass())->size_helper() * HeapWordSize; | |
305 if (!InstanceKlass::cast(klass())->can_be_fastpath_allocated()) { | |
306 sizeOrSpecies = -sizeOrSpecies; | |
307 } | |
308 } | |
309 | |
310 return VMToCompiler::createResolvedJavaType(klass(), name, simpleName, java_class, sizeOrSpecies, CHECK_NH); | |
311 } | 283 } |
312 | 284 |
313 BasicType GraalCompiler::kindToBasicType(jchar ch) { | 285 BasicType GraalCompiler::kindToBasicType(jchar ch) { |
314 switch(ch) { | 286 switch(ch) { |
315 case 'z': return T_BOOLEAN; | 287 case 'z': return T_BOOLEAN; |