comparison src/share/vm/oops/symbol.cpp @ 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 1d7922586cf6
children bd7a7ce2e264
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
22 * 22 *
23 */ 23 */
24 24
25 25
26 #include "precompiled.hpp" 26 #include "precompiled.hpp"
27 #include "oops/oop.inline.hpp" 27 #include "classfile/altHashing.hpp"
28 #include "classfile/classLoaderData.hpp"
28 #include "oops/symbol.hpp" 29 #include "oops/symbol.hpp"
29 #include "runtime/os.hpp" 30 #include "runtime/os.hpp"
30 #include "memory/allocation.inline.hpp" 31 #include "memory/allocation.inline.hpp"
32 #include "memory/resourceArea.hpp"
31 33
32 Symbol::Symbol(const u1* name, int length, int refcount) : _refcount(refcount), _length(length) { 34 Symbol::Symbol(const u1* name, int length, int refcount) : _refcount(refcount), _length(length) {
33 _identity_hash = os::random(); 35 _identity_hash = os::random();
34 for (int i = 0; i < _length; i++) { 36 for (int i = 0; i < _length; i++) {
35 byte_at_put(i, name[i]); 37 byte_at_put(i, name[i]);
36 } 38 }
37 } 39 }
38 40
39 void* Symbol::operator new(size_t sz, int len, TRAPS) { 41 void* Symbol::operator new(size_t sz, int len, TRAPS) {
40 int alloc_size = object_size(len)*HeapWordSize; 42 int alloc_size = size(len)*HeapWordSize;
41 address res = (address) AllocateHeap(alloc_size, mtSymbol); 43 address res = (address) AllocateHeap(alloc_size, mtSymbol);
42 DEBUG_ONLY(set_allocation_type(res, ResourceObj::C_HEAP);)
43 return res; 44 return res;
44 } 45 }
45 46
46 void* Symbol::operator new(size_t sz, int len, Arena* arena, TRAPS) { 47 void* Symbol::operator new(size_t sz, int len, Arena* arena, TRAPS) {
47 int alloc_size = object_size(len)*HeapWordSize; 48 int alloc_size = size(len)*HeapWordSize;
48 address res = (address)arena->Amalloc(alloc_size); 49 address res = (address)arena->Amalloc(alloc_size);
49 DEBUG_ONLY(set_allocation_type(res, ResourceObj::ARENA);)
50 return res; 50 return res;
51 }
52
53 void* Symbol::operator new(size_t sz, int len, ClassLoaderData* loader_data, TRAPS) {
54 address res;
55 int alloc_size = size(len)*HeapWordSize;
56 res = (address) Metaspace::allocate(loader_data, size(len), true,
57 Metaspace::NonClassType, CHECK_NULL);
58 return res;
59 }
60
61 void Symbol::operator delete(void *p) {
62 assert(((Symbol*)p)->refcount() == 0, "should not call this");
63 FreeHeap(p);
51 } 64 }
52 65
53 // ------------------------------------------------------------------ 66 // ------------------------------------------------------------------
54 // Symbol::equals 67 // Symbol::equals
55 // 68 //
189 } 202 }
190 } 203 }
191 return str; 204 return str;
192 } 205 }
193 206
207 // Alternate hashing for unbalanced symbol tables.
208 unsigned int Symbol::new_hash(jint seed) {
209 ResourceMark rm;
210 // Use alternate hashing algorithm on this symbol.
211 return AltHashing::murmur3_32(seed, (const jbyte*)as_C_string(), utf8_length());
212 }
194 213
195 void Symbol::print_on(outputStream* st) const { 214 void Symbol::print_on(outputStream* st) const {
196 if (this == NULL) { 215 if (this == NULL) {
197 st->print_cr("NULL"); 216 st->print_cr("NULL");
198 } else { 217 } else {