Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/prims/jvmtiRawMonitor.hpp
32285 views
/*1* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP25#define SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP2627#include "runtime/objectMonitor.hpp"28#include "utilities/growableArray.hpp"2930//31// class JvmtiRawMonitor32//33// Used by JVMTI methods: All RawMonitor methods (CreateRawMonitor, EnterRawMonitor, etc.)34//35// Wrapper for ObjectMonitor class that saves the Monitor's name36//3738class JvmtiRawMonitor : public ObjectMonitor {39private:40int _magic;41char * _name;42// JVMTI_RM_MAGIC is set in contructor and unset in destructor.43enum { JVMTI_RM_MAGIC = (int)(('T' << 24) | ('I' << 16) | ('R' << 8) | 'M') };4445int SimpleEnter (Thread * Self) ;46int SimpleExit (Thread * Self) ;47int SimpleWait (Thread * Self, jlong millis) ;48int SimpleNotify (Thread * Self, bool All) ;4950public:51JvmtiRawMonitor(const char *name);52~JvmtiRawMonitor();53int raw_enter(TRAPS);54int raw_exit(TRAPS);55int raw_wait(jlong millis, bool interruptable, TRAPS);56int raw_notify(TRAPS);57int raw_notifyAll(TRAPS);58int magic() { return _magic; }59const char *get_name() { return _name; }60bool is_valid();61};6263// Onload pending raw monitors64// Class is used to cache onload or onstart monitor enter65// which will transition into real monitor when66// VM is fully initialized.67class JvmtiPendingMonitors : public AllStatic {6869private:70static GrowableArray<JvmtiRawMonitor*> *_monitors; // Cache raw monitor enter7172inline static GrowableArray<JvmtiRawMonitor*>* monitors() { return _monitors; }7374static void dispose() {75delete monitors();76}7778public:79static void enter(JvmtiRawMonitor *monitor) {80monitors()->append(monitor);81}8283static int count() {84return monitors()->length();85}8687static void destroy(JvmtiRawMonitor *monitor) {88while (monitors()->contains(monitor)) {89monitors()->remove(monitor);90}91}9293// Return false if monitor is not found in the list.94static bool exit(JvmtiRawMonitor *monitor) {95if (monitors()->contains(monitor)) {96monitors()->remove(monitor);97return true;98} else {99return false;100}101}102103static void transition_raw_monitors();104};105106#endif // SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP107108109