comparison src/share/vm/graal/graalCompilerToVM.cpp @ 14104:a38a54030ea2

pass metaspace pointers instead of object to VM
author twisti
date Thu, 06 Mar 2014 21:03:59 -0800
parents dd783f0ecf17
children f62c770c22be
comparison
equal deleted inserted replaced
14103:9d8aaa3200a3 14104:a38a54030ea2
41 #include "runtime/javaCalls.hpp" 41 #include "runtime/javaCalls.hpp"
42 #include "runtime/vmStructs.hpp" 42 #include "runtime/vmStructs.hpp"
43 #include "runtime/gpu.hpp" 43 #include "runtime/gpu.hpp"
44 44
45 45
46 Method* getMethodFromHotSpotMethod(oop hotspot_method) {
47 assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethod::klass()), "sanity");
48 return asMethod(HotSpotResolvedJavaMethod::metaspaceMethod(hotspot_method));
49 }
50
51 // Entry to native method implementation that transitions current thread to '_thread_in_vm'. 46 // Entry to native method implementation that transitions current thread to '_thread_in_vm'.
52 #define C2V_VMENTRY(result_type, name, signature) \ 47 #define C2V_VMENTRY(result_type, name, signature) \
53 JNIEXPORT result_type JNICALL c2v_ ## name signature { \ 48 JNIEXPORT result_type JNICALL c2v_ ## name signature { \
54 TRACE_graal_3("CompilerToVM::" #name); \ 49 TRACE_graal_3("CompilerToVM::" #name); \
55 GRAAL_VM_ENTRY_MARK; \ 50 GRAAL_VM_ENTRY_MARK; \
355 info->long_at_put(0, (jlong) result.access_flags().as_int()); 350 info->long_at_put(0, (jlong) result.access_flags().as_int());
356 info->long_at_put(1, (jlong) result.offset()); 351 info->long_at_put(1, (jlong) result.offset());
357 return (jlong) (address) result.field_holder(); 352 return (jlong) (address) result.field_holder();
358 C2V_END 353 C2V_END
359 354
360 C2V_VMENTRY(jlong, resolveMethod, (JNIEnv *, jobject, jobject resolved_type, jstring name, jstring signature)) 355 C2V_VMENTRY(jlong, resolveMethod, (JNIEnv *, jobject, jlong metaspace_klass, jstring name, jstring signature))
361 assert(JNIHandles::resolve(resolved_type) != NULL, ""); 356 Klass* klass = (Klass*) metaspace_klass;
362 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaClass(resolved_type));
363 Symbol* name_symbol = java_lang_String::as_symbol(JNIHandles::resolve(name), THREAD); 357 Symbol* name_symbol = java_lang_String::as_symbol(JNIHandles::resolve(name), THREAD);
364 Symbol* signature_symbol = java_lang_String::as_symbol(JNIHandles::resolve(signature), THREAD); 358 Symbol* signature_symbol = java_lang_String::as_symbol(JNIHandles::resolve(signature), THREAD);
365 return (jlong) (address) klass->lookup_method(name_symbol, signature_symbol); 359 return (jlong) (address) klass->lookup_method(name_symbol, signature_symbol);
366 C2V_END 360 C2V_END
367 361
368 C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jobject hotspot_klass)) 362 C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jlong metaspace_klass))
369 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaClass(hotspot_klass)); 363 Klass* klass = (Klass*) metaspace_klass;
370 assert(klass != NULL, "method must not be called for primitive types"); 364 assert(klass != NULL, "method must not be called for primitive types");
371 return Dependencies::find_finalizable_subclass(klass) != NULL; 365 return Dependencies::find_finalizable_subclass(klass) != NULL;
372 C2V_END 366 C2V_END
373 367
374 C2V_VMENTRY(jlong, getClassInitializer, (JNIEnv *, jobject, jobject klass)) 368 C2V_VMENTRY(jlong, getClassInitializer, (JNIEnv *, jobject, jlong metaspace_klass))
375 instanceKlassHandle k(THREAD, java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaClass(klass))); 369 InstanceKlass* klass = (InstanceKlass*) metaspace_klass;
376 Method* clinit = k->class_initializer(); 370 return (jlong) (address) klass->class_initializer();
377 return (jlong) (address) clinit;
378 C2V_END 371 C2V_END
379 372
380 C2V_VMENTRY(jlong, getMaxCallTargetOffset, (JNIEnv *env, jobject, jlong addr)) 373 C2V_VMENTRY(jlong, getMaxCallTargetOffset, (JNIEnv *env, jobject, jlong addr))
381 address target_addr = (address) addr; 374 address target_addr = (address) addr;
382 if (target_addr != 0x0) { 375 if (target_addr != 0x0) {
706 699
707 oop array = GraalCompiler::instance()->dump_deopted_leaf_graphs(CHECK_NULL); 700 oop array = GraalCompiler::instance()->dump_deopted_leaf_graphs(CHECK_NULL);
708 return JNIHandles::make_local(array); 701 return JNIHandles::make_local(array);
709 C2V_END 702 C2V_END
710 703
711 C2V_ENTRY(jlongArray, getLineNumberTable, (JNIEnv *env, jobject, jobject hotspot_method)) 704 C2V_ENTRY(jlongArray, getLineNumberTable, (JNIEnv *env, jobject, jlong metaspace_method))
712 Method* method = getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method)); 705 Method* method = (Method*) metaspace_method;
713 if (!method->has_linenumber_table()) { 706 if (!method->has_linenumber_table()) {
714 return NULL; 707 return NULL;
715 } 708 }
716 u2 num_entries = 0; 709 u2 num_entries = 0;
717 CompressedLineNumberReadStream streamForSize(method->compressed_linenumber_table()); 710 CompressedLineNumberReadStream streamForSize(method->compressed_linenumber_table());
733 } 726 }
734 727
735 return result; 728 return result;
736 C2V_END 729 C2V_END
737 730
738 C2V_VMENTRY(jlong, getLocalVariableTableStart, (JNIEnv *, jobject, jobject hotspot_method)) 731 C2V_VMENTRY(jlong, getLocalVariableTableStart, (JNIEnv *, jobject, jlong metaspace_method))
739 ResourceMark rm; 732 ResourceMark rm;
740 Method* method = getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method)); 733 Method* method = (Method*) metaspace_method;
741 if (!method->has_localvariable_table()) { 734 if (!method->has_localvariable_table()) {
742 return 0; 735 return 0;
743 } 736 }
744 return (jlong) (address) method->localvariable_table_start(); 737 return (jlong) (address) method->localvariable_table_start();
745 C2V_END 738 C2V_END
746 739
747 C2V_VMENTRY(jint, getLocalVariableTableLength, (JNIEnv *, jobject, jobject hotspot_method)) 740 C2V_VMENTRY(jint, getLocalVariableTableLength, (JNIEnv *, jobject, jlong metaspace_method))
748 ResourceMark rm; 741 ResourceMark rm;
749 Method* method = getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method)); 742 Method* method = (Method*) metaspace_method;
750 return method->localvariable_table_length(); 743 return method->localvariable_table_length();
751 C2V_END 744 C2V_END
752 745
753 C2V_VMENTRY(void, reprofile, (JNIEnv *env, jobject, jlong metaspace_method)) 746 C2V_VMENTRY(void, reprofile, (JNIEnv *env, jobject, jlong metaspace_method))
754 Method* method = asMethod(metaspace_method); 747 Method* method = asMethod(metaspace_method);
810 #else 803 #else
811 return env->NewStringUTF(""); 804 return env->NewStringUTF("");
812 #endif 805 #endif
813 C2V_END 806 C2V_END
814 807
815 C2V_VMENTRY(int, allocateCompileId, (JNIEnv *env, jobject, jobject hotspot_method, int entry_bci)) 808 C2V_VMENTRY(int, allocateCompileId, (JNIEnv *env, jobject, jlong metaspace_method, int entry_bci))
816 HandleMark hm; 809 HandleMark hm;
817 ResourceMark rm; 810 ResourceMark rm;
818 Method* method = getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method)); 811 Method* method = (Method*) metaspace_method;
819 return CompileBroker::assign_compile_id_unlocked(THREAD, method, entry_bci); 812 return CompileBroker::assign_compile_id_unlocked(THREAD, method, entry_bci);
820 C2V_END 813 C2V_END
821 814
822 815
823 C2V_VMENTRY(jboolean, isMature, (JNIEnv *env, jobject, jlong metaspace_method_data)) 816 C2V_VMENTRY(jboolean, isMature, (JNIEnv *env, jobject, jlong metaspace_method_data))
834 #define SPECULATION_LOG "Lcom/oracle/graal/api/code/SpeculationLog;" 827 #define SPECULATION_LOG "Lcom/oracle/graal/api/code/SpeculationLog;"
835 #define STRING "Ljava/lang/String;" 828 #define STRING "Ljava/lang/String;"
836 #define OBJECT "Ljava/lang/Object;" 829 #define OBJECT "Ljava/lang/Object;"
837 #define CLASS "Ljava/lang/Class;" 830 #define CLASS "Ljava/lang/Class;"
838 #define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;" 831 #define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;"
839 #define HS_RESOLVED_TYPE "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedObjectType;"
840 #define HS_RESOLVED_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod;" 832 #define HS_RESOLVED_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod;"
841 #define HS_COMPILED_CODE "Lcom/oracle/graal/hotspot/HotSpotCompiledCode;" 833 #define HS_COMPILED_CODE "Lcom/oracle/graal/hotspot/HotSpotCompiledCode;"
842 #define HS_CONFIG "Lcom/oracle/graal/hotspot/HotSpotVMConfig;" 834 #define HS_CONFIG "Lcom/oracle/graal/hotspot/HotSpotVMConfig;"
843 #define HS_INSTALLED_CODE "Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;" 835 #define HS_INSTALLED_CODE "Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;"
844 #define METASPACE_KLASS "J" 836 #define METASPACE_KLASS "J"
869 {CC"lookupKlassInPool", CC"("METASPACE_CONSTANT_POOL"I)"METASPACE_KLASS, FN_PTR(lookupKlassInPool)}, 861 {CC"lookupKlassInPool", CC"("METASPACE_CONSTANT_POOL"I)"METASPACE_KLASS, FN_PTR(lookupKlassInPool)},
870 {CC"lookupAppendixInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(lookupAppendixInPool)}, 862 {CC"lookupAppendixInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(lookupAppendixInPool)},
871 {CC"lookupMethodInPool", CC"("METASPACE_CONSTANT_POOL"IB)"METASPACE_METHOD, FN_PTR(lookupMethodInPool)}, 863 {CC"lookupMethodInPool", CC"("METASPACE_CONSTANT_POOL"IB)"METASPACE_METHOD, FN_PTR(lookupMethodInPool)},
872 {CC"loadReferencedTypeInPool", CC"("METASPACE_CONSTANT_POOL"IB)V", FN_PTR(loadReferencedTypeInPool)}, 864 {CC"loadReferencedTypeInPool", CC"("METASPACE_CONSTANT_POOL"IB)V", FN_PTR(loadReferencedTypeInPool)},
873 {CC"resolveField", CC"("METASPACE_CONSTANT_POOL"IB[J)"METASPACE_KLASS, FN_PTR(resolveField)}, 865 {CC"resolveField", CC"("METASPACE_CONSTANT_POOL"IB[J)"METASPACE_KLASS, FN_PTR(resolveField)},
874 {CC"resolveMethod", CC"("HS_RESOLVED_TYPE STRING STRING")"METASPACE_METHOD, FN_PTR(resolveMethod)}, 866 {CC"resolveMethod", CC"("METASPACE_KLASS STRING STRING")"METASPACE_METHOD, FN_PTR(resolveMethod)},
875 {CC"getClassInitializer", CC"("HS_RESOLVED_TYPE")"METASPACE_METHOD, FN_PTR(getClassInitializer)}, 867 {CC"getClassInitializer", CC"("METASPACE_KLASS")"METASPACE_METHOD, FN_PTR(getClassInitializer)},
876 {CC"hasFinalizableSubclass", CC"("HS_RESOLVED_TYPE")Z", FN_PTR(hasFinalizableSubclass)}, 868 {CC"hasFinalizableSubclass", CC"("METASPACE_KLASS")Z", FN_PTR(hasFinalizableSubclass)},
877 {CC"getMaxCallTargetOffset", CC"(J)J", FN_PTR(getMaxCallTargetOffset)}, 869 {CC"getMaxCallTargetOffset", CC"(J)J", FN_PTR(getMaxCallTargetOffset)},
878 {CC"getMetaspaceMethod", CC"("CLASS"I)"METASPACE_METHOD, FN_PTR(getMetaspaceMethod)}, 870 {CC"getMetaspaceMethod", CC"("CLASS"I)"METASPACE_METHOD, FN_PTR(getMetaspaceMethod)},
879 {CC"initializeConfiguration", CC"("HS_CONFIG")V", FN_PTR(initializeConfiguration)}, 871 {CC"initializeConfiguration", CC"("HS_CONFIG")V", FN_PTR(initializeConfiguration)},
880 {CC"installCode0", CC"("HS_COMPILED_CODE HS_INSTALLED_CODE SPECULATION_LOG")I", FN_PTR(installCode0)}, 872 {CC"installCode0", CC"("HS_COMPILED_CODE HS_INSTALLED_CODE SPECULATION_LOG")I", FN_PTR(installCode0)},
881 {CC"notifyCompilationStatistics", CC"(I"HS_RESOLVED_METHOD"ZIJJ"HS_INSTALLED_CODE")V", FN_PTR(notifyCompilationStatistics)}, 873 {CC"notifyCompilationStatistics", CC"(I"HS_RESOLVED_METHOD"ZIJJ"HS_INSTALLED_CODE")V", FN_PTR(notifyCompilationStatistics)},
882 {CC"printCompilationStatistics", CC"(ZZ)V", FN_PTR(printCompilationStatistics)}, 874 {CC"printCompilationStatistics", CC"(ZZ)V", FN_PTR(printCompilationStatistics)},
883 {CC"resetCompilationStatistics", CC"()V", FN_PTR(resetCompilationStatistics)}, 875 {CC"resetCompilationStatistics", CC"()V", FN_PTR(resetCompilationStatistics)},
884 {CC"disassembleCodeBlob", CC"(J)"STRING, FN_PTR(disassembleCodeBlob)}, 876 {CC"disassembleCodeBlob", CC"(J)"STRING, FN_PTR(disassembleCodeBlob)},
885 {CC"executeCompiledMethodVarargs", CC"(["OBJECT HS_INSTALLED_CODE")"OBJECT, FN_PTR(executeCompiledMethodVarargs)}, 877 {CC"executeCompiledMethodVarargs", CC"(["OBJECT HS_INSTALLED_CODE")"OBJECT, FN_PTR(executeCompiledMethodVarargs)},
886 {CC"getDeoptedLeafGraphIds", CC"()[J", FN_PTR(getDeoptedLeafGraphIds)}, 878 {CC"getDeoptedLeafGraphIds", CC"()[J", FN_PTR(getDeoptedLeafGraphIds)},
887 {CC"getLineNumberTable", CC"("HS_RESOLVED_METHOD")[J", FN_PTR(getLineNumberTable)}, 879 {CC"getLineNumberTable", CC"("METASPACE_METHOD")[J", FN_PTR(getLineNumberTable)},
888 {CC"getLocalVariableTableStart", CC"("HS_RESOLVED_METHOD")J", FN_PTR(getLocalVariableTableStart)}, 880 {CC"getLocalVariableTableStart", CC"("METASPACE_METHOD")J", FN_PTR(getLocalVariableTableStart)},
889 {CC"getLocalVariableTableLength", CC"("HS_RESOLVED_METHOD")I", FN_PTR(getLocalVariableTableLength)}, 881 {CC"getLocalVariableTableLength", CC"("METASPACE_METHOD")I", FN_PTR(getLocalVariableTableLength)},
890 {CC"reprofile", CC"("METASPACE_METHOD")V", FN_PTR(reprofile)}, 882 {CC"reprofile", CC"("METASPACE_METHOD")V", FN_PTR(reprofile)},
891 {CC"invalidateInstalledCode", CC"("HS_INSTALLED_CODE")V", FN_PTR(invalidateInstalledCode)}, 883 {CC"invalidateInstalledCode", CC"("HS_INSTALLED_CODE")V", FN_PTR(invalidateInstalledCode)},
892 {CC"readUnsafeUncompressedPointer", CC"("OBJECT"J)"OBJECT, FN_PTR(readUnsafeUncompressedPointer)}, 884 {CC"readUnsafeUncompressedPointer", CC"("OBJECT"J)"OBJECT, FN_PTR(readUnsafeUncompressedPointer)},
893 {CC"readUnsafeKlassPointer", CC"("OBJECT")J", FN_PTR(readUnsafeKlassPointer)}, 885 {CC"readUnsafeKlassPointer", CC"("OBJECT")J", FN_PTR(readUnsafeKlassPointer)},
894 {CC"collectCounters", CC"()[J", FN_PTR(collectCounters)}, 886 {CC"collectCounters", CC"()[J", FN_PTR(collectCounters)},
895 {CC"getGPUs", CC"()"STRING, FN_PTR(getGPUs)}, 887 {CC"getGPUs", CC"()"STRING, FN_PTR(getGPUs)},
896 {CC"allocateCompileId", CC"("HS_RESOLVED_METHOD"I)I", FN_PTR(allocateCompileId)}, 888 {CC"allocateCompileId", CC"("METASPACE_METHOD"I)I", FN_PTR(allocateCompileId)},
897 {CC"isMature", CC"("METASPACE_METHOD_DATA")Z", FN_PTR(isMature)}, 889 {CC"isMature", CC"("METASPACE_METHOD_DATA")Z", FN_PTR(isMature)},
898 }; 890 };
899 891
900 int CompilerToVM_methods_count() { 892 int CompilerToVM_methods_count() {
901 return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod); 893 return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod);