src/hotspot/share/prims/jvmtiRawMonitor.hpp
author vromero
Mon, 08 Oct 2018 06:52:41 -0700
changeset 52038 957de5be48bc
parent 47216 71c04702a3d5
child 53244 9807daeb47c4
permissions -rw-r--r--
8209407: VerifyError is thrown for inner class with lambda Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6975
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
     1
/*
15432
9d976ca484d8 8000692: Remove old KERNEL code
zgu
parents: 7397
diff changeset
     2
 * Copyright (c) 1999, 2013, 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
#include "runtime/objectMonitor.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    29
#include "utilities/growableArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    30
6975
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    31
//
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    32
// class JvmtiRawMonitor
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    33
//
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    34
// Used by JVMTI methods: All RawMonitor methods (CreateRawMonitor, EnterRawMonitor, etc.)
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    35
//
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    36
// Wrapper for ObjectMonitor class that saves the Monitor's name
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    37
//
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    38
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    39
class JvmtiRawMonitor : public ObjectMonitor  {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    40
private:
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    41
  int           _magic;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    42
  char *        _name;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    43
  // JVMTI_RM_MAGIC is set in contructor and unset in destructor.
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    44
  enum { JVMTI_RM_MAGIC = (int)(('T' << 24) | ('I' << 16) | ('R' << 8) | 'M') };
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    45
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    46
  int       SimpleEnter (Thread * Self) ;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    47
  int       SimpleExit  (Thread * Self) ;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    48
  int       SimpleWait  (Thread * Self, jlong millis) ;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    49
  int       SimpleNotify (Thread * Self, bool All) ;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    50
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    51
public:
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    52
  JvmtiRawMonitor(const char *name);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    53
  ~JvmtiRawMonitor();
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    54
  int       raw_enter(TRAPS);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    55
  int       raw_exit(TRAPS);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    56
  int       raw_wait(jlong millis, bool interruptable, TRAPS);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    57
  int       raw_notify(TRAPS);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    58
  int       raw_notifyAll(TRAPS);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    59
  int            magic()   { return _magic;  }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    60
  const char *get_name()   { return _name; }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    61
  bool        is_valid();
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    62
};
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    63
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    64
// Onload pending raw monitors
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    65
// Class is used to cache onload or onstart monitor enter
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    66
// which will transition into real monitor when
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    67
// VM is fully initialized.
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    68
class JvmtiPendingMonitors : public AllStatic {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    69
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    70
private:
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    71
  static GrowableArray<JvmtiRawMonitor*> *_monitors; // Cache raw monitor enter
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    72
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    73
  inline static GrowableArray<JvmtiRawMonitor*>* monitors() { return _monitors; }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    74
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    75
  static void dispose() {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    76
    delete monitors();
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    77
  }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    78
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    79
public:
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    80
  static void enter(JvmtiRawMonitor *monitor) {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    81
    monitors()->append(monitor);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    82
  }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    83
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    84
  static int count() {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    85
    return monitors()->length();
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    86
  }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    87
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    88
  static void destroy(JvmtiRawMonitor *monitor) {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    89
    while (monitors()->contains(monitor)) {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    90
      monitors()->remove(monitor);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    91
    }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    92
  }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    93
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    94
  // Return false if monitor is not found in the list.
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    95
  static bool exit(JvmtiRawMonitor *monitor) {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    96
    if (monitors()->contains(monitor)) {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    97
      monitors()->remove(monitor);
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    98
      return true;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
    99
    } else {
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   100
      return false;
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   101
    }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   102
  }
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   103
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   104
  static void transition_raw_monitors();
dc9b63952682 6988353: refactor contended sync subsystem
acorn
parents:
diff changeset
   105
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
   106
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
   107
#endif // SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP