src/hotspot/share/oops/methodData.cpp
changeset 59056 15936b142f86
parent 58545 725244418646
child 59247 56bf71d64d51
equal deleted inserted replaced
59055:57ad70bcf06c 59056:15936b142f86
   666   }
   666   }
   667   st->cr();
   667   st->cr();
   668 }
   668 }
   669 
   669 
   670 int ParametersTypeData::compute_cell_count(Method* m) {
   670 int ParametersTypeData::compute_cell_count(Method* m) {
   671   if (!MethodData::profile_parameters_for_method(m)) {
   671   if (!MethodData::profile_parameters_for_method(methodHandle(Thread::current(), m))) {
   672     return 0;
   672     return 0;
   673   }
   673   }
   674   int max = TypeProfileParmsLimit == -1 ? INT_MAX : TypeProfileParmsLimit;
   674   int max = TypeProfileParmsLimit == -1 ? INT_MAX : TypeProfileParmsLimit;
   675   int obj_args = TypeStackSlotEntries::compute_cell_count(m->signature(), !m->is_static(), max);
   675   int obj_args = TypeStackSlotEntries::compute_cell_count(m->signature(), !m->is_static(), max);
   676   if (obj_args > 0) {
   676   if (obj_args > 0) {
   707 
   707 
   708 MethodData* MethodData::allocate(ClassLoaderData* loader_data, const methodHandle& method, TRAPS) {
   708 MethodData* MethodData::allocate(ClassLoaderData* loader_data, const methodHandle& method, TRAPS) {
   709   int size = MethodData::compute_allocation_size_in_words(method);
   709   int size = MethodData::compute_allocation_size_in_words(method);
   710 
   710 
   711   return new (loader_data, size, MetaspaceObj::MethodDataType, THREAD)
   711   return new (loader_data, size, MetaspaceObj::MethodDataType, THREAD)
   712     MethodData(method(), size, THREAD);
   712     MethodData(method, size, THREAD);
   713 }
   713 }
   714 
   714 
   715 int MethodData::bytecode_cell_count(Bytecodes::Code code) {
   715 int MethodData::bytecode_cell_count(Bytecodes::Code code) {
   716   if (is_client_compilation_mode_vm()) {
   716   if (is_client_compilation_mode_vm()) {
   717     return no_profile_data;
   717     return no_profile_data;
  1218   _method = method();
  1218   _method = method();
  1219   initialize();
  1219   initialize();
  1220 }
  1220 }
  1221 
  1221 
  1222 void MethodData::initialize() {
  1222 void MethodData::initialize() {
       
  1223   Thread* thread = Thread::current();
  1223   NoSafepointVerifier no_safepoint;  // init function atomic wrt GC
  1224   NoSafepointVerifier no_safepoint;  // init function atomic wrt GC
  1224   ResourceMark rm;
  1225   ResourceMark rm(thread);
  1225 
  1226 
  1226   init();
  1227   init();
  1227   set_creation_mileage(mileage_of(method()));
  1228   set_creation_mileage(mileage_of(method()));
  1228 
  1229 
  1229   // Go through the bytecodes and allocate and initialize the
  1230   // Go through the bytecodes and allocate and initialize the
  1230   // corresponding data cells.
  1231   // corresponding data cells.
  1231   int data_size = 0;
  1232   int data_size = 0;
  1232   int empty_bc_count = 0;  // number of bytecodes lacking data
  1233   int empty_bc_count = 0;  // number of bytecodes lacking data
  1233   _data[0] = 0;  // apparently not set below.
  1234   _data[0] = 0;  // apparently not set below.
  1234   BytecodeStream stream(method());
  1235   BytecodeStream stream(methodHandle(thread, method()));
  1235   Bytecodes::Code c;
  1236   Bytecodes::Code c;
  1236   bool needs_speculative_traps = false;
  1237   bool needs_speculative_traps = false;
  1237   while ((c = stream.next()) >= 0) {
  1238   while ((c = stream.next()) >= 0) {
  1238     int size_in_bytes = initialize_data(&stream, data_size);
  1239     int size_in_bytes = initialize_data(&stream, data_size);
  1239     data_size += size_in_bytes;
  1240     data_size += size_in_bytes;
  1282   // least well-defined.
  1283   // least well-defined.
  1283   _hint_di = first_di();
  1284   _hint_di = first_di();
  1284 
  1285 
  1285   post_initialize(&stream);
  1286   post_initialize(&stream);
  1286 
  1287 
  1287   assert(object_size == compute_allocation_size_in_bytes(methodHandle(_method)), "MethodData: computed size != initialized size");
  1288   assert(object_size == compute_allocation_size_in_bytes(methodHandle(thread, _method)), "MethodData: computed size != initialized size");
  1288   set_size(object_size);
  1289   set_size(object_size);
  1289 }
  1290 }
  1290 
  1291 
  1291 void MethodData::init() {
  1292 void MethodData::init() {
  1292   _invocation_counter.init();
  1293   _invocation_counter.init();
  1294   _invocation_counter_start = 0;
  1295   _invocation_counter_start = 0;
  1295   _backedge_counter_start = 0;
  1296   _backedge_counter_start = 0;
  1296 
  1297 
  1297   // Set per-method invoke- and backedge mask.
  1298   // Set per-method invoke- and backedge mask.
  1298   double scale = 1.0;
  1299   double scale = 1.0;
  1299   CompilerOracle::has_option_value(_method, "CompileThresholdScaling", scale);
  1300   methodHandle mh(Thread::current(), _method);
       
  1301   CompilerOracle::has_option_value(mh, "CompileThresholdScaling", scale);
  1300   _invoke_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0InvokeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
  1302   _invoke_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0InvokeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
  1301   _backedge_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0BackedgeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
  1303   _backedge_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0BackedgeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
  1302 
  1304 
  1303   _tenure_traps = 0;
  1305   _tenure_traps = 0;
  1304   _num_loops = 0;
  1306   _num_loops = 0;
  1311 #endif
  1313 #endif
  1312 
  1314 
  1313 #if INCLUDE_RTM_OPT
  1315 #if INCLUDE_RTM_OPT
  1314   _rtm_state = NoRTM; // No RTM lock eliding by default
  1316   _rtm_state = NoRTM; // No RTM lock eliding by default
  1315   if (UseRTMLocking &&
  1317   if (UseRTMLocking &&
  1316       !CompilerOracle::has_option_string(_method, "NoRTMLockEliding")) {
  1318       !CompilerOracle::has_option_string(mh, "NoRTMLockEliding")) {
  1317     if (CompilerOracle::has_option_string(_method, "UseRTMLockEliding") || !UseRTMDeopt) {
  1319     if (CompilerOracle::has_option_string(mh, "UseRTMLockEliding") || !UseRTMDeopt) {
  1318       // Generate RTM lock eliding code without abort ratio calculation code.
  1320       // Generate RTM lock eliding code without abort ratio calculation code.
  1319       _rtm_state = UseRTM;
  1321       _rtm_state = UseRTM;
  1320     } else if (UseRTMDeopt) {
  1322     } else if (UseRTMDeopt) {
  1321       // Generate RTM lock eliding code and include abort ratio calculation
  1323       // Generate RTM lock eliding code and include abort ratio calculation
  1322       // code if UseRTMDeopt is on.
  1324       // code if UseRTMDeopt is on.