Mercurial > hg > truffle
comparison src/share/vm/graal/graalCompilerToVM.cpp @ 5150:fdd9dd4508fa
some GC fixes
avoid non-Java bytecodes in code() array passed to Graal
author | Christian Haeubl <christian.haeubl@oracle.com> |
---|---|
date | Thu, 22 Mar 2012 18:54:02 -0700 |
parents | ab038e0d6b43 |
children | ae72dd38eeb1 |
comparison
equal
deleted
inserted
replaced
5149:c5eaee66bfa1 | 5150:fdd9dd4508fa |
---|---|
50 | 50 |
51 // public byte[] RiMethod_code(HotSpotResolvedMethod method); | 51 // public byte[] RiMethod_code(HotSpotResolvedMethod method); |
52 JNIEXPORT jbyteArray JNICALL Java_com_oracle_graal_hotspot_bridge_CompilerToVMImpl_RiMethod_1code(JNIEnv *env, jobject, jobject hotspot_method) { | 52 JNIEXPORT jbyteArray JNICALL Java_com_oracle_graal_hotspot_bridge_CompilerToVMImpl_RiMethod_1code(JNIEnv *env, jobject, jobject hotspot_method) { |
53 TRACE_graal_3("CompilerToVM::RiMethod_code"); | 53 TRACE_graal_3("CompilerToVM::RiMethod_code"); |
54 methodHandle method = getMethodFromHotSpotMethod(hotspot_method); | 54 methodHandle method = getMethodFromHotSpotMethod(hotspot_method); |
55 | |
56 // copy all bytecodes | |
55 int code_size = method->code_size(); | 57 int code_size = method->code_size(); |
56 jbyteArray result = env->NewByteArray(code_size); | 58 jbyteArray result = env->NewByteArray(code_size); |
57 env->SetByteArrayRegion(result, 0, code_size, (const jbyte *) method->code_base()); | 59 env->SetByteArrayRegion(result, 0, code_size, (const jbyte *) method->code_base()); |
60 | |
61 // iterate over all bytecodes and replace non-Java bytecodes | |
62 if (RewriteBytecodes || RewriteFrequentPairs) { | |
63 BytecodeStream s(method); | |
64 while(!s.is_last_bytecode()) { | |
65 jbyte code = s.next(); | |
66 env->SetByteArrayRegion(result, s.bci(), 1, &code); | |
67 } | |
68 } | |
69 | |
70 // replace all breakpoints | |
71 if (method->number_of_breakpoints() > 0) { | |
72 BreakpointInfo* bp = instanceKlass::cast(method->method_holder())->breakpoints(); | |
73 for (; bp != NULL; bp = bp->next()) { | |
74 if (bp->match(method())) { | |
75 jbyte code = bp->orig_bytecode(); | |
76 env->SetByteArrayRegion(result, bp->bci(), 1, &code); | |
77 } | |
78 } | |
79 } | |
80 | |
58 return result; | 81 return result; |
59 } | 82 } |
60 | 83 |
61 // public String RiMethod_signature(HotSpotResolvedMethod method); | 84 // public String RiMethod_signature(HotSpotResolvedMethod method); |
62 JNIEXPORT jstring JNICALL Java_com_oracle_graal_hotspot_bridge_CompilerToVMImpl_RiMethod_1signature(JNIEnv *env, jobject, jobject hotspot_method) { | 85 JNIEXPORT jstring JNICALL Java_com_oracle_graal_hotspot_bridge_CompilerToVMImpl_RiMethod_1signature(JNIEnv *env, jobject, jobject hotspot_method) { |