Mercurial > hg > truffle
comparison src/share/vm/graal/graalVMEntries.cpp @ 3559:f70a4cc629e7
remove some dependencies on ci interface
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 24 Aug 2011 17:46:51 +0200 |
parents | 22d11b3bc561 |
children | 8780fa370aab b3f0f8a01ca2 |
comparison
equal
deleted
inserted
replaced
3558:bc95d122df79 | 3559:f70a4cc629e7 |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 | 23 |
24 #include "precompiled.hpp" | 24 #include "precompiled.hpp" |
25 #include "c1/c1_Runtime1.hpp" | |
26 #include "ci/ciMethodData.hpp" | |
25 #include "graal/graalVMEntries.hpp" | 27 #include "graal/graalVMEntries.hpp" |
26 #include "graal/graalCompiler.hpp" | 28 #include "graal/graalCompiler.hpp" |
27 #include "graal/graalJavaAccess.hpp" | 29 #include "graal/graalJavaAccess.hpp" |
28 #include "graal/graalCodeInstaller.hpp" | 30 #include "graal/graalCodeInstaller.hpp" |
29 #include "graal/graalVMExits.hpp" | 31 #include "graal/graalVMExits.hpp" |
30 #include "graal/graalVmIds.hpp" | 32 #include "graal/graalVmIds.hpp" |
31 #include "c1/c1_Runtime1.hpp" | |
32 #include "memory/oopFactory.hpp" | 33 #include "memory/oopFactory.hpp" |
33 #include "ci/ciMethodData.hpp" | 34 #include "oops/generateOopMap.hpp" |
34 | 35 |
35 methodOop getMethodFromHotSpotMethod(jobject hotspot_method) { | 36 methodOop getMethodFromHotSpotMethod(jobject hotspot_method) { |
36 return getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method)); | 37 return getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method)); |
37 } | 38 } |
38 | 39 |
132 } | 133 } |
133 | 134 |
134 // public boolean RiMethod_hasBalancedMonitors(long vmId); | 135 // public boolean RiMethod_hasBalancedMonitors(long vmId); |
135 JNIEXPORT jint JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_1hasBalancedMonitors(JNIEnv *, jobject, jobject hotspot_method) { | 136 JNIEXPORT jint JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_1hasBalancedMonitors(JNIEnv *, jobject, jobject hotspot_method) { |
136 TRACE_graal_3("VMEntries::RiMethod_hasBalancedMonitors"); | 137 TRACE_graal_3("VMEntries::RiMethod_hasBalancedMonitors"); |
137 ciMethod* cimethod; | 138 |
138 { | 139 VM_ENTRY_MARK; |
139 VM_ENTRY_MARK; | 140 |
140 methodOop method = getMethodFromHotSpotMethod(hotspot_method); | 141 // Analyze the method to see if monitors are used properly. |
141 cimethod = (ciMethod*)CURRENT_ENV->get_object(method); | 142 methodHandle method(THREAD, getMethodFromHotSpotMethod(hotspot_method)); |
142 } | 143 assert(method->has_monitor_bytecodes(), "should have checked this"); |
143 return cimethod->has_balanced_monitors(); | 144 |
145 // Check to see if a previous compilation computed the monitor-matching analysis. | |
146 if (method->guaranteed_monitor_matching()) { | |
147 return true; | |
148 } | |
149 | |
150 { | |
151 EXCEPTION_MARK; | |
152 ResourceMark rm(THREAD); | |
153 GeneratePairingInfo gpi(method); | |
154 gpi.compute_map(CATCH); | |
155 if (!gpi.monitor_safe()) { | |
156 return false; | |
157 } | |
158 method->set_guaranteed_monitor_matching(); | |
159 } | |
160 return true; | |
144 } | 161 } |
145 | 162 |
146 // public RiMethod getRiMethod(java.lang.reflect.Method reflectionMethod); | 163 // public RiMethod getRiMethod(java.lang.reflect.Method reflectionMethod); |
147 JNIEXPORT jobject JNICALL Java_com_oracle_graal_runtime_VMEntries_getRiMethod(JNIEnv *, jobject, jobject reflection_method_handle) { | 164 JNIEXPORT jobject JNICALL Java_com_oracle_graal_runtime_VMEntries_getRiMethod(JNIEnv *, jobject, jobject reflection_method_handle) { |
148 TRACE_graal_3("VMEntries::getRiMethod"); | 165 TRACE_graal_3("VMEntries::getRiMethod"); |
157 } | 174 } |
158 | 175 |
159 // public boolean RiMethod_uniqueConcreteMethod(long vmId); | 176 // public boolean RiMethod_uniqueConcreteMethod(long vmId); |
160 JNIEXPORT jobject JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_1uniqueConcreteMethod(JNIEnv *, jobject, jobject hotspot_method) { | 177 JNIEXPORT jobject JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_1uniqueConcreteMethod(JNIEnv *, jobject, jobject hotspot_method) { |
161 TRACE_graal_3("VMEntries::RiMethod_uniqueConcreteMethod"); | 178 TRACE_graal_3("VMEntries::RiMethod_uniqueConcreteMethod"); |
162 VM_ENTRY_MARK; | 179 |
163 methodOop m = getMethodFromHotSpotMethod(hotspot_method); | 180 VM_ENTRY_MARK; |
164 ciMethod* cimethod = (ciMethod*)CURRENT_ENV->get_object(m); | 181 methodOop method = getMethodFromHotSpotMethod(hotspot_method); |
165 if (cimethod->holder()->is_interface()) { | 182 klassOop holder = method->method_holder(); |
183 if (holder->klass_part()->is_interface()) { | |
166 // Cannot trust interfaces. Because of: | 184 // Cannot trust interfaces. Because of: |
167 // interface I { void foo(); } | 185 // interface I { void foo(); } |
168 // class A { public void foo() {} } | 186 // class A { public void foo() {} } |
169 // class B extends A implements I { } | 187 // class B extends A implements I { } |
170 // class C extends B { public void foo() { } } | 188 // class C extends B { public void foo() { } } |
171 // class D extends B { } | 189 // class D extends B { } |
172 // Would lead to identify C.foo() as the unique concrete method for I.foo() without seeing A.foo(). | 190 // Would lead to identify C.foo() as the unique concrete method for I.foo() without seeing A.foo(). |
173 return false; | 191 return false; |
174 } | 192 } |
175 klassOop klass = (klassOop)cimethod->holder()->get_oop(); | 193 methodOop unique_concrete; |
176 methodHandle method((methodOop)cimethod->get_oop()); | |
177 methodHandle unique_concrete; | |
178 { | 194 { |
179 ResourceMark rm; | 195 ResourceMark rm; |
180 MutexLocker locker(Compile_lock); | 196 MutexLocker locker(Compile_lock); |
181 unique_concrete = methodHandle(Dependencies::find_unique_concrete_method(klass, method())); | 197 unique_concrete = Dependencies::find_unique_concrete_method(holder, method); |
182 } | 198 } |
183 if (unique_concrete.is_null()) { | 199 if (unique_concrete == NULL) { |
184 return NULL; | 200 return NULL; |
185 } | 201 } else { |
186 | 202 oop method_resolved = GraalCompiler::createHotSpotMethodResolved(unique_concrete, CHECK_NULL); |
187 oop method_resolved = GraalCompiler::createHotSpotMethodResolved(unique_concrete(), CHECK_NULL); | 203 return JNIHandles::make_local(THREAD, method_resolved); |
188 return JNIHandles::make_local(THREAD, method_resolved); | 204 } |
189 } | 205 } |
190 | 206 |
191 // public native int RiMethod_invocationCount(long vmId); | 207 // public native int RiMethod_invocationCount(long vmId); |
192 JNIEXPORT jint JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_1invocationCount(JNIEnv *, jobject, jobject hotspot_method) { | 208 JNIEXPORT jint JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_1invocationCount(JNIEnv *, jobject, jobject hotspot_method) { |
193 TRACE_graal_3("VMEntries::RiMethod_invocationCount"); | 209 TRACE_graal_3("VMEntries::RiMethod_invocationCount"); |