8005817: Shark: implement deoptimization support

Fri, 11 Jan 2013 16:47:23 -0800

author
twisti
date
Fri, 11 Jan 2013 16:47:23 -0800
changeset 4442
c566b81b3323
parent 4441
f9bda35f4226
child 4443
c095a7f289aa

8005817: Shark: implement deoptimization support
Reviewed-by: twisti
Contributed-by: Roman Kennke <rkennke@redhat.com>

src/cpu/zero/vm/frame_zero.cpp file | annotate | diff | comparison | revisions
src/cpu/zero/vm/frame_zero.inline.hpp file | annotate | diff | comparison | revisions
src/cpu/zero/vm/sharkFrame_zero.hpp file | annotate | diff | comparison | revisions
src/share/vm/shark/sharkInvariants.hpp file | annotate | diff | comparison | revisions
src/share/vm/shark/sharkTopLevelBlock.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/cpu/zero/vm/frame_zero.cpp	Fri Jan 11 16:47:23 2013 -0800
     1.2 +++ b/src/cpu/zero/vm/frame_zero.cpp	Fri Jan 11 16:47:23 2013 -0800
     1.3 @@ -98,10 +98,20 @@
     1.4  #endif // CC_INTERP
     1.5  
     1.6  void frame::patch_pc(Thread* thread, address pc) {
     1.7 -  // We borrow this call to set the thread pointer in the interpreter
     1.8 -  // state; the hook to set up deoptimized frames isn't supplied it.
     1.9 -  assert(pc == NULL, "should be");
    1.10 -  get_interpreterState()->set_thread((JavaThread *) thread);
    1.11 +
    1.12 +  if (pc != NULL) {
    1.13 +    _cb = CodeCache::find_blob(pc);
    1.14 +    SharkFrame* sharkframe = zeroframe()->as_shark_frame();
    1.15 +    sharkframe->set_pc(pc);
    1.16 +    _pc = pc;
    1.17 +    _deopt_state = is_deoptimized;
    1.18 +
    1.19 +  } else {
    1.20 +    // We borrow this call to set the thread pointer in the interpreter
    1.21 +    // state; the hook to set up deoptimized frames isn't supplied it.
    1.22 +    assert(pc == NULL, "should be");
    1.23 +    get_interpreterState()->set_thread((JavaThread *) thread);
    1.24 +  }
    1.25  }
    1.26  
    1.27  bool frame::safe_for_sender(JavaThread *thread) {
     2.1 --- a/src/cpu/zero/vm/frame_zero.inline.hpp	Fri Jan 11 16:47:23 2013 -0800
     2.2 +++ b/src/cpu/zero/vm/frame_zero.inline.hpp	Fri Jan 11 16:47:23 2013 -0800
     2.3 @@ -45,27 +45,36 @@
     2.4    case ZeroFrame::ENTRY_FRAME:
     2.5      _pc = StubRoutines::call_stub_return_pc();
     2.6      _cb = NULL;
     2.7 +    _deopt_state = not_deoptimized;
     2.8      break;
     2.9  
    2.10    case ZeroFrame::INTERPRETER_FRAME:
    2.11      _pc = NULL;
    2.12      _cb = NULL;
    2.13 +    _deopt_state = not_deoptimized;
    2.14      break;
    2.15  
    2.16 -  case ZeroFrame::SHARK_FRAME:
    2.17 +  case ZeroFrame::SHARK_FRAME: {
    2.18      _pc = zero_sharkframe()->pc();
    2.19      _cb = CodeCache::find_blob_unsafe(pc());
    2.20 +    address original_pc = nmethod::get_deopt_original_pc(this);
    2.21 +    if (original_pc != NULL) {
    2.22 +      _pc = original_pc;
    2.23 +      _deopt_state = is_deoptimized;
    2.24 +    } else {
    2.25 +      _deopt_state = not_deoptimized;
    2.26 +    }
    2.27      break;
    2.28 -
    2.29 +  }
    2.30    case ZeroFrame::FAKE_STUB_FRAME:
    2.31      _pc = NULL;
    2.32      _cb = NULL;
    2.33 +    _deopt_state = not_deoptimized;
    2.34      break;
    2.35  
    2.36    default:
    2.37      ShouldNotReachHere();
    2.38    }
    2.39 -  _deopt_state = not_deoptimized;
    2.40  }
    2.41  
    2.42  // Accessors
     3.1 --- a/src/cpu/zero/vm/sharkFrame_zero.hpp	Fri Jan 11 16:47:23 2013 -0800
     3.2 +++ b/src/cpu/zero/vm/sharkFrame_zero.hpp	Fri Jan 11 16:47:23 2013 -0800
     3.3 @@ -68,6 +68,10 @@
     3.4      return (address) value_of_word(pc_off);
     3.5    }
     3.6  
     3.7 +  void set_pc(address pc) const {
     3.8 +    *((address*) addr_of_word(pc_off)) = pc;
     3.9 +  }
    3.10 +
    3.11    intptr_t* unextended_sp() const {
    3.12      return (intptr_t *) value_of_word(unextended_sp_off);
    3.13    }
     4.1 --- a/src/share/vm/shark/sharkInvariants.hpp	Fri Jan 11 16:47:23 2013 -0800
     4.2 +++ b/src/share/vm/shark/sharkInvariants.hpp	Fri Jan 11 16:47:23 2013 -0800
     4.3 @@ -99,12 +99,14 @@
     4.4    DebugInformationRecorder* debug_info() const {
     4.5      return env()->debug_info();
     4.6    }
     4.7 +  SharkCodeBuffer* code_buffer() const {
     4.8 +    return builder()->code_buffer();
     4.9 +  }
    4.10 +
    4.11 + public:
    4.12    Dependencies* dependencies() const {
    4.13      return env()->dependencies();
    4.14    }
    4.15 -  SharkCodeBuffer* code_buffer() const {
    4.16 -    return builder()->code_buffer();
    4.17 -  }
    4.18  
    4.19    // Commonly used classes
    4.20   protected:
     5.1 --- a/src/share/vm/shark/sharkTopLevelBlock.cpp	Fri Jan 11 16:47:23 2013 -0800
     5.2 +++ b/src/share/vm/shark/sharkTopLevelBlock.cpp	Fri Jan 11 16:47:23 2013 -0800
     5.3 @@ -1030,7 +1030,6 @@
     5.4        dest_method->holder() == java_lang_Object_klass())
     5.5      return dest_method;
     5.6  
     5.7 -#ifdef SHARK_CAN_DEOPTIMIZE_ANYWHERE
     5.8    // This code can replace a virtual call with a direct call if this
     5.9    // class is the only one in the entire set of loaded classes that
    5.10    // implements this method.  This makes the compiled code dependent
    5.11 @@ -1064,6 +1063,8 @@
    5.12    if (monomorphic_target != NULL) {
    5.13      assert(!monomorphic_target->is_abstract(), "shouldn't be");
    5.14  
    5.15 +    function()->dependencies()->assert_unique_concrete_method(actual_receiver, monomorphic_target);
    5.16 +
    5.17      // Opto has a bunch of type checking here that I don't
    5.18      // understand.  It's to inhibit casting in one direction,
    5.19      // possibly because objects in Opto can have inexact
    5.20 @@ -1097,7 +1098,6 @@
    5.21    // with non-monomorphic targets if the receiver has an exact
    5.22    // type.  We don't mark types this way, so we can't do this.
    5.23  
    5.24 -#endif // SHARK_CAN_DEOPTIMIZE_ANYWHERE
    5.25  
    5.26    return NULL;
    5.27  }
    5.28 @@ -1298,8 +1298,9 @@
    5.29  
    5.30    // Try to inline the call
    5.31    if (!call_is_virtual) {
    5.32 -    if (SharkInliner::attempt_inline(call_method, current_state()))
    5.33 +    if (SharkInliner::attempt_inline(call_method, current_state())) {
    5.34        return;
    5.35 +    }
    5.36    }
    5.37  
    5.38    // Find the method we are calling

mercurial