comparison src/share/vm/classfile/placeholders.hpp @ 2177:3582bf76420e

6990754: Use native memory and reference counting to implement SymbolTable Summary: move symbols from permgen into C heap and reference count them Reviewed-by: never, acorn, jmasa, stefank
author coleenp
date Thu, 27 Jan 2011 16:11:27 -0800
parents c760f78e0a53
children 1d1603768966
comparison
equal deleted inserted replaced
2176:27e4ea99855d 2177:3582bf76420e
32 32
33 // Placeholder objects. These represent classes currently 33 // Placeholder objects. These represent classes currently
34 // being loaded, as well as arrays of primitives. 34 // being loaded, as well as arrays of primitives.
35 // 35 //
36 36
37 class PlaceholderTable : public TwoOopHashtable { 37 class PlaceholderTable : public TwoOopHashtable<Symbol*> {
38 friend class VMStructs; 38 friend class VMStructs;
39 39
40 public: 40 public:
41 PlaceholderTable(int table_size); 41 PlaceholderTable(int table_size);
42 42
43 PlaceholderEntry* new_entry(int hash, symbolOop name, oop loader, bool havesupername, symbolOop supername); 43 PlaceholderEntry* new_entry(int hash, Symbol* name, oop loader, bool havesupername, Symbol* supername);
44 void free_entry(PlaceholderEntry* entry);
44 45
45 PlaceholderEntry* bucket(int i) { 46 PlaceholderEntry* bucket(int i) {
46 return (PlaceholderEntry*)Hashtable::bucket(i); 47 return (PlaceholderEntry*)Hashtable<Symbol*>::bucket(i);
47 } 48 }
48 49
49 PlaceholderEntry** bucket_addr(int i) { 50 PlaceholderEntry** bucket_addr(int i) {
50 return (PlaceholderEntry**)Hashtable::bucket_addr(i); 51 return (PlaceholderEntry**)Hashtable<Symbol*>::bucket_addr(i);
51 } 52 }
52 53
53 void add_entry(int index, PlaceholderEntry* new_entry) { 54 void add_entry(int index, PlaceholderEntry* new_entry) {
54 Hashtable::add_entry(index, (HashtableEntry*)new_entry); 55 Hashtable<Symbol*>::add_entry(index, (HashtableEntry<Symbol*>*)new_entry);
55 } 56 }
56 57
57 void add_entry(int index, unsigned int hash, symbolHandle name, 58 void add_entry(int index, unsigned int hash, Symbol* name,
58 Handle loader, bool havesupername, symbolHandle supername); 59 Handle loader, bool havesupername, Symbol* supername);
59 60
60 // This returns a symbolOop to match type for SystemDictionary 61 // This returns a Symbol* to match type for SystemDictionary
61 symbolOop find_entry(int index, unsigned int hash, 62 Symbol* find_entry(int index, unsigned int hash,
62 symbolHandle name, Handle loader); 63 Symbol* name, Handle loader);
63 64
64 PlaceholderEntry* get_entry(int index, unsigned int hash, 65 PlaceholderEntry* get_entry(int index, unsigned int hash,
65 symbolHandle name, Handle loader); 66 Symbol* name, Handle loader);
66 67
67 // caller to create a placeholder entry must enumerate an action 68 // caller to create a placeholder entry must enumerate an action
68 // caller claims ownership of that action 69 // caller claims ownership of that action
69 // For parallel classloading: 70 // For parallel classloading:
70 // multiple LOAD_INSTANCE threads can proceed in parallel 71 // multiple LOAD_INSTANCE threads can proceed in parallel
82 83
83 // find_and_add returns probe pointer - old or new 84 // find_and_add returns probe pointer - old or new
84 // If no entry exists, add a placeholder entry and push SeenThread 85 // If no entry exists, add a placeholder entry and push SeenThread
85 // If entry exists, reuse entry and push SeenThread for classloadAction 86 // If entry exists, reuse entry and push SeenThread for classloadAction
86 PlaceholderEntry* find_and_add(int index, unsigned int hash, 87 PlaceholderEntry* find_and_add(int index, unsigned int hash,
87 symbolHandle name, Handle loader, 88 Symbol* name, Handle loader,
88 classloadAction action, symbolHandle supername, 89 classloadAction action, Symbol* supername,
89 Thread* thread); 90 Thread* thread);
90 91
91 void remove_entry(int index, unsigned int hash, 92 void remove_entry(int index, unsigned int hash,
92 symbolHandle name, Handle loader); 93 Symbol* name, Handle loader);
93 94
94 // Remove placeholder information 95 // Remove placeholder information
95 void find_and_remove(int index, unsigned int hash, 96 void find_and_remove(int index, unsigned int hash,
96 symbolHandle name, Handle loader, Thread* thread); 97 Symbol* name, Handle loader, Thread* thread);
97 98
98 // GC support. 99 // GC support.
99 void oops_do(OopClosure* f); 100 void oops_do(OopClosure* f);
100 101
101 // JVMTI support 102 // JVMTI support
102 void entries_do(void f(symbolOop, oop)); 103 void entries_do(void f(Symbol*, oop));
103 104
104 #ifndef PRODUCT 105 #ifndef PRODUCT
105 void print(); 106 void print();
106 #endif 107 #endif
107 void verify(); 108 void verify();
149 // All threads examining the placeholder table must hold the 150 // All threads examining the placeholder table must hold the
150 // SystemDictionary_lock, so we don't need special precautions 151 // SystemDictionary_lock, so we don't need special precautions
151 // on store ordering here. 152 // on store ordering here.
152 // The system dictionary is the only user of this class. 153 // The system dictionary is the only user of this class.
153 154
154 class PlaceholderEntry : public HashtableEntry { 155 class PlaceholderEntry : public HashtableEntry<Symbol*> {
155 friend class VMStructs; 156 friend class VMStructs;
156 157
157 158
158 private: 159 private:
159 oop _loader; // initiating loader 160 oop _loader; // initiating loader
160 bool _havesupername; // distinguish between null supername, and unknown 161 bool _havesupername; // distinguish between null supername, and unknown
161 symbolOop _supername; 162 Symbol* _supername;
162 Thread* _definer; // owner of define token 163 Thread* _definer; // owner of define token
163 klassOop _instanceKlass; // instanceKlass from successful define 164 klassOop _instanceKlass; // instanceKlass from successful define
164 SeenThread* _superThreadQ; // doubly-linked queue of Threads loading a superclass for this class 165 SeenThread* _superThreadQ; // doubly-linked queue of Threads loading a superclass for this class
165 SeenThread* _loadInstanceThreadQ; // loadInstance thread 166 SeenThread* _loadInstanceThreadQ; // loadInstance thread
166 // can be multiple threads if classloader object lock broken by application 167 // can be multiple threads if classloader object lock broken by application
171 // _definer owns token 172 // _definer owns token
172 // queue waits for and returns results from _definer 173 // queue waits for and returns results from _definer
173 174
174 public: 175 public:
175 // Simple accessors, used only by SystemDictionary 176 // Simple accessors, used only by SystemDictionary
176 symbolOop klass() const { return (symbolOop)literal(); } 177 Symbol* klassname() const { return literal(); }
177 symbolOop* klass_addr() { return (symbolOop*)literal_addr(); }
178 178
179 oop loader() const { return _loader; } 179 oop loader() const { return _loader; }
180 void set_loader(oop loader) { _loader = loader; } 180 void set_loader(oop loader) { _loader = loader; }
181 oop* loader_addr() { return &_loader; } 181 oop* loader_addr() { return &_loader; }
182 182
183 bool havesupername() const { return _havesupername; } 183 bool havesupername() const { return _havesupername; }
184 void set_havesupername(bool havesupername) { _havesupername = havesupername; } 184 void set_havesupername(bool havesupername) { _havesupername = havesupername; }
185 185
186 symbolOop supername() const { return _supername; } 186 Symbol* supername() const { return _supername; }
187 void set_supername(symbolOop supername) { _supername = supername; } 187 void set_supername(Symbol* supername) {
188 symbolOop* supername_addr() { return &_supername; } 188 _supername = supername;
189 if (_supername != NULL) _supername->increment_refcount();
190 }
189 191
190 Thread* definer() const {return _definer; } 192 Thread* definer() const {return _definer; }
191 void set_definer(Thread* definer) { _definer = definer; } 193 void set_definer(Thread* definer) { _definer = definer; }
192 194
193 klassOop instanceKlass() const {return _instanceKlass; } 195 klassOop instanceKlass() const {return _instanceKlass; }
202 204
203 SeenThread* defineThreadQ() const { return _defineThreadQ; } 205 SeenThread* defineThreadQ() const { return _defineThreadQ; }
204 void set_defineThreadQ(SeenThread* SeenThread) { _defineThreadQ = SeenThread; } 206 void set_defineThreadQ(SeenThread* SeenThread) { _defineThreadQ = SeenThread; }
205 207
206 PlaceholderEntry* next() const { 208 PlaceholderEntry* next() const {
207 return (PlaceholderEntry*)HashtableEntry::next(); 209 return (PlaceholderEntry*)HashtableEntry<Symbol*>::next();
208 } 210 }
209 211
210 PlaceholderEntry** next_addr() { 212 PlaceholderEntry** next_addr() {
211 return (PlaceholderEntry**)HashtableEntry::next_addr(); 213 return (PlaceholderEntry**)HashtableEntry<Symbol*>::next_addr();
212 } 214 }
213 215
214 // Test for equality 216 // Test for equality
215 // Entries are unique for class/classloader name pair 217 // Entries are unique for class/classloader name pair
216 bool equals(symbolOop class_name, oop class_loader) const { 218 bool equals(Symbol* class_name, oop class_loader) const {
217 return (klass() == class_name && loader() == class_loader); 219 return (klassname() == class_name && loader() == class_loader);
218 } 220 }
219 221
220 SeenThread* actionToQueue(PlaceholderTable::classloadAction action) { 222 SeenThread* actionToQueue(PlaceholderTable::classloadAction action) {
221 SeenThread* queuehead; 223 SeenThread* queuehead;
222 switch (action) { 224 switch (action) {