comparison src/share/vm/jvmci/jvmciRuntime.cpp @ 23784:19222d463306

JVMCI re-initialization check is in the wrong location (JDK-8167353)
author Doug Simon <doug.simon@oracle.com>
date Fri, 07 Oct 2016 16:18:19 +0200
parents b1b5c71c04b7
children a81ca24b52bc
comparison
equal deleted inserted replaced
23783:1523f2f7832f 23784:19222d463306
636 JVMCIRuntime::ensure_jvmci_class_loader_is_initialized(); 636 JVMCIRuntime::ensure_jvmci_class_loader_is_initialized();
637 return JNIHandles::make_local(THREAD, SystemDictionary::jvmci_loader()); 637 return JNIHandles::make_local(THREAD, SystemDictionary::jvmci_loader());
638 JVM_END 638 JVM_END
639 639
640 Handle JVMCIRuntime::callStatic(const char* className, const char* methodName, const char* signature, JavaCallArguments* args, TRAPS) { 640 Handle JVMCIRuntime::callStatic(const char* className, const char* methodName, const char* signature, JavaCallArguments* args, TRAPS) {
641 guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime");
642
643 TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_(Handle())); 641 TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_(Handle()));
644 KlassHandle klass = resolve_or_fail(name, CHECK_(Handle())); 642 KlassHandle klass = resolve_or_fail(name, CHECK_(Handle()));
645 TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_(Handle())); 643 TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_(Handle()));
646 TempNewSymbol sig = SymbolTable::new_symbol(signature, CHECK_(Handle())); 644 TempNewSymbol sig = SymbolTable::new_symbol(signature, CHECK_(Handle()));
647 JavaValue result(T_OBJECT); 645 JavaValue result(T_OBJECT);
652 } 650 }
653 return Handle((oop)result.get_jobject()); 651 return Handle((oop)result.get_jobject());
654 } 652 }
655 653
656 void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(TRAPS) { 654 void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(TRAPS) {
657 if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { 655 guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime");
658 Thread* THREAD = Thread::current(); 656 JVMCIRuntime::ensure_jvmci_class_loader_is_initialized();
659 ResourceMark rm; 657 // This should only be called in the context of the JVMCI class being initialized
660 #ifdef ASSERT 658 instanceKlassHandle klass = InstanceKlass::cast(SystemDictionary::JVMCI_klass());
661 // This should only be called in the context of the JVMCI class being initialized 659 guarantee(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD),
662 TempNewSymbol name = SymbolTable::new_symbol("jdk/vm/ci/runtime/JVMCI", CHECK); 660 "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization");
663 Klass* k = resolve_or_fail(name, CHECK); 661
664 instanceKlassHandle klass = InstanceKlass::cast(k); 662 Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime",
665 assert(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD), 663 "runtime",
666 "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization"); 664 "()Ljdk/vm/ci/hotspot/HotSpotJVMCIRuntime;", NULL, CHECK);
667 #endif 665 objArrayOop trivial_prefixes = HotSpotJVMCIRuntime::trivialPrefixes(result);
668 666 if (trivial_prefixes != NULL) {
669 Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime", 667 char** prefixes = NEW_C_HEAP_ARRAY(char*, trivial_prefixes->length(), mtCompiler);
670 "runtime", 668 for (int i = 0; i < trivial_prefixes->length(); i++) {
671 "()Ljdk/vm/ci/hotspot/HotSpotJVMCIRuntime;", NULL, CHECK); 669 oop str = trivial_prefixes->obj_at(i);
672 objArrayOop trivial_prefixes = HotSpotJVMCIRuntime::trivialPrefixes(result); 670 if (str == NULL) {
673 if (trivial_prefixes != NULL) { 671 THROW(vmSymbols::java_lang_NullPointerException());
674 char** prefixes = NEW_C_HEAP_ARRAY(char*, trivial_prefixes->length(), mtCompiler); 672 } else {
675 for (int i = 0; i < trivial_prefixes->length(); i++) { 673 prefixes[i] = strdup(java_lang_String::as_utf8_string(str));
676 oop str = trivial_prefixes->obj_at(i);
677 if (str == NULL) {
678 THROW(vmSymbols::java_lang_NullPointerException());
679 } else {
680 prefixes[i] = strdup(java_lang_String::as_utf8_string(str));
681 }
682 } 674 }
683 _trivial_prefixes = prefixes; 675 }
684 _trivial_prefixes_count = trivial_prefixes->length(); 676 _trivial_prefixes = prefixes;
685 } 677 _trivial_prefixes_count = trivial_prefixes->length();
686 int adjustment = HotSpotJVMCIRuntime::compilationLevelAdjustment(result); 678 }
687 assert(adjustment >= JVMCIRuntime::none && 679 int adjustment = HotSpotJVMCIRuntime::compilationLevelAdjustment(result);
688 adjustment <= JVMCIRuntime::by_full_signature, 680 assert(adjustment >= JVMCIRuntime::none &&
689 "compilation level adjustment out of bounds"); 681 adjustment <= JVMCIRuntime::by_full_signature,
690 _comp_level_adjustment = (CompLevelAdjustment) adjustment; 682 "compilation level adjustment out of bounds");
691 _HotSpotJVMCIRuntime_initialized = true; 683 _comp_level_adjustment = (CompLevelAdjustment) adjustment;
692 _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result()); 684 _HotSpotJVMCIRuntime_initialized = true;
693 } 685 _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result());
694 } 686 }
695 687
696 void JVMCIRuntime::initialize_JVMCI(TRAPS) { 688 void JVMCIRuntime::initialize_JVMCI(TRAPS) {
697 if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { 689 if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) {
698 callStatic("jdk/vm/ci/runtime/JVMCI", 690 callStatic("jdk/vm/ci/runtime/JVMCI",