src/share/vm/prims/jvmtiRawMonitor.hpp

Wed, 23 Jan 2013 13:02:39 -0500

author
jprovino
date
Wed, 23 Jan 2013 13:02:39 -0500
changeset 4542
db9981fd3124
parent 2314
f95d63e2154a
child 4492
8b46b0196eb0
permissions
-rw-r--r--

8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
Summary: Rename INCLUDE_ALTERNATE_GCS to INCLUDE_ALL_GCS and replace SERIALGC with INCLUDE_ALL_GCS.
Reviewed-by: coleenp, stefank

     1 /*
     2  * Copyright (c) 1999, 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  */
    25 #ifndef SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP
    26 #define SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP
    28 #ifndef JVMTI_KERNEL
    29 #include "runtime/objectMonitor.hpp"
    30 #include "utilities/growableArray.hpp"
    31 #endif
    33 //
    34 // class JvmtiRawMonitor
    35 //
    36 // Used by JVMTI methods: All RawMonitor methods (CreateRawMonitor, EnterRawMonitor, etc.)
    37 //
    38 // Wrapper for ObjectMonitor class that saves the Monitor's name
    39 //
    41 class JvmtiRawMonitor : public ObjectMonitor  {
    42 private:
    43   int           _magic;
    44   char *        _name;
    45   // JVMTI_RM_MAGIC is set in contructor and unset in destructor.
    46   enum { JVMTI_RM_MAGIC = (int)(('T' << 24) | ('I' << 16) | ('R' << 8) | 'M') };
    48   int       SimpleEnter (Thread * Self) ;
    49   int       SimpleExit  (Thread * Self) ;
    50   int       SimpleWait  (Thread * Self, jlong millis) ;
    51   int       SimpleNotify (Thread * Self, bool All) ;
    53 public:
    54   JvmtiRawMonitor(const char *name);
    55   ~JvmtiRawMonitor();
    56   int       raw_enter(TRAPS);
    57   int       raw_exit(TRAPS);
    58   int       raw_wait(jlong millis, bool interruptable, TRAPS);
    59   int       raw_notify(TRAPS);
    60   int       raw_notifyAll(TRAPS);
    61   int            magic()   { return _magic;  }
    62   const char *get_name()   { return _name; }
    63   bool        is_valid();
    64 };
    66 // Onload pending raw monitors
    67 // Class is used to cache onload or onstart monitor enter
    68 // which will transition into real monitor when
    69 // VM is fully initialized.
    70 class JvmtiPendingMonitors : public AllStatic {
    72 private:
    73   static GrowableArray<JvmtiRawMonitor*> *_monitors; // Cache raw monitor enter
    75   inline static GrowableArray<JvmtiRawMonitor*>* monitors() { return _monitors; }
    77   static void dispose() {
    78     delete monitors();
    79   }
    81 public:
    82   static void enter(JvmtiRawMonitor *monitor) {
    83     monitors()->append(monitor);
    84   }
    86   static int count() {
    87     return monitors()->length();
    88   }
    90   static void destroy(JvmtiRawMonitor *monitor) {
    91     while (monitors()->contains(monitor)) {
    92       monitors()->remove(monitor);
    93     }
    94   }
    96   // Return false if monitor is not found in the list.
    97   static bool exit(JvmtiRawMonitor *monitor) {
    98     if (monitors()->contains(monitor)) {
    99       monitors()->remove(monitor);
   100       return true;
   101     } else {
   102       return false;
   103     }
   104   }
   106   static void transition_raw_monitors();
   107 };
   109 #endif // SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP

mercurial