author | jiangli |
Mon, 21 May 2012 14:10:35 -0400 | |
changeset 12772 | d317e5e08194 |
parent 12263 | d20640f4f8fe |
child 13087 | 673ea6efaf18 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2332
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2332
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2332
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP |
26 |
#define SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP |
|
27 |
||
28 |
#include "memory/allocation.inline.hpp" |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
29 |
#include "oops/symbol.hpp" |
7397 | 30 |
#include "utilities/hashtable.hpp" |
31 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
32 |
// The symbol table holds all Symbol*s and corresponding interned strings. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
33 |
// Symbol*s and literal strings should be canonicalized. |
1 | 34 |
// |
35 |
// The interned strings are created lazily. |
|
36 |
// |
|
37 |
// It is implemented as an open hash table with a fixed number of buckets. |
|
38 |
// |
|
39 |
// %note: |
|
40 |
// - symbolTableEntrys are allocated in blocks to reduce the space overhead. |
|
41 |
||
42 |
class BoolObjectClosure; |
|
43 |
||
44 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
45 |
// Class to hold a newly created or referenced Symbol* temporarily in scope. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
46 |
// new_symbol() and lookup() will create a Symbol* if not already in the |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
47 |
// symbol table and add to the symbol's reference count. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
48 |
// probe() and lookup_only() will increment the refcount if symbol is found. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
49 |
class TempNewSymbol : public StackObj { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
50 |
Symbol* _temp; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
51 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
52 |
public: |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
53 |
TempNewSymbol() : _temp(NULL) {} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
54 |
// Creating or looking up a symbol increments the symbol's reference count |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
55 |
TempNewSymbol(Symbol *s) : _temp(s) {} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
56 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
57 |
// Operator= increments reference count. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
58 |
void operator=(const TempNewSymbol &s) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
59 |
_temp = s._temp; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
60 |
if (_temp !=NULL) _temp->increment_refcount(); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
61 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
62 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
63 |
// Decrement reference counter so it can go away if it's unique |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
64 |
~TempNewSymbol() { if (_temp != NULL) _temp->decrement_refcount(); } |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
65 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
66 |
// Operators so they can be used like Symbols |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
67 |
Symbol* operator -> () const { return _temp; } |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
68 |
bool operator == (Symbol* o) const { return _temp == o; } |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
69 |
// Sneaky conversion function |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
70 |
operator Symbol*() { return _temp; } |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
71 |
}; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
72 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
73 |
class SymbolTable : public Hashtable<Symbol*> { |
1 | 74 |
friend class VMStructs; |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
75 |
friend class ClassFileParser; |
1 | 76 |
|
77 |
private: |
|
78 |
// The symbol table |
|
79 |
static SymbolTable* _the_table; |
|
80 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
81 |
// For statistics |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
82 |
static int symbols_removed; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
83 |
static int symbols_counted; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
84 |
|
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
85 |
Symbol* allocate_symbol(const u1* name, int len, bool c_heap, TRAPS); // Assumes no characters larger than 0x7F |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
86 |
|
1 | 87 |
// Adding elements |
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
88 |
Symbol* basic_add(int index, u1* name, int len, unsigned int hashValue, |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
89 |
bool c_heap, TRAPS); |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
90 |
|
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
91 |
bool basic_add(Handle class_loader, constantPoolHandle cp, int names_count, |
1 | 92 |
const char** names, int* lengths, int* cp_indices, |
93 |
unsigned int* hashValues, TRAPS); |
|
94 |
||
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
95 |
static void new_symbols(Handle class_loader, constantPoolHandle cp, |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
96 |
int names_count, |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
97 |
const char** name, int* lengths, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
98 |
int* cp_indices, unsigned int* hashValues, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
99 |
TRAPS) { |
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
100 |
add(class_loader, cp, names_count, name, lengths, cp_indices, hashValues, THREAD); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
101 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
102 |
|
1 | 103 |
// Table size |
104 |
enum { |
|
105 |
symbol_table_size = 20011 |
|
106 |
}; |
|
107 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
108 |
Symbol* lookup(int index, const char* name, int len, unsigned int hash); |
1 | 109 |
|
110 |
SymbolTable() |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
111 |
: Hashtable<Symbol*>(symbol_table_size, sizeof (HashtableEntry<Symbol*>)) {} |
1 | 112 |
|
113 |
SymbolTable(HashtableBucket* t, int number_of_entries) |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
114 |
: Hashtable<Symbol*>(symbol_table_size, sizeof (HashtableEntry<Symbol*>), t, |
1 | 115 |
number_of_entries) {} |
116 |
||
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
117 |
// Arena for permanent symbols (null class loader) that are never unloaded |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
118 |
static Arena* _arena; |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
119 |
static Arena* arena() { return _arena; } // called for statistics |
1 | 120 |
|
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
121 |
static void initialize_symbols(int arena_alloc_size = 0); |
1 | 122 |
public: |
123 |
enum { |
|
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
124 |
symbol_alloc_batch_size = 8, |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
125 |
// Pick initial size based on java -version size measurements |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
126 |
symbol_alloc_arena_size = 360*K |
1 | 127 |
}; |
128 |
||
129 |
// The symbol table |
|
130 |
static SymbolTable* the_table() { return _the_table; } |
|
131 |
||
132 |
static void create_table() { |
|
133 |
assert(_the_table == NULL, "One symbol table allowed."); |
|
134 |
_the_table = new SymbolTable(); |
|
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
135 |
initialize_symbols(symbol_alloc_arena_size); |
1 | 136 |
} |
137 |
||
138 |
static void create_table(HashtableBucket* t, int length, |
|
139 |
int number_of_entries) { |
|
140 |
assert(_the_table == NULL, "One symbol table allowed."); |
|
141 |
assert(length == symbol_table_size * sizeof(HashtableBucket), |
|
142 |
"bad shared symbol size."); |
|
143 |
_the_table = new SymbolTable(t, number_of_entries); |
|
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
144 |
// if CDS give symbol table a default arena size since most symbols |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
145 |
// are already allocated in the shared misc section. |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
146 |
initialize_symbols(); |
1 | 147 |
} |
148 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
149 |
static Symbol* lookup(const char* name, int len, TRAPS); |
1 | 150 |
// lookup only, won't add. Also calculate hash. |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
151 |
static Symbol* lookup_only(const char* name, int len, unsigned int& hash); |
1 | 152 |
// Only copy to C string to be added if lookup failed. |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
153 |
static Symbol* lookup(const Symbol* sym, int begin, int end, TRAPS); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
154 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
155 |
static void release(Symbol* sym); |
1 | 156 |
|
11480
1bf714e8adb4
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
8885
diff
changeset
|
157 |
// Look up the address of the literal in the SymbolTable for this Symbol* |
1bf714e8adb4
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
8885
diff
changeset
|
158 |
static Symbol** lookup_symbol_addr(Symbol* sym); |
1bf714e8adb4
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
8885
diff
changeset
|
159 |
|
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
160 |
// jchar (utf16) version of lookups |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
161 |
static Symbol* lookup_unicode(const jchar* name, int len, TRAPS); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
162 |
static Symbol* lookup_only_unicode(const jchar* name, int len, unsigned int& hash); |
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
163 |
|
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
164 |
static void add(Handle class_loader, constantPoolHandle cp, int names_count, |
1 | 165 |
const char** names, int* lengths, int* cp_indices, |
166 |
unsigned int* hashValues, TRAPS); |
|
167 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
168 |
// Release any dead symbols |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
169 |
static void unlink(); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
170 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
171 |
// iterate over symbols |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
172 |
static void symbols_do(SymbolClosure *cl); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
173 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
174 |
// Symbol creation |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
175 |
static Symbol* new_symbol(const char* utf8_buffer, int length, TRAPS) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
176 |
assert(utf8_buffer != NULL, "just checking"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
177 |
return lookup(utf8_buffer, length, THREAD); |
1 | 178 |
} |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
179 |
static Symbol* new_symbol(const char* name, TRAPS) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
180 |
return new_symbol(name, (int)strlen(name), THREAD); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
181 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
182 |
static Symbol* new_symbol(const Symbol* sym, int begin, int end, TRAPS) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
183 |
assert(begin <= end && end <= sym->utf8_length(), "just checking"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
184 |
return lookup(sym, begin, end, THREAD); |
1 | 185 |
} |
186 |
||
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
187 |
// Create a symbol in the arena for symbols that are not deleted |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
188 |
static Symbol* new_permanent_symbol(const char* name, TRAPS); |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
189 |
|
1 | 190 |
// Symbol lookup |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
191 |
static Symbol* lookup(int index, const char* name, int len, TRAPS); |
1 | 192 |
|
193 |
// Needed for preloading classes in signatures when compiling. |
|
194 |
// Returns the symbol is already present in symbol table, otherwise |
|
195 |
// NULL. NO ALLOCATION IS GUARANTEED! |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
196 |
static Symbol* probe(const char* name, int len) { |
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
197 |
unsigned int ignore_hash; |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
198 |
return lookup_only(name, len, ignore_hash); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
199 |
} |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
200 |
static Symbol* probe_unicode(const jchar* name, int len) { |
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
201 |
unsigned int ignore_hash; |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
202 |
return lookup_only_unicode(name, len, ignore_hash); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
203 |
} |
1 | 204 |
|
205 |
// Histogram |
|
206 |
static void print_histogram() PRODUCT_RETURN; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
207 |
static void print() PRODUCT_RETURN; |
1 | 208 |
|
209 |
// Debugging |
|
210 |
static void verify(); |
|
211 |
||
212 |
// Sharing |
|
213 |
static void copy_buckets(char** top, char*end) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
214 |
the_table()->Hashtable<Symbol*>::copy_buckets(top, end); |
1 | 215 |
} |
216 |
static void copy_table(char** top, char*end) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
217 |
the_table()->Hashtable<Symbol*>::copy_table(top, end); |
1 | 218 |
} |
219 |
static void reverse(void* boundary = NULL) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
220 |
the_table()->Hashtable<Symbol*>::reverse(boundary); |
1 | 221 |
} |
222 |
}; |
|
223 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
224 |
class StringTable : public Hashtable<oop> { |
1 | 225 |
friend class VMStructs; |
226 |
||
227 |
private: |
|
228 |
// The string table |
|
229 |
static StringTable* _the_table; |
|
230 |
||
231 |
static oop intern(Handle string_or_null, jchar* chars, int length, TRAPS); |
|
232 |
oop basic_add(int index, Handle string_or_null, jchar* name, int len, |
|
233 |
unsigned int hashValue, TRAPS); |
|
234 |
||
235 |
oop lookup(int index, jchar* chars, int length, unsigned int hashValue); |
|
236 |
||
8727 | 237 |
StringTable() : Hashtable<oop>((int)StringTableSize, |
238 |
sizeof (HashtableEntry<oop>)) {} |
|
1 | 239 |
|
240 |
StringTable(HashtableBucket* t, int number_of_entries) |
|
8727 | 241 |
: Hashtable<oop>((int)StringTableSize, sizeof (HashtableEntry<oop>), t, |
242 |
number_of_entries) {} |
|
1 | 243 |
|
244 |
public: |
|
245 |
// The string table |
|
246 |
static StringTable* the_table() { return _the_table; } |
|
247 |
||
248 |
static void create_table() { |
|
249 |
assert(_the_table == NULL, "One string table allowed."); |
|
250 |
_the_table = new StringTable(); |
|
251 |
} |
|
252 |
||
253 |
static void create_table(HashtableBucket* t, int length, |
|
254 |
int number_of_entries) { |
|
255 |
assert(_the_table == NULL, "One string table allowed."); |
|
8727 | 256 |
assert((size_t)length == StringTableSize * sizeof(HashtableBucket), |
1 | 257 |
"bad shared string size."); |
258 |
_the_table = new StringTable(t, number_of_entries); |
|
259 |
} |
|
260 |
||
261 |
// GC support |
|
262 |
// Delete pointers to otherwise-unreachable objects. |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
263 |
static void unlink(BoolObjectClosure* cl); |
1 | 264 |
|
265 |
// Invoke "f->do_oop" on the locations of all oops in the table. |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
266 |
static void oops_do(OopClosure* f); |
1 | 267 |
|
268 |
// Probing |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
269 |
static oop lookup(Symbol* symbol); |
1 | 270 |
|
271 |
// Interning |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
272 |
static oop intern(Symbol* symbol, TRAPS); |
1 | 273 |
static oop intern(oop string, TRAPS); |
274 |
static oop intern(const char *utf8_string, TRAPS); |
|
275 |
||
276 |
// Debugging |
|
277 |
static void verify(); |
|
278 |
||
279 |
// Sharing |
|
280 |
static void copy_buckets(char** top, char*end) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
281 |
the_table()->Hashtable<oop>::copy_buckets(top, end); |
1 | 282 |
} |
283 |
static void copy_table(char** top, char*end) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
284 |
the_table()->Hashtable<oop>::copy_table(top, end); |
1 | 285 |
} |
286 |
static void reverse() { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
287 |
the_table()->Hashtable<oop>::reverse(); |
1 | 288 |
} |
289 |
}; |
|
7397 | 290 |
|
291 |
#endif // SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP |