Mercurial > hg > graal-compiler
diff src/share/vm/graal/graalCompilerToVM.cpp @ 8349:8d6ea1915d42
merged CodeInfo into InstalledCode (GRAAL-156)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 18 Mar 2013 18:26:12 +0100 |
parents | 79f0ff46290b |
children | 10293cbfc2b6 c3657d00e343 |
line wrap: on
line diff
--- a/src/share/vm/graal/graalCompilerToVM.cpp Mon Mar 18 18:03:16 2013 +0100 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Mon Mar 18 18:26:12 2013 +0100 @@ -794,7 +794,7 @@ C2V_END -C2V_VMENTRY(jint, installCode0, (JNIEnv *jniEnv, jobject, jobject compResult, jobject installed_code, jobject info, jobject triggered_deoptimizations)) +C2V_VMENTRY(jint, installCode0, (JNIEnv *jniEnv, jobject, jobject compResult, jobject installed_code, jobject triggered_deoptimizations)) ResourceMark rm; HandleMark hm; Handle compResultHandle = JNIHandles::resolve(compResult); @@ -808,23 +808,31 @@ if (result != GraalEnv::ok) { assert(nm == NULL, "should be"); } else { - if (info != NULL) { - arrayOop codeCopy = oopFactory::new_byteArray(nm->code_size(), CHECK_0); - memcpy(codeCopy->base(T_BYTE), nm->code_begin(), nm->code_size()); - HotSpotCodeInfo::set_code(info, codeCopy); - HotSpotCodeInfo::set_start(info, (jlong) nm->code_begin()); - } - if (!installed_code_handle.is_null()) { assert(installed_code_handle->is_a(HotSpotInstalledCode::klass()), "wrong type"); HotSpotInstalledCode::set_nmethod(installed_code_handle, (jlong) nm); HotSpotInstalledCode::set_method(installed_code_handle, HotSpotCompilationResult::method(compResult)); + HotSpotInstalledCode::set_start(installed_code_handle, (jlong) nm->code_begin()); assert(nm == NULL || !installed_code_handle->is_scavengable() || nm->on_scavenge_root_list(), "nm should be scavengable if installed_code is scavengable"); } } return result; C2V_END +C2V_VMENTRY(jobject, getCode, (JNIEnv *jniEnv, jobject, jlong metaspace_nmethod)) + ResourceMark rm; + HandleMark hm; + + nmethod* nm = (nmethod*) (address) metaspace_nmethod; + if (nm == NULL || !nm->is_alive()) { + return NULL; + } + int length = nm->code_size(); + arrayOop codeCopy = oopFactory::new_byteArray(length, CHECK_0); + memcpy(codeCopy->base(T_BYTE), nm->code_begin(), length); + return JNIHandles::make_local(codeCopy); +C2V_END + C2V_VMENTRY(jobject, disassembleNMethod, (JNIEnv *jniEnv, jobject, jlong metaspace_nmethod)) ResourceMark rm; HandleMark hm; @@ -1028,7 +1036,6 @@ #define HS_CONFIG "Lcom/oracle/graal/hotspot/HotSpotVMConfig;" #define HS_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotMethod;" #define HS_INSTALLED_CODE "Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;" -#define HS_CODE_INFO "Lcom/oracle/graal/hotspot/meta/HotSpotCodeInfo;" #define METHOD_DATA "Lcom/oracle/graal/hotspot/meta/HotSpotMethodData;" #define METASPACE_METHOD "J" #define METASPACE_METHOD_DATA "J" @@ -1064,7 +1071,8 @@ {CC"getMetaspaceConstructor", CC"("REFLECT_CONSTRUCTOR"["HS_RESOLVED_TYPE")"METASPACE_METHOD, FN_PTR(getMetaspaceConstructor)}, {CC"getJavaField", CC"("REFLECT_FIELD")"HS_RESOLVED_FIELD, FN_PTR(getJavaField)}, {CC"initializeConfiguration", CC"("HS_CONFIG")V", FN_PTR(initializeConfiguration)}, - {CC"installCode0", CC"("HS_COMP_RESULT HS_INSTALLED_CODE HS_CODE_INFO"[Z)I", FN_PTR(installCode0)}, + {CC"installCode0", CC"("HS_COMP_RESULT HS_INSTALLED_CODE"[Z)I", FN_PTR(installCode0)}, + {CC"getCode", CC"(J)[B", FN_PTR(getCode)}, {CC"disassembleNMethod", CC"(J)"STRING, FN_PTR(disassembleNMethod)}, {CC"executeCompiledMethod", CC"("METASPACE_METHOD NMETHOD OBJECT OBJECT OBJECT")"OBJECT, FN_PTR(executeCompiledMethod)}, {CC"executeCompiledMethodVarargs", CC"("METASPACE_METHOD NMETHOD "["OBJECT")"OBJECT, FN_PTR(executeCompiledMethodVarargs)},