annotate src/share/vm/classfile/placeholders.hpp @ 3011:f00918f35c7f

inlining and runtime interface related changes: added codeSize() and compilerStorage() to RiMethod HotSpotMethodResolved uses reflective methods instead of vmIds and survives compilations HotSpotResolvedType.isInitialized not represented as field (can change) inlining stores graphs into method objects and reuses them
author Lukas Stadler <lukas.stadler@jku.at>
date Thu, 16 Jun 2011 20:36:17 +0200
parents 1d1603768966
children d2a62e0f25eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2426
1d1603768966 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 2177
diff changeset
2 * Copyright (c) 2003, 2011, 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: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
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: 0
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_CLASSFILE_PLACEHOLDERS_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_CLASSFILE_PLACEHOLDERS_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
1983
c760f78e0a53 7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents: 1972
diff changeset
28 #include "runtime/thread.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "utilities/hashtable.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class PlaceholderEntry;
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // Placeholder objects. These represent classes currently
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // being loaded, as well as arrays of primitives.
a61af66fc99e Initial load
duke
parents:
diff changeset
35 //
a61af66fc99e Initial load
duke
parents:
diff changeset
36
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
37 class PlaceholderTable : public TwoOopHashtable<Symbol*> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
38 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
41 PlaceholderTable(int table_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
42
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
43 PlaceholderEntry* new_entry(int hash, Symbol* name, oop loader, bool havesupername, Symbol* supername);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
44 void free_entry(PlaceholderEntry* entry);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 PlaceholderEntry* bucket(int i) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
47 return (PlaceholderEntry*)Hashtable<Symbol*>::bucket(i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 PlaceholderEntry** bucket_addr(int i) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
51 return (PlaceholderEntry**)Hashtable<Symbol*>::bucket_addr(i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 void add_entry(int index, PlaceholderEntry* new_entry) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
55 Hashtable<Symbol*>::add_entry(index, (HashtableEntry<Symbol*>*)new_entry);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
58 void add_entry(int index, unsigned int hash, Symbol* name,
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
59 Handle loader, bool havesupername, Symbol* supername);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
60
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
61 // This returns a Symbol* to match type for SystemDictionary
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
62 Symbol* find_entry(int index, unsigned int hash,
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
63 Symbol* name, Handle loader);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 PlaceholderEntry* get_entry(int index, unsigned int hash,
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
66 Symbol* name, Handle loader);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // caller to create a placeholder entry must enumerate an action
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // caller claims ownership of that action
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // For parallel classloading:
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // multiple LOAD_INSTANCE threads can proceed in parallel
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // multiple LOAD_SUPER threads can proceed in parallel
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // LOAD_SUPER needed to check for class circularity
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // DEFINE_CLASS: ultimately define class must be single threaded
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // on a class/classloader basis
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // so the head of that queue owns the token
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // and the rest of the threads return the result the first thread gets
a61af66fc99e Initial load
duke
parents:
diff changeset
78 enum classloadAction {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 LOAD_INSTANCE = 1, // calling load_instance_class
a61af66fc99e Initial load
duke
parents:
diff changeset
80 LOAD_SUPER = 2, // loading superclass for this class
a61af66fc99e Initial load
duke
parents:
diff changeset
81 DEFINE_CLASS = 3 // find_or_define class
a61af66fc99e Initial load
duke
parents:
diff changeset
82 };
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // find_and_add returns probe pointer - old or new
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // If no entry exists, add a placeholder entry and push SeenThread
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // If entry exists, reuse entry and push SeenThread for classloadAction
a61af66fc99e Initial load
duke
parents:
diff changeset
87 PlaceholderEntry* find_and_add(int index, unsigned int hash,
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
88 Symbol* name, Handle loader,
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
89 classloadAction action, Symbol* supername,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
90 Thread* thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 void remove_entry(int index, unsigned int hash,
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
93 Symbol* name, Handle loader);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // Remove placeholder information
a61af66fc99e Initial load
duke
parents:
diff changeset
96 void find_and_remove(int index, unsigned int hash,
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
97 Symbol* name, Handle loader, Thread* thread);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // GC support.
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void oops_do(OopClosure* f);
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // JVMTI support
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
103 void entries_do(void f(Symbol*, oop));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
106 void print();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
108 void verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
109 };
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // SeenThread objects represent list of threads that are
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // currently performing a load action on a class.
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // For class circularity, set before loading a superclass.
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // For bootclasssearchpath, set before calling load_instance_class.
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Defining must be single threaded on a class/classloader basis
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // For DEFINE_CLASS, the head of the queue owns the
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // define token and the rest of the threads wait to return the
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // result the first thread gets.
a61af66fc99e Initial load
duke
parents:
diff changeset
119 class SeenThread: public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
121 Thread *_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 SeenThread* _stnext;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 SeenThread* _stprev;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
125 SeenThread(Thread *thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 _thread = thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 _stnext = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 _stprev = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 Thread* thread() const { return _thread;}
a61af66fc99e Initial load
duke
parents:
diff changeset
131 void set_thread(Thread *thread) { _thread = thread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 SeenThread* next() const { return _stnext;}
a61af66fc99e Initial load
duke
parents:
diff changeset
134 void set_next(SeenThread *seen) { _stnext = seen; }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 void set_prev(SeenThread *seen) { _stprev = seen; }
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
138 void printActionQ() {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 SeenThread* seen = this;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 while (seen != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 seen->thread()->print_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
142 tty->print(", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
143 seen = seen->next();
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
147 };
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Placeholder objects represent classes currently being loaded.
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // All threads examining the placeholder table must hold the
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // SystemDictionary_lock, so we don't need special precautions
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // on store ordering here.
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // The system dictionary is the only user of this class.
a61af66fc99e Initial load
duke
parents:
diff changeset
154
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
155 class PlaceholderEntry : public HashtableEntry<Symbol*> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
156 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
160 oop _loader; // initiating loader
a61af66fc99e Initial load
duke
parents:
diff changeset
161 bool _havesupername; // distinguish between null supername, and unknown
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
162 Symbol* _supername;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
163 Thread* _definer; // owner of define token
a61af66fc99e Initial load
duke
parents:
diff changeset
164 klassOop _instanceKlass; // instanceKlass from successful define
a61af66fc99e Initial load
duke
parents:
diff changeset
165 SeenThread* _superThreadQ; // doubly-linked queue of Threads loading a superclass for this class
a61af66fc99e Initial load
duke
parents:
diff changeset
166 SeenThread* _loadInstanceThreadQ; // loadInstance thread
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // can be multiple threads if classloader object lock broken by application
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // or if classloader supports parallel classloading
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 SeenThread* _defineThreadQ; // queue of Threads trying to define this class
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // including _definer
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // _definer owns token
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // queue waits for and returns results from _definer
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // Simple accessors, used only by SystemDictionary
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
177 Symbol* klassname() const { return literal(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179 oop loader() const { return _loader; }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 void set_loader(oop loader) { _loader = loader; }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 oop* loader_addr() { return &_loader; }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 bool havesupername() const { return _havesupername; }
a61af66fc99e Initial load
duke
parents:
diff changeset
184 void set_havesupername(bool havesupername) { _havesupername = havesupername; }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
186 Symbol* supername() const { return _supername; }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
187 void set_supername(Symbol* supername) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
188 _supername = supername;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
189 if (_supername != NULL) _supername->increment_refcount();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
190 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 Thread* definer() const {return _definer; }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 void set_definer(Thread* definer) { _definer = definer; }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 klassOop instanceKlass() const {return _instanceKlass; }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 void set_instanceKlass(klassOop instanceKlass) { _instanceKlass = instanceKlass; }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 klassOop* instanceKlass_addr() { return &_instanceKlass; }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 SeenThread* superThreadQ() const { return _superThreadQ; }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 void set_superThreadQ(SeenThread* SeenThread) { _superThreadQ = SeenThread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 SeenThread* loadInstanceThreadQ() const { return _loadInstanceThreadQ; }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 void set_loadInstanceThreadQ(SeenThread* SeenThread) { _loadInstanceThreadQ = SeenThread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 SeenThread* defineThreadQ() const { return _defineThreadQ; }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 void set_defineThreadQ(SeenThread* SeenThread) { _defineThreadQ = SeenThread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 PlaceholderEntry* next() const {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
209 return (PlaceholderEntry*)HashtableEntry<Symbol*>::next();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 PlaceholderEntry** next_addr() {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
213 return (PlaceholderEntry**)HashtableEntry<Symbol*>::next_addr();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
215
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // Test for equality
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // Entries are unique for class/classloader name pair
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
218 bool equals(Symbol* class_name, oop class_loader) const {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1983
diff changeset
219 return (klassname() == class_name && loader() == class_loader);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 SeenThread* actionToQueue(PlaceholderTable::classloadAction action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 SeenThread* queuehead;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 switch (action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 case PlaceholderTable::LOAD_INSTANCE:
a61af66fc99e Initial load
duke
parents:
diff changeset
226 queuehead = _loadInstanceThreadQ;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 case PlaceholderTable::LOAD_SUPER:
a61af66fc99e Initial load
duke
parents:
diff changeset
229 queuehead = _superThreadQ;
a61af66fc99e Initial load
duke
parents:
diff changeset
230 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
231 case PlaceholderTable::DEFINE_CLASS:
a61af66fc99e Initial load
duke
parents:
diff changeset
232 queuehead = _defineThreadQ;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
234 default: Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236 return queuehead;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 void set_threadQ(SeenThread* seenthread, PlaceholderTable::classloadAction action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 switch (action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 case PlaceholderTable::LOAD_INSTANCE:
a61af66fc99e Initial load
duke
parents:
diff changeset
242 _loadInstanceThreadQ = seenthread;
a61af66fc99e Initial load
duke
parents:
diff changeset
243 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
244 case PlaceholderTable::LOAD_SUPER:
a61af66fc99e Initial load
duke
parents:
diff changeset
245 _superThreadQ = seenthread;
a61af66fc99e Initial load
duke
parents:
diff changeset
246 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
247 case PlaceholderTable::DEFINE_CLASS:
a61af66fc99e Initial load
duke
parents:
diff changeset
248 _defineThreadQ = seenthread;
a61af66fc99e Initial load
duke
parents:
diff changeset
249 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
250 default: Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 return;
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 super_load_in_progress() {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 return (_superThreadQ != 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 bool instance_load_in_progress() {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 return (_loadInstanceThreadQ != NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 bool define_class_in_progress() {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 return (_defineThreadQ != NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // Doubly-linked list of Threads per action for class/classloader pair
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // Class circularity support: links in thread before loading superclass
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // bootstrapsearchpath support: links in a thread before load_instance_class
a61af66fc99e Initial load
duke
parents:
diff changeset
270 // definers: use as queue of define requestors, including owner of
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // define token. Appends for debugging of requestor order
a61af66fc99e Initial load
duke
parents:
diff changeset
272 void add_seen_thread(Thread* thread, PlaceholderTable::classloadAction action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 assert_lock_strong(SystemDictionary_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
274 SeenThread* threadEntry = new SeenThread(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
275 SeenThread* seen = actionToQueue(action);
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 if (seen == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 set_threadQ(threadEntry, action);
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 SeenThread* next;
a61af66fc99e Initial load
duke
parents:
diff changeset
282 while ((next = seen->next()) != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 seen = next;
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 seen->set_next(threadEntry);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 threadEntry->set_prev(seen);
a61af66fc99e Initial load
duke
parents:
diff changeset
287 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289
a61af66fc99e Initial load
duke
parents:
diff changeset
290 bool check_seen_thread(Thread* thread, PlaceholderTable::classloadAction action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 assert_lock_strong(SystemDictionary_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
292 SeenThread* threadQ = actionToQueue(action);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 SeenThread* seen = threadQ;
a61af66fc99e Initial load
duke
parents:
diff changeset
294 while (seen) {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 if (thread == seen->thread()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
298 seen = seen->next();
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // returns true if seenthreadQ is now empty
a61af66fc99e Initial load
duke
parents:
diff changeset
304 // Note, caller must ensure probe still exists while holding
a61af66fc99e Initial load
duke
parents:
diff changeset
305 // SystemDictionary_lock
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // ignores if cleanup has already been done
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // if found, deletes SeenThread
a61af66fc99e Initial load
duke
parents:
diff changeset
308 bool remove_seen_thread(Thread* thread, PlaceholderTable::classloadAction action) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 assert_lock_strong(SystemDictionary_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
310 SeenThread* threadQ = actionToQueue(action);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 SeenThread* seen = threadQ;
a61af66fc99e Initial load
duke
parents:
diff changeset
312 SeenThread* prev = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
313 while (seen) {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 if (thread == seen->thread()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
315 if (prev) {
a61af66fc99e Initial load
duke
parents:
diff changeset
316 prev->set_next(seen->next());
a61af66fc99e Initial load
duke
parents:
diff changeset
317 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 set_threadQ(seen->next(), action);
a61af66fc99e Initial load
duke
parents:
diff changeset
319 }
a61af66fc99e Initial load
duke
parents:
diff changeset
320 if (seen->next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
321 seen->next()->set_prev(prev);
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323 delete seen;
a61af66fc99e Initial load
duke
parents:
diff changeset
324 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
325 }
a61af66fc99e Initial load
duke
parents:
diff changeset
326 prev = seen;
a61af66fc99e Initial load
duke
parents:
diff changeset
327 seen = seen->next();
a61af66fc99e Initial load
duke
parents:
diff changeset
328 }
a61af66fc99e Initial load
duke
parents:
diff changeset
329 return (actionToQueue(action) == NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332 // GC support
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // Applies "f->do_oop" to all root oops in the placeholder table.
a61af66fc99e Initial load
duke
parents:
diff changeset
334 void oops_do(OopClosure* blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336 // Print method doesn't append a cr
a61af66fc99e Initial load
duke
parents:
diff changeset
337 void print() const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
338 void verify() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
339 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
340
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
341 #endif // SHARE_VM_CLASSFILE_PLACEHOLDERS_HPP