src/share/vm/oops/symbol.cpp

changeset 3682
fc9d8850ab8b
parent 2708
1d1603768966
child 3900
d2a62e0f25eb
     1.1 --- a/src/share/vm/oops/symbol.cpp	Thu Mar 15 13:37:13 2012 +0100
     1.2 +++ b/src/share/vm/oops/symbol.cpp	Fri Mar 23 11:16:05 2012 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -29,15 +29,25 @@
    1.11  #include "runtime/os.hpp"
    1.12  #include "memory/allocation.inline.hpp"
    1.13  
    1.14 -Symbol::Symbol(const u1* name, int length) : _refcount(0), _length(length) {
    1.15 +Symbol::Symbol(const u1* name, int length, int refcount) : _refcount(refcount), _length(length) {
    1.16    _identity_hash = os::random();
    1.17    for (int i = 0; i < _length; i++) {
    1.18      byte_at_put(i, name[i]);
    1.19    }
    1.20  }
    1.21  
    1.22 -void* Symbol::operator new(size_t size, int len) {
    1.23 -  return (void *) AllocateHeap(object_size(len) * HeapWordSize, "symbol");
    1.24 +void* Symbol::operator new(size_t sz, int len, TRAPS) {
    1.25 +  int alloc_size = object_size(len)*HeapWordSize;
    1.26 +  address res = (address) AllocateHeap(alloc_size, "symbol");
    1.27 +  DEBUG_ONLY(set_allocation_type(res, ResourceObj::C_HEAP);)
    1.28 +  return res;
    1.29 +}
    1.30 +
    1.31 +void* Symbol::operator new(size_t sz, int len, Arena* arena, TRAPS) {
    1.32 +  int alloc_size = object_size(len)*HeapWordSize;
    1.33 +  address res = (address)arena->Amalloc(alloc_size);
    1.34 +  DEBUG_ONLY(set_allocation_type(res, ResourceObj::ARENA);)
    1.35 +  return res;
    1.36  }
    1.37  
    1.38  // ------------------------------------------------------------------
    1.39 @@ -206,26 +216,5 @@
    1.40    }
    1.41  }
    1.42  
    1.43 -void Symbol::increment_refcount() {
    1.44 -  // Only increment the refcount if positive.  If negative either
    1.45 -  // overflow has occurred or it is a permanent symbol in a read only
    1.46 -  // shared archive.
    1.47 -  if (_refcount >= 0) {
    1.48 -    Atomic::inc(&_refcount);
    1.49 -    NOT_PRODUCT(Atomic::inc(&_total_count);)
    1.50 -  }
    1.51 -}
    1.52 -
    1.53 -void Symbol::decrement_refcount() {
    1.54 -  if (_refcount >= 0) {
    1.55 -    Atomic::dec(&_refcount);
    1.56 -#ifdef ASSERT
    1.57 -    if (_refcount < 0) {
    1.58 -      print();
    1.59 -      assert(false, "reference count underflow for symbol");
    1.60 -    }
    1.61 -#endif
    1.62 -  }
    1.63 -}
    1.64 -
    1.65 +// SymbolTable prints this in its statistics
    1.66  NOT_PRODUCT(int Symbol::_total_count = 0;)

mercurial