Mercurial > hg > truffle
comparison src/share/vm/prims/jvmtiRawMonitor.hpp @ 1878:fa83ab460c54
6988353: refactor contended sync subsystem
Summary: reduce complexity by factoring synchronizer.cpp
Reviewed-by: dholmes, never, coleenp
author | acorn |
---|---|
date | Fri, 22 Oct 2010 15:59:34 -0400 |
parents | |
children | f95d63e2154a |
comparison
equal
deleted
inserted
replaced
1874:75ab0162aa84 | 1878:fa83ab460c54 |
---|---|
1 /* | |
2 * Copyright (c) 1999, 2007, 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 */ | |
24 | |
25 // | |
26 // class JvmtiRawMonitor | |
27 // | |
28 // Used by JVMTI methods: All RawMonitor methods (CreateRawMonitor, EnterRawMonitor, etc.) | |
29 // | |
30 // Wrapper for ObjectMonitor class that saves the Monitor's name | |
31 // | |
32 | |
33 class JvmtiRawMonitor : public ObjectMonitor { | |
34 private: | |
35 int _magic; | |
36 char * _name; | |
37 // JVMTI_RM_MAGIC is set in contructor and unset in destructor. | |
38 enum { JVMTI_RM_MAGIC = (int)(('T' << 24) | ('I' << 16) | ('R' << 8) | 'M') }; | |
39 | |
40 int SimpleEnter (Thread * Self) ; | |
41 int SimpleExit (Thread * Self) ; | |
42 int SimpleWait (Thread * Self, jlong millis) ; | |
43 int SimpleNotify (Thread * Self, bool All) ; | |
44 | |
45 public: | |
46 JvmtiRawMonitor(const char *name); | |
47 ~JvmtiRawMonitor(); | |
48 int raw_enter(TRAPS); | |
49 int raw_exit(TRAPS); | |
50 int raw_wait(jlong millis, bool interruptable, TRAPS); | |
51 int raw_notify(TRAPS); | |
52 int raw_notifyAll(TRAPS); | |
53 int magic() { return _magic; } | |
54 const char *get_name() { return _name; } | |
55 bool is_valid(); | |
56 }; | |
57 | |
58 // Onload pending raw monitors | |
59 // Class is used to cache onload or onstart monitor enter | |
60 // which will transition into real monitor when | |
61 // VM is fully initialized. | |
62 class JvmtiPendingMonitors : public AllStatic { | |
63 | |
64 private: | |
65 static GrowableArray<JvmtiRawMonitor*> *_monitors; // Cache raw monitor enter | |
66 | |
67 inline static GrowableArray<JvmtiRawMonitor*>* monitors() { return _monitors; } | |
68 | |
69 static void dispose() { | |
70 delete monitors(); | |
71 } | |
72 | |
73 public: | |
74 static void enter(JvmtiRawMonitor *monitor) { | |
75 monitors()->append(monitor); | |
76 } | |
77 | |
78 static int count() { | |
79 return monitors()->length(); | |
80 } | |
81 | |
82 static void destroy(JvmtiRawMonitor *monitor) { | |
83 while (monitors()->contains(monitor)) { | |
84 monitors()->remove(monitor); | |
85 } | |
86 } | |
87 | |
88 // Return false if monitor is not found in the list. | |
89 static bool exit(JvmtiRawMonitor *monitor) { | |
90 if (monitors()->contains(monitor)) { | |
91 monitors()->remove(monitor); | |
92 return true; | |
93 } else { | |
94 return false; | |
95 } | |
96 } | |
97 | |
98 static void transition_raw_monitors(); | |
99 }; |