author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 46746 | hotspot/src/share/vm/classfile/symbolTable.hpp@ea379ebb9447 |
child 48157 | 7c4d43c26352 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
45114
45644c5f6b8e
8180048: Interned string and symbol table leak memory during parallel unlinking
tschatzl
parents:
39713
diff
changeset
|
2 |
* Copyright (c) 1997, 2017, 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; |
|
13087 | 43 |
class outputStream; |
37995 | 44 |
class SerializeClosure; |
1 | 45 |
|
35497
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
46 |
// TempNewSymbol acts as a handle class in a handle/body idiom and is |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
47 |
// responsible for proper resource management of the body (which is a Symbol*). |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
48 |
// The body is resource managed by a reference counting scheme. |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
49 |
// TempNewSymbol can therefore be used to properly hold a newly created or referenced |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
50 |
// Symbol* temporarily in scope. |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
51 |
// |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
52 |
// Routines in SymbolTable will initialize the reference count of a Symbol* before |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
53 |
// it becomes "managed" by TempNewSymbol instances. As a handle class, TempNewSymbol |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
54 |
// needs to maintain proper reference counting in context of copy semantics. |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
55 |
// |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
56 |
// In SymbolTable, new_symbol() and lookup() will create a Symbol* if not already in the |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
57 |
// 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
|
58 |
// 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
|
59 |
class TempNewSymbol : public StackObj { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
60 |
Symbol* _temp; |
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 |
public: |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
63 |
TempNewSymbol() : _temp(NULL) {} |
35497
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
64 |
|
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
65 |
// Conversion from a Symbol* to a TempNewSymbol. |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
66 |
// Does not increment the current reference count. |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
67 |
TempNewSymbol(Symbol *s) : _temp(s) {} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
68 |
|
35497
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
69 |
// Copy constructor increments reference count. |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
70 |
TempNewSymbol(const TempNewSymbol& rhs) : _temp(rhs._temp) { |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
71 |
if (_temp != NULL) { |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
72 |
_temp->increment_refcount(); |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
73 |
} |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
74 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
75 |
|
35497
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
76 |
// Assignment operator uses a c++ trick called copy and swap idiom. |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
77 |
// rhs is passed by value so within the scope of this method it is a copy. |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
78 |
// At method exit it contains the former value of _temp, triggering the correct refcount |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
79 |
// decrement upon destruction. |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
80 |
void operator=(TempNewSymbol rhs) { |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
81 |
Symbol* tmp = rhs._temp; |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
82 |
rhs._temp = _temp; |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
83 |
_temp = tmp; |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
84 |
} |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13199
diff
changeset
|
85 |
|
35497
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
86 |
// Decrement reference counter so it can go away if it's unused |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
87 |
~TempNewSymbol() { |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
88 |
if (_temp != NULL) { |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
89 |
_temp->decrement_refcount(); |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
90 |
} |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
91 |
} |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
92 |
|
35497
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
93 |
// Symbol* conversion operators |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
94 |
Symbol* operator -> () const { return _temp; } |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
95 |
bool operator == (Symbol* o) const { return _temp == o; } |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
96 |
operator Symbol*() { return _temp; } |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
97 |
}; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
98 |
|
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
26421
diff
changeset
|
99 |
template <class T, class N> class CompactHashtable; |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
26421
diff
changeset
|
100 |
|
26421
37d88e604ad0
8056084: Refactor Hashtable to allow implementations without rehashing support
mgerdin
parents:
24426
diff
changeset
|
101 |
class SymbolTable : public RehashableHashtable<Symbol*, mtSymbol> { |
1 | 102 |
friend class VMStructs; |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
103 |
friend class ClassFileParser; |
1 | 104 |
|
105 |
private: |
|
106 |
// The symbol table |
|
107 |
static SymbolTable* _the_table; |
|
108 |
||
13087 | 109 |
// Set if one bucket is out of balance due to hash algorithm deficiency |
110 |
static bool _needs_rehashing; |
|
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
26421
diff
changeset
|
111 |
static bool _lookup_shared_first; |
13087 | 112 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
113 |
// For statistics |
22545
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
114 |
static int _symbols_removed; |
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
115 |
static int _symbols_counted; |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
116 |
|
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
26421
diff
changeset
|
117 |
// shared symbol table. |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
26421
diff
changeset
|
118 |
static CompactHashtable<Symbol*, char> _shared_table; |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
26421
diff
changeset
|
119 |
|
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
120 |
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
|
121 |
|
1 | 122 |
// Adding elements |
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
123 |
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
|
124 |
bool c_heap, TRAPS); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
125 |
bool basic_add(ClassLoaderData* loader_data, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
28363
diff
changeset
|
126 |
const constantPoolHandle& cp, int names_count, |
1 | 127 |
const char** names, int* lengths, int* cp_indices, |
128 |
unsigned int* hashValues, TRAPS); |
|
129 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
130 |
static void new_symbols(ClassLoaderData* loader_data, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
28363
diff
changeset
|
131 |
const constantPoolHandle& cp, int names_count, |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
132 |
const char** name, int* lengths, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
133 |
int* cp_indices, unsigned int* hashValues, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
134 |
TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
135 |
add(loader_data, 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
|
136 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
137 |
|
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
26421
diff
changeset
|
138 |
static Symbol* lookup_shared(const char* name, int len, unsigned int hash); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
26421
diff
changeset
|
139 |
Symbol* lookup_dynamic(int index, const char* name, int len, unsigned int hash); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
140 |
Symbol* lookup(int index, const char* name, int len, unsigned int hash); |
1 | 141 |
|
142 |
SymbolTable() |
|
26421
37d88e604ad0
8056084: Refactor Hashtable to allow implementations without rehashing support
mgerdin
parents:
24426
diff
changeset
|
143 |
: RehashableHashtable<Symbol*, mtSymbol>(SymbolTableSize, sizeof (HashtableEntry<Symbol*, mtSymbol>)) {} |
1 | 144 |
|
13195 | 145 |
SymbolTable(HashtableBucket<mtSymbol>* t, int number_of_entries) |
26421
37d88e604ad0
8056084: Refactor Hashtable to allow implementations without rehashing support
mgerdin
parents:
24426
diff
changeset
|
146 |
: RehashableHashtable<Symbol*, mtSymbol>(SymbolTableSize, sizeof (HashtableEntry<Symbol*, mtSymbol>), t, |
1 | 147 |
number_of_entries) {} |
148 |
||
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
149 |
// 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
|
150 |
static Arena* _arena; |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
151 |
static Arena* arena() { return _arena; } // called for statistics |
1 | 152 |
|
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
153 |
static void initialize_symbols(int arena_alloc_size = 0); |
22545
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
154 |
|
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
155 |
static volatile int _parallel_claimed_idx; |
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
156 |
|
45114
45644c5f6b8e
8180048: Interned string and symbol table leak memory during parallel unlinking
tschatzl
parents:
39713
diff
changeset
|
157 |
typedef SymbolTable::BucketUnlinkContext BucketUnlinkContext; |
45644c5f6b8e
8180048: Interned string and symbol table leak memory during parallel unlinking
tschatzl
parents:
39713
diff
changeset
|
158 |
// Release any dead symbols. Unlinked bucket entries are collected in the given |
45644c5f6b8e
8180048: Interned string and symbol table leak memory during parallel unlinking
tschatzl
parents:
39713
diff
changeset
|
159 |
// context to be freed later. |
45644c5f6b8e
8180048: Interned string and symbol table leak memory during parallel unlinking
tschatzl
parents:
39713
diff
changeset
|
160 |
// This allows multiple threads to work on the table at once. |
45644c5f6b8e
8180048: Interned string and symbol table leak memory during parallel unlinking
tschatzl
parents:
39713
diff
changeset
|
161 |
static void buckets_unlink(int start_idx, int end_idx, BucketUnlinkContext* context); |
1 | 162 |
public: |
163 |
enum { |
|
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
164 |
symbol_alloc_batch_size = 8, |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
165 |
// 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
|
166 |
symbol_alloc_arena_size = 360*K |
1 | 167 |
}; |
168 |
||
169 |
// The symbol table |
|
170 |
static SymbolTable* the_table() { return _the_table; } |
|
171 |
||
20393
0675c0224a5a
8019375: Internal symbol table size should be tunable.
kevinw
parents:
20053
diff
changeset
|
172 |
// Size of one bucket in the string table. Used when checking for rollover. |
0675c0224a5a
8019375: Internal symbol table size should be tunable.
kevinw
parents:
20053
diff
changeset
|
173 |
static uint bucket_size() { return sizeof(HashtableBucket<mtSymbol>); } |
0675c0224a5a
8019375: Internal symbol table size should be tunable.
kevinw
parents:
20053
diff
changeset
|
174 |
|
1 | 175 |
static void create_table() { |
176 |
assert(_the_table == NULL, "One symbol table allowed."); |
|
177 |
_the_table = new SymbolTable(); |
|
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
178 |
initialize_symbols(symbol_alloc_arena_size); |
1 | 179 |
} |
180 |
||
13097
c146b608d91f
7178670: runtime/7158800/BadUtf8.java fails in SymbolTable::rehash_table
coleenp
parents:
13087
diff
changeset
|
181 |
static unsigned int hash_symbol(const char* s, int len); |
37198
b96542d1afa1
8152380: Shared symbol table should never use alternate hashcode
iklam
parents:
35497
diff
changeset
|
182 |
static unsigned int hash_shared_symbol(const char* s, int len); |
13087 | 183 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
184 |
static Symbol* lookup(const char* name, int len, TRAPS); |
1 | 185 |
// 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
|
186 |
static Symbol* lookup_only(const char* name, int len, unsigned int& hash); |
1 | 187 |
// 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
|
188 |
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
|
189 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
190 |
static void release(Symbol* sym); |
1 | 191 |
|
11480
1bf714e8adb4
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
8885
diff
changeset
|
192 |
// 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
|
193 |
static Symbol** lookup_symbol_addr(Symbol* sym); |
1bf714e8adb4
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
8885
diff
changeset
|
194 |
|
33628 | 195 |
// jchar (UTF16) version of lookups |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
196 |
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
|
197 |
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
|
198 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
199 |
static void add(ClassLoaderData* loader_data, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
28363
diff
changeset
|
200 |
const constantPoolHandle& cp, int names_count, |
1 | 201 |
const char** names, int* lengths, int* cp_indices, |
202 |
unsigned int* hashValues, TRAPS); |
|
203 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
204 |
// Release any dead symbols |
22545
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
205 |
static void unlink() { |
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
206 |
int processed = 0; |
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
207 |
int removed = 0; |
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
208 |
unlink(&processed, &removed); |
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
209 |
} |
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
210 |
static void unlink(int* processed, int* removed); |
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
211 |
// Release any dead symbols, possibly parallel version |
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
212 |
static void possibly_parallel_unlink(int* processed, int* removed); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
213 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
214 |
// iterate over symbols |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
215 |
static void symbols_do(SymbolClosure *cl); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
45114
diff
changeset
|
216 |
static void metaspace_pointers_do(MetaspaceClosure* it); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
217 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
218 |
// Symbol creation |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
219 |
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
|
220 |
assert(utf8_buffer != NULL, "just checking"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
221 |
return lookup(utf8_buffer, length, THREAD); |
1 | 222 |
} |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
223 |
static Symbol* new_symbol(const char* name, TRAPS) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
224 |
return new_symbol(name, (int)strlen(name), THREAD); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
225 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
226 |
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
|
227 |
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
|
228 |
return lookup(sym, begin, end, THREAD); |
1 | 229 |
} |
230 |
||
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
231 |
// 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
|
232 |
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
|
233 |
|
1 | 234 |
// Symbol lookup |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
235 |
static Symbol* lookup(int index, const char* name, int len, TRAPS); |
1 | 236 |
|
237 |
// Needed for preloading classes in signatures when compiling. |
|
238 |
// Returns the symbol is already present in symbol table, otherwise |
|
239 |
// NULL. NO ALLOCATION IS GUARANTEED! |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
240 |
static Symbol* probe(const char* name, int len) { |
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
241 |
unsigned int ignore_hash; |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
242 |
return lookup_only(name, len, ignore_hash); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
243 |
} |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
244 |
static Symbol* probe_unicode(const jchar* name, int len) { |
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
245 |
unsigned int ignore_hash; |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
246 |
return lookup_only_unicode(name, len, ignore_hash); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
247 |
} |
1 | 248 |
|
249 |
// Histogram |
|
250 |
static void print_histogram() PRODUCT_RETURN; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
251 |
static void print() PRODUCT_RETURN; |
1 | 252 |
|
253 |
// Debugging |
|
254 |
static void verify(); |
|
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
26421
diff
changeset
|
255 |
static void dump(outputStream* st, bool verbose=false); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
26421
diff
changeset
|
256 |
static void read(const char* filename, TRAPS); |
1 | 257 |
|
258 |
// Sharing |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
45114
diff
changeset
|
259 |
static void write_to_archive(); |
37995 | 260 |
static void serialize(SerializeClosure* soc); |
39713 | 261 |
static u4 encode_shared(Symbol* sym); |
262 |
static Symbol* decode_shared(u4 offset); |
|
13087 | 263 |
|
264 |
// Rehash the symbol table if it gets out of balance |
|
265 |
static void rehash_table(); |
|
266 |
static bool needs_rehashing() { return _needs_rehashing; } |
|
22545
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
267 |
// Parallel chunked scanning |
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
268 |
static void clear_parallel_claimed_index() { _parallel_claimed_idx = 0; } |
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
269 |
static int parallel_claimed_index() { return _parallel_claimed_idx; } |
1 | 270 |
}; |
271 |
||
7397 | 272 |
#endif // SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP |