Mercurial > hg > graal-compiler
comparison src/share/vm/graal/graalCompilerToVM.cpp @ 4993:897b7d18bebc
added RiCompiledMethod.execute and the required VM infrastructure
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Tue, 28 Feb 2012 18:00:35 +0100 |
parents | 5d154704b04c |
children | b5dc2403c1e7 |
comparison
equal
deleted
inserted
replaced
4992:f86ddbd42a7b | 4993:897b7d18bebc |
---|---|
862 // if install_code is true then we installed the code into the given method, no need to return an RiCompiledMethod | 862 // if install_code is true then we installed the code into the given method, no need to return an RiCompiledMethod |
863 if (!install_code && nm != NULL) { | 863 if (!install_code && nm != NULL) { |
864 instanceKlass::cast(HotSpotCompiledMethod::klass())->initialize(CHECK_NULL); | 864 instanceKlass::cast(HotSpotCompiledMethod::klass())->initialize(CHECK_NULL); |
865 Handle obj = instanceKlass::cast(HotSpotCompiledMethod::klass())->allocate_permanent_instance(CHECK_NULL); | 865 Handle obj = instanceKlass::cast(HotSpotCompiledMethod::klass())->allocate_permanent_instance(CHECK_NULL); |
866 assert(obj() != NULL, "must succeed in allocating instance"); | 866 assert(obj() != NULL, "must succeed in allocating instance"); |
867 HotSpotCompiledMethod::set_compiler(obj, VMToCompiler::compilerInstance()()); | |
867 HotSpotCompiledMethod::set_nmethod(obj, (jlong) nm); | 868 HotSpotCompiledMethod::set_nmethod(obj, (jlong) nm); |
868 HotSpotCompiledMethod::set_method(obj, HotSpotTargetMethod::method(targetMethod)); | 869 HotSpotCompiledMethod::set_method(obj, HotSpotTargetMethod::method(targetMethod)); |
869 nm->set_graal_compiled_method(obj()); | 870 nm->set_graal_compiled_method(obj()); |
870 return JNIHandles::make_local(obj()); | 871 return JNIHandles::make_local(obj()); |
871 } else { | 872 } else { |
919 bufferedStream(st); | 920 bufferedStream(st); |
920 method->print_codes_on(&st); | 921 method->print_codes_on(&st); |
921 | 922 |
922 Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL); | 923 Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL); |
923 return JNIHandles::make_local(result()); | 924 return JNIHandles::make_local(result()); |
925 } | |
926 | |
927 // public Object executeCompiledMethod(HotSpotCompiledMethod method, Object arg1, Object arg2, Object arg3); | |
928 JNIEXPORT jobject JNICALL Java_com_oracle_max_graal_hotspot_bridge_CompilerToVMImpl_executeCompiledMethod(JNIEnv *env, jobject, jobject method, jobject arg1, jobject arg2, jobject arg3) { | |
929 TRACE_graal_3("CompilerToVM::executeCompiledMethod"); | |
930 | |
931 VM_ENTRY_MARK; | |
932 ResourceMark rm; | |
933 HandleMark hm; | |
934 | |
935 methodHandle actualMethod = getMethodFromHotSpotMethod(HotSpotCompiledMethod::method(method)); | |
936 assert(method != NULL, "just checking"); | |
937 JavaValue result(T_OBJECT); | |
938 JavaCallArguments args; | |
939 args.push_oop(JNIHandles::resolve(arg1)); | |
940 args.push_oop(JNIHandles::resolve(arg2)); | |
941 args.push_oop(JNIHandles::resolve(arg3)); | |
942 | |
943 nmethod* nm = (nmethod*) HotSpotCompiledMethod::nmethod(method); | |
944 if (nm == NULL || !nm->is_alive()) { | |
945 THROW_0(vmSymbols::MethodInvalidatedException()); | |
946 } | |
947 | |
948 JavaCalls::call(&result, actualMethod, nm, &args, CHECK_NULL); | |
949 | |
950 return JNIHandles::make_local((oop) result.get_jobject()); | |
924 } | 951 } |
925 | 952 |
926 | 953 |
927 #define CC (char*) /*cast a literal from (const char*)*/ | 954 #define CC (char*) /*cast a literal from (const char*)*/ |
928 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(Java_com_oracle_max_graal_hotspot_bridge_CompilerToVMImpl_##f)) | 955 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(Java_com_oracle_max_graal_hotspot_bridge_CompilerToVMImpl_##f)) |
982 {CC"getConfiguration", CC"()"CONFIG, FN_PTR(getConfiguration)}, | 1009 {CC"getConfiguration", CC"()"CONFIG, FN_PTR(getConfiguration)}, |
983 {CC"installMethod", CC"("TARGET_METHOD"Z)"HS_COMP_METHOD, FN_PTR(installMethod)}, | 1010 {CC"installMethod", CC"("TARGET_METHOD"Z)"HS_COMP_METHOD, FN_PTR(installMethod)}, |
984 {CC"installStub", CC"("TARGET_METHOD")"PROXY, FN_PTR(installStub)}, | 1011 {CC"installStub", CC"("TARGET_METHOD")"PROXY, FN_PTR(installStub)}, |
985 {CC"disassembleNative", CC"([BJ)"STRING, FN_PTR(disassembleNative)}, | 1012 {CC"disassembleNative", CC"([BJ)"STRING, FN_PTR(disassembleNative)}, |
986 {CC"disassembleJava", CC"("RESOLVED_METHOD")"STRING, FN_PTR(disassembleJava)}, | 1013 {CC"disassembleJava", CC"("RESOLVED_METHOD")"STRING, FN_PTR(disassembleJava)}, |
1014 {CC"executeCompiledMethod", CC"("HS_COMP_METHOD OBJECT OBJECT OBJECT")"OBJECT, FN_PTR(executeCompiledMethod)}, | |
987 }; | 1015 }; |
988 | 1016 |
989 int CompilerToVM_methods_count() { | 1017 int CompilerToVM_methods_count() { |
990 return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod); | 1018 return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod); |
991 } | 1019 } |