comparison src/share/vm/graal/graalVMEntries.cpp @ 3563:8780fa370aab

Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
author Peter Hofer <peter.hofer@jku.at>
date Wed, 31 Aug 2011 14:55:40 +0200
parents f70a4cc629e7
children dbf8d6a4201f 76a7f1732bb0
comparison
equal deleted inserted replaced
3562:549b9bcb8db6 3563:8780fa370aab
747 assert(type != T_OBJECT, "primitive type expecteds"); 747 assert(type != T_OBJECT, "primitive type expecteds");
748 ciKlass* klass = ciTypeArrayKlass::make(type); 748 ciKlass* klass = ciTypeArrayKlass::make(type);
749 return JNIHandles::make_local(THREAD, GraalCompiler::get_RiType(klass, KlassHandle(), THREAD)); 749 return JNIHandles::make_local(THREAD, GraalCompiler::get_RiType(klass, KlassHandle(), THREAD));
750 } 750 }
751 751
752 // public long getMaxCallTargetOffset(CiRuntimeCall rtcall);
753 JNIEXPORT jlong JNICALL Java_com_oracle_graal_runtime_VMEntries_getMaxCallTargetOffset(JNIEnv *env, jobject, jobject rtcall) {
754 TRACE_graal_3("VMEntries::VMEntries_getMaxCallTargetOffset");
755 VM_ENTRY_MARK;
756 oop call = JNIHandles::resolve(rtcall);
757 address target_addr = 0x0;
758 if (call == CiRuntimeCall::ArithmeticSin()) {
759 target_addr = CAST_FROM_FN_PTR(address, SharedRuntime::dsin);
760 } else if (call == CiRuntimeCall::ArithmeticCos()) {
761 target_addr = CAST_FROM_FN_PTR(address, SharedRuntime::dcos);
762 } else if (call == CiRuntimeCall::ArithmeticTan()) {
763 target_addr = CAST_FROM_FN_PTR(address, SharedRuntime::dtan);
764 } else if (call == CiRuntimeCall::JavaTimeMillis()) {
765 target_addr = CAST_FROM_FN_PTR(address, os::javaTimeMillis);
766 } else if (call == CiRuntimeCall::JavaTimeNanos()) {
767 target_addr = CAST_FROM_FN_PTR(address, os::javaTimeNanos);
768 }
769 if (target_addr != 0x0) {
770 int64_t off_low = (int64_t)target_addr - ((int64_t)CodeCache::low_bound() + sizeof(int));
771 int64_t off_high = (int64_t)target_addr - ((int64_t)CodeCache::high_bound() + sizeof(int));
772 return MAX2(ABS(off_low), ABS(off_high));
773 }
774 return -1;
775 }
776
752 // public RiType getType(Class<?> javaClass); 777 // public RiType getType(Class<?> javaClass);
753 JNIEXPORT jobject JNICALL Java_com_oracle_graal_runtime_VMEntries_getType(JNIEnv *env, jobject, jobject javaClass) { 778 JNIEXPORT jobject JNICALL Java_com_oracle_graal_runtime_VMEntries_getType(JNIEnv *env, jobject, jobject javaClass) {
754 TRACE_graal_3("VMEntries::VMEntries_getType"); 779 TRACE_graal_3("VMEntries::VMEntries_getType");
755 VM_ENTRY_MARK; 780 VM_ENTRY_MARK;
756 oop javaClassOop = JNIHandles::resolve(javaClass); 781 oop javaClassOop = JNIHandles::resolve(javaClass);
939 #define TARGET_METHOD "Lcom/oracle/max/graal/runtime/HotSpotTargetMethod;" 964 #define TARGET_METHOD "Lcom/oracle/max/graal/runtime/HotSpotTargetMethod;"
940 #define CONFIG "Lcom/oracle/max/graal/runtime/HotSpotVMConfig;" 965 #define CONFIG "Lcom/oracle/max/graal/runtime/HotSpotVMConfig;"
941 #define HS_METHOD "Lcom/oracle/max/graal/runtime/HotSpotMethod;" 966 #define HS_METHOD "Lcom/oracle/max/graal/runtime/HotSpotMethod;"
942 #define CI_CONSTANT "Lcom/sun/cri/ci/CiConstant;" 967 #define CI_CONSTANT "Lcom/sun/cri/ci/CiConstant;"
943 #define CI_KIND "Lcom/sun/cri/ci/CiKind;" 968 #define CI_KIND "Lcom/sun/cri/ci/CiKind;"
969 #define CI_RUNTIME_CALL "Lcom/sun/cri/ci/CiRuntimeCall;"
944 #define STRING "Ljava/lang/String;" 970 #define STRING "Ljava/lang/String;"
945 #define OBJECT "Ljava/lang/Object;" 971 #define OBJECT "Ljava/lang/Object;"
946 #define CLASS "Ljava/lang/Class;" 972 #define CLASS "Ljava/lang/Class;"
947 973
948 JNINativeMethod VMEntries_methods[] = { 974 JNINativeMethod VMEntries_methods[] = {
973 {CC"RiType_superType", CC"("RESOLVED_TYPE")"TYPE, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_RiType_1superType)}, 999 {CC"RiType_superType", CC"("RESOLVED_TYPE")"TYPE, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_RiType_1superType)},
974 {CC"RiType_arrayOf", CC"("RESOLVED_TYPE")"TYPE, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_RiType_1arrayOf)}, 1000 {CC"RiType_arrayOf", CC"("RESOLVED_TYPE")"TYPE, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_RiType_1arrayOf)},
975 {CC"RiType_fields", CC"("RESOLVED_TYPE")["FIELD, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_RiType_1fields)}, 1001 {CC"RiType_fields", CC"("RESOLVED_TYPE")["FIELD, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_RiType_1fields)},
976 {CC"RiType_isInitialized", CC"("RESOLVED_TYPE")Z", FN_PTR(Java_com_oracle_graal_runtime_VMEntries_RiType_1isInitialized)}, 1002 {CC"RiType_isInitialized", CC"("RESOLVED_TYPE")Z", FN_PTR(Java_com_oracle_graal_runtime_VMEntries_RiType_1isInitialized)},
977 {CC"getPrimitiveArrayType", CC"("CI_KIND")"TYPE, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_getPrimitiveArrayType)}, 1003 {CC"getPrimitiveArrayType", CC"("CI_KIND")"TYPE, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_getPrimitiveArrayType)},
1004 {CC"getMaxCallTargetOffset", CC"("CI_RUNTIME_CALL")J", FN_PTR(Java_com_oracle_graal_runtime_VMEntries_getMaxCallTargetOffset)},
978 {CC"getType", CC"("CLASS")"TYPE, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_getType)}, 1005 {CC"getType", CC"("CLASS")"TYPE, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_getType)},
979 {CC"getConfiguration", CC"()"CONFIG, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_getConfiguration)}, 1006 {CC"getConfiguration", CC"()"CONFIG, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_getConfiguration)},
980 {CC"installMethod", CC"("TARGET_METHOD")V", FN_PTR(Java_com_oracle_graal_runtime_VMEntries_installMethod)}, 1007 {CC"installMethod", CC"("TARGET_METHOD")V", FN_PTR(Java_com_oracle_graal_runtime_VMEntries_installMethod)},
981 {CC"installStub", CC"("TARGET_METHOD")"PROXY, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_installStub)}, 1008 {CC"installStub", CC"("TARGET_METHOD")"PROXY, FN_PTR(Java_com_oracle_graal_runtime_VMEntries_installStub)},
982 {CC"recordBailout", CC"("STRING")V", FN_PTR(Java_com_oracle_graal_runtime_VMEntries_recordBailout)} 1009 {CC"recordBailout", CC"("STRING")V", FN_PTR(Java_com_oracle_graal_runtime_VMEntries_recordBailout)}