< prev index next >

src/hotspot/share/ci/ciEnv.cpp

Print this page

1006     } else {
1007       record_failure("invalid non-klass dependency");
1008     }
1009   }
1010 }
1011 
1012 // ------------------------------------------------------------------
1013 // ciEnv::register_method
1014 void ciEnv::register_method(ciMethod* target,
1015                             int entry_bci,
1016                             CodeOffsets* offsets,
1017                             int orig_pc_offset,
1018                             CodeBuffer* code_buffer,
1019                             int frame_words,
1020                             OopMapSet* oop_map_set,
1021                             ExceptionHandlerTable* handler_table,
1022                             ImplicitExceptionTable* inc_table,
1023                             AbstractCompiler* compiler,
1024                             bool has_unsafe_access,
1025                             bool has_wide_vectors,


1026                             RTMState  rtm_state,
1027                             const GrowableArrayView<RuntimeStub*>& native_invokers) {
1028   VM_ENTRY_MARK;
1029   nmethod* nm = NULL;
1030   {
1031     methodHandle method(THREAD, target->get_Method());
1032 
1033     // We require method counters to store some method state (max compilation levels) required by the compilation policy.
1034     if (method->get_method_counters(THREAD) == NULL) {
1035       record_failure("can't create method counters");
1036       // All buffers in the CodeBuffer are allocated in the CodeCache.
1037       // If the code buffer is created on each compile attempt
1038       // as in C2, then it must be freed.
1039       code_buffer->free_blob();
1040       return;
1041     }
1042 
1043     // To prevent compile queue updates.
1044     MutexLocker locker(THREAD, MethodCompileQueue_lock);
1045 

1105     assert(offsets->value(CodeOffsets::Deopt) != -1, "must have deopt entry");
1106     assert(offsets->value(CodeOffsets::Exceptions) != -1, "must have exception entry");
1107 
1108     nm =  nmethod::new_nmethod(method,
1109                                compile_id(),
1110                                entry_bci,
1111                                offsets,
1112                                orig_pc_offset,
1113                                debug_info(), dependencies(), code_buffer,
1114                                frame_words, oop_map_set,
1115                                handler_table, inc_table,
1116                                compiler, task()->comp_level(),
1117                                native_invokers);
1118 
1119     // Free codeBlobs
1120     code_buffer->free_blob();
1121 
1122     if (nm != NULL) {
1123       nm->set_has_unsafe_access(has_unsafe_access);
1124       nm->set_has_wide_vectors(has_wide_vectors);



1125 #if INCLUDE_RTM_OPT
1126       nm->set_rtm_state(rtm_state);
1127 #endif
1128 
1129       // Record successful registration.
1130       // (Put nm into the task handle *before* publishing to the Java heap.)
1131       if (task() != NULL) {
1132         task()->set_code(nm);
1133       }
1134 
1135       if (entry_bci == InvocationEntryBci) {
1136         if (TieredCompilation) {
1137           // If there is an old version we're done with it
1138           CompiledMethod* old = method->code();
1139           if (TraceMethodReplacement && old != NULL) {
1140             ResourceMark rm;
1141             char *method_name = method->name_and_sig_as_C_string();
1142             tty->print_cr("Replacing method %s", method_name);
1143           }
1144           if (old != NULL) {

1166           lt.print("Installing osr method (%d) %s @ %d",
1167                     task()->comp_level(), method_name, entry_bci);
1168         }
1169         MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
1170         if (nm->make_in_use()) {
1171           method->method_holder()->add_osr_nmethod(nm);
1172         }
1173       }
1174     }
1175   }  // safepoints are allowed again
1176 
1177   if (nm != NULL) {
1178     // JVMTI -- compiled method notification (must be done outside lock)
1179     nm->post_compiled_method_load_event();
1180   } else {
1181     // The CodeCache is full.
1182     record_failure("code cache is full");
1183   }
1184 }
1185 







1186 // ------------------------------------------------------------------
1187 // ciEnv::comp_level
1188 int ciEnv::comp_level() {
1189   if (task() == NULL)  return CompilationPolicy::highest_compile_level();
1190   return task()->comp_level();
1191 }
1192 
1193 // ------------------------------------------------------------------
1194 // ciEnv::compile_id
1195 uint ciEnv::compile_id() {
1196   if (task() == NULL)  return 0;
1197   return task()->compile_id();
1198 }
1199 
1200 // ------------------------------------------------------------------
1201 // ciEnv::notice_inlined_method()
1202 void ciEnv::notice_inlined_method(ciMethod* method) {
1203   _num_inlined_bytecodes += method->code_size_for_inlining();
1204 }
1205 

1006     } else {
1007       record_failure("invalid non-klass dependency");
1008     }
1009   }
1010 }
1011 
1012 // ------------------------------------------------------------------
1013 // ciEnv::register_method
1014 void ciEnv::register_method(ciMethod* target,
1015                             int entry_bci,
1016                             CodeOffsets* offsets,
1017                             int orig_pc_offset,
1018                             CodeBuffer* code_buffer,
1019                             int frame_words,
1020                             OopMapSet* oop_map_set,
1021                             ExceptionHandlerTable* handler_table,
1022                             ImplicitExceptionTable* inc_table,
1023                             AbstractCompiler* compiler,
1024                             bool has_unsafe_access,
1025                             bool has_wide_vectors,
1026                             bool has_monitors,
1027                             int immediate_oops_patched,
1028                             RTMState  rtm_state,
1029                             const GrowableArrayView<RuntimeStub*>& native_invokers) {
1030   VM_ENTRY_MARK;
1031   nmethod* nm = NULL;
1032   {
1033     methodHandle method(THREAD, target->get_Method());
1034 
1035     // We require method counters to store some method state (max compilation levels) required by the compilation policy.
1036     if (method->get_method_counters(THREAD) == NULL) {
1037       record_failure("can't create method counters");
1038       // All buffers in the CodeBuffer are allocated in the CodeCache.
1039       // If the code buffer is created on each compile attempt
1040       // as in C2, then it must be freed.
1041       code_buffer->free_blob();
1042       return;
1043     }
1044 
1045     // To prevent compile queue updates.
1046     MutexLocker locker(THREAD, MethodCompileQueue_lock);
1047 

1107     assert(offsets->value(CodeOffsets::Deopt) != -1, "must have deopt entry");
1108     assert(offsets->value(CodeOffsets::Exceptions) != -1, "must have exception entry");
1109 
1110     nm =  nmethod::new_nmethod(method,
1111                                compile_id(),
1112                                entry_bci,
1113                                offsets,
1114                                orig_pc_offset,
1115                                debug_info(), dependencies(), code_buffer,
1116                                frame_words, oop_map_set,
1117                                handler_table, inc_table,
1118                                compiler, task()->comp_level(),
1119                                native_invokers);
1120 
1121     // Free codeBlobs
1122     code_buffer->free_blob();
1123 
1124     if (nm != NULL) {
1125       nm->set_has_unsafe_access(has_unsafe_access);
1126       nm->set_has_wide_vectors(has_wide_vectors);
1127       nm->set_has_monitors(has_monitors);
1128       nm->set_immediate_oops_patched(immediate_oops_patched);
1129       assert (!method->is_synchronized() || nm->has_monitors(), "");
1130 #if INCLUDE_RTM_OPT
1131       nm->set_rtm_state(rtm_state);
1132 #endif
1133 
1134       // Record successful registration.
1135       // (Put nm into the task handle *before* publishing to the Java heap.)
1136       if (task() != NULL) {
1137         task()->set_code(nm);
1138       }
1139 
1140       if (entry_bci == InvocationEntryBci) {
1141         if (TieredCompilation) {
1142           // If there is an old version we're done with it
1143           CompiledMethod* old = method->code();
1144           if (TraceMethodReplacement && old != NULL) {
1145             ResourceMark rm;
1146             char *method_name = method->name_and_sig_as_C_string();
1147             tty->print_cr("Replacing method %s", method_name);
1148           }
1149           if (old != NULL) {

1171           lt.print("Installing osr method (%d) %s @ %d",
1172                     task()->comp_level(), method_name, entry_bci);
1173         }
1174         MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
1175         if (nm->make_in_use()) {
1176           method->method_holder()->add_osr_nmethod(nm);
1177         }
1178       }
1179     }
1180   }  // safepoints are allowed again
1181 
1182   if (nm != NULL) {
1183     // JVMTI -- compiled method notification (must be done outside lock)
1184     nm->post_compiled_method_load_event();
1185   } else {
1186     // The CodeCache is full.
1187     record_failure("code cache is full");
1188   }
1189 }
1190 
1191 // ------------------------------------------------------------------
1192 // ciEnv::find_system_klass
1193 ciKlass* ciEnv::find_system_klass(ciSymbol* klass_name) {
1194   VM_ENTRY_MARK;
1195   return get_klass_by_name_impl(NULL, constantPoolHandle(), klass_name, false);
1196 }
1197 
1198 // ------------------------------------------------------------------
1199 // ciEnv::comp_level
1200 int ciEnv::comp_level() {
1201   if (task() == NULL)  return CompilationPolicy::highest_compile_level();
1202   return task()->comp_level();
1203 }
1204 
1205 // ------------------------------------------------------------------
1206 // ciEnv::compile_id
1207 uint ciEnv::compile_id() {
1208   if (task() == NULL)  return 0;
1209   return task()->compile_id();
1210 }
1211 
1212 // ------------------------------------------------------------------
1213 // ciEnv::notice_inlined_method()
1214 void ciEnv::notice_inlined_method(ciMethod* method) {
1215   _num_inlined_bytecodes += method->code_size_for_inlining();
1216 }
1217 
< prev index next >