8035493: JVMTI PopFrame capability must instruct compilers not to prune locals

Sat, 22 Feb 2014 10:22:05 +0100

author
mgronlun
date
Sat, 22 Feb 2014 10:22:05 +0100
changeset 9942
eddd586d1a4c
parent 9941
45c8de52649c
child 9943
423fa1fba08e

8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
Reviewed-by: kvn, sla, coleenp, sspitsyn

src/share/vm/c1/c1_GraphBuilder.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_Instruction.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_ValueStack.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_ValueStack.hpp file | annotate | diff | comparison | revisions
src/share/vm/ci/ciEnv.cpp file | annotate | diff | comparison | revisions
src/share/vm/ci/ciEnv.hpp file | annotate | diff | comparison | revisions
src/share/vm/ci/ciMethod.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/c2compiler.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/graphKit.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp	Tue Jun 02 14:29:43 2020 +0800
     1.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Sat Feb 22 10:22:05 2014 +0100
     1.3 @@ -2376,7 +2376,7 @@
     1.4    if (!has_handler() && (!instruction->needs_exception_state() || instruction->exception_state() != NULL)) {
     1.5      assert(instruction->exception_state() == NULL
     1.6             || instruction->exception_state()->kind() == ValueStack::EmptyExceptionState
     1.7 -           || (instruction->exception_state()->kind() == ValueStack::ExceptionState && _compilation->env()->jvmti_can_access_local_variables()),
     1.8 +           || (instruction->exception_state()->kind() == ValueStack::ExceptionState && _compilation->env()->should_retain_local_variables()),
     1.9             "exception_state should be of exception kind");
    1.10      return new XHandlers();
    1.11    }
    1.12 @@ -2467,7 +2467,7 @@
    1.13        // This scope and all callees do not handle exceptions, so the local
    1.14        // variables of this scope are not needed. However, the scope itself is
    1.15        // required for a correct exception stack trace -> clear out the locals.
    1.16 -      if (_compilation->env()->jvmti_can_access_local_variables()) {
    1.17 +      if (_compilation->env()->should_retain_local_variables()) {
    1.18          cur_state = cur_state->copy(ValueStack::ExceptionState, cur_state->bci());
    1.19        } else {
    1.20          cur_state = cur_state->copy(ValueStack::EmptyExceptionState, cur_state->bci());
    1.21 @@ -3353,7 +3353,7 @@
    1.22  ValueStack* GraphBuilder::copy_state_for_exception_with_bci(int bci) {
    1.23    ValueStack* s = copy_state_exhandling_with_bci(bci);
    1.24    if (s == NULL) {
    1.25 -    if (_compilation->env()->jvmti_can_access_local_variables()) {
    1.26 +    if (_compilation->env()->should_retain_local_variables()) {
    1.27        s = state()->copy(ValueStack::ExceptionState, bci);
    1.28      } else {
    1.29        s = state()->copy(ValueStack::EmptyExceptionState, bci);
     2.1 --- a/src/share/vm/c1/c1_Instruction.cpp	Tue Jun 02 14:29:43 2020 +0800
     2.2 +++ b/src/share/vm/c1/c1_Instruction.cpp	Sat Feb 22 10:22:05 2014 +0100
     2.3 @@ -76,7 +76,7 @@
     2.4  
     2.5  void Instruction::update_exception_state(ValueStack* state) {
     2.6    if (state != NULL && (state->kind() == ValueStack::EmptyExceptionState || state->kind() == ValueStack::ExceptionState)) {
     2.7 -    assert(state->kind() == ValueStack::EmptyExceptionState || Compilation::current()->env()->jvmti_can_access_local_variables(), "unexpected state kind");
     2.8 +    assert(state->kind() == ValueStack::EmptyExceptionState || Compilation::current()->env()->should_retain_local_variables(), "unexpected state kind");
     2.9      _exception_state = state;
    2.10    } else {
    2.11      _exception_state = NULL;
     3.1 --- a/src/share/vm/c1/c1_ValueStack.cpp	Tue Jun 02 14:29:43 2020 +0800
     3.2 +++ b/src/share/vm/c1/c1_ValueStack.cpp	Sat Feb 22 10:22:05 2014 +0100
     3.3 @@ -52,7 +52,7 @@
     3.4    , _stack()
     3.5    , _locks(copy_from->locks_size())
     3.6  {
     3.7 -  assert(kind != EmptyExceptionState || !Compilation::current()->env()->jvmti_can_access_local_variables(), "need locals");
     3.8 +  assert(kind != EmptyExceptionState || !Compilation::current()->env()->should_retain_local_variables(), "need locals");
     3.9    if (kind != EmptyExceptionState) {
    3.10      // only allocate space if we need to copy the locals-array
    3.11      _locals = Values(copy_from->locals_size());
     4.1 --- a/src/share/vm/c1/c1_ValueStack.hpp	Tue Jun 02 14:29:43 2020 +0800
     4.2 +++ b/src/share/vm/c1/c1_ValueStack.hpp	Sat Feb 22 10:22:05 2014 +0100
     4.3 @@ -75,7 +75,7 @@
     4.4  
     4.5    void set_caller_state(ValueStack* s)           {
     4.6      assert(kind() == EmptyExceptionState ||
     4.7 -           (Compilation::current()->env()->jvmti_can_access_local_variables() && kind() == ExceptionState),
     4.8 +           (Compilation::current()->env()->should_retain_local_variables() && kind() == ExceptionState),
     4.9             "only EmptyExceptionStates can be modified");
    4.10      _caller_state = s;
    4.11    }
     5.1 --- a/src/share/vm/ci/ciEnv.cpp	Tue Jun 02 14:29:43 2020 +0800
     5.2 +++ b/src/share/vm/ci/ciEnv.cpp	Sat Feb 22 10:22:05 2014 +0100
     5.3 @@ -139,6 +139,11 @@
     5.4    _ClassCastException_instance = NULL;
     5.5    _the_null_string = NULL;
     5.6    _the_min_jint_string = NULL;
     5.7 +
     5.8 +  _jvmti_can_hotswap_or_post_breakpoint = false;
     5.9 +  _jvmti_can_access_local_variables = false;
    5.10 +  _jvmti_can_post_on_exceptions = false;
    5.11 +  _jvmti_can_pop_frame = false;
    5.12  }
    5.13  
    5.14  ciEnv::ciEnv(Arena* arena) : _ciEnv_arena(mtCompiler) {
    5.15 @@ -189,6 +194,11 @@
    5.16    _ClassCastException_instance = NULL;
    5.17    _the_null_string = NULL;
    5.18    _the_min_jint_string = NULL;
    5.19 +
    5.20 +  _jvmti_can_hotswap_or_post_breakpoint = false;
    5.21 +  _jvmti_can_access_local_variables = false;
    5.22 +  _jvmti_can_post_on_exceptions = false;
    5.23 +  _jvmti_can_pop_frame = false;
    5.24  }
    5.25  
    5.26  ciEnv::~ciEnv() {
    5.27 @@ -208,6 +218,31 @@
    5.28    _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint();
    5.29    _jvmti_can_access_local_variables     = JvmtiExport::can_access_local_variables();
    5.30    _jvmti_can_post_on_exceptions         = JvmtiExport::can_post_on_exceptions();
    5.31 +  _jvmti_can_pop_frame                  = JvmtiExport::can_pop_frame();
    5.32 +}
    5.33 +
    5.34 +bool ciEnv::should_retain_local_variables() const {
    5.35 +  return _jvmti_can_access_local_variables || _jvmti_can_pop_frame;
    5.36 +}
    5.37 +
    5.38 +bool ciEnv::jvmti_state_changed() const {
    5.39 +  if (!_jvmti_can_access_local_variables &&
    5.40 +      JvmtiExport::can_access_local_variables()) {
    5.41 +    return true;
    5.42 +  }
    5.43 +  if (!_jvmti_can_hotswap_or_post_breakpoint &&
    5.44 +      JvmtiExport::can_hotswap_or_post_breakpoint()) {
    5.45 +    return true;
    5.46 +  }
    5.47 +  if (!_jvmti_can_post_on_exceptions &&
    5.48 +      JvmtiExport::can_post_on_exceptions()) {
    5.49 +    return true;
    5.50 +  }
    5.51 +  if (!_jvmti_can_pop_frame &&
    5.52 +      JvmtiExport::can_pop_frame()) {
    5.53 +    return true;
    5.54 +  }
    5.55 +  return false;
    5.56  }
    5.57  
    5.58  // ------------------------------------------------------------------
    5.59 @@ -953,13 +988,7 @@
    5.60      No_Safepoint_Verifier nsv;
    5.61  
    5.62      // Change in Jvmti state may invalidate compilation.
    5.63 -    if (!failing() &&
    5.64 -        ( (!jvmti_can_hotswap_or_post_breakpoint() &&
    5.65 -           JvmtiExport::can_hotswap_or_post_breakpoint()) ||
    5.66 -          (!jvmti_can_access_local_variables() &&
    5.67 -           JvmtiExport::can_access_local_variables()) ||
    5.68 -          (!jvmti_can_post_on_exceptions() &&
    5.69 -           JvmtiExport::can_post_on_exceptions()) )) {
    5.70 +    if (!failing() && jvmti_state_changed()) {
    5.71        record_failure("Jvmti state change invalidated dependencies");
    5.72      }
    5.73  
     6.1 --- a/src/share/vm/ci/ciEnv.hpp	Tue Jun 02 14:29:43 2020 +0800
     6.2 +++ b/src/share/vm/ci/ciEnv.hpp	Sat Feb 22 10:22:05 2014 +0100
     6.3 @@ -69,6 +69,7 @@
     6.4    bool  _jvmti_can_hotswap_or_post_breakpoint;
     6.5    bool  _jvmti_can_access_local_variables;
     6.6    bool  _jvmti_can_post_on_exceptions;
     6.7 +  bool  _jvmti_can_pop_frame;
     6.8  
     6.9    // Cache DTrace flags
    6.10    bool  _dtrace_extended_probes;
    6.11 @@ -336,8 +337,9 @@
    6.12  
    6.13    // Cache Jvmti state
    6.14    void  cache_jvmti_state();
    6.15 +  bool  jvmti_state_changed() const;
    6.16 +  bool  should_retain_local_variables() const;
    6.17    bool  jvmti_can_hotswap_or_post_breakpoint() const { return _jvmti_can_hotswap_or_post_breakpoint; }
    6.18 -  bool  jvmti_can_access_local_variables()     const { return _jvmti_can_access_local_variables; }
    6.19    bool  jvmti_can_post_on_exceptions()         const { return _jvmti_can_post_on_exceptions; }
    6.20  
    6.21    // Cache DTrace flags
     7.1 --- a/src/share/vm/ci/ciMethod.cpp	Tue Jun 02 14:29:43 2020 +0800
     7.2 +++ b/src/share/vm/ci/ciMethod.cpp	Sat Feb 22 10:22:05 2014 +0100
     7.3 @@ -415,7 +415,7 @@
     7.4  // information.
     7.5  MethodLivenessResult ciMethod::liveness_at_bci(int bci) {
     7.6    MethodLivenessResult result = raw_liveness_at_bci(bci);
     7.7 -  if (CURRENT_ENV->jvmti_can_access_local_variables() || DeoptimizeALot || CompileTheWorld) {
     7.8 +  if (CURRENT_ENV->should_retain_local_variables() || DeoptimizeALot || CompileTheWorld) {
     7.9      // Keep all locals live for the user's edification and amusement.
    7.10      result.at_put_range(0, result.size(), true);
    7.11    }
     8.1 --- a/src/share/vm/opto/c2compiler.cpp	Tue Jun 02 14:29:43 2020 +0800
     8.2 +++ b/src/share/vm/opto/c2compiler.cpp	Sat Feb 22 10:22:05 2014 +0100
     8.3 @@ -109,7 +109,7 @@
     8.4    assert(is_initialized(), "Compiler thread must be initialized");
     8.5  
     8.6    bool subsume_loads = SubsumeLoads;
     8.7 -  bool do_escape_analysis = DoEscapeAnalysis && !env->jvmti_can_access_local_variables();
     8.8 +  bool do_escape_analysis = DoEscapeAnalysis && !env->should_retain_local_variables();
     8.9    bool eliminate_boxing = EliminateAutoBox;
    8.10    while (!env->failing()) {
    8.11      // Attempt to compile while subsuming loads into machine instructions.
     9.1 --- a/src/share/vm/opto/graphKit.cpp	Tue Jun 02 14:29:43 2020 +0800
     9.2 +++ b/src/share/vm/opto/graphKit.cpp	Sat Feb 22 10:22:05 2014 +0100
     9.3 @@ -864,7 +864,7 @@
     9.4      }
     9.5    }
     9.6  
     9.7 -  if (env()->jvmti_can_access_local_variables()) {
     9.8 +  if (env()->should_retain_local_variables()) {
     9.9      // At any safepoint, this method can get breakpointed, which would
    9.10      // then require an immediate deoptimization.
    9.11      can_prune_locals = false;  // do not prune locals

mercurial