< prev index next >

src/hotspot/share/ci/ciEnv.cpp

Print this page

1013     } else {
1014       record_failure("invalid non-klass dependency");
1015     }
1016   }
1017 }
1018 
1019 // ------------------------------------------------------------------
1020 // ciEnv::register_method
1021 void ciEnv::register_method(ciMethod* target,
1022                             int entry_bci,
1023                             CodeOffsets* offsets,
1024                             int orig_pc_offset,
1025                             CodeBuffer* code_buffer,
1026                             int frame_words,
1027                             OopMapSet* oop_map_set,
1028                             ExceptionHandlerTable* handler_table,
1029                             ImplicitExceptionTable* inc_table,
1030                             AbstractCompiler* compiler,
1031                             bool has_unsafe_access,
1032                             bool has_wide_vectors,


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

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



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

1174                     task()->comp_level(), method_name, entry_bci);
1175         }
1176         MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
1177         if (nm->make_in_use()) {
1178           method->method_holder()->add_osr_nmethod(nm);
1179         }
1180       }
1181     }
1182   }  // safepoints are allowed again
1183 
1184   if (nm != NULL) {
1185     // JVMTI -- compiled method notification (must be done outside lock)
1186     nm->post_compiled_method_load_event();
1187   } else {
1188     // The CodeCache is full.
1189     record_failure("code cache is full");
1190   }
1191 }
1192 
1193 // ------------------------------------------------------------------







1194 // ciEnv::comp_level
1195 int ciEnv::comp_level() {
1196   if (task() == NULL)  return CompilationPolicy::highest_compile_level();
1197   return task()->comp_level();
1198 }
1199 
1200 // ------------------------------------------------------------------
1201 // ciEnv::compile_id
1202 uint ciEnv::compile_id() {
1203   if (task() == NULL)  return 0;
1204   return task()->compile_id();
1205 }
1206 
1207 // ------------------------------------------------------------------
1208 // ciEnv::notice_inlined_method()
1209 void ciEnv::notice_inlined_method(ciMethod* method) {
1210   _num_inlined_bytecodes += method->code_size_for_inlining();
1211 }
1212 
1213 // ------------------------------------------------------------------

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

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

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