annotate src/share/vm/classfile/placeholders.hpp @ 1091:6aa7255741f3

6906727: UseCompressedOops: some card-marking fixes related to object arrays Summary: Introduced a new write_ref_array(HeapWords* start, size_t count) method that does the requisite MemRegion range calculation so (some of the) clients of the erstwhile write_ref_array(MemRegion mr) do not need to worry. This removed all external uses of array_size(), which was also simplified and made private. Asserts were added to catch other possible issues. Further, less essential, fixes stemming from this investigation are deferred to CR 6904516 (to follow shortly in hs17). Reviewed-by: kvn, coleenp, jmasa
author ysr
date Thu, 03 Dec 2009 15:01:57 -0800
parents a61af66fc99e
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 class PlaceholderEntry;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // Placeholder objects. These represent classes currently
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // being loaded, as well as arrays of primitives.
a61af66fc99e Initial load
duke
parents:
diff changeset
29 //
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class PlaceholderTable : public TwoOopHashtable {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
35 PlaceholderTable(int table_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 PlaceholderEntry* new_entry(int hash, symbolOop name, oop loader, bool havesupername, symbolOop supername);
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 PlaceholderEntry* bucket(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 return (PlaceholderEntry*)Hashtable::bucket(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
41 }
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 PlaceholderEntry** bucket_addr(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 return (PlaceholderEntry**)Hashtable::bucket_addr(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 }
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 void add_entry(int index, PlaceholderEntry* new_entry) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 Hashtable::add_entry(index, (HashtableEntry*)new_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
49 }
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 void add_entry(int index, unsigned int hash, symbolHandle name,
a61af66fc99e Initial load
duke
parents:
diff changeset
52 Handle loader, bool havesupername, symbolHandle supername);
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // This returns a symbolOop to match type for SystemDictionary
a61af66fc99e Initial load
duke
parents:
diff changeset
55 symbolOop find_entry(int index, unsigned int hash,
a61af66fc99e Initial load
duke
parents:
diff changeset
56 symbolHandle name, Handle loader);
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 PlaceholderEntry* get_entry(int index, unsigned int hash,
a61af66fc99e Initial load
duke
parents:
diff changeset
59 symbolHandle name, Handle loader);
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // caller to create a placeholder entry must enumerate an action
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // caller claims ownership of that action
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // For parallel classloading:
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // multiple LOAD_INSTANCE threads can proceed in parallel
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // multiple LOAD_SUPER threads can proceed in parallel
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // LOAD_SUPER needed to check for class circularity
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // DEFINE_CLASS: ultimately define class must be single threaded
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // on a class/classloader basis
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // so the head of that queue owns the token
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // and the rest of the threads return the result the first thread gets
a61af66fc99e Initial load
duke
parents:
diff changeset
71 enum classloadAction {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 LOAD_INSTANCE = 1, // calling load_instance_class
a61af66fc99e Initial load
duke
parents:
diff changeset
73 LOAD_SUPER = 2, // loading superclass for this class
a61af66fc99e Initial load
duke
parents:
diff changeset
74 DEFINE_CLASS = 3 // find_or_define class
a61af66fc99e Initial load
duke
parents:
diff changeset
75 };
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // find_and_add returns probe pointer - old or new
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // If no entry exists, add a placeholder entry and push SeenThread
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // If entry exists, reuse entry and push SeenThread for classloadAction
a61af66fc99e Initial load
duke
parents:
diff changeset
80 PlaceholderEntry* find_and_add(int index, unsigned int hash,
a61af66fc99e Initial load
duke
parents:
diff changeset
81 symbolHandle name, Handle loader,
a61af66fc99e Initial load
duke
parents:
diff changeset
82 classloadAction action, symbolHandle supername,
a61af66fc99e Initial load
duke
parents:
diff changeset
83 Thread* thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 void remove_entry(int index, unsigned int hash,
a61af66fc99e Initial load
duke
parents:
diff changeset
86 symbolHandle name, Handle loader);
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // Remove placeholder information
a61af66fc99e Initial load
duke
parents:
diff changeset
89 void find_and_remove(int index, unsigned int hash,
a61af66fc99e Initial load
duke
parents:
diff changeset
90 symbolHandle name, Handle loader, Thread* thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // GC support.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 void oops_do(OopClosure* f);
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // JVMTI support
a61af66fc99e Initial load
duke
parents:
diff changeset
96 void entries_do(void f(symbolOop, oop));
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
99 void print();
a61af66fc99e Initial load
duke
parents:
diff changeset
100 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
101 void verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
102 };
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // SeenThread objects represent list of threads that are
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // currently performing a load action on a class.
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // For class circularity, set before loading a superclass.
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // For bootclasssearchpath, set before calling load_instance_class.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // Defining must be single threaded on a class/classloader basis
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // For DEFINE_CLASS, the head of the queue owns the
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // define token and the rest of the threads wait to return the
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // result the first thread gets.
a61af66fc99e Initial load
duke
parents:
diff changeset
112 class SeenThread: public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
114 Thread *_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 SeenThread* _stnext;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 SeenThread* _stprev;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
118 SeenThread(Thread *thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 _thread = thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 _stnext = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 _stprev = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123 Thread* thread() const { return _thread;}
a61af66fc99e Initial load
duke
parents:
diff changeset
124 void set_thread(Thread *thread) { _thread = thread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 SeenThread* next() const { return _stnext;}
a61af66fc99e Initial load
duke
parents:
diff changeset
127 void set_next(SeenThread *seen) { _stnext = seen; }
a61af66fc99e Initial load
duke
parents:
diff changeset
128 void set_prev(SeenThread *seen) { _stprev = seen; }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
131 void printActionQ() {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 SeenThread* seen = this;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 while (seen != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 seen->thread()->print_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
135 tty->print(", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
136 seen = seen->next();
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
140 };
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // Placeholder objects represent classes currently being loaded.
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // All threads examining the placeholder table must hold the
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // SystemDictionary_lock, so we don't need special precautions
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // on store ordering here.
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // The system dictionary is the only user of this class.
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 class PlaceholderEntry : public HashtableEntry {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
153 oop _loader; // initiating loader
a61af66fc99e Initial load
duke
parents:
diff changeset
154 bool _havesupername; // distinguish between null supername, and unknown
a61af66fc99e Initial load
duke
parents:
diff changeset
155 symbolOop _supername;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 Thread* _definer; // owner of define token
a61af66fc99e Initial load
duke
parents:
diff changeset
157 klassOop _instanceKlass; // instanceKlass from successful define
a61af66fc99e Initial load
duke
parents:
diff changeset
158 SeenThread* _superThreadQ; // doubly-linked queue of Threads loading a superclass for this class
a61af66fc99e Initial load
duke
parents:
diff changeset
159 SeenThread* _loadInstanceThreadQ; // loadInstance thread
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // can be multiple threads if classloader object lock broken by application
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // or if classloader supports parallel classloading
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 SeenThread* _defineThreadQ; // queue of Threads trying to define this class
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // including _definer
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // _definer owns token
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // queue waits for and returns results from _definer
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // Simple accessors, used only by SystemDictionary
a61af66fc99e Initial load
duke
parents:
diff changeset
170 symbolOop klass() const { return (symbolOop)literal(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
171 symbolOop* klass_addr() { return (symbolOop*)literal_addr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 oop loader() const { return _loader; }
a61af66fc99e Initial load
duke
parents:
diff changeset
174 void set_loader(oop loader) { _loader = loader; }
a61af66fc99e Initial load
duke
parents:
diff changeset
175 oop* loader_addr() { return &_loader; }
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 bool havesupername() const { return _havesupername; }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 void set_havesupername(bool havesupername) { _havesupername = havesupername; }
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 symbolOop supername() const { return _supername; }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 void set_supername(symbolOop supername) { _supername = supername; }
a61af66fc99e Initial load
duke
parents:
diff changeset
182 symbolOop* supername_addr() { return &_supername; }
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 Thread* definer() const {return _definer; }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 void set_definer(Thread* definer) { _definer = definer; }
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 klassOop instanceKlass() const {return _instanceKlass; }
a61af66fc99e Initial load
duke
parents:
diff changeset
188 void set_instanceKlass(klassOop instanceKlass) { _instanceKlass = instanceKlass; }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 klassOop* instanceKlass_addr() { return &_instanceKlass; }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 SeenThread* superThreadQ() const { return _superThreadQ; }
a61af66fc99e Initial load
duke
parents:
diff changeset
192 void set_superThreadQ(SeenThread* SeenThread) { _superThreadQ = SeenThread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 SeenThread* loadInstanceThreadQ() const { return _loadInstanceThreadQ; }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 void set_loadInstanceThreadQ(SeenThread* SeenThread) { _loadInstanceThreadQ = SeenThread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 SeenThread* defineThreadQ() const { return _defineThreadQ; }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 void set_defineThreadQ(SeenThread* SeenThread) { _defineThreadQ = SeenThread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 PlaceholderEntry* next() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 return (PlaceholderEntry*)HashtableEntry::next();
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 PlaceholderEntry** next_addr() {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 return (PlaceholderEntry**)HashtableEntry::next_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // Test for equality
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // Entries are unique for class/classloader name pair
a61af66fc99e Initial load
duke
parents:
diff changeset
210 bool equals(symbolOop class_name, oop class_loader) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 return (klass() == class_name && loader() == class_loader);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 SeenThread* actionToQueue(PlaceholderTable::classloadAction action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 SeenThread* queuehead;
a61af66fc99e Initial load
duke
parents:
diff changeset
216 switch (action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 case PlaceholderTable::LOAD_INSTANCE:
a61af66fc99e Initial load
duke
parents:
diff changeset
218 queuehead = _loadInstanceThreadQ;
a61af66fc99e Initial load
duke
parents:
diff changeset
219 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 case PlaceholderTable::LOAD_SUPER:
a61af66fc99e Initial load
duke
parents:
diff changeset
221 queuehead = _superThreadQ;
a61af66fc99e Initial load
duke
parents:
diff changeset
222 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
223 case PlaceholderTable::DEFINE_CLASS:
a61af66fc99e Initial load
duke
parents:
diff changeset
224 queuehead = _defineThreadQ;
a61af66fc99e Initial load
duke
parents:
diff changeset
225 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
226 default: Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228 return queuehead;
a61af66fc99e Initial load
duke
parents:
diff changeset
229 }
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 void set_threadQ(SeenThread* seenthread, PlaceholderTable::classloadAction action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 switch (action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 case PlaceholderTable::LOAD_INSTANCE:
a61af66fc99e Initial load
duke
parents:
diff changeset
234 _loadInstanceThreadQ = seenthread;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 case PlaceholderTable::LOAD_SUPER:
a61af66fc99e Initial load
duke
parents:
diff changeset
237 _superThreadQ = seenthread;
a61af66fc99e Initial load
duke
parents:
diff changeset
238 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
239 case PlaceholderTable::DEFINE_CLASS:
a61af66fc99e Initial load
duke
parents:
diff changeset
240 _defineThreadQ = seenthread;
a61af66fc99e Initial load
duke
parents:
diff changeset
241 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
242 default: Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 bool super_load_in_progress() {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 return (_superThreadQ != NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 bool instance_load_in_progress() {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 return (_loadInstanceThreadQ != NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 bool define_class_in_progress() {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 return (_defineThreadQ != NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // Doubly-linked list of Threads per action for class/classloader pair
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // Class circularity support: links in thread before loading superclass
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // bootstrapsearchpath support: links in a thread before load_instance_class
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // definers: use as queue of define requestors, including owner of
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // define token. Appends for debugging of requestor order
a61af66fc99e Initial load
duke
parents:
diff changeset
264 void add_seen_thread(Thread* thread, PlaceholderTable::classloadAction action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 assert_lock_strong(SystemDictionary_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 SeenThread* threadEntry = new SeenThread(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
267 SeenThread* seen = actionToQueue(action);
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 if (seen == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 set_threadQ(threadEntry, action);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 SeenThread* next;
a61af66fc99e Initial load
duke
parents:
diff changeset
274 while ((next = seen->next()) != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
275 seen = next;
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277 seen->set_next(threadEntry);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 threadEntry->set_prev(seen);
a61af66fc99e Initial load
duke
parents:
diff changeset
279 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 bool check_seen_thread(Thread* thread, PlaceholderTable::classloadAction action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 assert_lock_strong(SystemDictionary_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
284 SeenThread* threadQ = actionToQueue(action);
a61af66fc99e Initial load
duke
parents:
diff changeset
285 SeenThread* seen = threadQ;
a61af66fc99e Initial load
duke
parents:
diff changeset
286 while (seen) {
a61af66fc99e Initial load
duke
parents:
diff changeset
287 if (thread == seen->thread()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290 seen = seen->next();
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
292 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 // returns true if seenthreadQ is now empty
a61af66fc99e Initial load
duke
parents:
diff changeset
296 // Note, caller must ensure probe still exists while holding
a61af66fc99e Initial load
duke
parents:
diff changeset
297 // SystemDictionary_lock
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // ignores if cleanup has already been done
a61af66fc99e Initial load
duke
parents:
diff changeset
299 // if found, deletes SeenThread
a61af66fc99e Initial load
duke
parents:
diff changeset
300 bool remove_seen_thread(Thread* thread, PlaceholderTable::classloadAction action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
301 assert_lock_strong(SystemDictionary_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
302 SeenThread* threadQ = actionToQueue(action);
a61af66fc99e Initial load
duke
parents:
diff changeset
303 SeenThread* seen = threadQ;
a61af66fc99e Initial load
duke
parents:
diff changeset
304 SeenThread* prev = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
305 while (seen) {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 if (thread == seen->thread()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
307 if (prev) {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 prev->set_next(seen->next());
a61af66fc99e Initial load
duke
parents:
diff changeset
309 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 set_threadQ(seen->next(), action);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312 if (seen->next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
313 seen->next()->set_prev(prev);
a61af66fc99e Initial load
duke
parents:
diff changeset
314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
315 delete seen;
a61af66fc99e Initial load
duke
parents:
diff changeset
316 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318 prev = seen;
a61af66fc99e Initial load
duke
parents:
diff changeset
319 seen = seen->next();
a61af66fc99e Initial load
duke
parents:
diff changeset
320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
321 return (actionToQueue(action) == NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // GC support
a61af66fc99e Initial load
duke
parents:
diff changeset
325 // Applies "f->do_oop" to all root oops in the placeholder table.
a61af66fc99e Initial load
duke
parents:
diff changeset
326 void oops_do(OopClosure* blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
327
a61af66fc99e Initial load
duke
parents:
diff changeset
328 // Print method doesn't append a cr
a61af66fc99e Initial load
duke
parents:
diff changeset
329 void print() const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
330 void verify() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
331 };