Mercurial > hg > truffle
annotate src/share/vm/oops/symbol.cpp @ 13892:5e19b2f0e2f2
Increase TruffleGraphMaxNodes.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 06 Feb 2014 17:31:48 +0100 |
parents | 9758d9f36299 |
children | cd6b3f1a94ff |
rev | line source |
---|---|
0 | 1 /* |
8675
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1138
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1138
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1138
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
25 |
1972 | 26 #include "precompiled.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
27 #include "classfile/altHashing.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
28 #include "classfile/classLoaderData.hpp" |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
29 #include "oops/symbol.hpp" |
8675
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
30 #include "runtime/atomic.inline.hpp" |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
31 #include "runtime/os.hpp" |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
32 #include "memory/allocation.inline.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
33 #include "memory/resourceArea.hpp" |
0 | 34 |
11033
d9eed26d638a
8009575: Reduce Symbol::_refcount from 4 bytes to 2 bytes
iklam
parents:
10376
diff
changeset
|
35 Symbol::Symbol(const u1* name, int length, int refcount) { |
d9eed26d638a
8009575: Reduce Symbol::_refcount from 4 bytes to 2 bytes
iklam
parents:
10376
diff
changeset
|
36 _refcount = refcount; |
d9eed26d638a
8009575: Reduce Symbol::_refcount from 4 bytes to 2 bytes
iklam
parents:
10376
diff
changeset
|
37 _length = length; |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
38 _identity_hash = os::random(); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
39 for (int i = 0; i < _length; i++) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
40 byte_at_put(i, name[i]); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
41 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
42 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
43 |
12146
9758d9f36299
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
11033
diff
changeset
|
44 void* Symbol::operator new(size_t sz, int len, TRAPS) throw() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
45 int alloc_size = size(len)*HeapWordSize; |
6197 | 46 address res = (address) AllocateHeap(alloc_size, mtSymbol); |
5979
fc9d8850ab8b
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
2426
diff
changeset
|
47 return res; |
fc9d8850ab8b
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
2426
diff
changeset
|
48 } |
fc9d8850ab8b
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
2426
diff
changeset
|
49 |
12146
9758d9f36299
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
11033
diff
changeset
|
50 void* Symbol::operator new(size_t sz, int len, Arena* arena, TRAPS) throw() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
51 int alloc_size = size(len)*HeapWordSize; |
5979
fc9d8850ab8b
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
2426
diff
changeset
|
52 address res = (address)arena->Amalloc(alloc_size); |
fc9d8850ab8b
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
2426
diff
changeset
|
53 return res; |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
54 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
55 |
12146
9758d9f36299
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
11033
diff
changeset
|
56 void* Symbol::operator new(size_t sz, int len, ClassLoaderData* loader_data, TRAPS) throw() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
57 address res; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
58 int alloc_size = size(len)*HeapWordSize; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
59 res = (address) Metaspace::allocate(loader_data, size(len), true, |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
8851
diff
changeset
|
60 MetaspaceObj::SymbolType, CHECK_NULL); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
61 return res; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
62 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
63 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
64 void Symbol::operator delete(void *p) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
65 assert(((Symbol*)p)->refcount() == 0, "should not call this"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
66 FreeHeap(p); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
67 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
68 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
69 // ------------------------------------------------------------------ |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
70 // Symbol::equals |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
71 // |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
72 // Compares the symbol with a string of the given length. |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
73 bool Symbol::equals(const char* str, int len) const { |
0 | 74 int l = utf8_length(); |
75 if (l != len) return false; | |
76 while (l-- > 0) { | |
77 if (str[l] != (char) byte_at(l)) | |
78 return false; | |
79 } | |
80 assert(l == -1, "we should be at the beginning"); | |
81 return true; | |
82 } | |
83 | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
84 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
85 // ------------------------------------------------------------------ |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
86 // Symbol::starts_with |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
87 // |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
88 // Tests if the symbol starts with the specified prefix of the given |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
89 // length. |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
90 bool Symbol::starts_with(const char* prefix, int len) const { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
91 if (len > utf8_length()) return false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
92 while (len-- > 0) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
93 if (prefix[len] != (char) byte_at(len)) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
94 return false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
95 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
96 assert(len == -1, "we should be at the beginning"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
97 return true; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
98 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
99 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
100 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
101 // ------------------------------------------------------------------ |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
102 // Symbol::index_of |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
103 // |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
104 // Finds if the given string is a substring of this symbol's utf8 bytes. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
105 // Return -1 on failure. Otherwise return the first index where str occurs. |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
106 int Symbol::index_of_at(int i, const char* str, int len) const { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
107 assert(i >= 0 && i <= utf8_length(), "oob"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
108 if (len <= 0) return 0; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
109 char first_char = str[0]; |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
110 address bytes = (address) ((Symbol*)this)->base(); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
111 address limit = bytes + utf8_length() - len; // inclusive limit |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
112 address scan = bytes + i; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
113 if (scan > limit) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
114 return -1; |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
115 for (; scan <= limit; scan++) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
116 scan = (address) memchr(scan, first_char, (limit + 1 - scan)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
117 if (scan == NULL) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
118 return -1; // not found |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
119 assert(scan >= bytes+i && scan <= limit, "scan oob"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
120 if (memcmp(scan, str, len) == 0) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
121 return (int)(scan - bytes); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
122 } |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
123 return -1; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
124 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
125 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
222
diff
changeset
|
126 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
127 char* Symbol::as_C_string(char* buf, int size) const { |
0 | 128 if (size > 0) { |
129 int len = MIN2(size - 1, utf8_length()); | |
130 for (int i = 0; i < len; i++) { | |
131 buf[i] = byte_at(i); | |
132 } | |
133 buf[len] = '\0'; | |
134 } | |
135 return buf; | |
136 } | |
137 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
138 char* Symbol::as_C_string() const { |
0 | 139 int len = utf8_length(); |
140 char* str = NEW_RESOURCE_ARRAY(char, len + 1); | |
141 return as_C_string(str, len + 1); | |
142 } | |
143 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
144 char* Symbol::as_C_string_flexible_buffer(Thread* t, |
0 | 145 char* buf, int size) const { |
146 char* str; | |
147 int len = utf8_length(); | |
148 int buf_len = len + 1; | |
149 if (size < buf_len) { | |
150 str = NEW_RESOURCE_ARRAY(char, buf_len); | |
151 } else { | |
152 str = buf; | |
153 } | |
154 return as_C_string(str, buf_len); | |
155 } | |
156 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
157 void Symbol::print_symbol_on(outputStream* st) const { |
7990
fcc9e7681d63
8006410: allocating without ResourceMark when CompileCommand was specified
vlivanov
parents:
6972
diff
changeset
|
158 ResourceMark rm; |
0 | 159 st = st ? st : tty; |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
160 st->print("%s", as_quoted_ascii()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
161 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
162 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
163 char* Symbol::as_quoted_ascii() const { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
164 const char *ptr = (const char *)&_body[0]; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
165 int quoted_length = UTF8::quoted_ascii_length(ptr, utf8_length()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
166 char* result = NEW_RESOURCE_ARRAY(char, quoted_length + 1); |
8851
8c03fc47511d
8011048: Possible reading from unmapped memory in UTF8::as_quoted_ascii()
iklam
parents:
8675
diff
changeset
|
167 UTF8::as_quoted_ascii(ptr, utf8_length(), result, quoted_length + 1); |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
168 return result; |
0 | 169 } |
170 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
171 jchar* Symbol::as_unicode(int& length) const { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
172 Symbol* this_ptr = (Symbol*)this; |
0 | 173 length = UTF8::unicode_length((char*)this_ptr->bytes(), utf8_length()); |
174 jchar* result = NEW_RESOURCE_ARRAY(jchar, length); | |
175 if (length > 0) { | |
176 UTF8::convert_to_unicode((char*)this_ptr->bytes(), result, length); | |
177 } | |
178 return result; | |
179 } | |
180 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
181 const char* Symbol::as_klass_external_name(char* buf, int size) const { |
0 | 182 if (size > 0) { |
183 char* str = as_C_string(buf, size); | |
184 int length = (int)strlen(str); | |
185 // Turn all '/'s into '.'s (also for array klasses) | |
186 for (int index = 0; index < length; index++) { | |
187 if (str[index] == '/') { | |
188 str[index] = '.'; | |
189 } | |
190 } | |
191 return str; | |
192 } else { | |
193 return buf; | |
194 } | |
195 } | |
196 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
197 const char* Symbol::as_klass_external_name() const { |
0 | 198 char* str = as_C_string(); |
199 int length = (int)strlen(str); | |
200 // Turn all '/'s into '.'s (also for array klasses) | |
201 for (int index = 0; index < length; index++) { | |
202 if (str[index] == '/') { | |
203 str[index] = '.'; | |
204 } | |
205 } | |
206 return str; | |
207 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
208 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
209 // Alternate hashing for unbalanced symbol tables. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
210 unsigned int Symbol::new_hash(jint seed) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
211 ResourceMark rm; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
212 // Use alternate hashing algorithm on this symbol. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
213 return AltHashing::murmur3_32(seed, (const jbyte*)as_C_string(), utf8_length()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
214 } |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
215 |
8675
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
216 void Symbol::increment_refcount() { |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
217 // Only increment the refcount if positive. If negative either |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
218 // overflow has occurred or it is a permanent symbol in a read only |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
219 // shared archive. |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
220 if (_refcount >= 0) { |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
221 Atomic::inc(&_refcount); |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
222 NOT_PRODUCT(Atomic::inc(&_total_count);) |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
223 } |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
224 } |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
225 |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
226 void Symbol::decrement_refcount() { |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
227 if (_refcount >= 0) { |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
228 Atomic::dec(&_refcount); |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
229 #ifdef ASSERT |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
230 if (_refcount < 0) { |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
231 print(); |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
232 assert(false, "reference count underflow for symbol"); |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
233 } |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
234 #endif |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
235 } |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
236 } |
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7990
diff
changeset
|
237 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
238 void Symbol::print_on(outputStream* st) const { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
239 if (this == NULL) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
240 st->print_cr("NULL"); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
241 } else { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
242 st->print("Symbol: '"); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
243 print_symbol_on(st); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
244 st->print("'"); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
245 st->print(" count %d", refcount()); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
246 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
247 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
248 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
249 // The print_value functions are present in all builds, to support the |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
250 // disassembler and error reporting. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
251 void Symbol::print_value_on(outputStream* st) const { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
252 if (this == NULL) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
253 st->print("NULL"); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
254 } else { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
255 st->print("'"); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
256 for (int i = 0; i < utf8_length(); i++) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
257 st->print("%c", byte_at(i)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
258 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
259 st->print("'"); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
260 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
261 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
262 |
5979
fc9d8850ab8b
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
2426
diff
changeset
|
263 // SymbolTable prints this in its statistics |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
264 NOT_PRODUCT(int Symbol::_total_count = 0;) |