Mercurial > hg > graal-compiler
comparison src/share/vm/oops/symbol.cpp @ 5979:fc9d8850ab8b
7150058: Allocate symbols from null boot loader to an arena for NMT
Summary: Move symbol allocation to an arena so NMT doesn't have to track them at startup.
Reviewed-by: never, kamg, zgu
author | coleenp |
---|---|
date | Fri, 23 Mar 2012 11:16:05 -0400 |
parents | 1d1603768966 |
children | d2a62e0f25eb |
comparison
equal
deleted
inserted
replaced
5978:51612f0c0a79 | 5979:fc9d8850ab8b |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
27 #include "oops/oop.inline.hpp" | 27 #include "oops/oop.inline.hpp" |
28 #include "oops/symbol.hpp" | 28 #include "oops/symbol.hpp" |
29 #include "runtime/os.hpp" | 29 #include "runtime/os.hpp" |
30 #include "memory/allocation.inline.hpp" | 30 #include "memory/allocation.inline.hpp" |
31 | 31 |
32 Symbol::Symbol(const u1* name, int length) : _refcount(0), _length(length) { | 32 Symbol::Symbol(const u1* name, int length, int refcount) : _refcount(refcount), _length(length) { |
33 _identity_hash = os::random(); | 33 _identity_hash = os::random(); |
34 for (int i = 0; i < _length; i++) { | 34 for (int i = 0; i < _length; i++) { |
35 byte_at_put(i, name[i]); | 35 byte_at_put(i, name[i]); |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 void* Symbol::operator new(size_t size, int len) { | 39 void* Symbol::operator new(size_t sz, int len, TRAPS) { |
40 return (void *) AllocateHeap(object_size(len) * HeapWordSize, "symbol"); | 40 int alloc_size = object_size(len)*HeapWordSize; |
41 address res = (address) AllocateHeap(alloc_size, "symbol"); | |
42 DEBUG_ONLY(set_allocation_type(res, ResourceObj::C_HEAP);) | |
43 return res; | |
44 } | |
45 | |
46 void* Symbol::operator new(size_t sz, int len, Arena* arena, TRAPS) { | |
47 int alloc_size = object_size(len)*HeapWordSize; | |
48 address res = (address)arena->Amalloc(alloc_size); | |
49 DEBUG_ONLY(set_allocation_type(res, ResourceObj::ARENA);) | |
50 return res; | |
41 } | 51 } |
42 | 52 |
43 // ------------------------------------------------------------------ | 53 // ------------------------------------------------------------------ |
44 // Symbol::equals | 54 // Symbol::equals |
45 // | 55 // |
204 } | 214 } |
205 st->print("'"); | 215 st->print("'"); |
206 } | 216 } |
207 } | 217 } |
208 | 218 |
209 void Symbol::increment_refcount() { | 219 // SymbolTable prints this in its statistics |
210 // Only increment the refcount if positive. If negative either | |
211 // overflow has occurred or it is a permanent symbol in a read only | |
212 // shared archive. | |
213 if (_refcount >= 0) { | |
214 Atomic::inc(&_refcount); | |
215 NOT_PRODUCT(Atomic::inc(&_total_count);) | |
216 } | |
217 } | |
218 | |
219 void Symbol::decrement_refcount() { | |
220 if (_refcount >= 0) { | |
221 Atomic::dec(&_refcount); | |
222 #ifdef ASSERT | |
223 if (_refcount < 0) { | |
224 print(); | |
225 assert(false, "reference count underflow for symbol"); | |
226 } | |
227 #endif | |
228 } | |
229 } | |
230 | |
231 NOT_PRODUCT(int Symbol::_total_count = 0;) | 220 NOT_PRODUCT(int Symbol::_total_count = 0;) |