Mercurial > hg > truffle
comparison src/share/vm/classfile/placeholders.hpp @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | d2a62e0f25eb |
children | 070d523b96a7 |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
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, Symbol* name, oop loader, bool havesupername, Symbol* supername); | 43 PlaceholderEntry* new_entry(int hash, Symbol* name, ClassLoaderData* loader_data, bool havesupername, Symbol* supername); |
44 void free_entry(PlaceholderEntry* entry); | 44 void free_entry(PlaceholderEntry* entry); |
45 | 45 |
46 PlaceholderEntry* bucket(int i) { | 46 PlaceholderEntry* bucket(int i) { |
47 return (PlaceholderEntry*)Hashtable<Symbol*, mtClass>::bucket(i); | 47 return (PlaceholderEntry*)Hashtable<Symbol*, mtClass>::bucket(i); |
48 } | 48 } |
54 void add_entry(int index, PlaceholderEntry* new_entry) { | 54 void add_entry(int index, PlaceholderEntry* new_entry) { |
55 Hashtable<Symbol*, mtClass>::add_entry(index, (HashtableEntry<Symbol*, mtClass>*)new_entry); | 55 Hashtable<Symbol*, mtClass>::add_entry(index, (HashtableEntry<Symbol*, mtClass>*)new_entry); |
56 } | 56 } |
57 | 57 |
58 void add_entry(int index, unsigned int hash, Symbol* name, | 58 void add_entry(int index, unsigned int hash, Symbol* name, |
59 Handle loader, bool havesupername, Symbol* supername); | 59 ClassLoaderData* loader_data, bool havesupername, Symbol* supername); |
60 | 60 |
61 // This returns a Symbol* to match type for SystemDictionary | 61 // This returns a Symbol* to match type for SystemDictionary |
62 Symbol* find_entry(int index, unsigned int hash, | 62 Symbol* find_entry(int index, unsigned int hash, |
63 Symbol* name, Handle loader); | 63 Symbol* name, ClassLoaderData* loader_data); |
64 | 64 |
65 PlaceholderEntry* get_entry(int index, unsigned int hash, | 65 PlaceholderEntry* get_entry(int index, unsigned int hash, |
66 Symbol* name, Handle loader); | 66 Symbol* name, ClassLoaderData* loader_data); |
67 | 67 |
68 // caller to create a placeholder entry must enumerate an action | 68 // caller to create a placeholder entry must enumerate an action |
69 // caller claims ownership of that action | 69 // caller claims ownership of that action |
70 // For parallel classloading: | 70 // For parallel classloading: |
71 // multiple LOAD_INSTANCE threads can proceed in parallel | 71 // multiple LOAD_INSTANCE threads can proceed in parallel |
83 | 83 |
84 // find_and_add returns probe pointer - old or new | 84 // find_and_add returns probe pointer - old or new |
85 // If no entry exists, add a placeholder entry and push SeenThread | 85 // If no entry exists, add a placeholder entry and push SeenThread |
86 // If entry exists, reuse entry and push SeenThread for classloadAction | 86 // If entry exists, reuse entry and push SeenThread for classloadAction |
87 PlaceholderEntry* find_and_add(int index, unsigned int hash, | 87 PlaceholderEntry* find_and_add(int index, unsigned int hash, |
88 Symbol* name, Handle loader, | 88 Symbol* name, ClassLoaderData* loader_data, |
89 classloadAction action, Symbol* supername, | 89 classloadAction action, Symbol* supername, |
90 Thread* thread); | 90 Thread* thread); |
91 | 91 |
92 void remove_entry(int index, unsigned int hash, | 92 void remove_entry(int index, unsigned int hash, |
93 Symbol* name, Handle loader); | 93 Symbol* name, ClassLoaderData* loader_data); |
94 | 94 |
95 // Remove placeholder information | 95 // Remove placeholder information |
96 void find_and_remove(int index, unsigned int hash, | 96 void find_and_remove(int index, unsigned int hash, |
97 Symbol* name, Handle loader, Thread* thread); | 97 Symbol* name, ClassLoaderData* loader_data, Thread* thread); |
98 | 98 |
99 // GC support. | 99 // GC support. |
100 void oops_do(OopClosure* f); | 100 void classes_do(KlassClosure* f); |
101 | 101 |
102 // JVMTI support | 102 // JVMTI support |
103 void entries_do(void f(Symbol*, oop)); | 103 void entries_do(void f(Symbol*)); |
104 | 104 |
105 #ifndef PRODUCT | 105 #ifndef PRODUCT |
106 void print(); | 106 void print(); |
107 #endif | 107 #endif |
108 void verify(); | 108 void verify(); |
155 class PlaceholderEntry : public HashtableEntry<Symbol*, mtClass> { | 155 class PlaceholderEntry : public HashtableEntry<Symbol*, mtClass> { |
156 friend class VMStructs; | 156 friend class VMStructs; |
157 | 157 |
158 | 158 |
159 private: | 159 private: |
160 oop _loader; // initiating loader | 160 ClassLoaderData* _loader_data; // initiating loader |
161 bool _havesupername; // distinguish between null supername, and unknown | 161 bool _havesupername; // distinguish between null supername, and unknown |
162 Symbol* _supername; | 162 Symbol* _supername; |
163 Thread* _definer; // owner of define token | 163 Thread* _definer; // owner of define token |
164 klassOop _instanceKlass; // instanceKlass from successful define | 164 Klass* _instanceKlass; // InstanceKlass from successful define |
165 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 |
166 SeenThread* _loadInstanceThreadQ; // loadInstance thread | 166 SeenThread* _loadInstanceThreadQ; // loadInstance thread |
167 // can be multiple threads if classloader object lock broken by application | 167 // can be multiple threads if classloader object lock broken by application |
168 // or if classloader supports parallel classloading | 168 // or if classloader supports parallel classloading |
169 | 169 |
174 | 174 |
175 public: | 175 public: |
176 // Simple accessors, used only by SystemDictionary | 176 // Simple accessors, used only by SystemDictionary |
177 Symbol* klassname() const { return literal(); } | 177 Symbol* klassname() const { return literal(); } |
178 | 178 |
179 oop loader() const { return _loader; } | 179 ClassLoaderData* loader_data() const { return _loader_data; } |
180 void set_loader(oop loader) { _loader = loader; } | 180 void set_loader_data(ClassLoaderData* loader_data) { _loader_data = loader_data; } |
181 oop* loader_addr() { return &_loader; } | |
182 | 181 |
183 bool havesupername() const { return _havesupername; } | 182 bool havesupername() const { return _havesupername; } |
184 void set_havesupername(bool havesupername) { _havesupername = havesupername; } | 183 void set_havesupername(bool havesupername) { _havesupername = havesupername; } |
185 | 184 |
186 Symbol* supername() const { return _supername; } | 185 Symbol* supername() const { return _supername; } |
190 } | 189 } |
191 | 190 |
192 Thread* definer() const {return _definer; } | 191 Thread* definer() const {return _definer; } |
193 void set_definer(Thread* definer) { _definer = definer; } | 192 void set_definer(Thread* definer) { _definer = definer; } |
194 | 193 |
195 klassOop instanceKlass() const {return _instanceKlass; } | 194 Klass* InstanceKlass() const {return _instanceKlass; } |
196 void set_instanceKlass(klassOop instanceKlass) { _instanceKlass = instanceKlass; } | 195 void set_instanceKlass(Klass* InstanceKlass) { _instanceKlass = InstanceKlass; } |
197 klassOop* instanceKlass_addr() { return &_instanceKlass; } | |
198 | 196 |
199 SeenThread* superThreadQ() const { return _superThreadQ; } | 197 SeenThread* superThreadQ() const { return _superThreadQ; } |
200 void set_superThreadQ(SeenThread* SeenThread) { _superThreadQ = SeenThread; } | 198 void set_superThreadQ(SeenThread* SeenThread) { _superThreadQ = SeenThread; } |
201 | 199 |
202 SeenThread* loadInstanceThreadQ() const { return _loadInstanceThreadQ; } | 200 SeenThread* loadInstanceThreadQ() const { return _loadInstanceThreadQ; } |
213 return (PlaceholderEntry**)HashtableEntry<Symbol*, mtClass>::next_addr(); | 211 return (PlaceholderEntry**)HashtableEntry<Symbol*, mtClass>::next_addr(); |
214 } | 212 } |
215 | 213 |
216 // Test for equality | 214 // Test for equality |
217 // Entries are unique for class/classloader name pair | 215 // Entries are unique for class/classloader name pair |
218 bool equals(Symbol* class_name, oop class_loader) const { | 216 bool equals(Symbol* class_name, ClassLoaderData* loader) const { |
219 return (klassname() == class_name && loader() == class_loader); | 217 return (klassname() == class_name && loader_data() == loader); |
220 } | 218 } |
221 | 219 |
222 SeenThread* actionToQueue(PlaceholderTable::classloadAction action) { | 220 SeenThread* actionToQueue(PlaceholderTable::classloadAction action) { |
223 SeenThread* queuehead; | 221 SeenThread* queuehead; |
224 switch (action) { | 222 switch (action) { |
329 return (actionToQueue(action) == NULL); | 327 return (actionToQueue(action) == NULL); |
330 } | 328 } |
331 | 329 |
332 // GC support | 330 // GC support |
333 // Applies "f->do_oop" to all root oops in the placeholder table. | 331 // Applies "f->do_oop" to all root oops in the placeholder table. |
334 void oops_do(OopClosure* blk); | 332 void classes_do(KlassClosure* closure); |
335 | 333 |
336 // Print method doesn't append a cr | 334 // Print method doesn't append a cr |
337 void print() const PRODUCT_RETURN; | 335 void print() const PRODUCT_RETURN; |
338 void verify() const; | 336 void verify() const; |
339 }; | 337 }; |