Mercurial > hg > truffle
comparison src/share/vm/oops/symbol.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 | fc9d8850ab8b |
children | bd7a7ce2e264 |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
34 | 34 |
35 // Reference counting | 35 // Reference counting |
36 // | 36 // |
37 // All Symbols are allocated and added to the SymbolTable. | 37 // All Symbols are allocated and added to the SymbolTable. |
38 // When a class is unloaded, the reference counts of the Symbol pointers in | 38 // When a class is unloaded, the reference counts of the Symbol pointers in |
39 // the ConstantPool and in instanceKlass (see release_C_heap_structures) are | 39 // the ConstantPool and in InstanceKlass (see release_C_heap_structures) are |
40 // decremented. When the reference count for a Symbol goes to 0, the garbage | 40 // decremented. When the reference count for a Symbol goes to 0, the garbage |
41 // collector can free the Symbol and remove it from the SymbolTable. | 41 // collector can free the Symbol and remove it from the SymbolTable. |
42 // | 42 // |
43 // 0) Symbols need to be reference counted when a pointer to the Symbol is | 43 // 0) Symbols need to be reference counted when a pointer to the Symbol is |
44 // saved in persistent storage. This does not include the pointer | 44 // saved in persistent storage. This does not include the pointer |
94 // ClassFileParser::parseClassFile() where parsed_name is used in the cleanup | 94 // ClassFileParser::parseClassFile() where parsed_name is used in the cleanup |
95 // after a failed attempt to load a class. Here parsed_name is a | 95 // after a failed attempt to load a class. Here parsed_name is a |
96 // TempNewSymbol (passed in as a parameter) so the reference count on its symbol | 96 // TempNewSymbol (passed in as a parameter) so the reference count on its symbol |
97 // will be decremented when it goes out of scope. | 97 // will be decremented when it goes out of scope. |
98 | 98 |
99 class Symbol : public ResourceObj { | 99 |
100 // This cannot be inherited from ResourceObj because it cannot have a vtable. | |
101 // Since sometimes this is allocated from Metadata, pick a base allocation | |
102 // type without virtual functions. | |
103 class ClassLoaderData; | |
104 | |
105 class Symbol : public MetaspaceObj { | |
100 friend class VMStructs; | 106 friend class VMStructs; |
101 friend class SymbolTable; | 107 friend class SymbolTable; |
102 friend class MoveSymbols; | 108 friend class MoveSymbols; |
103 private: | 109 private: |
104 volatile int _refcount; | 110 volatile int _refcount; |
109 enum { | 115 enum { |
110 // max_symbol_length is constrained by type of _length | 116 // max_symbol_length is constrained by type of _length |
111 max_symbol_length = (1 << 16) -1 | 117 max_symbol_length = (1 << 16) -1 |
112 }; | 118 }; |
113 | 119 |
114 static int object_size(int length) { | 120 static int size(int length) { |
115 size_t size = heap_word_size(sizeof(Symbol) + (length > 0 ? length - 1 : 0)); | 121 size_t sz = heap_word_size(sizeof(Symbol) + (length > 0 ? length - 1 : 0)); |
116 return align_object_size(size); | 122 return align_object_size(sz); |
117 } | 123 } |
118 | 124 |
119 void byte_at_put(int index, int value) { | 125 void byte_at_put(int index, int value) { |
120 assert(index >=0 && index < _length, "symbol index overflow"); | 126 assert(index >=0 && index < _length, "symbol index overflow"); |
121 _body[index] = value; | 127 _body[index] = value; |
122 } | 128 } |
123 | 129 |
124 Symbol(const u1* name, int length, int refcount); | 130 Symbol(const u1* name, int length, int refcount); |
125 void* operator new(size_t size, int len, TRAPS); | 131 void* operator new(size_t size, int len, TRAPS); |
126 void* operator new(size_t size, int len, Arena* arena, TRAPS); | 132 void* operator new(size_t size, int len, Arena* arena, TRAPS); |
133 void* operator new(size_t size, int len, ClassLoaderData* loader_data, TRAPS); | |
134 | |
135 void operator delete(void* p); | |
127 | 136 |
128 public: | 137 public: |
129 // Low-level access (used with care, since not GC-safe) | 138 // Low-level access (used with care, since not GC-safe) |
130 const jbyte* base() const { return &_body[0]; } | 139 const jbyte* base() const { return &_body[0]; } |
131 | 140 |
132 int object_size() { return object_size(utf8_length()); } | 141 int size() { return size(utf8_length()); } |
133 | 142 |
134 // Returns the largest size symbol we can safely hold. | 143 // Returns the largest size symbol we can safely hold. |
135 static int max_length() { return max_symbol_length; } | 144 static int max_length() { return max_symbol_length; } |
136 | 145 |
137 int identity_hash() { return _identity_hash; } | 146 int identity_hash() { return _identity_hash; } |
147 | |
148 // For symbol table alternate hashing | |
149 unsigned int new_hash(jint seed); | |
138 | 150 |
139 // Reference counting. See comments above this class for when to use. | 151 // Reference counting. See comments above this class for when to use. |
140 int refcount() const { return _refcount; } | 152 int refcount() const { return _refcount; } |
141 inline void increment_refcount(); | 153 inline void increment_refcount(); |
142 inline void decrement_refcount(); | 154 inline void decrement_refcount(); |