hotspot/src/share/vm/prims/jvmtiRawMonitor.hpp
author stefank
Mon, 01 Oct 2012 13:29:11 +0200
changeset 13922 ab7d352debe6
parent 7397 5b173b4ca846
child 15432 9d976ca484d8
permissions -rw-r--r--
8000227: [obj|type]ArrayKlass::oop_print_on prints one line to tty instead of the provided output stream Reviewed-by: brutisso, sla, jmasa, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6975
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
6975
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
     4
 *
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
     8
 *
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    13
 * accompanied this code).
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    14
 *
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    18
 *
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    21
 * questions.
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    22
 *
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    23
 */
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    25
#ifndef SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    26
#define SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    28
#ifndef JVMTI_KERNEL
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    29
#include "runtime/objectMonitor.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    30
#include "utilities/growableArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    31
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    32
6975
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    33
//
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    34
// class JvmtiRawMonitor
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    35
//
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    36
// Used by JVMTI methods: All RawMonitor methods (CreateRawMonitor, EnterRawMonitor, etc.)
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    37
//
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    38
// Wrapper for ObjectMonitor class that saves the Monitor's name
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    39
//
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    40
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    41
class JvmtiRawMonitor : public ObjectMonitor  {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    42
private:
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    43
  int           _magic;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    44
  char *        _name;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    45
  // JVMTI_RM_MAGIC is set in contructor and unset in destructor.
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    46
  enum { JVMTI_RM_MAGIC = (int)(('T' << 24) | ('I' << 16) | ('R' << 8) | 'M') };
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    47
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    48
  int       SimpleEnter (Thread * Self) ;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    49
  int       SimpleExit  (Thread * Self) ;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    50
  int       SimpleWait  (Thread * Self, jlong millis) ;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    51
  int       SimpleNotify (Thread * Self, bool All) ;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    52
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    53
public:
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    54
  JvmtiRawMonitor(const char *name);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    55
  ~JvmtiRawMonitor();
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    56
  int       raw_enter(TRAPS);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    57
  int       raw_exit(TRAPS);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    58
  int       raw_wait(jlong millis, bool interruptable, TRAPS);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    59
  int       raw_notify(TRAPS);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    60
  int       raw_notifyAll(TRAPS);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    61
  int            magic()   { return _magic;  }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    62
  const char *get_name()   { return _name; }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    63
  bool        is_valid();
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    64
};
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    65
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    66
// Onload pending raw monitors
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    67
// Class is used to cache onload or onstart monitor enter
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    68
// which will transition into real monitor when
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    69
// VM is fully initialized.
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    70
class JvmtiPendingMonitors : public AllStatic {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    71
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    72
private:
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    73
  static GrowableArray<JvmtiRawMonitor*> *_monitors; // Cache raw monitor enter
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    74
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    75
  inline static GrowableArray<JvmtiRawMonitor*>* monitors() { return _monitors; }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    76
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    77
  static void dispose() {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    78
    delete monitors();
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    79
  }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    80
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    81
public:
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    82
  static void enter(JvmtiRawMonitor *monitor) {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    83
    monitors()->append(monitor);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    84
  }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    85
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    86
  static int count() {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    87
    return monitors()->length();
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    88
  }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    89
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    90
  static void destroy(JvmtiRawMonitor *monitor) {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    91
    while (monitors()->contains(monitor)) {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    92
      monitors()->remove(monitor);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    93
    }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    94
  }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    95
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    96
  // Return false if monitor is not found in the list.
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    97
  static bool exit(JvmtiRawMonitor *monitor) {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    98
    if (monitors()->contains(monitor)) {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    99
      monitors()->remove(monitor);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   100
      return true;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   101
    } else {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   102
      return false;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   103
    }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   104
  }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   105
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   106
  static void transition_raw_monitors();
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   107
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
   108
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
   109
#endif // SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP