Merge

Tue, 22 Feb 2011 18:13:03 -0800

author
iveresov
date
Tue, 22 Feb 2011 18:13:03 -0800
changeset 2596
d5a078cf7f39
parent 2595
d89a22843c62
parent 2570
5841dc1964f0
child 2597
ba5d119730dd

Merge

     1.1 --- a/src/share/vm/ci/ciEnv.cpp	Tue Feb 22 15:25:02 2011 -0800
     1.2 +++ b/src/share/vm/ci/ciEnv.cpp	Tue Feb 22 18:13:03 2011 -0800
     1.3 @@ -413,6 +413,7 @@
     1.4    }
     1.5    KlassHandle found_klass;
     1.6    {
     1.7 +    ttyUnlocker ttyul;  // release tty lock to avoid ordering problems
     1.8      MutexLocker ml(Compile_lock);
     1.9      klassOop kls;
    1.10      if (!require_local) {
     2.1 --- a/src/share/vm/utilities/ostream.cpp	Tue Feb 22 15:25:02 2011 -0800
     2.2 +++ b/src/share/vm/utilities/ostream.cpp	Tue Feb 22 18:13:03 2011 -0800
     2.3 @@ -699,6 +699,17 @@
     2.4    defaultStream::instance->release(holder);
     2.5  }
     2.6  
     2.7 +bool ttyLocker::release_tty_if_locked() {
     2.8 +  intx thread_id = os::current_thread_id();
     2.9 +  if (defaultStream::instance->writer() == thread_id) {
    2.10 +    // release the lock and return true so callers know if was
    2.11 +    // previously held.
    2.12 +    release_tty(thread_id);
    2.13 +    return true;
    2.14 +  }
    2.15 +  return false;
    2.16 +}
    2.17 +
    2.18  void ttyLocker::break_tty_lock_for_safepoint(intx holder) {
    2.19    if (defaultStream::instance != NULL &&
    2.20        defaultStream::instance->writer() == holder) {
     3.1 --- a/src/share/vm/utilities/ostream.hpp	Tue Feb 22 15:25:02 2011 -0800
     3.2 +++ b/src/share/vm/utilities/ostream.hpp	Tue Feb 22 18:13:03 2011 -0800
     3.3 @@ -123,18 +123,36 @@
     3.4  
     3.5  // advisory locking for the shared tty stream:
     3.6  class ttyLocker: StackObj {
     3.7 +  friend class ttyUnlocker;
     3.8   private:
     3.9    intx _holder;
    3.10  
    3.11   public:
    3.12    static intx  hold_tty();                // returns a "holder" token
    3.13    static void  release_tty(intx holder);  // must witness same token
    3.14 +  static bool  release_tty_if_locked();   // returns true if lock was released
    3.15    static void  break_tty_lock_for_safepoint(intx holder);
    3.16  
    3.17    ttyLocker()  { _holder = hold_tty(); }
    3.18    ~ttyLocker() { release_tty(_holder); }
    3.19  };
    3.20  
    3.21 +// Release the tty lock if it's held and reacquire it if it was
    3.22 +// locked.  Used to avoid lock ordering problems.
    3.23 +class ttyUnlocker: StackObj {
    3.24 + private:
    3.25 +  bool _was_locked;
    3.26 + public:
    3.27 +  ttyUnlocker()  {
    3.28 +    _was_locked = ttyLocker::release_tty_if_locked();
    3.29 +  }
    3.30 +  ~ttyUnlocker() {
    3.31 +    if (_was_locked) {
    3.32 +      ttyLocker::hold_tty();
    3.33 +    }
    3.34 +  }
    3.35 +};
    3.36 +
    3.37  // for writing to strings; buffer will expand automatically
    3.38  class stringStream : public outputStream {
    3.39   protected:

mercurial