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 #include "precompiled.hpp"
26 #include "memory/allocation.inline.hpp"
27 #include "prims/jvmtiRawMonitor.hpp"
28 #include "runtime/atomic.hpp"
29 #include "runtime/interfaceSupport.inline.hpp"
30 #include "runtime/orderAccess.hpp"
31 #include "runtime/thread.inline.hpp"
32
33 JvmtiRawMonitor::QNode::QNode(Thread* thread) : _next(NULL), _prev(NULL),
34 _event(thread->_ParkEvent),
35 _notified(0), _t_state(TS_RUN) {
36 }
37
38 GrowableArray<JvmtiRawMonitor*>* JvmtiPendingMonitors::_monitors =
39 new (ResourceObj::C_HEAP, mtInternal) GrowableArray<JvmtiRawMonitor*>(1, true);
40
41 void JvmtiPendingMonitors::transition_raw_monitors() {
42 assert((Threads::number_of_threads()==1),
43 "Java thread has not been created yet or more than one java thread "
44 "is running. Raw monitor transition will not work");
45 JavaThread* current_java_thread = JavaThread::current();
46 assert(current_java_thread->thread_state() == _thread_in_vm, "Must be in vm");
47 for (int i = 0; i < count(); i++) {
48 JvmtiRawMonitor* rmonitor = monitors()->at(i);
49 rmonitor->raw_enter(current_java_thread);
50 }
51 // pending monitors are converted to real monitor so delete them all.
52 dispose();
53 }
54
55 //
56 // class JvmtiRawMonitor
57 //
58
59 JvmtiRawMonitor::JvmtiRawMonitor(const char* name) : _owner(NULL),
60 _recursions(0),
61 _entry_list(NULL),
62 _wait_set(NULL),
63 _waiters(0),
64 _magic(JVMTI_RM_MAGIC),
65 _name(NULL) {
66 #ifdef ASSERT
67 _name = strcpy(NEW_C_HEAP_ARRAY(char, strlen(name) + 1, mtInternal), name);
68 #endif
69 }
|
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 #include "precompiled.hpp"
26 #include "memory/allocation.inline.hpp"
27 #include "prims/jvmtiRawMonitor.hpp"
28 #include "runtime/atomic.hpp"
29 #include "runtime/interfaceSupport.inline.hpp"
30 #include "runtime/orderAccess.hpp"
31 #include "runtime/thread.inline.hpp"
32 #if INCLUDE_TSAN
33 #include "tsan/tsan.hpp"
34 #endif // INCLUDE_TSAN
35
36 JvmtiRawMonitor::QNode::QNode(Thread* thread) : _next(NULL), _prev(NULL),
37 _event(thread->_ParkEvent),
38 _notified(0), _t_state(TS_RUN) {
39 }
40
41 GrowableArray<JvmtiRawMonitor*>* JvmtiPendingMonitors::_monitors =
42 new (ResourceObj::C_HEAP, mtInternal) GrowableArray<JvmtiRawMonitor*>(1, true);
43
44 void JvmtiPendingMonitors::transition_raw_monitors() {
45 assert((Threads::number_of_threads()==1),
46 "Java thread has not been created yet or more than one java thread "
47 "is running. Raw monitor transition will not work");
48 JavaThread* current_java_thread = JavaThread::current();
49 assert(current_java_thread->thread_state() == _thread_in_vm, "Must be in vm");
50 for (int i = 0; i < count(); i++) {
51 JvmtiRawMonitor* rmonitor = monitors()->at(i);
52 rmonitor->raw_enter(current_java_thread);
53 TSAN_RUNTIME_ONLY(TSAN_RAW_LOCK_ACQUIRED(rmonitor));
54 }
55 // pending monitors are converted to real monitor so delete them all.
56 dispose();
57 }
58
59 //
60 // class JvmtiRawMonitor
61 //
62
63 JvmtiRawMonitor::JvmtiRawMonitor(const char* name) : _owner(NULL),
64 _recursions(0),
65 _entry_list(NULL),
66 _wait_set(NULL),
67 _waiters(0),
68 _magic(JVMTI_RM_MAGIC),
69 _name(NULL) {
70 #ifdef ASSERT
71 _name = strcpy(NEW_C_HEAP_ARRAY(char, strlen(name) + 1, mtInternal), name);
72 #endif
73 }
|