src/share/vm/oops/symbol.cpp

Print this page




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  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 "oops/symbol.hpp"
  30 #include "runtime/atomic.inline.hpp"
  31 #include "runtime/os.hpp"
  32 #include "memory/allocation.inline.hpp"
  33 #include "memory/resourceArea.hpp"
  34 
  35 Symbol::Symbol(const u1* name, int length, int refcount) : _refcount(refcount), _length(length) {


  36   _identity_hash = os::random();
  37   for (int i = 0; i < _length; i++) {
  38     byte_at_put(i, name[i]);
  39   }
  40 }
  41 
  42 void* Symbol::operator new(size_t sz, int len, TRAPS) {
  43   int alloc_size = size(len)*HeapWordSize;
  44   address res = (address) AllocateHeap(alloc_size, mtSymbol);
  45   return res;
  46 }
  47 
  48 void* Symbol::operator new(size_t sz, int len, Arena* arena, TRAPS) {
  49   int alloc_size = size(len)*HeapWordSize;
  50   address res = (address)arena->Amalloc(alloc_size);
  51   return res;
  52 }
  53 
  54 void* Symbol::operator new(size_t sz, int len, ClassLoaderData* loader_data, TRAPS) {
  55   address res;




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  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 "oops/symbol.hpp"
  30 #include "runtime/atomic.inline.hpp"
  31 #include "runtime/os.hpp"
  32 #include "memory/allocation.inline.hpp"
  33 #include "memory/resourceArea.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) {
  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) {
  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) {
  57   address res;


TPATH=src/share/vm/oops WDIR=/scratch/iklam/jdk/sym2b/webrev RTOP=../../../..