src/share/vm/oops/symbol.cpp

Print this page
rev 6676 : 8044775: Improve usage of umbrella header atomic.inline.hpp.
Reviewed-by: stefank, kvn


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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) 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;




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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 "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;