< prev index next >

src/share/vm/oops/symbol.cpp

Print this page




  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 
  26 #include "precompiled.hpp"
  27 #include "classfile/altHashing.hpp"
  28 #include "classfile/classLoaderData.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "memory/resourceArea.hpp"
  31 #include "oops/symbol.hpp"
  32 #include "runtime/atomic.inline.hpp"
  33 #include "runtime/os.hpp"
  34 
  35 Symbol::Symbol(const u1* name, int length, int refcount) {
  36   _refcount = refcount;
  37   _length = length;
  38   _identity_hash = os::random();
  39   for (int i = 0; i < _length; i++) {
  40     byte_at_put(i, name[i]);
  41   }
  42 }
  43 
  44 void* Symbol::operator new(size_t sz, int len, TRAPS) throw() {
  45   int alloc_size = size(len)*HeapWordSize;
  46   address res = (address) AllocateHeap(alloc_size, mtSymbol);
  47   return res;
  48 }
  49 
  50 void* Symbol::operator new(size_t sz, int len, Arena* arena, TRAPS) throw() {
  51   int alloc_size = size(len)*HeapWordSize;
  52   address res = (address)arena->Amalloc(alloc_size);
  53   return res;
  54 }
  55 
  56 void* Symbol::operator new(size_t sz, int len, ClassLoaderData* loader_data, TRAPS) throw() {
  57   address res;
  58   int alloc_size = size(len)*HeapWordSize;




  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 
  26 #include "precompiled.hpp"
  27 #include "classfile/altHashing.hpp"
  28 #include "classfile/classLoaderData.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "memory/resourceArea.hpp"
  31 #include "oops/symbol.hpp"
  32 #include "runtime/atomic.inline.hpp"
  33 #include "runtime/os.hpp"
  34 
  35 Symbol::Symbol(const u1* name, int length, int refcount) {
  36   _refcount = refcount;
  37   _length = length;
  38   _identity_hash = (short)os::random();
  39   for (int i = 0; i < _length; i++) {
  40     byte_at_put(i, name[i]);
  41   }
  42 }
  43 
  44 void* Symbol::operator new(size_t sz, int len, TRAPS) throw() {
  45   int alloc_size = size(len)*HeapWordSize;
  46   address res = (address) AllocateHeap(alloc_size, mtSymbol);
  47   return res;
  48 }
  49 
  50 void* Symbol::operator new(size_t sz, int len, Arena* arena, TRAPS) throw() {
  51   int alloc_size = size(len)*HeapWordSize;
  52   address res = (address)arena->Amalloc(alloc_size);
  53   return res;
  54 }
  55 
  56 void* Symbol::operator new(size_t sz, int len, ClassLoaderData* loader_data, TRAPS) throw() {
  57   address res;
  58   int alloc_size = size(len)*HeapWordSize;


< prev index next >