comparison src/share/vm/graal/graalRuntime.cpp @ 16428:78ddecd6255f

added CHECK macros in uses of SymbolTable::new_symbol; added CHECK_ABORT macros for TRAPS functions that must abort the VM if they throw an exception
author Doug Simon <doug.simon@oracle.com>
date Tue, 08 Jul 2014 21:38:21 +0200
parents 4481cf549cfc
children a7d9b88ecd68
comparison
equal deleted inserted replaced
16427:84a14e69fa8b 16428:78ddecd6255f
60 // Ensure _non_oop_bits is initialized 60 // Ensure _non_oop_bits is initialized
61 Universe::non_oop_word(); 61 Universe::non_oop_word();
62 62
63 env->RegisterNatives(c2vmClass, CompilerToVM_methods, CompilerToVM_methods_count()); 63 env->RegisterNatives(c2vmClass, CompilerToVM_methods, CompilerToVM_methods_count());
64 } 64 }
65 GUARANTEE_NO_PENDING_EXCEPTION("Could not register natives"); 65 if (HAS_PENDING_EXCEPTION) {
66 abort_on_pending_exception(PENDING_EXCEPTION, "Could not register natives");
67 }
66 } 68 }
67 69
68 BufferBlob* GraalRuntime::initialize_buffer_blob() { 70 BufferBlob* GraalRuntime::initialize_buffer_blob() {
69 JavaThread* THREAD = JavaThread::current(); 71 JavaThread* THREAD = JavaThread::current();
70 BufferBlob* buffer_blob = THREAD->get_buffer_blob(); 72 BufferBlob* buffer_blob = THREAD->get_buffer_blob();
650 return JNIHandles::make_local(THREAD, GraalRuntime::get_service_impls(serviceKlass, THREAD)()); 652 return JNIHandles::make_local(THREAD, GraalRuntime::get_service_impls(serviceKlass, THREAD)());
651 JVM_END 653 JVM_END
652 654
653 // private static TruffleRuntime Truffle.createRuntime() 655 // private static TruffleRuntime Truffle.createRuntime()
654 JVM_ENTRY(jobject, JVM_CreateTruffleRuntime(JNIEnv *env, jclass c)) 656 JVM_ENTRY(jobject, JVM_CreateTruffleRuntime(JNIEnv *env, jclass c))
655 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime", THREAD); 657 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime", CHECK_NULL);
656 KlassHandle klass = GraalRuntime::resolve_or_fail(name, CHECK_NULL); 658 KlassHandle klass = GraalRuntime::resolve_or_fail(name, CHECK_NULL);
657 659
658 TempNewSymbol makeInstance = SymbolTable::new_symbol("makeInstance", THREAD); 660 TempNewSymbol makeInstance = SymbolTable::new_symbol("makeInstance", CHECK_NULL);
659 TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime;", THREAD); 661 TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime;", CHECK_NULL);
660 JavaValue result(T_OBJECT); 662 JavaValue result(T_OBJECT);
661 JavaCalls::call_static(&result, klass, makeInstance, sig, THREAD); 663 JavaCalls::call_static(&result, klass, makeInstance, sig, CHECK_NULL);
662 GUARANTEE_NO_PENDING_EXCEPTION("Couldn't initialize HotSpotTruffleRuntime");
663 return JNIHandles::make_local((oop) result.get_jobject()); 664 return JNIHandles::make_local((oop) result.get_jobject());
664 JVM_END 665 JVM_END
665 666
666 Handle GraalRuntime::get_HotSpotGraalRuntime() { 667 Handle GraalRuntime::get_HotSpotGraalRuntime() {
667 if (JNIHandles::resolve(_HotSpotGraalRuntime_instance) == NULL) { 668 if (JNIHandles::resolve(_HotSpotGraalRuntime_instance) == NULL) {
668 Thread* THREAD = Thread::current(); 669 Thread* THREAD = Thread::current();
669 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", THREAD); 670 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", CHECK_ABORT_(Handle()));
670 KlassHandle klass = load_required_class(name); 671 KlassHandle klass = load_required_class(name);
671 TempNewSymbol runtime = SymbolTable::new_symbol("runtime", THREAD); 672 TempNewSymbol runtime = SymbolTable::new_symbol("runtime", CHECK_ABORT_(Handle()));
672 TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/hotspot/HotSpotGraalRuntime;", THREAD); 673 TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/hotspot/HotSpotGraalRuntime;", CHECK_ABORT_(Handle()));
673 JavaValue result(T_OBJECT); 674 JavaValue result(T_OBJECT);
674 JavaCalls::call_static(&result, klass, runtime, sig, THREAD); 675 JavaCalls::call_static(&result, klass, runtime, sig, CHECK_ABORT_(Handle()));
675 GUARANTEE_NO_PENDING_EXCEPTION("Couldn't initialize HotSpotGraalRuntime");
676 _HotSpotGraalRuntime_instance = JNIHandles::make_global((oop) result.get_jobject()); 676 _HotSpotGraalRuntime_instance = JNIHandles::make_global((oop) result.get_jobject());
677 } 677 }
678 return Handle(JNIHandles::resolve_non_null(_HotSpotGraalRuntime_instance)); 678 return Handle(JNIHandles::resolve_non_null(_HotSpotGraalRuntime_instance));
679 } 679 }
680 680
696 if (HAS_PENDING_EXCEPTION) { 696 if (HAS_PENDING_EXCEPTION) {
697 // Errors in parsing Graal arguments cause exceptions. 697 // Errors in parsing Graal arguments cause exceptions.
698 // We now load and initialize HotSpotOptions which in turn 698 // We now load and initialize HotSpotOptions which in turn
699 // causes argument parsing to be redone with better error messages. 699 // causes argument parsing to be redone with better error messages.
700 CLEAR_PENDING_EXCEPTION; 700 CLEAR_PENDING_EXCEPTION;
701 TempNewSymbol name = SymbolTable::new_symbol("Lcom/oracle/graal/hotspot/HotSpotOptions;", THREAD); 701 TempNewSymbol name = SymbolTable::new_symbol("Lcom/oracle/graal/hotspot/HotSpotOptions;", CHECK_ABORT_(JNI_ERR));
702 instanceKlassHandle hotSpotOptionsClass = resolve_or_fail(name, THREAD); 702 instanceKlassHandle hotSpotOptionsClass = resolve_or_fail(name, CHECK_ABORT_(JNI_ERR));
703 GUARANTEE_NO_PENDING_EXCEPTION("Error in check_arguments");
704 703
705 parse_arguments(hotSpotOptionsClass, THREAD); 704 parse_arguments(hotSpotOptionsClass, THREAD);
706 assert(HAS_PENDING_EXCEPTION, "must be"); 705 assert(HAS_PENDING_EXCEPTION, "must be");
707 706
708 ResourceMark rm; 707 ResourceMark rm;
882 assert((int) strlen(name) == name_len, "must be"); 881 assert((int) strlen(name) == name_len, "must be");
883 name_handle = java_lang_String::create_from_str(name, CHECK); 882 name_handle = java_lang_String::create_from_str(name, CHECK);
884 } 883 }
885 } 884 }
886 885
887 TempNewSymbol setOption = SymbolTable::new_symbol("setOption", THREAD); 886 TempNewSymbol setOption = SymbolTable::new_symbol("setOption", CHECK);
888 TempNewSymbol sig = SymbolTable::new_symbol("(Ljava/lang/String;Lcom/oracle/graal/options/OptionValue;CLjava/lang/String;J)V", THREAD); 887 TempNewSymbol sig = SymbolTable::new_symbol("(Ljava/lang/String;Lcom/oracle/graal/options/OptionValue;CLjava/lang/String;J)V", CHECK);
889 JavaValue result(T_VOID); 888 JavaValue result(T_VOID);
890 JavaCallArguments args; 889 JavaCallArguments args;
891 args.push_oop(name_handle()); 890 args.push_oop(name_handle());
892 args.push_oop(option()); 891 args.push_oop(option());
893 args.push_int(spec); 892 args.push_int(spec);
895 args.push_long(primitiveValue); 894 args.push_long(primitiveValue);
896 JavaCalls::call_static(&result, hotSpotOptionsClass, setOption, sig, &args, CHECK); 895 JavaCalls::call_static(&result, hotSpotOptionsClass, setOption, sig, &args, CHECK);
897 } 896 }
898 897
899 Handle GraalRuntime::get_OptionValue(const char* declaringClass, const char* fieldName, const char* fieldSig, TRAPS) { 898 Handle GraalRuntime::get_OptionValue(const char* declaringClass, const char* fieldName, const char* fieldSig, TRAPS) {
900 TempNewSymbol name = SymbolTable::new_symbol(declaringClass, THREAD); 899 TempNewSymbol name = SymbolTable::new_symbol(declaringClass, CHECK_NH);
901 Klass* klass = resolve_or_fail(name, CHECK_NH); 900 Klass* klass = resolve_or_fail(name, CHECK_NH);
902 901
903 // The class has been loaded so the field and signature should already be in the symbol 902 // The class has been loaded so the field and signature should already be in the symbol
904 // table. If they're not there, the field doesn't exist. 903 // table. If they're not there, the field doesn't exist.
905 TempNewSymbol fieldname = SymbolTable::probe(fieldName, (int)strlen(fieldName)); 904 TempNewSymbol fieldname = SymbolTable::probe(fieldName, (int)strlen(fieldName));
918 Handle ret = klass->java_mirror()->obj_field(fd.offset()); 917 Handle ret = klass->java_mirror()->obj_field(fd.offset());
919 return ret; 918 return ret;
920 } 919 }
921 920
922 Handle GraalRuntime::create_Service(const char* name, TRAPS) { 921 Handle GraalRuntime::create_Service(const char* name, TRAPS) {
923 TempNewSymbol kname = SymbolTable::new_symbol(name, THREAD); 922 TempNewSymbol kname = SymbolTable::new_symbol(name, CHECK_NH);
924 Klass* k = resolve_or_fail(kname, CHECK_NH); 923 Klass* k = resolve_or_fail(kname, CHECK_NH);
925 instanceKlassHandle klass(THREAD, k); 924 instanceKlassHandle klass(THREAD, k);
926 klass->initialize(CHECK_NH); 925 klass->initialize(CHECK_NH);
927 klass->check_valid_for_instantiation(true, CHECK_NH); 926 klass->check_valid_for_instantiation(true, CHECK_NH);
928 JavaValue result(T_VOID); 927 JavaValue result(T_VOID);
933 932
934 void GraalRuntime::shutdown() { 933 void GraalRuntime::shutdown() {
935 if (_HotSpotGraalRuntime_instance != NULL) { 934 if (_HotSpotGraalRuntime_instance != NULL) {
936 JavaThread* THREAD = JavaThread::current(); 935 JavaThread* THREAD = JavaThread::current();
937 HandleMark hm(THREAD); 936 HandleMark hm(THREAD);
938 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", THREAD); 937 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", CHECK_ABORT);
939 KlassHandle klass = load_required_class(name); 938 KlassHandle klass = load_required_class(name);
940 JavaValue result(T_VOID); 939 JavaValue result(T_VOID);
941 JavaCallArguments args; 940 JavaCallArguments args;
942 args.push_oop(get_HotSpotGraalRuntime()); 941 args.push_oop(get_HotSpotGraalRuntime());
943 JavaCalls::call_special(&result, klass, vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, THREAD); 942 JavaCalls::call_special(&result, klass, vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, CHECK_ABORT);
944 GUARANTEE_NO_PENDING_EXCEPTION("Error while calling shutdown");
945 943
946 JNIHandles::destroy_global(_HotSpotGraalRuntime_instance); 944 JNIHandles::destroy_global(_HotSpotGraalRuntime_instance);
947 _HotSpotGraalRuntime_instance = NULL; 945 _HotSpotGraalRuntime_instance = NULL;
948 } 946 }
949 } 947 }
960 thread); 958 thread);
961 } 959 }
962 960
963 oop GraalRuntime::compute_graal_class_loader(TRAPS) { 961 oop GraalRuntime::compute_graal_class_loader(TRAPS) {
964 assert(UseGraalClassLoader, "must be"); 962 assert(UseGraalClassLoader, "must be");
965 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/loader/Factory", THREAD); 963 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/loader/Factory", CHECK_NULL);
966 KlassHandle klass = SystemDictionary::resolve_or_null(name, THREAD); 964 KlassHandle klass = SystemDictionary::resolve_or_null(name, CHECK_NULL);
967 if (klass.is_null()) { 965
968 tty->print_cr("Could not load class %s", name->as_C_string()); 966 TempNewSymbol getClassLoader = SymbolTable::new_symbol("newClassLoader", CHECK_NULL);
969 vm_abort(false);
970 }
971
972 TempNewSymbol getClassLoader = SymbolTable::new_symbol("newClassLoader", THREAD);
973 JavaValue result(T_OBJECT); 967 JavaValue result(T_OBJECT);
974 JavaCalls::call_static(&result, klass, getClassLoader, vmSymbols::void_classloader_signature(), THREAD); 968 JavaCalls::call_static(&result, klass, getClassLoader, vmSymbols::void_classloader_signature(), CHECK_NULL);
975 GUARANTEE_NO_PENDING_EXCEPTION("Couldn't initialize HotSpotGraalRuntime");
976 return (oop) result.get_jobject(); 969 return (oop) result.get_jobject();
977 } 970 }
978 971
979 void GraalRuntime::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) { 972 void GraalRuntime::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) {
980 Thread* THREAD = Thread::current(); 973 Thread* THREAD = Thread::current();