Mercurial > hg > truffle
comparison src/share/vm/graal/graalCompilerToVM.cpp @ 13254:42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
author | twisti |
---|---|
date | Thu, 05 Dec 2013 18:13:04 -0800 |
parents | 8b5852df0471 |
children | fdd6ef90d66d |
comparison
equal
deleted
inserted
replaced
13253:4d1cd29cceb0 | 13254:42aaf7306707 |
---|---|
280 return NULL; | 280 return NULL; |
281 C2V_END | 281 C2V_END |
282 | 282 |
283 C2V_VMENTRY(void, initializeMethod,(JNIEnv *, jobject, jlong metaspace_method, jobject hotspot_method)) | 283 C2V_VMENTRY(void, initializeMethod,(JNIEnv *, jobject, jlong metaspace_method, jobject hotspot_method)) |
284 methodHandle method = asMethod(metaspace_method); | 284 methodHandle method = asMethod(metaspace_method); |
285 Handle name = java_lang_String::create_from_symbol(method->name(), CHECK); | |
286 InstanceKlass::cast(HotSpotResolvedJavaMethod::klass())->initialize(CHECK); | 285 InstanceKlass::cast(HotSpotResolvedJavaMethod::klass())->initialize(CHECK); |
287 HotSpotResolvedJavaMethod::set_name(hotspot_method, name()); | |
288 HotSpotResolvedJavaMethod::set_codeSize(hotspot_method, method->code_size()); | |
289 HotSpotResolvedJavaMethod::set_exceptionHandlerCount(hotspot_method, method->exception_table_length()); | 286 HotSpotResolvedJavaMethod::set_exceptionHandlerCount(hotspot_method, method->exception_table_length()); |
290 HotSpotResolvedJavaMethod::set_callerSensitive(hotspot_method, method->caller_sensitive()); | 287 HotSpotResolvedJavaMethod::set_callerSensitive(hotspot_method, method->caller_sensitive()); |
291 HotSpotResolvedJavaMethod::set_forceInline(hotspot_method, method->force_inline()); | 288 HotSpotResolvedJavaMethod::set_forceInline(hotspot_method, method->force_inline()); |
292 HotSpotResolvedJavaMethod::set_dontInline(hotspot_method, method->dont_inline()); | 289 HotSpotResolvedJavaMethod::set_dontInline(hotspot_method, method->dont_inline()); |
293 HotSpotResolvedJavaMethod::set_ignoredBySecurityStackWalk(hotspot_method, method->is_ignored_by_security_stack_walk()); | 290 HotSpotResolvedJavaMethod::set_ignoredBySecurityStackWalk(hotspot_method, method->is_ignored_by_security_stack_walk()); |
358 | 355 |
359 return JNIHandles::make_local(THREAD, result); | 356 return JNIHandles::make_local(THREAD, result); |
360 C2V_END | 357 C2V_END |
361 | 358 |
362 C2V_VMENTRY(jobject, lookupConstantInPool, (JNIEnv *env, jobject, jobject type, jint index)) | 359 C2V_VMENTRY(jobject, lookupConstantInPool, (JNIEnv *env, jobject, jobject type, jint index)) |
363 | |
364 ConstantPool* cp = InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(type)))->constants(); | 360 ConstantPool* cp = InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(type)))->constants(); |
365 | |
366 oop result = NULL; | 361 oop result = NULL; |
367 constantTag tag = cp->tag_at(index); | 362 constantTag tag = cp->tag_at(index); |
368 | 363 |
369 switch (tag.value()) { | 364 switch (tag.value()) { |
370 case JVM_CONSTANT_Integer: | |
371 result = VMToCompiler::createConstant(Kind::Int(), cp->int_at(index), CHECK_NULL); | |
372 break; | |
373 | |
374 case JVM_CONSTANT_Long: | |
375 result = VMToCompiler::createConstant(Kind::Long(), cp->long_at(index), CHECK_NULL); | |
376 break; | |
377 | |
378 case JVM_CONSTANT_Float: | |
379 result = VMToCompiler::createConstantFloat(cp->float_at(index), CHECK_NULL); | |
380 break; | |
381 | |
382 case JVM_CONSTANT_Double: | |
383 result = VMToCompiler::createConstantDouble(cp->double_at(index), CHECK_NULL); | |
384 break; | |
385 | |
386 case JVM_CONSTANT_Class: | |
387 case JVM_CONSTANT_UnresolvedClass: | |
388 case JVM_CONSTANT_UnresolvedClassInError: | |
389 { | |
390 Handle type = GraalCompiler::get_JavaType(cp, index, cp->pool_holder(), CHECK_NULL); | |
391 result = type(); | |
392 break; | |
393 } | |
394 | |
395 case JVM_CONSTANT_String: | 365 case JVM_CONSTANT_String: |
396 { | 366 { |
397 oop result_oop = cp->resolve_possibly_cached_constant_at(index, CHECK_NULL); | 367 result = cp->resolve_possibly_cached_constant_at(index, CHECK_NULL); |
398 result = VMToCompiler::createConstantObject(result_oop, CHECK_NULL); | |
399 break; | 368 break; |
400 } | 369 } |
401 | 370 |
402 case JVM_CONSTANT_MethodHandle: | 371 case JVM_CONSTANT_MethodHandle: |
403 case JVM_CONSTANT_MethodHandleInError: | 372 case JVM_CONSTANT_MethodHandleInError: |
404 case JVM_CONSTANT_MethodType: | 373 case JVM_CONSTANT_MethodType: |
405 case JVM_CONSTANT_MethodTypeInError: | 374 case JVM_CONSTANT_MethodTypeInError: |
406 { | 375 { |
407 oop result_oop = cp->resolve_constant_at(index, CHECK_NULL); | 376 result = cp->resolve_constant_at(index, CHECK_NULL); |
408 result = VMToCompiler::createConstantObject(result_oop, CHECK_NULL); | |
409 break; | 377 break; |
410 } | 378 } |
411 | 379 |
412 default: | 380 default: |
413 fatal(err_msg_res("unknown constant pool tag %s at cpi %d in %s", tag.internal_name(), index, cp->pool_holder()->name()->as_C_string())); | 381 fatal(err_msg_res("unknown constant pool tag %s at cpi %d in %s", tag.internal_name(), index, cp->pool_holder()->name()->as_C_string())); |
450 return JNIHandles::make_local(THREAD, VMToCompiler::createUnresolvedJavaMethod(name, signature, type, THREAD)); | 418 return JNIHandles::make_local(THREAD, VMToCompiler::createUnresolvedJavaMethod(name, signature, type, THREAD)); |
451 } | 419 } |
452 C2V_END | 420 C2V_END |
453 | 421 |
454 C2V_VMENTRY(jobject, lookupTypeInPool, (JNIEnv *env, jobject, jobject type, jint index)) | 422 C2V_VMENTRY(jobject, lookupTypeInPool, (JNIEnv *env, jobject, jobject type, jint index)) |
455 | |
456 ConstantPool* cp = InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(type)))->constants(); | 423 ConstantPool* cp = InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(type)))->constants(); |
457 Handle result = GraalCompiler::get_JavaType(cp, index, cp->pool_holder(), CHECK_NULL); | 424 Handle result = GraalCompiler::get_JavaType(cp, index, cp->pool_holder(), CHECK_NULL); |
458 return JNIHandles::make_local(THREAD, result()); | 425 return JNIHandles::make_local(THREAD, result()); |
459 C2V_END | 426 C2V_END |
460 | 427 |
971 | 938 |
972 return JNIHandles::make_local(local_array()); | 939 return JNIHandles::make_local(local_array()); |
973 C2V_END | 940 C2V_END |
974 | 941 |
975 | 942 |
976 C2V_VMENTRY(jobject, getFileName, (JNIEnv *, jobject, jobject klass)) | |
977 ResourceMark rm; | |
978 InstanceKlass* k = (InstanceKlass*) asKlass(HotSpotResolvedObjectType::metaspaceKlass(klass)); | |
979 Symbol *s = k->source_file_name(); | |
980 int length; | |
981 jchar *name = s->as_unicode(length); | |
982 | |
983 Handle result = java_lang_String::create_from_unicode(name, length, CHECK_NULL); | |
984 return JNIHandles::make_local(result()); | |
985 | |
986 C2V_END | |
987 | |
988 | |
989 C2V_VMENTRY(void, reprofile, (JNIEnv *env, jobject, jlong metaspace_method)) | 943 C2V_VMENTRY(void, reprofile, (JNIEnv *env, jobject, jlong metaspace_method)) |
990 Method* method = asMethod(metaspace_method); | 944 Method* method = asMethod(metaspace_method); |
991 MethodCounters* mcs = method->method_counters(); | 945 MethodCounters* mcs = method->method_counters(); |
992 if (mcs != NULL) { | 946 if (mcs != NULL) { |
993 mcs->clear_counters(); | 947 mcs->clear_counters(); |
1060 #define STRING "Ljava/lang/String;" | 1014 #define STRING "Ljava/lang/String;" |
1061 #define OBJECT "Ljava/lang/Object;" | 1015 #define OBJECT "Ljava/lang/Object;" |
1062 #define CLASS "Ljava/lang/Class;" | 1016 #define CLASS "Ljava/lang/Class;" |
1063 #define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;" | 1017 #define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;" |
1064 #define HS_RESOLVED_TYPE "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedObjectType;" | 1018 #define HS_RESOLVED_TYPE "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedObjectType;" |
1065 #define HS_RESOLVED_JAVA_TYPE "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaType;" | |
1066 #define HS_RESOLVED_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod;" | 1019 #define HS_RESOLVED_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod;" |
1067 #define HS_RESOLVED_FIELD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaField;" | 1020 #define HS_RESOLVED_FIELD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaField;" |
1068 #define HS_COMPILED_CODE "Lcom/oracle/graal/hotspot/HotSpotCompiledCode;" | 1021 #define HS_COMPILED_CODE "Lcom/oracle/graal/hotspot/HotSpotCompiledCode;" |
1069 #define HS_CONFIG "Lcom/oracle/graal/hotspot/HotSpotVMConfig;" | 1022 #define HS_CONFIG "Lcom/oracle/graal/hotspot/HotSpotVMConfig;" |
1070 #define HS_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotMethod;" | 1023 #define HS_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotMethod;" |
1107 {CC"disassembleCodeBlob", CC"(J)"STRING, FN_PTR(disassembleCodeBlob)}, | 1060 {CC"disassembleCodeBlob", CC"(J)"STRING, FN_PTR(disassembleCodeBlob)}, |
1108 {CC"executeCompiledMethodVarargs", CC"(["OBJECT HS_INSTALLED_CODE")"OBJECT, FN_PTR(executeCompiledMethodVarargs)}, | 1061 {CC"executeCompiledMethodVarargs", CC"(["OBJECT HS_INSTALLED_CODE")"OBJECT, FN_PTR(executeCompiledMethodVarargs)}, |
1109 {CC"getDeoptedLeafGraphIds", CC"()[J", FN_PTR(getDeoptedLeafGraphIds)}, | 1062 {CC"getDeoptedLeafGraphIds", CC"()[J", FN_PTR(getDeoptedLeafGraphIds)}, |
1110 {CC"getLineNumberTable", CC"("HS_RESOLVED_METHOD")[J", FN_PTR(getLineNumberTable)}, | 1063 {CC"getLineNumberTable", CC"("HS_RESOLVED_METHOD")[J", FN_PTR(getLineNumberTable)}, |
1111 {CC"getLocalVariableTable", CC"("HS_RESOLVED_METHOD")["LOCAL, FN_PTR(getLocalVariableTable)}, | 1064 {CC"getLocalVariableTable", CC"("HS_RESOLVED_METHOD")["LOCAL, FN_PTR(getLocalVariableTable)}, |
1112 {CC"getFileName", CC"("HS_RESOLVED_JAVA_TYPE")"STRING, FN_PTR(getFileName)}, | |
1113 {CC"reprofile", CC"("METASPACE_METHOD")V", FN_PTR(reprofile)}, | 1065 {CC"reprofile", CC"("METASPACE_METHOD")V", FN_PTR(reprofile)}, |
1114 {CC"invalidateInstalledCode", CC"("HS_INSTALLED_CODE")V", FN_PTR(invalidateInstalledCode)}, | 1066 {CC"invalidateInstalledCode", CC"("HS_INSTALLED_CODE")V", FN_PTR(invalidateInstalledCode)}, |
1115 {CC"readUnsafeUncompressedPointer", CC"("OBJECT"J)"OBJECT, FN_PTR(readUnsafeUncompressedPointer)}, | 1067 {CC"readUnsafeUncompressedPointer", CC"("OBJECT"J)"OBJECT, FN_PTR(readUnsafeUncompressedPointer)}, |
1116 {CC"readUnsafeKlassPointer", CC"("OBJECT")J", FN_PTR(readUnsafeKlassPointer)}, | 1068 {CC"readUnsafeKlassPointer", CC"("OBJECT")J", FN_PTR(readUnsafeKlassPointer)}, |
1117 {CC"collectCounters", CC"()[J", FN_PTR(collectCounters)}, | 1069 {CC"collectCounters", CC"()[J", FN_PTR(collectCounters)}, |