1.1 --- a/src/share/vm/runtime/deoptimization.cpp Tue Mar 25 12:54:21 2014 -0700 1.2 +++ b/src/share/vm/runtime/deoptimization.cpp Tue Mar 25 17:07:36 2014 -0700 1.3 @@ -1288,7 +1288,8 @@ 1.4 gather_statistics(reason, action, trap_bc); 1.5 1.6 // Ensure that we can record deopt. history: 1.7 - bool create_if_missing = ProfileTraps; 1.8 + // Need MDO to record RTM code generation state. 1.9 + bool create_if_missing = ProfileTraps RTM_OPT_ONLY( || UseRTMLocking ); 1.10 1.11 MethodData* trap_mdo = 1.12 get_method_data(thread, trap_method, create_if_missing); 1.13 @@ -1489,6 +1490,7 @@ 1.14 bool maybe_prior_trap = false; 1.15 bool maybe_prior_recompile = false; 1.16 pdata = query_update_method_data(trap_mdo, trap_bci, reason, 1.17 + nm->method(), 1.18 //outputs: 1.19 this_trap_count, 1.20 maybe_prior_trap, 1.21 @@ -1534,7 +1536,7 @@ 1.22 } 1.23 1.24 // Go back to the compiler if there are too many traps in this method. 1.25 - if (this_trap_count >= (uint)PerMethodTrapLimit) { 1.26 + if (this_trap_count >= per_method_trap_limit(reason)) { 1.27 // If there are too many traps in this method, force a recompile. 1.28 // This will allow the compiler to see the limit overflow, and 1.29 // take corrective action, if possible. 1.30 @@ -1568,6 +1570,17 @@ 1.31 if (tstate1 != tstate0) 1.32 pdata->set_trap_state(tstate1); 1.33 } 1.34 + 1.35 +#if INCLUDE_RTM_OPT 1.36 + // Restart collecting RTM locking abort statistic if the method 1.37 + // is recompiled for a reason other than RTM state change. 1.38 + // Assume that in new recompiled code the statistic could be different, 1.39 + // for example, due to different inlining. 1.40 + if ((reason != Reason_rtm_state_change) && (trap_mdo != NULL) && 1.41 + UseRTMDeopt && (nm->rtm_state() != ProfileRTM)) { 1.42 + trap_mdo->atomic_set_rtm_state(ProfileRTM); 1.43 + } 1.44 +#endif 1.45 } 1.46 1.47 if (inc_recompile_count) { 1.48 @@ -1622,6 +1635,7 @@ 1.49 Deoptimization::query_update_method_data(MethodData* trap_mdo, 1.50 int trap_bci, 1.51 Deoptimization::DeoptReason reason, 1.52 + Method* compiled_method, 1.53 //outputs: 1.54 uint& ret_this_trap_count, 1.55 bool& ret_maybe_prior_trap, 1.56 @@ -1645,9 +1659,16 @@ 1.57 // Find the profile data for this BCI. If there isn't one, 1.58 // try to allocate one from the MDO's set of spares. 1.59 // This will let us detect a repeated trap at this point. 1.60 - pdata = trap_mdo->allocate_bci_to_data(trap_bci); 1.61 + pdata = trap_mdo->allocate_bci_to_data(trap_bci, reason_is_speculate(reason) ? compiled_method : NULL); 1.62 1.63 if (pdata != NULL) { 1.64 + if (reason_is_speculate(reason) && !pdata->is_SpeculativeTrapData()) { 1.65 + if (LogCompilation && xtty != NULL) { 1.66 + ttyLocker ttyl; 1.67 + // no more room for speculative traps in this MDO 1.68 + xtty->elem("speculative_traps_oom"); 1.69 + } 1.70 + } 1.71 // Query the trap state of this profile datum. 1.72 int tstate0 = pdata->trap_state(); 1.73 if (!trap_state_has_reason(tstate0, per_bc_reason)) 1.74 @@ -1685,8 +1706,10 @@ 1.75 uint ignore_this_trap_count; 1.76 bool ignore_maybe_prior_trap; 1.77 bool ignore_maybe_prior_recompile; 1.78 + assert(!reason_is_speculate(reason), "reason speculate only used by compiler"); 1.79 query_update_method_data(trap_mdo, trap_bci, 1.80 (DeoptReason)reason, 1.81 + NULL, 1.82 ignore_this_trap_count, 1.83 ignore_maybe_prior_trap, 1.84 ignore_maybe_prior_recompile); 1.85 @@ -1814,7 +1837,9 @@ 1.86 "div0_check", 1.87 "age", 1.88 "predicate", 1.89 - "loop_limit_check" 1.90 + "loop_limit_check", 1.91 + "speculate_class_check", 1.92 + "rtm_state_change" 1.93 }; 1.94 const char* Deoptimization::_trap_action_name[Action_LIMIT] = { 1.95 // Note: Keep this in sync. with enum DeoptAction.