comparison src/share/vm/graal/graalCompilerToVM.cpp @ 7310:79a7b761755c

Added getLineNumberTable and getFileName capabilities.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 20 Dec 2012 14:50:56 +0100
parents 310a68c63b69
children 46f945023189
comparison
equal deleted inserted replaced
7309:75c18356504d 7310:79a7b761755c
936 } 936 }
937 Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL); 937 Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL);
938 return JNIHandles::make_local(result()); 938 return JNIHandles::make_local(result());
939 C2V_END 939 C2V_END
940 940
941 C2V_ENTRY(jlongArray, getLineNumberTable, (JNIEnv *env, jobject, jobject hotspot_method))
942 // XXX: Attention: it seEms that the line number table of a method just contains lines that are important, means that
943 // empty lines are left out or lines that can't have a breakpoint on it; eg int a; or try {
944 Method* method = getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method));
945 if(!method->has_linenumber_table()) {
946 return NULL;
947 }
948 u2 num_entries = 0;
949 CompressedLineNumberReadStream streamForSize(method->compressed_linenumber_table());
950 while (streamForSize.read_pair()) {
951 num_entries++;
952 }
953
954 CompressedLineNumberReadStream stream(method->compressed_linenumber_table());
955 jlongArray result = env->NewLongArray(2 * num_entries);
956
957 int i = 0;
958 jlong value;
959 while (stream.read_pair()) {
960 value = ((long) stream.bci());
961 env->SetLongArrayRegion(result,i,1,&value);
962 value = ((long) stream.line());
963 env->SetLongArrayRegion(result,i + 1,1,&value);
964 i += 2;
965 }
966
967 return result;
968 C2V_END
969
970
971 C2V_VMENTRY(jobject, getFileName, (JNIEnv *, jobject, jobject klass))
972 ResourceMark rm;
973 InstanceKlass* k = (InstanceKlass*) asKlass(HotSpotResolvedObjectType::metaspaceKlass(klass));
974 Symbol *s = k->source_file_name();
975 int length;
976 jchar *name = s->as_unicode(length);
977
978 Handle result = java_lang_String::create_from_unicode(name, length, CHECK_NULL);
979 return JNIHandles::make_local(result());
980
981 C2V_END
941 982
942 #define CC (char*) /*cast a literal from (const char*)*/ 983 #define CC (char*) /*cast a literal from (const char*)*/
943 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f)) 984 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f))
944 985
945 #define RESOLVED_TYPE "Lcom/oracle/graal/api/meta/ResolvedJavaType;" 986 #define RESOLVED_TYPE "Lcom/oracle/graal/api/meta/ResolvedJavaType;"
958 #define STRING "Ljava/lang/String;" 999 #define STRING "Ljava/lang/String;"
959 #define OBJECT "Ljava/lang/Object;" 1000 #define OBJECT "Ljava/lang/Object;"
960 #define CLASS "Ljava/lang/Class;" 1001 #define CLASS "Ljava/lang/Class;"
961 #define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;" 1002 #define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;"
962 #define HS_RESOLVED_TYPE "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedObjectType;" 1003 #define HS_RESOLVED_TYPE "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedObjectType;"
1004 #define HS_RESOLVED_JAVA_TYPE "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaType;"
963 #define HS_RESOLVED_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod;" 1005 #define HS_RESOLVED_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod;"
964 #define HS_RESOLVED_FIELD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaField;" 1006 #define HS_RESOLVED_FIELD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaField;"
965 #define HS_COMP_RESULT "Lcom/oracle/graal/hotspot/HotSpotCompilationResult;" 1007 #define HS_COMP_RESULT "Lcom/oracle/graal/hotspot/HotSpotCompilationResult;"
966 #define HS_CONFIG "Lcom/oracle/graal/hotspot/HotSpotVMConfig;" 1008 #define HS_CONFIG "Lcom/oracle/graal/hotspot/HotSpotVMConfig;"
967 #define HS_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotMethod;" 1009 #define HS_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotMethod;"
1006 {CC"disassembleNative", CC"([BJ)"STRING, FN_PTR(disassembleNative)}, 1048 {CC"disassembleNative", CC"([BJ)"STRING, FN_PTR(disassembleNative)},
1007 {CC"executeCompiledMethod", CC"("METASPACE_METHOD NMETHOD OBJECT OBJECT OBJECT")"OBJECT, FN_PTR(executeCompiledMethod)}, 1049 {CC"executeCompiledMethod", CC"("METASPACE_METHOD NMETHOD OBJECT OBJECT OBJECT")"OBJECT, FN_PTR(executeCompiledMethod)},
1008 {CC"executeCompiledMethodVarargs", CC"("METASPACE_METHOD NMETHOD "["OBJECT")"OBJECT, FN_PTR(executeCompiledMethodVarargs)}, 1050 {CC"executeCompiledMethodVarargs", CC"("METASPACE_METHOD NMETHOD "["OBJECT")"OBJECT, FN_PTR(executeCompiledMethodVarargs)},
1009 {CC"getDeoptedLeafGraphIds", CC"()[J", FN_PTR(getDeoptedLeafGraphIds)}, 1051 {CC"getDeoptedLeafGraphIds", CC"()[J", FN_PTR(getDeoptedLeafGraphIds)},
1010 {CC"decodePC", CC"(J)"STRING, FN_PTR(decodePC)}, 1052 {CC"decodePC", CC"(J)"STRING, FN_PTR(decodePC)},
1053 {CC"getLineNumberTable", CC"("HS_RESOLVED_METHOD")[J", FN_PTR(getLineNumberTable)},
1054 {CC"getFileName", CC"("HS_RESOLVED_JAVA_TYPE")"STRING, FN_PTR(getFileName)},
1011 }; 1055 };
1012 1056
1013 int CompilerToVM_methods_count() { 1057 int CompilerToVM_methods_count() {
1014 return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod); 1058 return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod);
1015 } 1059 }