src/share/vm/ci/ciEnv.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/ci

src/share/vm/ci/ciEnv.cpp

Print this page
rev 9032 : 8137167: JEP165: Compiler Control: Implementation task
Summary: Compiler Control JEP
Reviewed-by: roland, twisti


  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "ci/ciConstant.hpp"
  27 #include "ci/ciEnv.hpp"
  28 #include "ci/ciField.hpp"
  29 #include "ci/ciInstance.hpp"
  30 #include "ci/ciInstanceKlass.hpp"
  31 #include "ci/ciMethod.hpp"
  32 #include "ci/ciNullObject.hpp"
  33 #include "ci/ciReplay.hpp"
  34 #include "ci/ciUtilities.hpp"
  35 #include "classfile/systemDictionary.hpp"
  36 #include "classfile/vmSymbols.hpp"
  37 #include "code/codeCache.hpp"
  38 #include "code/scopeDesc.hpp"
  39 #include "compiler/compileBroker.hpp"
  40 #include "compiler/compileLog.hpp"
  41 #include "compiler/compilerOracle.hpp"

  42 #include "gc/shared/collectedHeap.inline.hpp"
  43 #include "interpreter/linkResolver.hpp"
  44 #include "memory/allocation.inline.hpp"
  45 #include "memory/oopFactory.hpp"
  46 #include "memory/universe.inline.hpp"
  47 #include "oops/methodData.hpp"
  48 #include "oops/objArrayKlass.hpp"
  49 #include "oops/objArrayOop.inline.hpp"
  50 #include "oops/oop.inline.hpp"
  51 #include "prims/jvmtiExport.hpp"
  52 #include "runtime/init.hpp"
  53 #include "runtime/reflection.hpp"
  54 #include "runtime/sharedRuntime.hpp"
  55 #include "runtime/thread.inline.hpp"
  56 #include "trace/tracing.hpp"
  57 #include "utilities/dtrace.hpp"
  58 #include "utilities/macros.hpp"
  59 #ifdef COMPILER1
  60 #include "c1/c1_Runtime1.hpp"
  61 #endif


 939       _task->print_tty();
 940     }
 941 #endif
 942     assert(counter_changed, "failed dependencies, but counter didn't change");
 943     record_failure("concurrent class loading");
 944   }
 945 }
 946 
 947 // ------------------------------------------------------------------
 948 // ciEnv::register_method
 949 void ciEnv::register_method(ciMethod* target,
 950                             int entry_bci,
 951                             CodeOffsets* offsets,
 952                             int orig_pc_offset,
 953                             CodeBuffer* code_buffer,
 954                             int frame_words,
 955                             OopMapSet* oop_map_set,
 956                             ExceptionHandlerTable* handler_table,
 957                             ImplicitExceptionTable* inc_table,
 958                             AbstractCompiler* compiler,
 959                             int comp_level,
 960                             bool has_unsafe_access,
 961                             bool has_wide_vectors,

 962                             RTMState  rtm_state) {
 963   VM_ENTRY_MARK;
 964   nmethod* nm = NULL;
 965   {
 966     // To prevent compile queue updates.
 967     MutexLocker locker(MethodCompileQueue_lock, THREAD);
 968 
 969     // Prevent SystemDictionary::add_to_hierarchy from running
 970     // and invalidating our dependencies until we install this method.
 971     // No safepoints are allowed. Otherwise, class redefinition can occur in between.
 972     MutexLocker ml(Compile_lock);
 973     No_Safepoint_Verifier nsv;
 974 
 975     // Change in Jvmti state may invalidate compilation.
 976     if (!failing() && jvmti_state_changed()) {
 977       record_failure("Jvmti state change invalidated dependencies");
 978     }
 979 
 980     // Change in DTrace flags may invalidate compilation.
 981     if (!failing() &&


1017       }
1018 
1019       // All buffers in the CodeBuffer are allocated in the CodeCache.
1020       // If the code buffer is created on each compile attempt
1021       // as in C2, then it must be freed.
1022       code_buffer->free_blob();
1023       return;
1024     }
1025 
1026     assert(offsets->value(CodeOffsets::Deopt) != -1, "must have deopt entry");
1027     assert(offsets->value(CodeOffsets::Exceptions) != -1, "must have exception entry");
1028 
1029     nm =  nmethod::new_nmethod(method,
1030                                compile_id(),
1031                                entry_bci,
1032                                offsets,
1033                                orig_pc_offset,
1034                                debug_info(), dependencies(), code_buffer,
1035                                frame_words, oop_map_set,
1036                                handler_table, inc_table,
1037                                compiler, comp_level);

1038     // Free codeBlobs
1039     code_buffer->free_blob();
1040 
1041     if (nm != NULL) {








1042       nm->set_has_unsafe_access(has_unsafe_access);
1043       nm->set_has_wide_vectors(has_wide_vectors);
1044 #if INCLUDE_RTM_OPT
1045       nm->set_rtm_state(rtm_state);
1046 #endif
1047 
1048       // Record successful registration.
1049       // (Put nm into the task handle *before* publishing to the Java heap.)
1050       if (task() != NULL) {
1051         task()->set_code(nm);
1052       }
1053 
1054       if (entry_bci == InvocationEntryBci) {
1055         if (TieredCompilation) {
1056           // If there is an old version we're done with it
1057           nmethod* old = method->code();
1058           if (TraceMethodReplacement && old != NULL) {
1059             ResourceMark rm;
1060             char *method_name = method->name_and_sig_as_C_string();
1061             tty->print_cr("Replacing method %s", method_name);
1062           }
1063           if (old != NULL) {
1064             old->make_not_entrant();
1065           }
1066         }
1067         if (TraceNMethodInstalls) {
1068           ResourceMark rm;
1069           char *method_name = method->name_and_sig_as_C_string();
1070           ttyLocker ttyl;
1071           tty->print_cr("Installing method (%d) %s ",
1072                         comp_level,
1073                         method_name);
1074         }
1075         // Allow the code to be executed
1076         method->set_code(method, nm);
1077       } else {
1078         if (TraceNMethodInstalls) {
1079           ResourceMark rm;
1080           char *method_name = method->name_and_sig_as_C_string();
1081           ttyLocker ttyl;
1082           tty->print_cr("Installing osr method (%d) %s @ %d",
1083                         comp_level,
1084                         method_name,
1085                         entry_bci);
1086         }
1087         method->method_holder()->add_osr_nmethod(nm);
1088       }
1089     }
1090   }  // safepoints are allowed again
1091 
1092   if (nm != NULL) {
1093     // JVMTI -- compiled method notification (must be done outside lock)
1094     nm->post_compiled_method_load_event();
1095   } else {
1096     // The CodeCache is full.
1097     record_failure("code cache is full");
1098   }
1099 }
1100 
1101 
1102 // ------------------------------------------------------------------
1103 // ciEnv::find_system_klass




  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "ci/ciConstant.hpp"
  27 #include "ci/ciEnv.hpp"
  28 #include "ci/ciField.hpp"
  29 #include "ci/ciInstance.hpp"
  30 #include "ci/ciInstanceKlass.hpp"
  31 #include "ci/ciMethod.hpp"
  32 #include "ci/ciNullObject.hpp"
  33 #include "ci/ciReplay.hpp"
  34 #include "ci/ciUtilities.hpp"
  35 #include "classfile/systemDictionary.hpp"
  36 #include "classfile/vmSymbols.hpp"
  37 #include "code/codeCache.hpp"
  38 #include "code/scopeDesc.hpp"
  39 #include "compiler/compileBroker.hpp"
  40 #include "compiler/compileLog.hpp"
  41 #include "compiler/compilerDirectives.hpp"
  42 #include "compiler/disassembler.hpp"
  43 #include "gc/shared/collectedHeap.inline.hpp"
  44 #include "interpreter/linkResolver.hpp"
  45 #include "memory/allocation.inline.hpp"
  46 #include "memory/oopFactory.hpp"
  47 #include "memory/universe.inline.hpp"
  48 #include "oops/methodData.hpp"
  49 #include "oops/objArrayKlass.hpp"
  50 #include "oops/objArrayOop.inline.hpp"
  51 #include "oops/oop.inline.hpp"
  52 #include "prims/jvmtiExport.hpp"
  53 #include "runtime/init.hpp"
  54 #include "runtime/reflection.hpp"
  55 #include "runtime/sharedRuntime.hpp"
  56 #include "runtime/thread.inline.hpp"
  57 #include "trace/tracing.hpp"
  58 #include "utilities/dtrace.hpp"
  59 #include "utilities/macros.hpp"
  60 #ifdef COMPILER1
  61 #include "c1/c1_Runtime1.hpp"
  62 #endif


 940       _task->print_tty();
 941     }
 942 #endif
 943     assert(counter_changed, "failed dependencies, but counter didn't change");
 944     record_failure("concurrent class loading");
 945   }
 946 }
 947 
 948 // ------------------------------------------------------------------
 949 // ciEnv::register_method
 950 void ciEnv::register_method(ciMethod* target,
 951                             int entry_bci,
 952                             CodeOffsets* offsets,
 953                             int orig_pc_offset,
 954                             CodeBuffer* code_buffer,
 955                             int frame_words,
 956                             OopMapSet* oop_map_set,
 957                             ExceptionHandlerTable* handler_table,
 958                             ImplicitExceptionTable* inc_table,
 959                             AbstractCompiler* compiler,

 960                             bool has_unsafe_access,
 961                             bool has_wide_vectors,
 962                             DirectiveSet* directives,
 963                             RTMState  rtm_state) {
 964   VM_ENTRY_MARK;
 965   nmethod* nm = NULL;
 966   {
 967     // To prevent compile queue updates.
 968     MutexLocker locker(MethodCompileQueue_lock, THREAD);
 969 
 970     // Prevent SystemDictionary::add_to_hierarchy from running
 971     // and invalidating our dependencies until we install this method.
 972     // No safepoints are allowed. Otherwise, class redefinition can occur in between.
 973     MutexLocker ml(Compile_lock);
 974     No_Safepoint_Verifier nsv;
 975 
 976     // Change in Jvmti state may invalidate compilation.
 977     if (!failing() && jvmti_state_changed()) {
 978       record_failure("Jvmti state change invalidated dependencies");
 979     }
 980 
 981     // Change in DTrace flags may invalidate compilation.
 982     if (!failing() &&


1018       }
1019 
1020       // All buffers in the CodeBuffer are allocated in the CodeCache.
1021       // If the code buffer is created on each compile attempt
1022       // as in C2, then it must be freed.
1023       code_buffer->free_blob();
1024       return;
1025     }
1026 
1027     assert(offsets->value(CodeOffsets::Deopt) != -1, "must have deopt entry");
1028     assert(offsets->value(CodeOffsets::Exceptions) != -1, "must have exception entry");
1029 
1030     nm =  nmethod::new_nmethod(method,
1031                                compile_id(),
1032                                entry_bci,
1033                                offsets,
1034                                orig_pc_offset,
1035                                debug_info(), dependencies(), code_buffer,
1036                                frame_words, oop_map_set,
1037                                handler_table, inc_table,
1038                                compiler, task()->comp_level());
1039 
1040     // Free codeBlobs
1041     code_buffer->free_blob();
1042 
1043     if (nm != NULL) {
1044       bool printnmethods = directives->PrintAssemblyOption || directives->PrintNMethodsOption;
1045       if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
1046         nm->print_nmethod(printnmethods);
1047       }
1048       if (directives->PrintAssemblyOption) {
1049         Disassembler::decode(nm);
1050       }
1051 
1052       nm->set_has_unsafe_access(has_unsafe_access);
1053       nm->set_has_wide_vectors(has_wide_vectors);
1054 #if INCLUDE_RTM_OPT
1055       nm->set_rtm_state(rtm_state);
1056 #endif
1057 
1058       // Record successful registration.
1059       // (Put nm into the task handle *before* publishing to the Java heap.)
1060       if (task() != NULL) {
1061         task()->set_code(nm);
1062       }
1063 
1064       if (entry_bci == InvocationEntryBci) {
1065         if (TieredCompilation) {
1066           // If there is an old version we're done with it
1067           nmethod* old = method->code();
1068           if (TraceMethodReplacement && old != NULL) {
1069             ResourceMark rm;
1070             char *method_name = method->name_and_sig_as_C_string();
1071             tty->print_cr("Replacing method %s", method_name);
1072           }
1073           if (old != NULL) {
1074             old->make_not_entrant();
1075           }
1076         }
1077         if (TraceNMethodInstalls) {
1078           ResourceMark rm;
1079           char *method_name = method->name_and_sig_as_C_string();
1080           ttyLocker ttyl;
1081           tty->print_cr("Installing method (%d) %s ",
1082                         task()->comp_level(),
1083                         method_name);
1084         }
1085         // Allow the code to be executed
1086         method->set_code(method, nm);
1087       } else {
1088         if (TraceNMethodInstalls) {
1089           ResourceMark rm;
1090           char *method_name = method->name_and_sig_as_C_string();
1091           ttyLocker ttyl;
1092           tty->print_cr("Installing osr method (%d) %s @ %d",
1093                         task()->comp_level(),
1094                         method_name,
1095                         entry_bci);
1096         }
1097         method->method_holder()->add_osr_nmethod(nm);
1098       }
1099     }
1100   }  // safepoints are allowed again
1101 
1102   if (nm != NULL) {
1103     // JVMTI -- compiled method notification (must be done outside lock)
1104     nm->post_compiled_method_load_event();
1105   } else {
1106     // The CodeCache is full.
1107     record_failure("code cache is full");
1108   }
1109 }
1110 
1111 
1112 // ------------------------------------------------------------------
1113 // ciEnv::find_system_klass


src/share/vm/ci/ciEnv.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File