Mercurial > hg > truffle
annotate src/share/vm/oops/symbol.hpp @ 4597:8bc6f680a88d
fixed visual studio project files
author | Christian Haeubl <christian.haeubl@oracle.com> |
---|---|
date | Tue, 14 Feb 2012 15:01:36 -0800 |
parents | 1d1603768966 |
children | fc9d8850ab8b |
rev | line source |
---|---|
0 | 1 /* |
2426
1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
2177
diff
changeset
|
2 * Copyright (c) 1997, 2011, 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 #ifndef SHARE_VM_OOPS_SYMBOL_HPP |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
26 #define SHARE_VM_OOPS_SYMBOL_HPP |
1972 | 27 |
28 #include "utilities/utf8.hpp" | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
29 #include "memory/allocation.hpp" |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
30 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
31 // A Symbol is a canonicalized string. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
32 // All Symbols reside in global SymbolTable and are reference counted. |
1972 | 33 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
34 // Reference counting |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
35 // |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
36 // All Symbols are allocated and added to the SymbolTable. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
37 // When a class is unloaded, the reference counts of the Symbol pointers in |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
38 // the ConstantPool and in instanceKlass (see release_C_heap_structures) are |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
39 // decremented. When the reference count for a Symbol goes to 0, the garbage |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
40 // collector can free the Symbol and remove it from the SymbolTable. |
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 // 0) Symbols need to be reference counted when a pointer to the Symbol is |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
43 // saved in persistent storage. This does not include the pointer |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
44 // in the SymbolTable bucket (the _literal field in HashtableEntry) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
45 // that points to the Symbol. All other stores of a Symbol* |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
46 // to a field of a persistent variable (e.g., the _name filed in |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
47 // FieldAccessInfo or _ptr in a CPSlot) is reference counted. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
48 // |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
49 // 1) The lookup of a "name" in the SymbolTable either creates a Symbol F for |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
50 // "name" and returns a pointer to F or finds a pre-existing Symbol F for |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
51 // "name" and returns a pointer to it. In both cases the reference count for F |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
52 // is incremented under the assumption that a pointer to F will be created from |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
53 // the return value. Thus the increment of the reference count is on the lookup |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
54 // and not on the assignment to the new Symbol*. That is |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
55 // Symbol* G = lookup() |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
56 // ^ increment on lookup() |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
57 // and not |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
58 // Symbol* G = lookup() |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
59 // ^ increment on assignmnet |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
60 // The reference count must be decremented manually when the copy of the |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
61 // pointer G is destroyed. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
62 // |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
63 // 2) For a local Symbol* A that is a copy of an existing Symbol* B, the |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
64 // reference counting is elided when the scope of B is greater than the scope |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
65 // of A. For example, in the code fragment |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
66 // below "klass" is passed as a parameter to the method. Symbol* "kn" |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
67 // is a copy of the name in "klass". |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
68 // |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
69 // Symbol* kn = klass->name(); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
70 // unsigned int d_hash = dictionary()->compute_hash(kn, class_loader); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
71 // |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
72 // The scope of "klass" is greater than the scope of "kn" so the reference |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
73 // counting for "kn" is elided. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
74 // |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
75 // Symbol* copied from ConstantPool entries are good candidates for reference |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
76 // counting elision. The ConstantPool entries for a class C exist until C is |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
77 // unloaded. If a Symbol* is copied out of the ConstantPool into Symbol* X, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
78 // the Symbol* in the ConstantPool will in general out live X so the reference |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
79 // counting on X can be elided. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
80 // |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
81 // For cases where the scope of A is not greater than the scope of B, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
82 // the reference counting is explicitly done. See ciSymbol, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
83 // ResolutionErrorEntry and ClassVerifier for examples. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
84 // |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
85 // 3) When a Symbol K is created for temporary use, generally for substrings of |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
86 // an existing symbol or to create a new symbol, assign it to a |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
87 // TempNewSymbol. The SymbolTable methods new_symbol(), lookup() |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
88 // and probe() all potentially return a pointer to a new Symbol. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
89 // The allocation (or lookup) of K increments the reference count for K |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
90 // and the destructor decrements the reference count. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
91 // |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
92 // Another example of TempNewSymbol usage is parsed_name used in |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
93 // ClassFileParser::parseClassFile() where parsed_name is used in the cleanup |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
94 // after a failed attempt to load a class. Here parsed_name is a |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
95 // TempNewSymbol (passed in as a parameter) so the reference count on its symbol |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
96 // will be decremented when it goes out of scope. |
0 | 97 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
98 class Symbol : public CHeapObj { |
0 | 99 friend class VMStructs; |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
100 friend class SymbolTable; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
101 friend class MoveSymbols; |
0 | 102 private: |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
103 volatile int _refcount; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
104 int _identity_hash; |
0 | 105 unsigned short _length; // number of UTF8 characters in the symbol |
106 jbyte _body[1]; | |
107 | |
108 enum { | |
109 // max_symbol_length is constrained by type of _length | |
110 max_symbol_length = (1 << 16) -1 | |
111 }; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
112 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
113 static int object_size(int length) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
114 size_t size = heap_word_size(sizeof(Symbol) + length); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
115 return align_object_size(size); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
116 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
117 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
118 void byte_at_put(int index, int value) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
119 assert(index >=0 && index < _length, "symbol index overflow"); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
120 _body[index] = value; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
121 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
122 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
123 Symbol(const u1* name, int length); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
124 void* operator new(size_t size, int len); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
125 |
0 | 126 public: |
127 // Low-level access (used with care, since not GC-safe) | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
128 const jbyte* base() const { return &_body[0]; } |
0 | 129 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
130 int object_size() { return object_size(utf8_length()); } |
0 | 131 |
132 // Returns the largest size symbol we can safely hold. | |
133 static int max_length() { | |
134 return max_symbol_length; | |
135 } | |
136 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
137 int identity_hash() { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
138 return _identity_hash; |
0 | 139 } |
140 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
141 // Reference counting. See comments above this class for when to use. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
142 int refcount() const { return _refcount; } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
143 void increment_refcount(); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
144 void decrement_refcount(); |
0 | 145 |
146 int byte_at(int index) const { | |
147 assert(index >=0 && index < _length, "symbol index overflow"); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
148 return base()[index]; |
0 | 149 } |
150 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
151 const jbyte* bytes() const { return base(); } |
0 | 152 |
153 int utf8_length() const { return _length; } | |
154 | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
155 // Compares the symbol with a string. |
0 | 156 bool equals(const char* str, int len) const; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
157 bool equals(const char* str) const { return equals(str, (int) strlen(str)); } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
158 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
159 // Tests if the symbol starts with the given prefix. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
160 bool starts_with(const char* prefix, int len) const; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
161 bool starts_with(const char* prefix) const { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
162 return starts_with(prefix, (int) strlen(prefix)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
163 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
164 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
165 // Tests if the symbol starts with the given prefix. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
166 int index_of_at(int i, const char* str, int len) const; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
167 int index_of_at(int i, const char* str) const { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
168 return index_of_at(i, str, (int) strlen(str)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
169 } |
0 | 170 |
171 // Three-way compare for sorting; returns -1/0/1 if receiver is </==/> than arg | |
172 // note that the ordering is not alfabetical | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
173 inline int fast_compare(Symbol* other) const; |
0 | 174 |
175 // Returns receiver converted to null-terminated UTF-8 string; string is | |
176 // allocated in resource area, or in the char buffer provided by caller. | |
177 char* as_C_string() const; | |
178 char* as_C_string(char* buf, int size) const; | |
179 // Use buf if needed buffer length is <= size. | |
180 char* as_C_string_flexible_buffer(Thread* t, char* buf, int size) const; | |
181 | |
182 | |
183 // Returns a null terminated utf8 string in a resource array | |
184 char* as_utf8() const { return as_C_string(); } | |
185 char* as_utf8_flexible_buffer(Thread* t, char* buf, int size) const { | |
186 return as_C_string_flexible_buffer(t, buf, size); | |
187 } | |
188 | |
189 jchar* as_unicode(int& length) const; | |
190 | |
191 // Treating this symbol as a class name, returns the Java name for the class. | |
192 // String is allocated in resource area if buffer is not provided. | |
193 // See Klass::external_name() | |
194 const char* as_klass_external_name() const; | |
195 const char* as_klass_external_name(char* buf, int size) const; | |
196 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
197 // Printing |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
198 void print_symbol_on(outputStream* st = NULL) const; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
199 void print_on(outputStream* st) const; // First level print |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
200 void print_value_on(outputStream* st) const; // Second level print. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
201 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
202 // printing on default output stream |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
203 void print() { print_on(tty); } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
204 void print_value() { print_value_on(tty); } |
0 | 205 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
206 #ifndef PRODUCT |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
207 // Empty constructor to create a dummy symbol object on stack |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
208 // only for getting its vtable pointer. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
209 Symbol() { } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
210 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
211 static int _total_count; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
212 #endif |
0 | 213 }; |
214 | |
215 // Note: this comparison is used for vtable sorting only; it doesn't matter | |
216 // what order it defines, as long as it is a total, time-invariant order | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
217 // Since Symbol*s are in C_HEAP, their relative order in memory never changes, |
0 | 218 // so use address comparison for speed |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
219 int Symbol::fast_compare(Symbol* other) const { |
0 | 220 return (((uintptr_t)this < (uintptr_t)other) ? -1 |
221 : ((uintptr_t)this == (uintptr_t) other) ? 0 : 1); | |
222 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
223 #endif // SHARE_VM_OOPS_SYMBOL_HPP |