Mercurial > hg > truffle
comparison src/share/vm/classfile/dictionary.hpp @ 6197:d2a62e0f25eb
6995781: Native Memory Tracking (Phase 1)
7151532: DCmd for hotspot native memory tracking
Summary: Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd
Reviewed-by: acorn, coleenp, fparain
author | zgu |
---|---|
date | Thu, 28 Jun 2012 17:03:16 -0400 |
parents | 1d1603768966 |
children | da91efe96a93 |
comparison
equal
deleted
inserted
replaced
6174:74533f63b116 | 6197:d2a62e0f25eb |
---|---|
34 | 34 |
35 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 35 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
36 // The data structure for the system dictionary (and the shared system | 36 // The data structure for the system dictionary (and the shared system |
37 // dictionary). | 37 // dictionary). |
38 | 38 |
39 class Dictionary : public TwoOopHashtable<klassOop> { | 39 class Dictionary : public TwoOopHashtable<klassOop, mtClass> { |
40 friend class VMStructs; | 40 friend class VMStructs; |
41 private: | 41 private: |
42 // current iteration index. | 42 // current iteration index. |
43 static int _current_class_index; | 43 static int _current_class_index; |
44 // pointer to the current hash table entry. | 44 // pointer to the current hash table entry. |
46 | 46 |
47 DictionaryEntry* get_entry(int index, unsigned int hash, | 47 DictionaryEntry* get_entry(int index, unsigned int hash, |
48 Symbol* name, Handle loader); | 48 Symbol* name, Handle loader); |
49 | 49 |
50 DictionaryEntry* bucket(int i) { | 50 DictionaryEntry* bucket(int i) { |
51 return (DictionaryEntry*)Hashtable<klassOop>::bucket(i); | 51 return (DictionaryEntry*)Hashtable<klassOop, mtClass>::bucket(i); |
52 } | 52 } |
53 | 53 |
54 // The following method is not MT-safe and must be done under lock. | 54 // The following method is not MT-safe and must be done under lock. |
55 DictionaryEntry** bucket_addr(int i) { | 55 DictionaryEntry** bucket_addr(int i) { |
56 return (DictionaryEntry**)Hashtable<klassOop>::bucket_addr(i); | 56 return (DictionaryEntry**)Hashtable<klassOop, mtClass>::bucket_addr(i); |
57 } | 57 } |
58 | 58 |
59 void add_entry(int index, DictionaryEntry* new_entry) { | 59 void add_entry(int index, DictionaryEntry* new_entry) { |
60 Hashtable<klassOop>::add_entry(index, (HashtableEntry<oop>*)new_entry); | 60 Hashtable<klassOop, mtClass>::add_entry(index, (HashtableEntry<oop, mtClass>*)new_entry); |
61 } | 61 } |
62 | 62 |
63 | 63 |
64 public: | 64 public: |
65 Dictionary(int table_size); | 65 Dictionary(int table_size); |
66 Dictionary(int table_size, HashtableBucket* t, int number_of_entries); | 66 Dictionary(int table_size, HashtableBucket<mtClass>* t, int number_of_entries); |
67 | 67 |
68 DictionaryEntry* new_entry(unsigned int hash, klassOop klass, oop loader); | 68 DictionaryEntry* new_entry(unsigned int hash, klassOop klass, oop loader); |
69 | 69 |
70 DictionaryEntry* new_entry(); | 70 DictionaryEntry* new_entry(); |
71 | 71 |
127 }; | 127 }; |
128 | 128 |
129 // The following classes can be in dictionary.cpp, but we need these | 129 // The following classes can be in dictionary.cpp, but we need these |
130 // to be in header file so that SA's vmStructs can access. | 130 // to be in header file so that SA's vmStructs can access. |
131 | 131 |
132 class ProtectionDomainEntry :public CHeapObj { | 132 class ProtectionDomainEntry :public CHeapObj<mtClass> { |
133 friend class VMStructs; | 133 friend class VMStructs; |
134 public: | 134 public: |
135 ProtectionDomainEntry* _next; | 135 ProtectionDomainEntry* _next; |
136 oop _protection_domain; | 136 oop _protection_domain; |
137 | 137 |
145 }; | 145 }; |
146 | 146 |
147 // An entry in the system dictionary, this describes a class as | 147 // An entry in the system dictionary, this describes a class as |
148 // { klassOop, loader, protection_domain }. | 148 // { klassOop, loader, protection_domain }. |
149 | 149 |
150 class DictionaryEntry : public HashtableEntry<klassOop> { | 150 class DictionaryEntry : public HashtableEntry<klassOop, mtClass> { |
151 friend class VMStructs; | 151 friend class VMStructs; |
152 private: | 152 private: |
153 // Contains the set of approved protection domains that can access | 153 // Contains the set of approved protection domains that can access |
154 // this system dictionary entry. | 154 // this system dictionary entry. |
155 ProtectionDomainEntry* _pd_set; | 155 ProtectionDomainEntry* _pd_set; |
164 | 164 |
165 klassOop klass() const { return (klassOop)literal(); } | 165 klassOop klass() const { return (klassOop)literal(); } |
166 klassOop* klass_addr() { return (klassOop*)literal_addr(); } | 166 klassOop* klass_addr() { return (klassOop*)literal_addr(); } |
167 | 167 |
168 DictionaryEntry* next() const { | 168 DictionaryEntry* next() const { |
169 return (DictionaryEntry*)HashtableEntry<klassOop>::next(); | 169 return (DictionaryEntry*)HashtableEntry<klassOop, mtClass>::next(); |
170 } | 170 } |
171 | 171 |
172 DictionaryEntry** next_addr() { | 172 DictionaryEntry** next_addr() { |
173 return (DictionaryEntry**)HashtableEntry<klassOop>::next_addr(); | 173 return (DictionaryEntry**)HashtableEntry<klassOop, mtClass>::next_addr(); |
174 } | 174 } |
175 | 175 |
176 oop loader() const { return _loader; } | 176 oop loader() const { return _loader; } |
177 void set_loader(oop loader) { _loader = loader; } | 177 void set_loader(oop loader) { _loader = loader; } |
178 oop* loader_addr() { return &_loader; } | 178 oop* loader_addr() { return &_loader; } |
226 } | 226 } |
227 }; | 227 }; |
228 | 228 |
229 // Entry in a SymbolPropertyTable, mapping a single Symbol* | 229 // Entry in a SymbolPropertyTable, mapping a single Symbol* |
230 // to a managed and an unmanaged pointer. | 230 // to a managed and an unmanaged pointer. |
231 class SymbolPropertyEntry : public HashtableEntry<Symbol*> { | 231 class SymbolPropertyEntry : public HashtableEntry<Symbol*, mtSymbol> { |
232 friend class VMStructs; | 232 friend class VMStructs; |
233 private: | 233 private: |
234 intptr_t _symbol_mode; // secondary key | 234 intptr_t _symbol_mode; // secondary key |
235 oop _property_oop; | 235 oop _property_oop; |
236 address _property_data; | 236 address _property_data; |
246 | 246 |
247 address property_data() const { return _property_data; } | 247 address property_data() const { return _property_data; } |
248 void set_property_data(address p) { _property_data = p; } | 248 void set_property_data(address p) { _property_data = p; } |
249 | 249 |
250 SymbolPropertyEntry* next() const { | 250 SymbolPropertyEntry* next() const { |
251 return (SymbolPropertyEntry*)HashtableEntry<Symbol*>::next(); | 251 return (SymbolPropertyEntry*)HashtableEntry<Symbol*, mtSymbol>::next(); |
252 } | 252 } |
253 | 253 |
254 SymbolPropertyEntry** next_addr() { | 254 SymbolPropertyEntry** next_addr() { |
255 return (SymbolPropertyEntry**)HashtableEntry<Symbol*>::next_addr(); | 255 return (SymbolPropertyEntry**)HashtableEntry<Symbol*, mtSymbol>::next_addr(); |
256 } | 256 } |
257 | 257 |
258 oop* property_oop_addr() { return &_property_oop; } | 258 oop* property_oop_addr() { return &_property_oop; } |
259 | 259 |
260 void print_on(outputStream* st) const { | 260 void print_on(outputStream* st) const { |
276 }; | 276 }; |
277 | 277 |
278 // A system-internal mapping of symbols to pointers, both managed | 278 // A system-internal mapping of symbols to pointers, both managed |
279 // and unmanaged. Used to record the auto-generation of each method | 279 // and unmanaged. Used to record the auto-generation of each method |
280 // MethodHandle.invoke(S)T, for all signatures (S)T. | 280 // MethodHandle.invoke(S)T, for all signatures (S)T. |
281 class SymbolPropertyTable : public Hashtable<Symbol*> { | 281 class SymbolPropertyTable : public Hashtable<Symbol*, mtSymbol> { |
282 friend class VMStructs; | 282 friend class VMStructs; |
283 private: | 283 private: |
284 SymbolPropertyEntry* bucket(int i) { | 284 SymbolPropertyEntry* bucket(int i) { |
285 return (SymbolPropertyEntry*) Hashtable<Symbol*>::bucket(i); | 285 return (SymbolPropertyEntry*) Hashtable<Symbol*, mtSymbol>::bucket(i); |
286 } | 286 } |
287 | 287 |
288 // The following method is not MT-safe and must be done under lock. | 288 // The following method is not MT-safe and must be done under lock. |
289 SymbolPropertyEntry** bucket_addr(int i) { | 289 SymbolPropertyEntry** bucket_addr(int i) { |
290 return (SymbolPropertyEntry**) Hashtable<Symbol*>::bucket_addr(i); | 290 return (SymbolPropertyEntry**) Hashtable<Symbol*, mtSymbol>::bucket_addr(i); |
291 } | 291 } |
292 | 292 |
293 void add_entry(int index, SymbolPropertyEntry* new_entry) { | 293 void add_entry(int index, SymbolPropertyEntry* new_entry) { |
294 ShouldNotReachHere(); | 294 ShouldNotReachHere(); |
295 } | 295 } |
296 void set_entry(int index, SymbolPropertyEntry* new_entry) { | 296 void set_entry(int index, SymbolPropertyEntry* new_entry) { |
297 ShouldNotReachHere(); | 297 ShouldNotReachHere(); |
298 } | 298 } |
299 | 299 |
300 SymbolPropertyEntry* new_entry(unsigned int hash, Symbol* symbol, intptr_t symbol_mode) { | 300 SymbolPropertyEntry* new_entry(unsigned int hash, Symbol* symbol, intptr_t symbol_mode) { |
301 SymbolPropertyEntry* entry = (SymbolPropertyEntry*) Hashtable<Symbol*>::new_entry(hash, symbol); | 301 SymbolPropertyEntry* entry = (SymbolPropertyEntry*) Hashtable<Symbol*, mtSymbol>::new_entry(hash, symbol); |
302 // Hashtable with Symbol* literal must increment and decrement refcount. | 302 // Hashtable with Symbol* literal must increment and decrement refcount. |
303 symbol->increment_refcount(); | 303 symbol->increment_refcount(); |
304 entry->set_symbol_mode(symbol_mode); | 304 entry->set_symbol_mode(symbol_mode); |
305 entry->set_property_oop(NULL); | 305 entry->set_property_oop(NULL); |
306 entry->set_property_data(NULL); | 306 entry->set_property_data(NULL); |
307 return entry; | 307 return entry; |
308 } | 308 } |
309 | 309 |
310 public: | 310 public: |
311 SymbolPropertyTable(int table_size); | 311 SymbolPropertyTable(int table_size); |
312 SymbolPropertyTable(int table_size, HashtableBucket* t, int number_of_entries); | 312 SymbolPropertyTable(int table_size, HashtableBucket<mtSymbol>* t, int number_of_entries); |
313 | 313 |
314 void free_entry(SymbolPropertyEntry* entry) { | 314 void free_entry(SymbolPropertyEntry* entry) { |
315 // decrement Symbol refcount here because hashtable doesn't. | 315 // decrement Symbol refcount here because hashtable doesn't. |
316 entry->literal()->decrement_refcount(); | 316 entry->literal()->decrement_refcount(); |
317 Hashtable<Symbol*>::free_entry(entry); | 317 Hashtable<Symbol*, mtSymbol>::free_entry(entry); |
318 } | 318 } |
319 | 319 |
320 unsigned int compute_hash(Symbol* sym, intptr_t symbol_mode) { | 320 unsigned int compute_hash(Symbol* sym, intptr_t symbol_mode) { |
321 // Use the regular identity_hash. | 321 // Use the regular identity_hash. |
322 return Hashtable<Symbol*>::compute_hash(sym) ^ symbol_mode; | 322 return Hashtable<Symbol*, mtSymbol>::compute_hash(sym) ^ symbol_mode; |
323 } | 323 } |
324 | 324 |
325 int index_for(Symbol* name, intptr_t symbol_mode) { | 325 int index_for(Symbol* name, intptr_t symbol_mode) { |
326 return hash_to_index(compute_hash(name, symbol_mode)); | 326 return hash_to_index(compute_hash(name, symbol_mode)); |
327 } | 327 } |