909 #endif
910 assert(counter_changed, "failed dependencies, but counter didn't change");
911 record_failure("concurrent class loading");
912 }
913 }
914
915 // ------------------------------------------------------------------
916 // ciEnv::register_method
917 void ciEnv::register_method(ciMethod* target,
918 int entry_bci,
919 CodeOffsets* offsets,
920 int orig_pc_offset,
921 CodeBuffer* code_buffer,
922 int frame_words,
923 OopMapSet* oop_map_set,
924 ExceptionHandlerTable* handler_table,
925 ImplicitExceptionTable* inc_table,
926 AbstractCompiler* compiler,
927 int comp_level,
928 bool has_unsafe_access,
929 bool has_wide_vectors) {
930 VM_ENTRY_MARK;
931 nmethod* nm = NULL;
932 {
933 // To prevent compile queue updates.
934 MutexLocker locker(MethodCompileQueue_lock, THREAD);
935
936 // Prevent SystemDictionary::add_to_hierarchy from running
937 // and invalidating our dependencies until we install this method.
938 // No safepoints are allowed. Otherwise, class redefinition can occur in between.
939 MutexLocker ml(Compile_lock);
940 No_Safepoint_Verifier nsv;
941
942 // Change in Jvmti state may invalidate compilation.
943 if (!failing() &&
944 ( (!jvmti_can_hotswap_or_post_breakpoint() &&
945 JvmtiExport::can_hotswap_or_post_breakpoint()) ||
946 (!jvmti_can_access_local_variables() &&
947 JvmtiExport::can_access_local_variables()) ||
948 (!jvmti_can_post_on_exceptions() &&
949 JvmtiExport::can_post_on_exceptions()) )) {
956 (!dtrace_method_probes() && DTraceMethodProbes) ||
957 (!dtrace_alloc_probes() && DTraceAllocProbes) )) {
958 record_failure("DTrace flags change invalidated dependencies");
959 }
960
961 if (!failing()) {
962 if (log() != NULL) {
963 // Log the dependencies which this compilation declares.
964 dependencies()->log_all_dependencies();
965 }
966
967 // Encode the dependencies now, so we can check them right away.
968 dependencies()->encode_content_bytes();
969
970 // Check for {class loads, evolution, breakpoints, ...} during compilation
971 validate_compile_task_dependencies(target);
972 }
973
974 methodHandle method(THREAD, target->get_Method());
975
976 if (failing()) {
977 // While not a true deoptimization, it is a preemptive decompile.
978 MethodData* mdo = method()->method_data();
979 if (mdo != NULL) {
980 mdo->inc_decompile_count();
981 }
982
983 // All buffers in the CodeBuffer are allocated in the CodeCache.
984 // If the code buffer is created on each compile attempt
985 // as in C2, then it must be freed.
986 code_buffer->free_blob();
987 return;
988 }
989
990 assert(offsets->value(CodeOffsets::Deopt) != -1, "must have deopt entry");
991 assert(offsets->value(CodeOffsets::Exceptions) != -1, "must have exception entry");
992
993 nm = nmethod::new_nmethod(method,
994 compile_id(),
995 entry_bci,
996 offsets,
997 orig_pc_offset,
998 debug_info(), dependencies(), code_buffer,
999 frame_words, oop_map_set,
1000 handler_table, inc_table,
1001 compiler, comp_level);
1002
1003 // Free codeBlobs
1004 code_buffer->free_blob();
1005
1006 if (nm != NULL) {
1007 nm->set_has_unsafe_access(has_unsafe_access);
1008 nm->set_has_wide_vectors(has_wide_vectors);
1009
1010 // Record successful registration.
1011 // (Put nm into the task handle *before* publishing to the Java heap.)
1012 if (task() != NULL) {
1013 task()->set_code(nm);
1014 }
1015
1016 if (entry_bci == InvocationEntryBci) {
1017 if (TieredCompilation) {
1018 // If there is an old version we're done with it
1019 nmethod* old = method->code();
1020 if (TraceMethodReplacement && old != NULL) {
1021 ResourceMark rm;
1022 char *method_name = method->name_and_sig_as_C_string();
|
909 #endif
910 assert(counter_changed, "failed dependencies, but counter didn't change");
911 record_failure("concurrent class loading");
912 }
913 }
914
915 // ------------------------------------------------------------------
916 // ciEnv::register_method
917 void ciEnv::register_method(ciMethod* target,
918 int entry_bci,
919 CodeOffsets* offsets,
920 int orig_pc_offset,
921 CodeBuffer* code_buffer,
922 int frame_words,
923 OopMapSet* oop_map_set,
924 ExceptionHandlerTable* handler_table,
925 ImplicitExceptionTable* inc_table,
926 AbstractCompiler* compiler,
927 int comp_level,
928 bool has_unsafe_access,
929 bool has_wide_vectors,
930 RTMState rtm_state) {
931 VM_ENTRY_MARK;
932 nmethod* nm = NULL;
933 {
934 // To prevent compile queue updates.
935 MutexLocker locker(MethodCompileQueue_lock, THREAD);
936
937 // Prevent SystemDictionary::add_to_hierarchy from running
938 // and invalidating our dependencies until we install this method.
939 // No safepoints are allowed. Otherwise, class redefinition can occur in between.
940 MutexLocker ml(Compile_lock);
941 No_Safepoint_Verifier nsv;
942
943 // Change in Jvmti state may invalidate compilation.
944 if (!failing() &&
945 ( (!jvmti_can_hotswap_or_post_breakpoint() &&
946 JvmtiExport::can_hotswap_or_post_breakpoint()) ||
947 (!jvmti_can_access_local_variables() &&
948 JvmtiExport::can_access_local_variables()) ||
949 (!jvmti_can_post_on_exceptions() &&
950 JvmtiExport::can_post_on_exceptions()) )) {
957 (!dtrace_method_probes() && DTraceMethodProbes) ||
958 (!dtrace_alloc_probes() && DTraceAllocProbes) )) {
959 record_failure("DTrace flags change invalidated dependencies");
960 }
961
962 if (!failing()) {
963 if (log() != NULL) {
964 // Log the dependencies which this compilation declares.
965 dependencies()->log_all_dependencies();
966 }
967
968 // Encode the dependencies now, so we can check them right away.
969 dependencies()->encode_content_bytes();
970
971 // Check for {class loads, evolution, breakpoints, ...} during compilation
972 validate_compile_task_dependencies(target);
973 }
974
975 methodHandle method(THREAD, target->get_Method());
976
977 #if INCLUDE_RTM_OPT
978 if (!failing() && (rtm_state != NoRTM) &&
979 (method()->method_data() != NULL) &&
980 (method()->method_data()->rtm_state() != rtm_state)) {
981 // Preemptive decompile if rtm state was changed.
982 record_failure("RTM state change invalidated rtm code");
983 }
984 #endif
985
986 if (failing()) {
987 // While not a true deoptimization, it is a preemptive decompile.
988 MethodData* mdo = method()->method_data();
989 if (mdo != NULL) {
990 mdo->inc_decompile_count();
991 }
992
993 // All buffers in the CodeBuffer are allocated in the CodeCache.
994 // If the code buffer is created on each compile attempt
995 // as in C2, then it must be freed.
996 code_buffer->free_blob();
997 return;
998 }
999
1000 assert(offsets->value(CodeOffsets::Deopt) != -1, "must have deopt entry");
1001 assert(offsets->value(CodeOffsets::Exceptions) != -1, "must have exception entry");
1002
1003 nm = nmethod::new_nmethod(method,
1004 compile_id(),
1005 entry_bci,
1006 offsets,
1007 orig_pc_offset,
1008 debug_info(), dependencies(), code_buffer,
1009 frame_words, oop_map_set,
1010 handler_table, inc_table,
1011 compiler, comp_level);
1012 #if INCLUDE_RTM_OPT
1013 nm->set_rtm_state(rtm_state);
1014 #endif
1015 // Free codeBlobs
1016 code_buffer->free_blob();
1017
1018 if (nm != NULL) {
1019 nm->set_has_unsafe_access(has_unsafe_access);
1020 nm->set_has_wide_vectors(has_wide_vectors);
1021
1022 // Record successful registration.
1023 // (Put nm into the task handle *before* publishing to the Java heap.)
1024 if (task() != NULL) {
1025 task()->set_code(nm);
1026 }
1027
1028 if (entry_bci == InvocationEntryBci) {
1029 if (TieredCompilation) {
1030 // If there is an old version we're done with it
1031 nmethod* old = method->code();
1032 if (TraceMethodReplacement && old != NULL) {
1033 ResourceMark rm;
1034 char *method_name = method->name_and_sig_as_C_string();
|