acorn@2233: /* zgu@4492: * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. acorn@2233: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. acorn@2233: * acorn@2233: * This code is free software; you can redistribute it and/or modify it acorn@2233: * under the terms of the GNU General Public License version 2 only, as acorn@2233: * published by the Free Software Foundation. acorn@2233: * acorn@2233: * This code is distributed in the hope that it will be useful, but WITHOUT acorn@2233: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or acorn@2233: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License acorn@2233: * version 2 for more details (a copy is included in the LICENSE file that acorn@2233: * accompanied this code). acorn@2233: * acorn@2233: * You should have received a copy of the GNU General Public License version acorn@2233: * 2 along with this work; if not, write to the Free Software Foundation, acorn@2233: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. acorn@2233: * acorn@2233: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA acorn@2233: * or visit www.oracle.com if you need additional information or have any acorn@2233: * questions. acorn@2233: * acorn@2233: */ acorn@2233: stefank@2314: #ifndef SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP stefank@2314: #define SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP stefank@2314: stefank@2314: #include "runtime/objectMonitor.hpp" stefank@2314: #include "utilities/growableArray.hpp" stefank@2314: acorn@2233: // acorn@2233: // class JvmtiRawMonitor acorn@2233: // acorn@2233: // Used by JVMTI methods: All RawMonitor methods (CreateRawMonitor, EnterRawMonitor, etc.) acorn@2233: // acorn@2233: // Wrapper for ObjectMonitor class that saves the Monitor's name acorn@2233: // acorn@2233: acorn@2233: class JvmtiRawMonitor : public ObjectMonitor { acorn@2233: private: acorn@2233: int _magic; acorn@2233: char * _name; acorn@2233: // JVMTI_RM_MAGIC is set in contructor and unset in destructor. acorn@2233: enum { JVMTI_RM_MAGIC = (int)(('T' << 24) | ('I' << 16) | ('R' << 8) | 'M') }; acorn@2233: acorn@2233: int SimpleEnter (Thread * Self) ; acorn@2233: int SimpleExit (Thread * Self) ; acorn@2233: int SimpleWait (Thread * Self, jlong millis) ; acorn@2233: int SimpleNotify (Thread * Self, bool All) ; acorn@2233: acorn@2233: public: acorn@2233: JvmtiRawMonitor(const char *name); acorn@2233: ~JvmtiRawMonitor(); acorn@2233: int raw_enter(TRAPS); acorn@2233: int raw_exit(TRAPS); acorn@2233: int raw_wait(jlong millis, bool interruptable, TRAPS); acorn@2233: int raw_notify(TRAPS); acorn@2233: int raw_notifyAll(TRAPS); acorn@2233: int magic() { return _magic; } acorn@2233: const char *get_name() { return _name; } acorn@2233: bool is_valid(); acorn@2233: }; acorn@2233: acorn@2233: // Onload pending raw monitors acorn@2233: // Class is used to cache onload or onstart monitor enter acorn@2233: // which will transition into real monitor when acorn@2233: // VM is fully initialized. acorn@2233: class JvmtiPendingMonitors : public AllStatic { acorn@2233: acorn@2233: private: acorn@2233: static GrowableArray *_monitors; // Cache raw monitor enter acorn@2233: acorn@2233: inline static GrowableArray* monitors() { return _monitors; } acorn@2233: acorn@2233: static void dispose() { acorn@2233: delete monitors(); acorn@2233: } acorn@2233: acorn@2233: public: acorn@2233: static void enter(JvmtiRawMonitor *monitor) { acorn@2233: monitors()->append(monitor); acorn@2233: } acorn@2233: acorn@2233: static int count() { acorn@2233: return monitors()->length(); acorn@2233: } acorn@2233: acorn@2233: static void destroy(JvmtiRawMonitor *monitor) { acorn@2233: while (monitors()->contains(monitor)) { acorn@2233: monitors()->remove(monitor); acorn@2233: } acorn@2233: } acorn@2233: acorn@2233: // Return false if monitor is not found in the list. acorn@2233: static bool exit(JvmtiRawMonitor *monitor) { acorn@2233: if (monitors()->contains(monitor)) { acorn@2233: monitors()->remove(monitor); acorn@2233: return true; acorn@2233: } else { acorn@2233: return false; acorn@2233: } acorn@2233: } acorn@2233: acorn@2233: static void transition_raw_monitors(); acorn@2233: }; stefank@2314: stefank@2314: #endif // SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP