annotate src/share/vm/classfile/symbolTable.hpp @ 4800:94ec88ca68e2

7115199: Add event tracing hooks and Java Flight Recorder infrastructure Summary: Added a nop tracing infrastructure, JFR makefile changes and other infrastructure used only by JFR. Reviewed-by: acorn, sspitsyn Contributed-by: markus.gronlund@oracle.com
author phh
date Wed, 11 Jan 2012 17:34:02 -0500
parents 352622fd140a
children fc9d8850ab8b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2418
352622fd140a 7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents: 2378
diff changeset
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 665
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 665
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: 665
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/allocation.inline.hpp"
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
29 #include "oops/symbol.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "utilities/hashtable.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
32 // The symbol table holds all Symbol*s and corresponding interned strings.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
33 // Symbol*s and literal strings should be canonicalized.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
34 //
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // The interned strings are created lazily.
a61af66fc99e Initial load
duke
parents:
diff changeset
36 //
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // It is implemented as an open hash table with a fixed number of buckets.
a61af66fc99e Initial load
duke
parents:
diff changeset
38 //
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // %note:
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // - symbolTableEntrys are allocated in blocks to reduce the space overhead.
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 class BoolObjectClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
45 // Class to hold a newly created or referenced Symbol* temporarily in scope.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
46 // new_symbol() and lookup() will create a Symbol* if not already in the
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
47 // symbol table and add to the symbol's reference count.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
48 // probe() and lookup_only() will increment the refcount if symbol is found.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
49 class TempNewSymbol : public StackObj {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
50 Symbol* _temp;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
51
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
52 public:
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
53 TempNewSymbol() : _temp(NULL) {}
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
54 // Creating or looking up a symbol increments the symbol's reference count
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
55 TempNewSymbol(Symbol *s) : _temp(s) {}
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
56
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
57 // Operator= increments reference count.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
58 void operator=(const TempNewSymbol &s) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
59 _temp = s._temp;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
60 if (_temp !=NULL) _temp->increment_refcount();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
61 }
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 // Decrement reference counter so it can go away if it's unique
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
64 ~TempNewSymbol() { if (_temp != NULL) _temp->decrement_refcount(); }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
65
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
66 // Operators so they can be used like Symbols
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
67 Symbol* operator -> () const { return _temp; }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
68 bool operator == (Symbol* o) const { return _temp == o; }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
69 // Sneaky conversion function
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
70 operator Symbol*() { return _temp; }
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
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
73 class SymbolTable : public Hashtable<Symbol*> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
74 friend class VMStructs;
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
75 friend class ClassFileParser;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // The symbol table
a61af66fc99e Initial load
duke
parents:
diff changeset
79 static SymbolTable* _the_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
80
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
81 // For statistics
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
82 static int symbols_removed;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
83 static int symbols_counted;
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 Symbol* allocate_symbol(const u1* name, int len, TRAPS); // Assumes no characters larger than 0x7F
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
86 bool allocate_symbols(int names_count, const u1** names, int* lengths, Symbol** syms, TRAPS);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
87
0
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // Adding elements
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
89 Symbol* basic_add(int index, u1* name, int len,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
90 unsigned int hashValue, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 bool basic_add(constantPoolHandle cp, int names_count,
a61af66fc99e Initial load
duke
parents:
diff changeset
92 const char** names, int* lengths, int* cp_indices,
a61af66fc99e Initial load
duke
parents:
diff changeset
93 unsigned int* hashValues, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
94
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
95 static void new_symbols(constantPoolHandle cp, int names_count,
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
96 const char** name, int* lengths,
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
97 int* cp_indices, unsigned int* hashValues,
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
98 TRAPS) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
99 add(cp, names_count, name, lengths, cp_indices, hashValues, THREAD);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
100 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
101
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
102
0
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Table size
a61af66fc99e Initial load
duke
parents:
diff changeset
104 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 symbol_table_size = 20011
a61af66fc99e Initial load
duke
parents:
diff changeset
106 };
a61af66fc99e Initial load
duke
parents:
diff changeset
107
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
108 Symbol* lookup(int index, const char* name, int len, unsigned int hash);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 SymbolTable()
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
111 : Hashtable<Symbol*>(symbol_table_size, sizeof (HashtableEntry<Symbol*>)) {}
0
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 SymbolTable(HashtableBucket* t, int number_of_entries)
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
114 : Hashtable<Symbol*>(symbol_table_size, sizeof (HashtableEntry<Symbol*>), t,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
115 number_of_entries) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
119 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 symbol_alloc_batch_size = 8
a61af66fc99e Initial load
duke
parents:
diff changeset
121 };
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // The symbol table
a61af66fc99e Initial load
duke
parents:
diff changeset
124 static SymbolTable* the_table() { return _the_table; }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 static void create_table() {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 assert(_the_table == NULL, "One symbol table allowed.");
a61af66fc99e Initial load
duke
parents:
diff changeset
128 _the_table = new SymbolTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 static void create_table(HashtableBucket* t, int length,
a61af66fc99e Initial load
duke
parents:
diff changeset
132 int number_of_entries) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 assert(_the_table == NULL, "One symbol table allowed.");
a61af66fc99e Initial load
duke
parents:
diff changeset
134 assert(length == symbol_table_size * sizeof(HashtableBucket),
a61af66fc99e Initial load
duke
parents:
diff changeset
135 "bad shared symbol size.");
a61af66fc99e Initial load
duke
parents:
diff changeset
136 _the_table = new SymbolTable(t, number_of_entries);
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
139 static Symbol* lookup(const char* name, int len, TRAPS);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // lookup only, won't add. Also calculate hash.
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
141 static Symbol* lookup_only(const char* name, int len, unsigned int& hash);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // Only copy to C string to be added if lookup failed.
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
143 static Symbol* lookup(const Symbol* sym, int begin, int end, TRAPS);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
144
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
145 static void release(Symbol* sym);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
146
4800
94ec88ca68e2 7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents: 2418
diff changeset
147 // Look up the address of the literal in the SymbolTable for this Symbol*
94ec88ca68e2 7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents: 2418
diff changeset
148 static Symbol** lookup_symbol_addr(Symbol* sym);
94ec88ca68e2 7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents: 2418
diff changeset
149
665
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
150 // jchar (utf16) version of lookups
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
151 static Symbol* lookup_unicode(const jchar* name, int len, TRAPS);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
152 static Symbol* lookup_only_unicode(const jchar* name, int len, unsigned int& hash);
665
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
153
0
a61af66fc99e Initial load
duke
parents:
diff changeset
154 static void add(constantPoolHandle cp, int names_count,
a61af66fc99e Initial load
duke
parents:
diff changeset
155 const char** names, int* lengths, int* cp_indices,
a61af66fc99e Initial load
duke
parents:
diff changeset
156 unsigned int* hashValues, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
157
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
158 // Release any dead symbols
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
159 static void unlink();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
160
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
161 // iterate over symbols
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
162 static void symbols_do(SymbolClosure *cl);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
163
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
164 // Symbol creation
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
165 static Symbol* new_symbol(const char* utf8_buffer, int length, TRAPS) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
166 assert(utf8_buffer != NULL, "just checking");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
167 return lookup(utf8_buffer, length, THREAD);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
169 static Symbol* new_symbol(const char* name, TRAPS) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
170 return new_symbol(name, (int)strlen(name), THREAD);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
171 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
172 static Symbol* new_symbol(const Symbol* sym, int begin, int end, TRAPS) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
173 assert(begin <= end && end <= sym->utf8_length(), "just checking");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
174 return lookup(sym, begin, end, THREAD);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // Symbol lookup
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
178 static Symbol* lookup(int index, const char* name, int len, TRAPS);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // Needed for preloading classes in signatures when compiling.
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // Returns the symbol is already present in symbol table, otherwise
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // NULL. NO ALLOCATION IS GUARANTEED!
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
183 static Symbol* probe(const char* name, int len) {
665
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
184 unsigned int ignore_hash;
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
185 return lookup_only(name, len, ignore_hash);
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
186 }
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
187 static Symbol* probe_unicode(const jchar* name, int len) {
665
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
188 unsigned int ignore_hash;
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
189 return lookup_only_unicode(name, len, ignore_hash);
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
190 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // Histogram
a61af66fc99e Initial load
duke
parents:
diff changeset
193 static void print_histogram() PRODUCT_RETURN;
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
194 static void print() PRODUCT_RETURN;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
197 static void verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // Sharing
a61af66fc99e Initial load
duke
parents:
diff changeset
200 static void copy_buckets(char** top, char*end) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
201 the_table()->Hashtable<Symbol*>::copy_buckets(top, end);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 static void copy_table(char** top, char*end) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
204 the_table()->Hashtable<Symbol*>::copy_table(top, end);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 static void reverse(void* boundary = NULL) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
207 the_table()->Hashtable<Symbol*>::reverse(boundary);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 };
a61af66fc99e Initial load
duke
parents:
diff changeset
210
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
211 class StringTable : public Hashtable<oop> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
212 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // The string table
a61af66fc99e Initial load
duke
parents:
diff changeset
216 static StringTable* _the_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 static oop intern(Handle string_or_null, jchar* chars, int length, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 oop basic_add(int index, Handle string_or_null, jchar* name, int len,
a61af66fc99e Initial load
duke
parents:
diff changeset
220 unsigned int hashValue, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 oop lookup(int index, jchar* chars, int length, unsigned int hashValue);
a61af66fc99e Initial load
duke
parents:
diff changeset
223
2378
924777755fad 6962930: make the string table size configurable
jcoomes
parents: 2177
diff changeset
224 StringTable() : Hashtable<oop>((int)StringTableSize,
924777755fad 6962930: make the string table size configurable
jcoomes
parents: 2177
diff changeset
225 sizeof (HashtableEntry<oop>)) {}
0
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 StringTable(HashtableBucket* t, int number_of_entries)
2378
924777755fad 6962930: make the string table size configurable
jcoomes
parents: 2177
diff changeset
228 : Hashtable<oop>((int)StringTableSize, sizeof (HashtableEntry<oop>), t,
924777755fad 6962930: make the string table size configurable
jcoomes
parents: 2177
diff changeset
229 number_of_entries) {}
0
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // The string table
a61af66fc99e Initial load
duke
parents:
diff changeset
233 static StringTable* the_table() { return _the_table; }
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 static void create_table() {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 assert(_the_table == NULL, "One string table allowed.");
a61af66fc99e Initial load
duke
parents:
diff changeset
237 _the_table = new StringTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 static void create_table(HashtableBucket* t, int length,
a61af66fc99e Initial load
duke
parents:
diff changeset
241 int number_of_entries) {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 assert(_the_table == NULL, "One string table allowed.");
2378
924777755fad 6962930: make the string table size configurable
jcoomes
parents: 2177
diff changeset
243 assert((size_t)length == StringTableSize * sizeof(HashtableBucket),
0
a61af66fc99e Initial load
duke
parents:
diff changeset
244 "bad shared string size.");
a61af66fc99e Initial load
duke
parents:
diff changeset
245 _the_table = new StringTable(t, number_of_entries);
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // GC support
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // Delete pointers to otherwise-unreachable objects.
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
250 static void unlink(BoolObjectClosure* cl);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // Invoke "f->do_oop" on the locations of all oops in the table.
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
253 static void oops_do(OopClosure* f);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // Probing
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
256 static oop lookup(Symbol* symbol);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // Interning
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
259 static oop intern(Symbol* symbol, TRAPS);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
260 static oop intern(oop string, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 static oop intern(const char *utf8_string, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
264 static void verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // Sharing
a61af66fc99e Initial load
duke
parents:
diff changeset
267 static void copy_buckets(char** top, char*end) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
268 the_table()->Hashtable<oop>::copy_buckets(top, end);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
269 }
a61af66fc99e Initial load
duke
parents:
diff changeset
270 static void copy_table(char** top, char*end) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
271 the_table()->Hashtable<oop>::copy_table(top, end);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 static void reverse() {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
274 the_table()->Hashtable<oop>::reverse();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
277
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
278 #endif // SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP