Mercurial > hg > truffle
comparison src/share/vm/graal/graalCompilerToVM.cpp @ 7037:dd81042f4eb1
added unit tests for ResolvedJavaType
replaced some CompilerToVM methods used by HotSpotResolvedJavaType with pure Java code
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 27 Nov 2012 11:21:48 +0100 |
parents | 58dbea9fb973 |
children | 34753b057324 |
comparison
equal
deleted
inserted
replaced
7036:8c4b757c2eb9 | 7037:dd81042f4eb1 |
---|---|
502 } | 502 } |
503 Handle holder = GraalCompiler::get_JavaType(method->method_holder(), CHECK_NULL); | 503 Handle holder = GraalCompiler::get_JavaType(method->method_holder(), CHECK_NULL); |
504 return JNIHandles::make_local(THREAD, VMToCompiler::createResolvedJavaMethod(holder, method(), THREAD)); | 504 return JNIHandles::make_local(THREAD, VMToCompiler::createResolvedJavaMethod(holder, method(), THREAD)); |
505 C2V_END | 505 C2V_END |
506 | 506 |
507 C2V_VMENTRY(jboolean, isSubtypeOf, (JNIEnv *, jobject, jobject klass, jobject jother)) | |
508 oop other = JNIHandles::resolve(jother); | |
509 assert(other->is_a(HotSpotResolvedJavaType::klass()), "resolved HotSpot type expected"); | |
510 assert(JNIHandles::resolve(klass) != NULL, ""); | |
511 Klass* thisKlass = java_lang_Class::as_Klass(HotSpotResolvedJavaType::javaMirror(klass)); | |
512 Klass* otherKlass = java_lang_Class::as_Klass(HotSpotResolvedJavaType::javaMirror(other)); | |
513 if (thisKlass->oop_is_instance()) { | |
514 return InstanceKlass::cast(thisKlass)->is_subtype_of(otherKlass); | |
515 } else if (thisKlass->oop_is_array()) { | |
516 return ArrayKlass::cast(thisKlass)->is_subtype_of(otherKlass); | |
517 } else { | |
518 fatal("unexpected class type"); | |
519 return false; | |
520 } | |
521 C2V_END | |
522 | |
523 C2V_VMENTRY(jobject, getLeastCommonAncestor, (JNIEnv *, jobject, jobject this_type, jobject other_type)) | |
524 | |
525 Klass* this_klass = java_lang_Class::as_Klass(HotSpotResolvedJavaType::javaMirror(this_type)); | |
526 Klass* other_klass = java_lang_Class::as_Klass(HotSpotResolvedJavaType::javaMirror(other_type)); | |
527 Klass* lca = this_klass->LCA(other_klass); | |
528 | |
529 return JNIHandles::make_local(GraalCompiler::get_JavaType(lca, THREAD)()); | |
530 C2V_END | |
531 | |
532 C2V_VMENTRY(jlong, getPrototypeMarkWord, (JNIEnv *, jobject, jobject klass)) | 507 C2V_VMENTRY(jlong, getPrototypeMarkWord, (JNIEnv *, jobject, jobject klass)) |
533 KlassHandle klass_handle(java_lang_Class::as_Klass(HotSpotResolvedJavaType::javaMirror(klass))); | 508 KlassHandle klass_handle(java_lang_Class::as_Klass(HotSpotResolvedJavaType::javaMirror(klass))); |
534 if (klass_handle->oop_is_array()) { | 509 if (klass_handle->oop_is_array()) { |
535 return (int32_t)(intptr_t) markOopDesc::prototype(); | 510 return (int32_t)(intptr_t) markOopDesc::prototype(); |
536 } else { | 511 } else { |
537 return (jlong) (intptr_t) klass_handle->prototype_header(); | 512 return (jlong) (intptr_t) klass_handle->prototype_header(); |
538 } | 513 } |
539 C2V_END | |
540 | |
541 C2V_VMENTRY(jobject, getUniqueConcreteSubtype, (JNIEnv *, jobject, jobject klass)) | |
542 KlassHandle klass_handle(java_lang_Class::as_Klass(HotSpotResolvedJavaType::javaMirror(klass))); | |
543 Klass *up_cast = klass_handle->up_cast_abstract(); | |
544 if (!up_cast->is_interface() && up_cast->subklass() == NULL) { | |
545 return JNIHandles::make_local(GraalCompiler::get_JavaType(up_cast, THREAD)()); | |
546 } | |
547 return NULL; | |
548 C2V_END | 514 C2V_END |
549 | 515 |
550 C2V_VMENTRY(jboolean, isTypeInitialized,(JNIEnv *, jobject, jobject hotspot_klass)) | 516 C2V_VMENTRY(jboolean, isTypeInitialized,(JNIEnv *, jobject, jobject hotspot_klass)) |
551 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedJavaType::javaMirror(hotspot_klass)); | 517 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedJavaType::javaMirror(hotspot_klass)); |
552 assert(klass != NULL, "method must not be called for primitive types"); | 518 assert(klass != NULL, "method must not be called for primitive types"); |
644 set_int(env, config, "markOffset", oopDesc::mark_offset_in_bytes()); | 610 set_int(env, config, "markOffset", oopDesc::mark_offset_in_bytes()); |
645 set_int(env, config, "prototypeMarkWordOffset", in_bytes(Klass::prototype_header_offset())); | 611 set_int(env, config, "prototypeMarkWordOffset", in_bytes(Klass::prototype_header_offset())); |
646 set_int(env, config, "superCheckOffsetOffset", in_bytes(Klass::super_check_offset_offset())); | 612 set_int(env, config, "superCheckOffsetOffset", in_bytes(Klass::super_check_offset_offset())); |
647 set_int(env, config, "secondarySuperCacheOffset", in_bytes(Klass::secondary_super_cache_offset())); | 613 set_int(env, config, "secondarySuperCacheOffset", in_bytes(Klass::secondary_super_cache_offset())); |
648 set_int(env, config, "secondarySupersOffset", in_bytes(Klass::secondary_supers_offset())); | 614 set_int(env, config, "secondarySupersOffset", in_bytes(Klass::secondary_supers_offset())); |
615 set_int(env, config, "subklassOffset", in_bytes(Klass::subklass_offset())); | |
616 set_int(env, config, "nextSiblingOffset", in_bytes(Klass::next_sibling_offset())); | |
649 set_int(env, config, "arrayLengthOffset", arrayOopDesc::length_offset_in_bytes()); | 617 set_int(env, config, "arrayLengthOffset", arrayOopDesc::length_offset_in_bytes()); |
650 set_int(env, config, "klassStateOffset", in_bytes(InstanceKlass::init_state_offset())); | 618 set_int(env, config, "klassStateOffset", in_bytes(InstanceKlass::init_state_offset())); |
651 set_int(env, config, "klassStateFullyInitialized", (int)InstanceKlass::fully_initialized); | 619 set_int(env, config, "klassStateFullyInitialized", (int)InstanceKlass::fully_initialized); |
652 set_int(env, config, "threadTlabTopOffset", in_bytes(JavaThread::tlab_top_offset())); | 620 set_int(env, config, "threadTlabTopOffset", in_bytes(JavaThread::tlab_top_offset())); |
653 set_int(env, config, "threadTlabEndOffset", in_bytes(JavaThread::tlab_end_offset())); | 621 set_int(env, config, "threadTlabEndOffset", in_bytes(JavaThread::tlab_end_offset())); |
960 {CC"lookupMethodInPool", CC"("HS_RESOLVED_TYPE"IB)"METHOD, FN_PTR(lookupMethodInPool)}, | 928 {CC"lookupMethodInPool", CC"("HS_RESOLVED_TYPE"IB)"METHOD, FN_PTR(lookupMethodInPool)}, |
961 {CC"lookupTypeInPool", CC"("HS_RESOLVED_TYPE"I)"TYPE, FN_PTR(lookupTypeInPool)}, | 929 {CC"lookupTypeInPool", CC"("HS_RESOLVED_TYPE"I)"TYPE, FN_PTR(lookupTypeInPool)}, |
962 {CC"lookupReferencedTypeInPool", CC"("HS_RESOLVED_TYPE"IB)V", FN_PTR(lookupReferencedTypeInPool)}, | 930 {CC"lookupReferencedTypeInPool", CC"("HS_RESOLVED_TYPE"IB)V", FN_PTR(lookupReferencedTypeInPool)}, |
963 {CC"lookupFieldInPool", CC"("HS_RESOLVED_TYPE"IB)"FIELD, FN_PTR(lookupFieldInPool)}, | 931 {CC"lookupFieldInPool", CC"("HS_RESOLVED_TYPE"IB)"FIELD, FN_PTR(lookupFieldInPool)}, |
964 {CC"resolveMethod", CC"("HS_RESOLVED_TYPE STRING STRING")"METHOD, FN_PTR(resolveMethod)}, | 932 {CC"resolveMethod", CC"("HS_RESOLVED_TYPE STRING STRING")"METHOD, FN_PTR(resolveMethod)}, |
965 {CC"isSubtypeOf", CC"("HS_RESOLVED_TYPE TYPE")Z", FN_PTR(isSubtypeOf)}, | |
966 {CC"getLeastCommonAncestor", CC"("HS_RESOLVED_TYPE HS_RESOLVED_TYPE")"TYPE, FN_PTR(getLeastCommonAncestor)}, | |
967 {CC"getUniqueConcreteSubtype", CC"("HS_RESOLVED_TYPE")"TYPE, FN_PTR(getUniqueConcreteSubtype)}, | |
968 {CC"getPrototypeMarkWord", CC"("HS_RESOLVED_TYPE")J", FN_PTR(getPrototypeMarkWord)}, | 933 {CC"getPrototypeMarkWord", CC"("HS_RESOLVED_TYPE")J", FN_PTR(getPrototypeMarkWord)}, |
969 {CC"getInstanceFields", CC"("HS_RESOLVED_TYPE")["HS_RESOLVED_FIELD, FN_PTR(getInstanceFields)}, | 934 {CC"getInstanceFields", CC"("HS_RESOLVED_TYPE")["HS_RESOLVED_FIELD, FN_PTR(getInstanceFields)}, |
970 {CC"isTypeInitialized", CC"("HS_RESOLVED_TYPE")Z", FN_PTR(isTypeInitialized)}, | 935 {CC"isTypeInitialized", CC"("HS_RESOLVED_TYPE")Z", FN_PTR(isTypeInitialized)}, |
971 {CC"initializeType", CC"("HS_RESOLVED_TYPE")V", FN_PTR(initializeType)}, | 936 {CC"initializeType", CC"("HS_RESOLVED_TYPE")V", FN_PTR(initializeType)}, |
972 {CC"getMaxCallTargetOffset", CC"(J)J", FN_PTR(getMaxCallTargetOffset)}, | 937 {CC"getMaxCallTargetOffset", CC"(J)J", FN_PTR(getMaxCallTargetOffset)}, |