Mercurial > hg > graal-compiler
comparison src/share/vm/graal/graalRuntime.cpp @ 16395:ad431bf0de07
added support to load classes from graal.jar with a separate class loader
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 03 Jul 2014 16:30:28 +0200 |
parents | da8f16efaa4c |
children | 4481cf549cfc |
comparison
equal
deleted
inserted
replaced
16394:0dd27c6472d7 | 16395:ad431bf0de07 |
---|---|
651 JVM_END | 651 JVM_END |
652 | 652 |
653 // private static TruffleRuntime Truffle.createRuntime() | 653 // private static TruffleRuntime Truffle.createRuntime() |
654 JVM_ENTRY(jobject, JVM_CreateTruffleRuntime(JNIEnv *env, jclass c)) | 654 JVM_ENTRY(jobject, JVM_CreateTruffleRuntime(JNIEnv *env, jclass c)) |
655 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime", THREAD); | 655 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime", THREAD); |
656 KlassHandle klass = GraalRuntime::load_required_class(name); | 656 KlassHandle klass = GraalRuntime::resolve_or_fail(name, CHECK_NULL); |
657 | 657 |
658 TempNewSymbol makeInstance = SymbolTable::new_symbol("makeInstance", THREAD); | 658 TempNewSymbol makeInstance = SymbolTable::new_symbol("makeInstance", THREAD); |
659 TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime;", THREAD); | 659 TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime;", THREAD); |
660 JavaValue result(T_OBJECT); | 660 JavaValue result(T_OBJECT); |
661 JavaCalls::call_static(&result, klass, makeInstance, sig, THREAD); | 661 JavaCalls::call_static(&result, klass, makeInstance, sig, THREAD); |
708 // Errors in parsing Graal arguments cause exceptions. | 708 // Errors in parsing Graal arguments cause exceptions. |
709 // We now load and initialize HotSpotOptions which in turn | 709 // We now load and initialize HotSpotOptions which in turn |
710 // causes argument parsing to be redone with better error messages. | 710 // causes argument parsing to be redone with better error messages. |
711 CLEAR_PENDING_EXCEPTION; | 711 CLEAR_PENDING_EXCEPTION; |
712 TempNewSymbol name = SymbolTable::new_symbol("Lcom/oracle/graal/hotspot/HotSpotOptions;", THREAD); | 712 TempNewSymbol name = SymbolTable::new_symbol("Lcom/oracle/graal/hotspot/HotSpotOptions;", THREAD); |
713 instanceKlassHandle hotSpotOptionsClass = SystemDictionary::resolve_or_fail(name, true, THREAD); | 713 instanceKlassHandle hotSpotOptionsClass = resolve_or_fail(name, THREAD); |
714 GUARANTEE_NO_PENDING_EXCEPTION("Error in check_arguments"); | 714 GUARANTEE_NO_PENDING_EXCEPTION("Error in check_arguments"); |
715 | 715 |
716 parse_arguments(hotSpotOptionsClass, THREAD); | 716 parse_arguments(hotSpotOptionsClass, THREAD); |
717 assert(HAS_PENDING_EXCEPTION, "must be"); | 717 assert(HAS_PENDING_EXCEPTION, "must be"); |
718 | 718 |
907 JavaCalls::call_static(&result, hotSpotOptionsClass, setOption, sig, &args, CHECK); | 907 JavaCalls::call_static(&result, hotSpotOptionsClass, setOption, sig, &args, CHECK); |
908 } | 908 } |
909 | 909 |
910 Handle GraalRuntime::get_OptionValue(const char* declaringClass, const char* fieldName, const char* fieldSig, TRAPS) { | 910 Handle GraalRuntime::get_OptionValue(const char* declaringClass, const char* fieldName, const char* fieldSig, TRAPS) { |
911 TempNewSymbol name = SymbolTable::new_symbol(declaringClass, THREAD); | 911 TempNewSymbol name = SymbolTable::new_symbol(declaringClass, THREAD); |
912 Klass* klass = SystemDictionary::resolve_or_fail(name, true, CHECK_NH); | 912 Klass* klass = resolve_or_fail(name, CHECK_NH); |
913 | 913 |
914 // The class has been loaded so the field and signature should already be in the symbol | 914 // The class has been loaded so the field and signature should already be in the symbol |
915 // table. If they're not there, the field doesn't exist. | 915 // table. If they're not there, the field doesn't exist. |
916 TempNewSymbol fieldname = SymbolTable::probe(fieldName, (int)strlen(fieldName)); | 916 TempNewSymbol fieldname = SymbolTable::probe(fieldName, (int)strlen(fieldName)); |
917 TempNewSymbol signame = SymbolTable::probe(fieldSig, (int)strlen(fieldSig)); | 917 TempNewSymbol signame = SymbolTable::probe(fieldSig, (int)strlen(fieldSig)); |
930 return ret; | 930 return ret; |
931 } | 931 } |
932 | 932 |
933 Handle GraalRuntime::create_Service(const char* name, TRAPS) { | 933 Handle GraalRuntime::create_Service(const char* name, TRAPS) { |
934 TempNewSymbol kname = SymbolTable::new_symbol(name, THREAD); | 934 TempNewSymbol kname = SymbolTable::new_symbol(name, THREAD); |
935 Klass* k = SystemDictionary::resolve_or_fail(kname, true, CHECK_NH); | 935 Klass* k = resolve_or_fail(kname, CHECK_NH); |
936 instanceKlassHandle klass(THREAD, k); | 936 instanceKlassHandle klass(THREAD, k); |
937 klass->initialize(CHECK_NH); | 937 klass->initialize(CHECK_NH); |
938 klass->check_valid_for_instantiation(true, CHECK_NH); | 938 klass->check_valid_for_instantiation(true, CHECK_NH); |
939 JavaValue result(T_VOID); | 939 JavaValue result(T_VOID); |
940 instanceHandle service = klass->allocate_instance_handle(CHECK_NH); | 940 instanceHandle service = klass->allocate_instance_handle(CHECK_NH); |
969 vmSymbols::printStackTrace_name(), | 969 vmSymbols::printStackTrace_name(), |
970 vmSymbols::void_method_signature(), | 970 vmSymbols::void_method_signature(), |
971 thread); | 971 thread); |
972 } | 972 } |
973 | 973 |
974 oop GraalRuntime::compute_graal_class_loader(TRAPS) { | |
975 assert(UseGraalClassLoader, "must be"); | |
976 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/loader/Factory", THREAD); | |
977 KlassHandle klass = SystemDictionary::resolve_or_null(name, THREAD); | |
978 if (klass.is_null()) { | |
979 tty->print_cr("Could not load class %s", name->as_C_string()); | |
980 vm_abort(false); | |
981 } | |
982 | |
983 TempNewSymbol getClassLoader = SymbolTable::new_symbol("newClassLoader", THREAD); | |
984 JavaValue result(T_OBJECT); | |
985 JavaCalls::call_static(&result, klass, getClassLoader, vmSymbols::void_classloader_signature(), THREAD); | |
986 GUARANTEE_NO_PENDING_EXCEPTION("Couldn't initialize HotSpotGraalRuntime"); | |
987 return (oop) result.get_jobject(); | |
988 } | |
989 | |
974 void GraalRuntime::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) { | 990 void GraalRuntime::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) { |
975 Thread* THREAD = Thread::current(); | 991 Thread* THREAD = Thread::current(); |
976 CLEAR_PENDING_EXCEPTION; | 992 CLEAR_PENDING_EXCEPTION; |
977 tty->print_cr(message); | 993 tty->print_cr(message); |
978 call_printStackTrace(exception, THREAD); | 994 call_printStackTrace(exception, THREAD); |
979 vm_abort(dump_core); | 995 vm_abort(dump_core); |
980 } | 996 } |
981 | 997 |
998 Klass* GraalRuntime::resolve_or_null(Symbol* name, TRAPS) { | |
999 return SystemDictionary::resolve_or_null(name, SystemDictionary::graal_loader(), Handle(), CHECK_NULL); | |
1000 } | |
1001 | |
1002 Klass* GraalRuntime::resolve_or_fail(Symbol* name, TRAPS) { | |
1003 return SystemDictionary::resolve_or_fail(name, SystemDictionary::graal_loader(), Handle(), true, CHECK_NULL); | |
1004 } | |
1005 | |
982 Klass* GraalRuntime::load_required_class(Symbol* name) { | 1006 Klass* GraalRuntime::load_required_class(Symbol* name) { |
983 Klass* klass = SystemDictionary::resolve_or_null(name, SystemDictionary::java_system_loader(), Handle(), Thread::current()); | 1007 Klass* klass = resolve_or_null(name, Thread::current()); |
984 if (klass == NULL) { | 1008 if (klass == NULL) { |
985 tty->print_cr("Could not load class %s", name->as_C_string()); | 1009 tty->print_cr("Could not load class %s", name->as_C_string()); |
986 vm_abort(false); | 1010 vm_abort(false); |
987 } | 1011 } |
988 return klass; | 1012 return klass; |