annotate src/share/vm/runtime/vmThread.hpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children f08d439fab8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1119
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1119
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1119
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_RUNTIME_VMTHREAD_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_RUNTIME_VMTHREAD_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "runtime/perfData.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "runtime/vm_operations.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #ifdef TARGET_OS_FAMILY_linux
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 # include "thread_linux.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #ifdef TARGET_OS_FAMILY_solaris
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 # include "thread_solaris.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #ifdef TARGET_OS_FAMILY_windows
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 # include "thread_windows.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
39
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40 //
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // Prioritized queue of VM operations.
a61af66fc99e Initial load
duke
parents:
diff changeset
42 //
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Encapsulates both queue management and
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // and priority policy
a61af66fc99e Initial load
duke
parents:
diff changeset
45 //
a61af66fc99e Initial load
duke
parents:
diff changeset
46 class VMOperationQueue : public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
48 enum Priorities {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 SafepointPriority, // Highest priority (operation executed at a safepoint)
a61af66fc99e Initial load
duke
parents:
diff changeset
50 MediumPriority, // Medium priority
a61af66fc99e Initial load
duke
parents:
diff changeset
51 nof_priorities
a61af66fc99e Initial load
duke
parents:
diff changeset
52 };
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // We maintain a doubled linked list, with explicit count.
a61af66fc99e Initial load
duke
parents:
diff changeset
55 int _queue_length[nof_priorities];
a61af66fc99e Initial load
duke
parents:
diff changeset
56 int _queue_counter;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 VM_Operation* _queue [nof_priorities];
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // we also allow the vmThread to register the ops it has drained so we
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // can scan them from oops_do
a61af66fc99e Initial load
duke
parents:
diff changeset
60 VM_Operation* _drain_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Double-linked non-empty list insert.
a61af66fc99e Initial load
duke
parents:
diff changeset
63 void insert(VM_Operation* q,VM_Operation* n);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 void unlink(VM_Operation* q);
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Basic queue manipulation
a61af66fc99e Initial load
duke
parents:
diff changeset
67 bool queue_empty (int prio);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 void queue_add_front (int prio, VM_Operation *op);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 void queue_add_back (int prio, VM_Operation *op);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 VM_Operation* queue_remove_front(int prio);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 void queue_oops_do(int queue, OopClosure* f);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void drain_list_oops_do(OopClosure* f);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 VM_Operation* queue_drain(int prio);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // lock-free query: may return the wrong answer but must not break
a61af66fc99e Initial load
duke
parents:
diff changeset
75 bool queue_peek(int prio) { return _queue_length[prio] > 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
78 VMOperationQueue();
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // Highlevel operations. Encapsulates policy
a61af66fc99e Initial load
duke
parents:
diff changeset
81 bool add(VM_Operation *op);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 VM_Operation* remove_next(); // Returns next or null
a61af66fc99e Initial load
duke
parents:
diff changeset
83 VM_Operation* remove_next_at_safepoint_priority() { return queue_remove_front(SafepointPriority); }
a61af66fc99e Initial load
duke
parents:
diff changeset
84 VM_Operation* drain_at_safepoint_priority() { return queue_drain(SafepointPriority); }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 void set_drain_list(VM_Operation* list) { _drain_list = list; }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 bool peek_at_safepoint_priority() { return queue_peek(SafepointPriority); }
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // GC support
a61af66fc99e Initial load
duke
parents:
diff changeset
89 void oops_do(OopClosure* f);
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 void verify_queue(int prio) PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 };
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 //
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // A single VMThread (the primordial thread) spawns all other threads
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // and is itself used by other threads to offload heavy vm operations
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // like scavenge, garbage_collect etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
99 //
a61af66fc99e Initial load
duke
parents:
diff changeset
100
1119
547f81740344 6361589: Print out stack trace for target thread of GC crash
minqi
parents: 989
diff changeset
101 class VMThread: public NamedThread {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
103 static ThreadPriority _current_priority;
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 static bool _should_terminate;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 static bool _terminated;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 static Monitor * _terminate_lock;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 static PerfCounter* _perf_accumulated_vm_operation_time;
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 void evaluate_operation(VM_Operation* op);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // Constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
113 VMThread();
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Tester
a61af66fc99e Initial load
duke
parents:
diff changeset
116 bool is_VM_thread() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 bool is_GC_thread() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // The ever running loop for the VMThread
a61af66fc99e Initial load
duke
parents:
diff changeset
120 void loop();
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // Called to stop the VM thread
a61af66fc99e Initial load
duke
parents:
diff changeset
123 static void wait_for_vm_thread_exit();
a61af66fc99e Initial load
duke
parents:
diff changeset
124 static bool should_terminate() { return _should_terminate; }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 static bool is_terminated() { return _terminated == true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // Execution of vm operation
a61af66fc99e Initial load
duke
parents:
diff changeset
128 static void execute(VM_Operation* op);
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // Returns the current vm operation if any.
a61af66fc99e Initial load
duke
parents:
diff changeset
131 static VM_Operation* vm_operation() { return _cur_vm_operation; }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // Returns the single instance of VMThread.
a61af66fc99e Initial load
duke
parents:
diff changeset
134 static VMThread* vm_thread() { return _vm_thread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // GC support
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 0
diff changeset
137 void oops_do(OopClosure* f, CodeBlobClosure* cf);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
140 void print_on(outputStream* st) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 void print() const { print_on(tty); }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 void verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Performance measurement
a61af66fc99e Initial load
duke
parents:
diff changeset
145 static PerfCounter* perf_accumulated_vm_operation_time() { return _perf_accumulated_vm_operation_time; }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // Entry for starting vm thread
a61af66fc99e Initial load
duke
parents:
diff changeset
148 virtual void run();
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // Creations/Destructions
a61af66fc99e Initial load
duke
parents:
diff changeset
151 static void create();
a61af66fc99e Initial load
duke
parents:
diff changeset
152 static void destroy();
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // VM_Operation support
a61af66fc99e Initial load
duke
parents:
diff changeset
156 static VM_Operation* _cur_vm_operation; // Current VM operation
a61af66fc99e Initial load
duke
parents:
diff changeset
157 static VMOperationQueue* _vm_queue; // Queue (w/ policy) of VM operations
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // Pointer to single-instance of VM thread
a61af66fc99e Initial load
duke
parents:
diff changeset
160 static VMThread* _vm_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
161 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
162
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
163 #endif // SHARE_VM_RUNTIME_VMTHREAD_HPP