author | coleenp |
Fri, 04 Jan 2019 15:06:01 -0500 | |
changeset 53149 | 259c36ef27df |
parent 52951 | 722eaae2a785 |
child 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53149
259c36ef27df
8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents:
52951
diff
changeset
|
2 |
* Copyright (c) 1997, 2019, 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 |
||
48157 | 28 |
#include "memory/allocation.hpp" |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
29 |
#include "memory/padded.hpp" |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
30 |
#include "oops/symbol.hpp" |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
31 |
#include "utilities/concurrentHashTable.hpp" |
7397 | 32 |
#include "utilities/hashtable.hpp" |
33 |
||
53149
259c36ef27df
8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents:
52951
diff
changeset
|
34 |
class JavaThread; |
259c36ef27df
8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents:
52951
diff
changeset
|
35 |
|
35497
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
36 |
// 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
|
37 |
// 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
|
38 |
// 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
|
39 |
// 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
|
40 |
// Symbol* temporarily in scope. |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
41 |
// |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
42 |
// 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
|
43 |
// 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
|
44 |
// 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
|
45 |
// |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
46 |
// 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
|
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 |
|
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
52 |
public: |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
53 |
TempNewSymbol() : _temp(NULL) {} |
35497
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
54 |
|
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
55 |
// Conversion from a Symbol* to a TempNewSymbol. |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
56 |
// Does not increment the current reference count. |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
57 |
TempNewSymbol(Symbol *s) : _temp(s) {} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
58 |
|
35497
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
59 |
// Copy constructor increments reference count. |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
60 |
TempNewSymbol(const TempNewSymbol& rhs) : _temp(rhs._temp) { |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
61 |
if (_temp != NULL) { |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
62 |
_temp->increment_refcount(); |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
63 |
} |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
64 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
65 |
|
35497
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
66 |
// 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
|
67 |
// 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
|
68 |
// 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
|
69 |
// decrement upon destruction. |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
70 |
void operator=(TempNewSymbol rhs) { |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
71 |
Symbol* tmp = rhs._temp; |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
72 |
rhs._temp = _temp; |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
73 |
_temp = tmp; |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
74 |
} |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
13199
diff
changeset
|
75 |
|
35497
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
76 |
// 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
|
77 |
~TempNewSymbol() { |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
78 |
if (_temp != NULL) { |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
79 |
_temp->decrement_refcount(); |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
80 |
} |
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
81 |
} |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
82 |
|
35497
94c7c07d0161
8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents:
34237
diff
changeset
|
83 |
// Symbol* conversion operators |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
84 |
Symbol* operator -> () const { return _temp; } |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
85 |
bool operator == (Symbol* o) const { return _temp == o; } |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
86 |
operator Symbol*() { return _temp; } |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
87 |
}; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
88 |
|
52047
7bc8b456e5ac
8210388: Use hash table to store archived subgraph_info records
iklam
parents:
51823
diff
changeset
|
89 |
class CompactHashtableWriter; |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
90 |
class SerializeClosure; |
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
26421
diff
changeset
|
91 |
|
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
92 |
class SymbolTableConfig; |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
93 |
typedef ConcurrentHashTable<Symbol*, |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
94 |
SymbolTableConfig, mtSymbol> SymbolTableHash; |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
95 |
|
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
96 |
class SymbolTableCreateEntry; |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
97 |
|
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
98 |
class SymbolTable : public CHeapObj<mtSymbol> { |
1 | 99 |
friend class VMStructs; |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
100 |
friend class Symbol; |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
101 |
friend class ClassFileParser; |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
102 |
friend class SymbolTableConfig; |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
103 |
friend class SymbolTableCreateEntry; |
1 | 104 |
|
105 |
private: |
|
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
106 |
static void delete_symbol(Symbol* sym); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
107 |
void grow(JavaThread* jt); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
108 |
void clean_dead_entries(JavaThread* jt); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
109 |
|
1 | 110 |
// The symbol table |
111 |
static SymbolTable* _the_table; |
|
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
112 |
static volatile bool _lookup_shared_first; |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
113 |
static volatile bool _alt_hash; |
13087 | 114 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
115 |
// For statistics |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
116 |
volatile size_t _symbols_removed; |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
117 |
volatile size_t _symbols_counted; |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
118 |
|
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
119 |
SymbolTableHash* _local_table; |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
120 |
size_t _current_size; |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
121 |
volatile bool _has_work; |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
122 |
// Set if one bucket is out of balance due to hash algorithm deficiency |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
123 |
volatile bool _needs_rehashing; |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
124 |
|
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
125 |
volatile size_t _items_count; |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
126 |
volatile size_t _uncleaned_items_count; |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
127 |
|
52931
3b0fe3d6c3d7
8209387: Follow ups to JDK-8195100 Use a low latency hashtable for SymbolTable
gziemski
parents:
52047
diff
changeset
|
128 |
double get_load_factor() const; |
3b0fe3d6c3d7
8209387: Follow ups to JDK-8195100 Use a low latency hashtable for SymbolTable
gziemski
parents:
52047
diff
changeset
|
129 |
double get_dead_factor() const; |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
130 |
|
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
131 |
void check_concurrent_work(); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
132 |
void trigger_concurrent_work(); |
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
26421
diff
changeset
|
133 |
|
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
134 |
static void item_added(); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
135 |
static void item_removed(); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
136 |
static void set_item_clean_count(size_t ncl); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
137 |
static void mark_item_clean_count(); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
138 |
|
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
139 |
SymbolTable(); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
140 |
|
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
141 |
Symbol* allocate_symbol(const char* name, int len, bool c_heap, TRAPS); // Assumes no characters larger than 0x7F |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
142 |
Symbol* do_lookup(const char* name, int len, uintx hash); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
143 |
Symbol* do_add_if_needed(const char* name, int len, uintx hash, bool heap, TRAPS); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
144 |
|
1 | 145 |
// Adding elements |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
146 |
static void add(ClassLoaderData* loader_data, |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
147 |
const constantPoolHandle& cp, int names_count, |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
148 |
const char** names, int* lengths, int* cp_indices, |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
149 |
unsigned int* hashValues, TRAPS); |
1 | 150 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
151 |
static void new_symbols(ClassLoaderData* loader_data, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
28363
diff
changeset
|
152 |
const constantPoolHandle& cp, int names_count, |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
153 |
const char** name, int* lengths, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
154 |
int* cp_indices, unsigned int* hashValues, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
155 |
TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
156 |
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
|
157 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
158 |
|
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
26421
diff
changeset
|
159 |
static Symbol* lookup_shared(const char* name, int len, unsigned int hash); |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
160 |
Symbol* lookup_dynamic(const char* name, int len, unsigned int hash); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
161 |
Symbol* lookup_common(const char* name, int len, unsigned int hash); |
1 | 162 |
|
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
163 |
// 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
|
164 |
static Arena* _arena; |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
165 |
static Arena* arena() { return _arena; } // called for statistics |
1 | 166 |
|
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
167 |
static void initialize_symbols(int arena_alloc_size = 0); |
22545
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
168 |
|
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
169 |
void concurrent_work(JavaThread* jt); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
170 |
void print_table_statistics(outputStream* st, const char* table_name); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
171 |
|
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
172 |
void try_rehash_table(); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
173 |
bool do_rehash(); |
52951 | 174 |
inline void update_needs_rehash(bool rehash); |
22545
b93a7f0e9b9d
8027476: Improve performance of Stringtable unlink
tschatzl
parents:
20393
diff
changeset
|
175 |
|
1 | 176 |
public: |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
177 |
// The symbol table |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
178 |
static SymbolTable* the_table() { return _the_table; } |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
179 |
size_t table_size(); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
180 |
|
1 | 181 |
enum { |
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
182 |
symbol_alloc_batch_size = 8, |
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
183 |
// Pick initial size based on java -version size measurements |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
184 |
symbol_alloc_arena_size = 360*K // TODO (revisit) |
1 | 185 |
}; |
186 |
||
187 |
static void create_table() { |
|
188 |
assert(_the_table == NULL, "One symbol table allowed."); |
|
189 |
_the_table = new SymbolTable(); |
|
12263
d20640f4f8fe
7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents:
11480
diff
changeset
|
190 |
initialize_symbols(symbol_alloc_arena_size); |
1 | 191 |
} |
192 |
||
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
193 |
static void unlink() { |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
194 |
do_check_concurrent_work(); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
195 |
} |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
196 |
static void do_check_concurrent_work(); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
197 |
static void do_concurrent_work(JavaThread* jt); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
198 |
static bool has_work() { return the_table()->_has_work; } |
13087 | 199 |
|
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
200 |
// Probing |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
201 |
static Symbol* lookup(const char* name, int len, TRAPS); |
1 | 202 |
// 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
|
203 |
static Symbol* lookup_only(const char* name, int len, unsigned int& hash); |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
204 |
// adds new symbol if not found |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
205 |
static Symbol* lookup(const Symbol* sym, int begin, int end, TRAPS); |
33628 | 206 |
// jchar (UTF16) version of lookups |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
207 |
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
|
208 |
static Symbol* lookup_only_unicode(const jchar* name, int len, unsigned int& hash); |
1 | 209 |
// Needed for preloading classes in signatures when compiling. |
210 |
// Returns the symbol is already present in symbol table, otherwise |
|
211 |
// NULL. NO ALLOCATION IS GUARANTEED! |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
212 |
static Symbol* probe(const char* name, int len) { |
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
213 |
unsigned int ignore_hash; |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
214 |
return lookup_only(name, len, ignore_hash); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
215 |
} |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
216 |
static Symbol* probe_unicode(const jchar* name, int len) { |
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
217 |
unsigned int ignore_hash; |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
218 |
return lookup_only_unicode(name, len, ignore_hash); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1
diff
changeset
|
219 |
} |
1 | 220 |
|
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
221 |
// Symbol creation |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
222 |
static Symbol* new_symbol(const char* utf8_buffer, int length, TRAPS) { |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
223 |
assert(utf8_buffer != NULL, "just checking"); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
224 |
return lookup(utf8_buffer, length, THREAD); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
225 |
} |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
226 |
static Symbol* new_symbol(const char* name, TRAPS) { |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
227 |
return new_symbol(name, (int)strlen(name), THREAD); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
228 |
} |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
229 |
static Symbol* new_symbol(const Symbol* sym, int begin, int end, TRAPS) { |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
230 |
assert(begin <= end && end <= sym->utf8_length(), "just checking"); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
231 |
return lookup(sym, begin, end, THREAD); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
232 |
} |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
233 |
// Create a symbol in the arena for symbols that are not deleted |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
234 |
static Symbol* new_permanent_symbol(const char* name, TRAPS); |
1 | 235 |
|
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
236 |
// Rehash the string table if it gets out of balance |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
237 |
static void rehash_table(); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
238 |
static bool needs_rehashing() |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
239 |
{ return SymbolTable::the_table()->_needs_rehashing; } |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
240 |
|
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
241 |
// Heap dumper and CDS |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
242 |
static void symbols_do(SymbolClosure *cl); |
1 | 243 |
|
244 |
// Sharing |
|
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
245 |
private: |
52047
7bc8b456e5ac
8210388: Use hash table to store archived subgraph_info records
iklam
parents:
51823
diff
changeset
|
246 |
static void copy_shared_symbol_table(CompactHashtableWriter* ch_table); |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
247 |
public: |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
248 |
static void write_to_archive() NOT_CDS_RETURN; |
52047
7bc8b456e5ac
8210388: Use hash table to store archived subgraph_info records
iklam
parents:
51823
diff
changeset
|
249 |
static void serialize_shared_table_header(SerializeClosure* soc) NOT_CDS_RETURN; |
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
250 |
static void metaspace_pointers_do(MetaspaceClosure* it); |
13087 | 251 |
|
51405
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
252 |
// Jcmd |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
253 |
static void dump(outputStream* st, bool verbose=false); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
254 |
// Debugging |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
255 |
static void verify(); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
256 |
static void read(const char* filename, TRAPS); |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
257 |
|
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
258 |
// Histogram |
8b23aa7cef47
8195100: Use a low latency hashtable for SymbolTable
gziemski
parents:
48157
diff
changeset
|
259 |
static void print_histogram() PRODUCT_RETURN; |
1 | 260 |
}; |
261 |
||
7397 | 262 |
#endif // SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP |