1.1 --- a/src/share/vm/runtime/deoptimization.cpp Mon Feb 01 23:18:47 2010 +0100 1.2 +++ b/src/share/vm/runtime/deoptimization.cpp Mon Feb 01 16:49:49 2010 -0800 1.3 @@ -1338,13 +1338,14 @@ 1.4 // Whether the interpreter is producing MDO data or not, we also need 1.5 // to use the MDO to detect hot deoptimization points and control 1.6 // aggressive optimization. 1.7 + bool inc_recompile_count = false; 1.8 + ProfileData* pdata = NULL; 1.9 if (ProfileTraps && update_trap_state && trap_mdo.not_null()) { 1.10 assert(trap_mdo() == get_method_data(thread, trap_method, false), "sanity"); 1.11 uint this_trap_count = 0; 1.12 bool maybe_prior_trap = false; 1.13 bool maybe_prior_recompile = false; 1.14 - ProfileData* pdata 1.15 - = query_update_method_data(trap_mdo, trap_bci, reason, 1.16 + pdata = query_update_method_data(trap_mdo, trap_bci, reason, 1.17 //outputs: 1.18 this_trap_count, 1.19 maybe_prior_trap, 1.20 @@ -1380,18 +1381,7 @@ 1.21 // Detect repeated recompilation at the same BCI, and enforce a limit. 1.22 if (make_not_entrant && maybe_prior_recompile) { 1.23 // More than one recompile at this point. 1.24 - trap_mdo->inc_overflow_recompile_count(); 1.25 - if (maybe_prior_trap 1.26 - && ((uint)trap_mdo->overflow_recompile_count() 1.27 - > (uint)PerBytecodeRecompilationCutoff)) { 1.28 - // Give up on the method containing the bad BCI. 1.29 - if (trap_method() == nm->method()) { 1.30 - make_not_compilable = true; 1.31 - } else { 1.32 - trap_method->set_not_compilable(); 1.33 - // But give grace to the enclosing nm->method(). 1.34 - } 1.35 - } 1.36 + inc_recompile_count = maybe_prior_trap; 1.37 } 1.38 } else { 1.39 // For reasons which are not recorded per-bytecode, we simply 1.40 @@ -1418,7 +1408,17 @@ 1.41 reset_counters = true; 1.42 } 1.43 1.44 - if (make_not_entrant && pdata != NULL) { 1.45 + } 1.46 + 1.47 + // Take requested actions on the method: 1.48 + 1.49 + // Recompile 1.50 + if (make_not_entrant) { 1.51 + if (!nm->make_not_entrant()) { 1.52 + return; // the call did not change nmethod's state 1.53 + } 1.54 + 1.55 + if (pdata != NULL) { 1.56 // Record the recompilation event, if any. 1.57 int tstate0 = pdata->trap_state(); 1.58 int tstate1 = trap_state_set_recompiled(tstate0, true); 1.59 @@ -1427,7 +1427,19 @@ 1.60 } 1.61 } 1.62 1.63 - // Take requested actions on the method: 1.64 + if (inc_recompile_count) { 1.65 + trap_mdo->inc_overflow_recompile_count(); 1.66 + if ((uint)trap_mdo->overflow_recompile_count() > 1.67 + (uint)PerBytecodeRecompilationCutoff) { 1.68 + // Give up on the method containing the bad BCI. 1.69 + if (trap_method() == nm->method()) { 1.70 + make_not_compilable = true; 1.71 + } else { 1.72 + trap_method->set_not_compilable(); 1.73 + // But give grace to the enclosing nm->method(). 1.74 + } 1.75 + } 1.76 + } 1.77 1.78 // Reset invocation counters 1.79 if (reset_counters) { 1.80 @@ -1437,13 +1449,8 @@ 1.81 reset_invocation_counter(trap_scope); 1.82 } 1.83 1.84 - // Recompile 1.85 - if (make_not_entrant) { 1.86 - nm->make_not_entrant(); 1.87 - } 1.88 - 1.89 // Give up compiling 1.90 - if (make_not_compilable) { 1.91 + if (make_not_compilable && !nm->method()->is_not_compilable()) { 1.92 assert(make_not_entrant, "consistent"); 1.93 nm->method()->set_not_compilable(); 1.94 } 1.95 @@ -1516,9 +1523,11 @@ 1.96 if (tstate1 != tstate0) 1.97 pdata->set_trap_state(tstate1); 1.98 } else { 1.99 - if (LogCompilation && xtty != NULL) 1.100 + if (LogCompilation && xtty != NULL) { 1.101 + ttyLocker ttyl; 1.102 // Missing MDP? Leave a small complaint in the log. 1.103 xtty->elem("missing_mdp bci='%d'", trap_bci); 1.104 + } 1.105 } 1.106 } 1.107 1.108 @@ -1672,6 +1681,7 @@ 1.109 "class_check", 1.110 "array_check", 1.111 "intrinsic", 1.112 + "bimorphic", 1.113 "unloaded", 1.114 "uninitialized", 1.115 "unreached",