Mercurial > hg > truffle
comparison src/share/vm/ci/ciEnv.cpp @ 4137:04b9a2566eec
Merge with hsx23/hotspot.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 17 Dec 2011 21:40:27 +0100 |
parents | 7958ebb561b0 5eb9169b1a14 |
children | 82af018d61db |
comparison
equal
deleted
inserted
replaced
3737:9dc19b7d89a3 | 4137:04b9a2566eec |
---|---|
470 // Found it. Build a CI handle. | 470 // Found it. Build a CI handle. |
471 return get_object(found_klass())->as_klass(); | 471 return get_object(found_klass())->as_klass(); |
472 } | 472 } |
473 | 473 |
474 if (require_local) return NULL; | 474 if (require_local) return NULL; |
475 | |
475 // Not yet loaded into the VM, or not governed by loader constraints. | 476 // Not yet loaded into the VM, or not governed by loader constraints. |
476 // Make a CI representative for it. | 477 // Make a CI representative for it. |
477 return get_unloaded_klass(accessing_klass, name); | 478 return get_unloaded_klass(accessing_klass, name); |
478 } | 479 } |
479 | 480 |
495 ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool, | 496 ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool, |
496 int index, | 497 int index, |
497 bool& is_accessible, | 498 bool& is_accessible, |
498 ciInstanceKlass* accessor) { | 499 ciInstanceKlass* accessor) { |
499 EXCEPTION_CONTEXT; | 500 EXCEPTION_CONTEXT; |
500 KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index)); | 501 KlassHandle klass(THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index)); |
501 Symbol* klass_name = NULL; | 502 Symbol* klass_name = NULL; |
502 if (klass.is_null()) { | 503 if (klass.is_null()) { |
503 // The klass has not been inserted into the constant pool. | 504 // The klass has not been inserted into the constant pool. |
504 // Try to look it up by name. | 505 // Try to look it up by name. |
505 { | 506 { |
782 } | 783 } |
783 | 784 |
784 // Either the declared holder was not loaded, or the method could | 785 // Either the declared holder was not loaded, or the method could |
785 // not be found. Create a dummy ciMethod to represent the failed | 786 // not be found. Create a dummy ciMethod to represent the failed |
786 // lookup. | 787 // lookup. |
787 | 788 ciSymbol* name = get_symbol(name_sym); |
788 return get_unloaded_method(declared_holder, | 789 ciSymbol* signature = get_symbol(sig_sym); |
789 get_symbol(name_sym), | 790 return get_unloaded_method(declared_holder, name, signature, accessor); |
790 get_symbol(sig_sym)); | |
791 } | 791 } |
792 | 792 |
793 | 793 |
794 // ------------------------------------------------------------------ | 794 // ------------------------------------------------------------------ |
795 // ciEnv::get_fake_invokedynamic_method_impl | 795 // ciEnv::get_fake_invokedynamic_method_impl |
796 ciMethod* ciEnv::get_fake_invokedynamic_method_impl(constantPoolHandle cpool, | 796 ciMethod* ciEnv::get_fake_invokedynamic_method_impl(constantPoolHandle cpool, |
797 int index, Bytecodes::Code bc) { | 797 int index, Bytecodes::Code bc, |
798 ciInstanceKlass* accessor) { | |
798 // Compare the following logic with InterpreterRuntime::resolve_invokedynamic. | 799 // Compare the following logic with InterpreterRuntime::resolve_invokedynamic. |
799 assert(bc == Bytecodes::_invokedynamic, "must be invokedynamic"); | 800 assert(bc == Bytecodes::_invokedynamic, "must be invokedynamic"); |
800 | 801 |
801 bool is_resolved = cpool->cache()->main_entry_at(index)->is_resolved(bc); | 802 bool is_resolved = cpool->cache()->main_entry_at(index)->is_resolved(bc); |
802 if (is_resolved && cpool->cache()->secondary_entry_at(index)->is_f1_null()) | 803 if (is_resolved && cpool->cache()->secondary_entry_at(index)->is_f1_null()) |
804 is_resolved = false; | 805 is_resolved = false; |
805 | 806 |
806 // Call site might not be resolved yet. We could create a real invoker method from the | 807 // Call site might not be resolved yet. We could create a real invoker method from the |
807 // compiler, but it is simpler to stop the code path here with an unlinked method. | 808 // compiler, but it is simpler to stop the code path here with an unlinked method. |
808 if (!is_resolved) { | 809 if (!is_resolved) { |
809 ciInstanceKlass* mh_klass = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass(); | 810 ciInstanceKlass* holder = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass(); |
810 ciSymbol* sig_sym = get_symbol(cpool->signature_ref_at(index)); | 811 ciSymbol* name = ciSymbol::invokeExact_name(); |
811 return get_unloaded_method(mh_klass, ciSymbol::invokeExact_name(), sig_sym); | 812 ciSymbol* signature = get_symbol(cpool->signature_ref_at(index)); |
813 return get_unloaded_method(holder, name, signature, accessor); | |
812 } | 814 } |
813 | 815 |
814 // Get the invoker methodOop from the constant pool. | 816 // Get the invoker methodOop from the constant pool. |
815 oop f1_value = cpool->cache()->main_entry_at(index)->f1(); | 817 oop f1_value = cpool->cache()->main_entry_at(index)->f1(); |
816 methodOop signature_invoker = (methodOop) f1_value; | 818 methodOop signature_invoker = (methodOop) f1_value; |
847 // ciEnv::get_method_by_index | 849 // ciEnv::get_method_by_index |
848 ciMethod* ciEnv::get_method_by_index(constantPoolHandle cpool, | 850 ciMethod* ciEnv::get_method_by_index(constantPoolHandle cpool, |
849 int index, Bytecodes::Code bc, | 851 int index, Bytecodes::Code bc, |
850 ciInstanceKlass* accessor) { | 852 ciInstanceKlass* accessor) { |
851 if (bc == Bytecodes::_invokedynamic) { | 853 if (bc == Bytecodes::_invokedynamic) { |
852 GUARDED_VM_ENTRY(return get_fake_invokedynamic_method_impl(cpool, index, bc);) | 854 GUARDED_VM_ENTRY(return get_fake_invokedynamic_method_impl(cpool, index, bc, accessor);) |
853 } else { | 855 } else { |
854 GUARDED_VM_ENTRY(return get_method_by_index_impl(cpool, index, bc, accessor);) | 856 GUARDED_VM_ENTRY(return get_method_by_index_impl( cpool, index, bc, accessor);) |
855 } | 857 } |
856 } | 858 } |
857 | 859 |
858 | 860 |
859 // ------------------------------------------------------------------ | 861 // ------------------------------------------------------------------ |
881 bool ciEnv::system_dictionary_modification_counter_changed() { | 883 bool ciEnv::system_dictionary_modification_counter_changed() { |
882 return _system_dictionary_modification_counter != SystemDictionary::number_of_modifications(); | 884 return _system_dictionary_modification_counter != SystemDictionary::number_of_modifications(); |
883 } | 885 } |
884 | 886 |
885 // ------------------------------------------------------------------ | 887 // ------------------------------------------------------------------ |
886 // ciEnv::check_for_system_dictionary_modification | 888 // ciEnv::validate_compile_task_dependencies |
887 // Check for changes to the system dictionary during compilation | 889 // |
888 // class loads, evolution, breakpoints | 890 // Check for changes during compilation (e.g. class loads, evolution, |
889 void ciEnv::check_for_system_dictionary_modification(ciMethod* target) { | 891 // breakpoints, call site invalidation). |
892 void ciEnv::validate_compile_task_dependencies(ciMethod* target) { | |
890 if (failing()) return; // no need for further checks | 893 if (failing()) return; // no need for further checks |
891 | 894 |
892 // Dependencies must be checked when the system dictionary changes. | 895 // First, check non-klass dependencies as we might return early and |
893 // If logging is enabled all violated dependences will be recorded in | 896 // not check klass dependencies if the system dictionary |
894 // the log. In debug mode check dependencies even if the system | 897 // modification counter hasn't changed (see below). |
895 // dictionary hasn't changed to verify that no invalid dependencies | |
896 // were inserted. Any violated dependences in this case are dumped to | |
897 // the tty. | |
898 | |
899 bool counter_changed = system_dictionary_modification_counter_changed(); | |
900 bool test_deps = counter_changed; | |
901 DEBUG_ONLY(test_deps = true); | |
902 if (!test_deps) return; | |
903 | |
904 bool print_failures = false; | |
905 DEBUG_ONLY(print_failures = !counter_changed); | |
906 | |
907 bool keep_going = (print_failures || xtty != NULL); | |
908 | |
909 int violated = 0; | |
910 | |
911 for (Dependencies::DepStream deps(dependencies()); deps.next(); ) { | 898 for (Dependencies::DepStream deps(dependencies()); deps.next(); ) { |
899 if (deps.is_klass_type()) continue; // skip klass dependencies | |
912 klassOop witness = deps.check_dependency(); | 900 klassOop witness = deps.check_dependency(); |
913 if (witness != NULL) { | 901 if (witness != NULL) { |
914 ++violated; | 902 record_failure("invalid non-klass dependency"); |
915 if (print_failures) deps.print_dependency(witness, /*verbose=*/ true); | 903 return; |
916 // If there's no log and we're not sanity-checking, we're done. | 904 } |
917 if (!keep_going) break; | 905 } |
918 } | 906 |
919 } | 907 // Klass dependencies must be checked when the system dictionary |
920 | 908 // changes. If logging is enabled all violated dependences will be |
921 if (violated != 0) { | 909 // recorded in the log. In debug mode check dependencies even if |
910 // the system dictionary hasn't changed to verify that no invalid | |
911 // dependencies were inserted. Any violated dependences in this | |
912 // case are dumped to the tty. | |
913 bool counter_changed = system_dictionary_modification_counter_changed(); | |
914 | |
915 bool verify_deps = trueInDebug; | |
916 if (!counter_changed && !verify_deps) return; | |
917 | |
918 int klass_violations = 0; | |
919 for (Dependencies::DepStream deps(dependencies()); deps.next(); ) { | |
920 if (!deps.is_klass_type()) continue; // skip non-klass dependencies | |
921 klassOop witness = deps.check_dependency(); | |
922 if (witness != NULL) { | |
923 klass_violations++; | |
924 if (!counter_changed) { | |
925 // Dependence failed but counter didn't change. Log a message | |
926 // describing what failed and allow the assert at the end to | |
927 // trigger. | |
928 deps.print_dependency(witness); | |
929 } else if (xtty == NULL) { | |
930 // If we're not logging then a single violation is sufficient, | |
931 // otherwise we want to log all the dependences which were | |
932 // violated. | |
933 break; | |
934 } | |
935 } | |
936 } | |
937 | |
938 if (klass_violations != 0) { | |
939 #ifdef ASSERT | |
940 if (!counter_changed && !PrintCompilation) { | |
941 // Print out the compile task that failed | |
942 _task->print_line(); | |
943 } | |
944 #endif | |
922 assert(counter_changed, "failed dependencies, but counter didn't change"); | 945 assert(counter_changed, "failed dependencies, but counter didn't change"); |
923 record_failure("concurrent class loading"); | 946 record_failure("concurrent class loading"); |
924 } | 947 } |
925 } | 948 } |
926 | 949 |
927 // ------------------------------------------------------------------ | 950 // ------------------------------------------------------------------ |
928 // ciEnv::register_method | 951 // ciEnv::register_method |
929 nmethod* ciEnv::register_method(ciMethod* target, | 952 void ciEnv::register_method(ciMethod* target, |
930 int entry_bci, | 953 int entry_bci, |
931 CodeOffsets* offsets, | 954 CodeOffsets* offsets, |
932 int orig_pc_offset, | 955 int orig_pc_offset, |
933 CodeBuffer* code_buffer, | 956 CodeBuffer* code_buffer, |
934 int frame_words, | 957 int frame_words, |
935 OopMapSet* oop_map_set, | 958 OopMapSet* oop_map_set, |
936 ExceptionHandlerTable* handler_table, | 959 ExceptionHandlerTable* handler_table, |
937 ImplicitExceptionTable* inc_table, | 960 ImplicitExceptionTable* inc_table, |
938 AbstractCompiler* compiler, | 961 AbstractCompiler* compiler, |
939 int comp_level, | 962 int comp_level, |
940 bool has_debug_info, | 963 bool has_unsafe_access) { |
941 bool has_unsafe_access, | |
942 bool install_code) { | |
943 VM_ENTRY_MARK; | 964 VM_ENTRY_MARK; |
944 nmethod* nm = NULL; | 965 nmethod* nm = NULL; |
945 { | 966 { |
946 // To prevent compile queue updates. | 967 // To prevent compile queue updates. |
947 MutexLocker locker(MethodCompileQueue_lock, THREAD); | 968 MutexLocker locker(MethodCompileQueue_lock, THREAD); |
948 | 969 |
949 // Prevent SystemDictionary::add_to_hierarchy from running | 970 // Prevent SystemDictionary::add_to_hierarchy from running |
950 // and invalidating our dependencies until we install this method. | 971 // and invalidating our dependencies until we install this method. |
951 MutexLocker ml(Compile_lock); | 972 MutexLocker ml(Compile_lock); |
952 | 973 |
953 // TODO(ls) this doesn't make much sense as long as graal doesn't support jvmti or dtrace... | |
954 #ifndef GRAAL | |
955 // Change in Jvmti state may invalidate compilation. | 974 // Change in Jvmti state may invalidate compilation. |
956 if (!failing() && | 975 if (!failing() && |
957 ( (!jvmti_can_hotswap_or_post_breakpoint() && | 976 ( (!jvmti_can_hotswap_or_post_breakpoint() && |
958 JvmtiExport::can_hotswap_or_post_breakpoint()) || | 977 JvmtiExport::can_hotswap_or_post_breakpoint()) || |
959 (!jvmti_can_access_local_variables() && | 978 (!jvmti_can_access_local_variables() && |
968 ( (!dtrace_extended_probes() && ExtendedDTraceProbes) || | 987 ( (!dtrace_extended_probes() && ExtendedDTraceProbes) || |
969 (!dtrace_method_probes() && DTraceMethodProbes) || | 988 (!dtrace_method_probes() && DTraceMethodProbes) || |
970 (!dtrace_alloc_probes() && DTraceAllocProbes) )) { | 989 (!dtrace_alloc_probes() && DTraceAllocProbes) )) { |
971 record_failure("DTrace flags change invalidated dependencies"); | 990 record_failure("DTrace flags change invalidated dependencies"); |
972 } | 991 } |
973 #endif | |
974 | 992 |
975 if (!failing()) { | 993 if (!failing()) { |
976 if (log() != NULL) { | 994 if (log() != NULL) { |
977 // Log the dependencies which this compilation declares. | 995 // Log the dependencies which this compilation declares. |
978 dependencies()->log_all_dependencies(); | 996 dependencies()->log_all_dependencies(); |
979 } | 997 } |
980 | 998 |
981 // Encode the dependencies now, so we can check them right away. | 999 // Encode the dependencies now, so we can check them right away. |
982 dependencies()->encode_content_bytes(); | 1000 dependencies()->encode_content_bytes(); |
983 | 1001 |
984 // Check for {class loads, evolution, breakpoints} during compilation | 1002 // Check for {class loads, evolution, breakpoints, ...} during compilation |
985 check_for_system_dictionary_modification(target); | 1003 validate_compile_task_dependencies(target); |
986 } | 1004 } |
987 | 1005 |
988 methodHandle method(THREAD, target->get_methodOop()); | 1006 methodHandle method(THREAD, target->get_methodOop()); |
989 | 1007 |
990 if (failing()) { | 1008 if (failing()) { |
1034 MutexUnlocker ml(Compile_lock); | 1052 MutexUnlocker ml(Compile_lock); |
1035 MutexUnlocker locker(MethodCompileQueue_lock); | 1053 MutexUnlocker locker(MethodCompileQueue_lock); |
1036 CompileBroker::handle_full_code_cache(); | 1054 CompileBroker::handle_full_code_cache(); |
1037 } | 1055 } |
1038 } else { | 1056 } else { |
1039 NOT_PRODUCT(nm->set_has_debug_info(has_debug_info); ) | |
1040 nm->set_has_unsafe_access(has_unsafe_access); | 1057 nm->set_has_unsafe_access(has_unsafe_access); |
1041 | 1058 |
1042 // Record successful registration. | 1059 // Record successful registration. |
1043 // (Put nm into the task handle *before* publishing to the Java heap.) | 1060 // (Put nm into the task handle *before* publishing to the Java heap.) |
1044 if (task() != NULL) task()->set_code(nm); | 1061 if (task() != NULL) task()->set_code(nm); |