comparison src/share/vm/graal/graalCompilerToVM.cpp @ 13483:37ec2cabf397

moved JavaType creation in CompilerToVM.lookupType into Java
author twisti
date Thu, 26 Dec 2013 12:37:28 -0800
parents 606959535fd4
children 03bb0ee05409
comparison
equal deleted inserted replaced
13482:7824f0c4dfcd 13483:37ec2cabf397
204 C2V_ENTRY(jint, getCompiledCodeSize, (JNIEnv *env, jobject, jlong metaspace_method)) 204 C2V_ENTRY(jint, getCompiledCodeSize, (JNIEnv *env, jobject, jlong metaspace_method))
205 nmethod* code = (asMethod(metaspace_method))->code(); 205 nmethod* code = (asMethod(metaspace_method))->code();
206 return code == NULL ? 0 : code->insts_size(); 206 return code == NULL ? 0 : code->insts_size();
207 C2V_END 207 C2V_END
208 208
209 C2V_VMENTRY(jobject, lookupType, (JNIEnv *env, jobject, jstring jname, jobject accessingClass, jboolean eagerResolve)) 209 C2V_VMENTRY(jlong, lookupType, (JNIEnv *env, jobject, jstring jname, jclass accessing_class, jboolean eagerResolve))
210 ResourceMark rm; 210 ResourceMark rm;
211
212 Handle name = JNIHandles::resolve(jname); 211 Handle name = JNIHandles::resolve(jname);
213 Symbol* nameSymbol = java_lang_String::as_symbol(name, THREAD); 212 Symbol* class_name = java_lang_String::as_symbol(name, THREAD);
214 assert(nameSymbol != NULL, "name to symbol creation failed"); 213 assert(class_name != NULL, "name to symbol creation failed");
215 assert(nameSymbol->size() > 1, "primitive types should be handled in Java code"); 214 assert(class_name->size() > 1, "primitive types should be handled in Java code");
216 215
217 oop result = NULL; 216 Klass* resolved_klass = NULL;
218 Klass* resolved_type = NULL; 217 Handle class_loader;
219 Handle classloader; 218 Handle protection_domain;
220 Handle protectionDomain; 219 if (JNIHandles::resolve(accessing_class) != NULL) {
221 if (JNIHandles::resolve(accessingClass) != NULL) { 220 Klass* accessing_klass = java_lang_Class::as_Klass(JNIHandles::resolve(accessing_class));
222 classloader = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaClass(accessingClass))->class_loader(); 221 class_loader = accessing_klass->class_loader();
223 protectionDomain = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaClass(accessingClass))->protection_domain(); 222 protection_domain = accessing_klass->protection_domain();
224 } 223 }
225 224
226 if (eagerResolve) { 225 if (eagerResolve) {
227 resolved_type = SystemDictionary::resolve_or_fail(nameSymbol, classloader, protectionDomain, true, THREAD); 226 resolved_klass = SystemDictionary::resolve_or_fail(class_name, class_loader, protection_domain, true, THREAD);
228 } else { 227 } else {
229 resolved_type = SystemDictionary::resolve_or_null(nameSymbol, classloader, protectionDomain, THREAD); 228 resolved_klass = SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, THREAD);
230 } 229 }
231 230
232 if (!HAS_PENDING_EXCEPTION) { 231 return (jlong) (address) resolved_klass;
233 if (resolved_type == NULL) {
234 assert(!eagerResolve, "failed eager resolution should have caused an exception");
235 Handle type = VMToCompiler::createUnresolvedJavaType(name, THREAD);
236 result = type();
237 } else {
238 Handle type = VMToCompiler::createResolvedJavaType(resolved_type->java_mirror(), CHECK_NULL);
239 result = type();
240 }
241 }
242
243 return JNIHandles::make_local(THREAD, result);
244 C2V_END 232 C2V_END
245 233
246 C2V_VMENTRY(jobject, lookupConstantInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) 234 C2V_VMENTRY(jobject, lookupConstantInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index))
247 ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; 235 ConstantPool* cp = (ConstantPool*) metaspace_constant_pool;
248 oop result = NULL; 236 oop result = NULL;
857 {CC"getStackTraceElement", CC"("METASPACE_METHOD"I)"STACK_TRACE_ELEMENT, FN_PTR(getStackTraceElement)}, 845 {CC"getStackTraceElement", CC"("METASPACE_METHOD"I)"STACK_TRACE_ELEMENT, FN_PTR(getStackTraceElement)},
858 {CC"initializeMethod", CC"("METASPACE_METHOD HS_RESOLVED_METHOD")V", FN_PTR(initializeMethod)}, 846 {CC"initializeMethod", CC"("METASPACE_METHOD HS_RESOLVED_METHOD")V", FN_PTR(initializeMethod)},
859 {CC"doNotInlineOrCompile", CC"("METASPACE_METHOD")V", FN_PTR(doNotInlineOrCompile)}, 847 {CC"doNotInlineOrCompile", CC"("METASPACE_METHOD")V", FN_PTR(doNotInlineOrCompile)},
860 {CC"isMethodCompilable", CC"("METASPACE_METHOD")Z", FN_PTR(isMethodCompilable)}, 848 {CC"isMethodCompilable", CC"("METASPACE_METHOD")Z", FN_PTR(isMethodCompilable)},
861 {CC"getCompiledCodeSize", CC"("METASPACE_METHOD")I", FN_PTR(getCompiledCodeSize)}, 849 {CC"getCompiledCodeSize", CC"("METASPACE_METHOD")I", FN_PTR(getCompiledCodeSize)},
862 {CC"lookupType", CC"("STRING HS_RESOLVED_TYPE"Z)"TYPE, FN_PTR(lookupType)}, 850 {CC"lookupType", CC"("STRING CLASS"Z)"METASPACE_KLASS, FN_PTR(lookupType)},
863 {CC"lookupConstantInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(lookupConstantInPool)}, 851 {CC"lookupConstantInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(lookupConstantInPool)},
864 {CC"lookupAppendixInPool", CC"("METASPACE_CONSTANT_POOL"IB)"OBJECT, FN_PTR(lookupAppendixInPool)}, 852 {CC"lookupAppendixInPool", CC"("METASPACE_CONSTANT_POOL"IB)"OBJECT, FN_PTR(lookupAppendixInPool)},
865 {CC"lookupMethodInPool", CC"("METASPACE_CONSTANT_POOL"IB)"METHOD, FN_PTR(lookupMethodInPool)}, 853 {CC"lookupMethodInPool", CC"("METASPACE_CONSTANT_POOL"IB)"METHOD, FN_PTR(lookupMethodInPool)},
866 {CC"lookupTypeInPool", CC"("METASPACE_CONSTANT_POOL"I)"TYPE, FN_PTR(lookupTypeInPool)}, 854 {CC"lookupTypeInPool", CC"("METASPACE_CONSTANT_POOL"I)"TYPE, FN_PTR(lookupTypeInPool)},
867 {CC"lookupReferencedTypeInPool", CC"("METASPACE_CONSTANT_POOL"IB)V", FN_PTR(lookupReferencedTypeInPool)}, 855 {CC"lookupReferencedTypeInPool", CC"("METASPACE_CONSTANT_POOL"IB)V", FN_PTR(lookupReferencedTypeInPool)},