src/share/vm/runtime/objectMonitor.hpp

Print this page


   1 /*
   2  * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 






  25 
  26 // ObjectWaiter serves as a "proxy" or surrogate thread.
  27 // TODO-FIXME: Eliminate ObjectWaiter and use the thread-specific
  28 // ParkEvent instead.  Beware, however, that the JVMTI code
  29 // knows about ObjectWaiters, so we'll have to reconcile that code.
  30 // See next_waiter(), first_waiter(), etc.
  31 
  32 class ObjectWaiter : public StackObj {
  33  public:
  34   enum TStates { TS_UNDEF, TS_READY, TS_RUN, TS_WAIT, TS_ENTER, TS_CXQ } ;
  35   enum Sorted  { PREPEND, APPEND, SORTED } ;
  36   ObjectWaiter * volatile _next;
  37   ObjectWaiter * volatile _prev;
  38   Thread*       _thread;
  39   ParkEvent *   _event;
  40   volatile int  _notified ;
  41   volatile TStates TState ;
  42   Sorted        _Sorted ;           // List placement disposition
  43   bool          _active ;           // Contention monitoring is enabled
  44  public:


 289   static PerfCounter * _sync_PrivateB ;
 290   static PerfCounter * _sync_MonInCirculation ;
 291   static PerfCounter * _sync_MonScavenged ;
 292   static PerfCounter * _sync_Inflations ;
 293   static PerfCounter * _sync_Deflations ;
 294   static PerfLongVariable * _sync_MonExtant ;
 295 
 296  public:
 297   static int Knob_Verbose;
 298   static int Knob_SpinLimit;
 299 };
 300 
 301 #undef TEVENT
 302 #define TEVENT(nom) {if (SyncVerbose) FEVENT(nom); }
 303 
 304 #define FEVENT(nom) { static volatile int ctr = 0 ; int v = ++ctr ; if ((v & (v-1)) == 0) { ::printf (#nom " : %d \n", v); ::fflush(stdout); }}
 305 
 306 #undef  TEVENT
 307 #define TEVENT(nom) {;}
 308 


   1 /*
   2  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_OBJECTMONITOR_HPP
  26 #define SHARE_VM_RUNTIME_OBJECTMONITOR_HPP
  27 
  28 #include "runtime/os.hpp"
  29 #include "runtime/perfData.hpp"
  30 
  31 
  32 // ObjectWaiter serves as a "proxy" or surrogate thread.
  33 // TODO-FIXME: Eliminate ObjectWaiter and use the thread-specific
  34 // ParkEvent instead.  Beware, however, that the JVMTI code
  35 // knows about ObjectWaiters, so we'll have to reconcile that code.
  36 // See next_waiter(), first_waiter(), etc.
  37 
  38 class ObjectWaiter : public StackObj {
  39  public:
  40   enum TStates { TS_UNDEF, TS_READY, TS_RUN, TS_WAIT, TS_ENTER, TS_CXQ } ;
  41   enum Sorted  { PREPEND, APPEND, SORTED } ;
  42   ObjectWaiter * volatile _next;
  43   ObjectWaiter * volatile _prev;
  44   Thread*       _thread;
  45   ParkEvent *   _event;
  46   volatile int  _notified ;
  47   volatile TStates TState ;
  48   Sorted        _Sorted ;           // List placement disposition
  49   bool          _active ;           // Contention monitoring is enabled
  50  public:


 295   static PerfCounter * _sync_PrivateB ;
 296   static PerfCounter * _sync_MonInCirculation ;
 297   static PerfCounter * _sync_MonScavenged ;
 298   static PerfCounter * _sync_Inflations ;
 299   static PerfCounter * _sync_Deflations ;
 300   static PerfLongVariable * _sync_MonExtant ;
 301 
 302  public:
 303   static int Knob_Verbose;
 304   static int Knob_SpinLimit;
 305 };
 306 
 307 #undef TEVENT
 308 #define TEVENT(nom) {if (SyncVerbose) FEVENT(nom); }
 309 
 310 #define FEVENT(nom) { static volatile int ctr = 0 ; int v = ++ctr ; if ((v & (v-1)) == 0) { ::printf (#nom " : %d \n", v); ::fflush(stdout); }}
 311 
 312 #undef  TEVENT
 313 #define TEVENT(nom) {;}
 314 
 315 
 316 #endif // SHARE_VM_RUNTIME_OBJECTMONITOR_HPP