author | mgronlun |
Tue, 03 Sep 2019 11:48:31 +0200 | |
branch | JEP-349-branch |
changeset 57987 | 23e3cd901cb6 |
parent 57983 | a57907813a83 |
child 58049 | 10ecdb5d3574 |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
57360 | 2 |
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
50113 | 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 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#include "precompiled.hpp" |
|
26 |
#include "jfr/recorder/checkpoint/types/jfrTypeSetUtils.hpp" |
|
27 |
#include "oops/instanceKlass.hpp" |
|
28 |
#include "oops/oop.inline.hpp" |
|
29 |
#include "oops/symbol.hpp" |
|
30 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
31 |
JfrSymbolId::JfrSymbolId() : |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
32 |
_sym_table(new SymbolTable(this)), |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
33 |
_cstring_table(new CStringTable(this)), |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
34 |
_sym_list(NULL), |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
35 |
_cstring_list(NULL), |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
36 |
_symbol_id_counter(0), |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
37 |
_class_unload(false) { |
50113 | 38 |
assert(_sym_table != NULL, "invariant"); |
39 |
assert(_cstring_table != NULL, "invariant"); |
|
40 |
} |
|
41 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
42 |
JfrSymbolId::~JfrSymbolId() { |
50113 | 43 |
clear(); |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
44 |
delete _sym_table; |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
45 |
delete _cstring_table; |
50113 | 46 |
} |
47 |
||
48 |
void JfrSymbolId::clear() { |
|
49 |
assert(_sym_table != NULL, "invariant"); |
|
50 |
if (_sym_table->has_entries()) { |
|
51 |
_sym_table->clear_entries(); |
|
52 |
} |
|
53 |
assert(!_sym_table->has_entries(), "invariant"); |
|
54 |
||
55 |
assert(_cstring_table != NULL, "invariant"); |
|
56 |
if (_cstring_table->has_entries()) { |
|
57 |
_cstring_table->clear_entries(); |
|
58 |
} |
|
59 |
assert(!_cstring_table->has_entries(), "invariant"); |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
60 |
|
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
61 |
_sym_list = NULL; |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
62 |
_cstring_list = NULL; |
50113 | 63 |
_symbol_id_counter = 0; |
64 |
} |
|
65 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
66 |
void JfrSymbolId::set_class_unload(bool class_unload) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
67 |
_class_unload = class_unload; |
50113 | 68 |
} |
69 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
70 |
void JfrSymbolId::link(const SymbolEntry* entry) { |
50113 | 71 |
assert(entry != NULL, "invariant"); |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
72 |
const_cast<Symbol*>(entry->literal())->increment_refcount(); |
50113 | 73 |
assert(entry->id() == 0, "invariant"); |
74 |
entry->set_id(++_symbol_id_counter); |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
75 |
entry->set_list_next(_sym_list); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
76 |
_sym_list = entry; |
50113 | 77 |
} |
78 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
79 |
bool JfrSymbolId::equals(uintptr_t hash, const SymbolEntry* entry) { |
50113 | 80 |
// query might be NULL |
81 |
assert(entry != NULL, "invariant"); |
|
82 |
assert(entry->hash() == hash, "invariant"); |
|
83 |
return true; |
|
84 |
} |
|
85 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
86 |
void JfrSymbolId::unlink(const SymbolEntry* entry) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
87 |
assert(entry != NULL, "invariant"); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
88 |
const_cast<Symbol*>(entry->literal())->decrement_refcount(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
89 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
90 |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
91 |
void JfrSymbolId::link(const CStringEntry* entry) { |
50113 | 92 |
assert(entry != NULL, "invariant"); |
93 |
assert(entry->id() == 0, "invariant"); |
|
94 |
entry->set_id(++_symbol_id_counter); |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
95 |
entry->set_list_next(_cstring_list); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
96 |
_cstring_list = entry; |
50113 | 97 |
} |
98 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
99 |
bool JfrSymbolId::equals(uintptr_t hash, const CStringEntry* entry) { |
50113 | 100 |
assert(entry != NULL, "invariant"); |
101 |
assert(entry->hash() == hash, "invariant"); |
|
102 |
return true; |
|
103 |
} |
|
104 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
105 |
void JfrSymbolId::unlink(const CStringEntry* entry) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
106 |
assert(entry != NULL, "invariant"); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
107 |
if (entry->id() != 1) { |
57987 | 108 |
JfrCHeapObj::free(const_cast<char*>(entry->literal()), strlen(entry->literal() + 1)); |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
109 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
110 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
111 |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
112 |
traceid JfrSymbolId::mark(const Symbol* symbol, bool leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
113 |
assert(symbol != NULL, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
114 |
return mark((uintptr_t)symbol->identity_hash(), symbol, leakp); |
50113 | 115 |
} |
116 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
117 |
static unsigned int last_symbol_hash = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
118 |
static traceid last_symbol_id = 0; |
50113 | 119 |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
120 |
traceid JfrSymbolId::mark(uintptr_t hash, const Symbol* data, bool leakp) { |
50113 | 121 |
assert(data != NULL, "invariant"); |
122 |
assert(_sym_table != NULL, "invariant"); |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
123 |
if (hash == last_symbol_hash) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
124 |
assert(last_symbol_id != 0, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
125 |
return last_symbol_id; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
126 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
127 |
const SymbolEntry& entry = _sym_table->lookup_put(hash, data); |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
128 |
if (_class_unload) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
129 |
entry.set_unloading(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
130 |
} |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
131 |
if (leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
132 |
entry.set_leakp(); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
133 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
134 |
last_symbol_hash = hash; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
135 |
last_symbol_id = entry.id(); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
136 |
return last_symbol_id; |
50113 | 137 |
} |
138 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
139 |
static unsigned int last_cstring_hash = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
140 |
static traceid last_cstring_id = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
141 |
|
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
142 |
traceid JfrSymbolId::mark(uintptr_t hash, const char* str, bool leakp) { |
50113 | 143 |
assert(str != NULL, "invariant"); |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
144 |
assert(_cstring_table != NULL, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
145 |
if (hash == last_cstring_hash) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
146 |
assert(last_cstring_id != 0, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
147 |
return last_cstring_id; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
148 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
149 |
const CStringEntry& entry = _cstring_table->lookup_put(hash, str); |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
150 |
if (_class_unload) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
151 |
entry.set_unloading(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
152 |
} |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
153 |
if (leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
154 |
entry.set_leakp(); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
155 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
156 |
last_cstring_hash = hash; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
157 |
last_cstring_id = entry.id(); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
158 |
return last_cstring_id; |
50113 | 159 |
} |
160 |
||
161 |
/* |
|
162 |
* jsr292 anonymous classes symbol is the external name + |
|
163 |
* the identity_hashcode slash appended: |
|
164 |
* java.lang.invoke.LambdaForm$BMH/22626602 |
|
165 |
* |
|
166 |
* caller needs ResourceMark |
|
167 |
*/ |
|
168 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
169 |
uintptr_t JfrSymbolId::unsafe_anonymous_klass_name_hash(const InstanceKlass* ik) { |
50113 | 170 |
assert(ik != NULL, "invariant"); |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51334
diff
changeset
|
171 |
assert(ik->is_unsafe_anonymous(), "invariant"); |
53176
6af596144294
8215773: applications/kitchensink/Kitchensink.java crash with "assert(ZAddress::is_marked(addr)) failed: Should be marked"
eosterlund
parents:
51444
diff
changeset
|
172 |
const oop mirror = ik->java_mirror_no_keepalive(); |
50113 | 173 |
assert(mirror != NULL, "invariant"); |
174 |
return (uintptr_t)mirror->identity_hash(); |
|
175 |
} |
|
176 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
177 |
static const char* create_unsafe_anonymous_klass_symbol(const InstanceKlass* ik, uintptr_t hash) { |
50113 | 178 |
assert(ik != NULL, "invariant"); |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51334
diff
changeset
|
179 |
assert(ik->is_unsafe_anonymous(), "invariant"); |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
180 |
assert(hash != 0, "invariant"); |
50113 | 181 |
char* anonymous_symbol = NULL; |
53176
6af596144294
8215773: applications/kitchensink/Kitchensink.java crash with "assert(ZAddress::is_marked(addr)) failed: Should be marked"
eosterlund
parents:
51444
diff
changeset
|
182 |
const oop mirror = ik->java_mirror_no_keepalive(); |
50113 | 183 |
assert(mirror != NULL, "invariant"); |
184 |
char hash_buf[40]; |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
185 |
sprintf(hash_buf, "/" UINTX_FORMAT, hash); |
50113 | 186 |
const size_t hash_len = strlen(hash_buf); |
187 |
const size_t result_len = ik->name()->utf8_length(); |
|
57987 | 188 |
anonymous_symbol = JfrCHeapObj::new_array<char>(result_len + hash_len + 1); |
50113 | 189 |
ik->name()->as_klass_external_name(anonymous_symbol, (int)result_len + 1); |
190 |
assert(strlen(anonymous_symbol) == result_len, "invariant"); |
|
191 |
strcpy(anonymous_symbol + result_len, hash_buf); |
|
192 |
assert(strlen(anonymous_symbol) == result_len + hash_len, "invariant"); |
|
193 |
return anonymous_symbol; |
|
194 |
} |
|
195 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
196 |
bool JfrSymbolId::is_unsafe_anonymous_klass(const Klass* k) { |
50113 | 197 |
assert(k != NULL, "invariant"); |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
198 |
return k->is_instance_klass() && ((const InstanceKlass*)k)->is_unsafe_anonymous(); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
199 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
200 |
|
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
201 |
static unsigned int last_anonymous_hash = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
202 |
static traceid last_anonymous_id = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
203 |
|
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
204 |
traceid JfrSymbolId::mark_unsafe_anonymous_klass_name(const InstanceKlass* ik, bool leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
205 |
assert(ik != NULL, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
206 |
assert(ik->is_unsafe_anonymous(), "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
207 |
const uintptr_t hash = unsafe_anonymous_klass_name_hash(ik); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
208 |
if (hash == last_anonymous_hash) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
209 |
assert(last_anonymous_id != 0, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
210 |
return last_anonymous_id; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
211 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
212 |
last_anonymous_hash = hash; |
57987 | 213 |
const CStringEntry* const entry = _cstring_table->lookup_only(hash); |
214 |
last_anonymous_id = entry != NULL ? entry->id() : mark(hash, create_unsafe_anonymous_klass_symbol(ik, hash), leakp); |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
215 |
return last_anonymous_id; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
216 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
217 |
|
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
218 |
traceid JfrSymbolId::mark(const Klass* k, bool leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
219 |
assert(k != NULL, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
220 |
traceid symbol_id = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
221 |
if (is_unsafe_anonymous_klass(k)) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
222 |
assert(k->is_instance_klass(), "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
223 |
symbol_id = mark_unsafe_anonymous_klass_name((const InstanceKlass*)k, leakp); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
224 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
225 |
if (0 == symbol_id) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
226 |
Symbol* const sym = k->name(); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
227 |
if (sym != NULL) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
228 |
symbol_id = mark(sym, leakp); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
229 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
230 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
231 |
assert(symbol_id > 0, "a symbol handler must mark the symbol for writing"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
232 |
return symbol_id; |
50113 | 233 |
} |
234 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
235 |
static void preload_bootstrap_loader_name(JfrSymbolId* symbol_id) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
236 |
assert(symbol_id != NULL, "invariant"); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
237 |
assert(!symbol_id->has_entries(), "invariant"); |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
238 |
symbol_id->mark(1, (const char*)&BOOTSTRAP_LOADER_NAME, false); // pre-load "bootstrap" into id 1 |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
239 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
240 |
|
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
241 |
static void reset_symbol_caches() { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
242 |
last_anonymous_hash = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
243 |
last_symbol_hash = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
244 |
last_cstring_hash = 0; |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
245 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
246 |
|
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
247 |
JfrArtifactSet::JfrArtifactSet(bool class_unload) : _symbol_id(new JfrSymbolId()), |
57360 | 248 |
_klass_list(NULL), |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
249 |
_total_count(0) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
250 |
preload_bootstrap_loader_name(_symbol_id); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
251 |
initialize(class_unload); |
50113 | 252 |
assert(_klass_list != NULL, "invariant"); |
253 |
} |
|
254 |
||
255 |
static const size_t initial_class_list_size = 200; |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
256 |
|
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
257 |
void JfrArtifactSet::initialize(bool class_unload) { |
50113 | 258 |
assert(_symbol_id != NULL, "invariant"); |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
259 |
_symbol_id->set_class_unload(class_unload); |
57360 | 260 |
_total_count = 0; |
50113 | 261 |
// resource allocation |
262 |
_klass_list = new GrowableArray<const Klass*>(initial_class_list_size, false, mtTracing); |
|
263 |
} |
|
264 |
||
265 |
JfrArtifactSet::~JfrArtifactSet() { |
|
266 |
clear(); |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
267 |
delete _symbol_id; |
50113 | 268 |
} |
269 |
||
270 |
void JfrArtifactSet::clear() { |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
271 |
reset_symbol_caches(); |
50113 | 272 |
_symbol_id->clear(); |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
273 |
preload_bootstrap_loader_name(_symbol_id); |
50113 | 274 |
// _klass_list will be cleared by a ResourceMark |
275 |
} |
|
276 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
277 |
traceid JfrArtifactSet::mark_unsafe_anonymous_klass_name(const Klass* klass, bool leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
278 |
assert(klass->is_instance_klass(), "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
279 |
return _symbol_id->mark_unsafe_anonymous_klass_name((const InstanceKlass*)klass, leakp); |
50113 | 280 |
} |
281 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
282 |
traceid JfrArtifactSet::mark(uintptr_t hash, const Symbol* sym, bool leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
283 |
return _symbol_id->mark(hash, sym, leakp); |
50113 | 284 |
} |
285 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
286 |
traceid JfrArtifactSet::mark(const Klass* klass, bool leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
287 |
return _symbol_id->mark(klass, leakp); |
50113 | 288 |
} |
289 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
290 |
traceid JfrArtifactSet::mark(const Symbol* symbol, bool leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
291 |
return _symbol_id->mark(symbol, leakp); |
50113 | 292 |
} |
293 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
294 |
traceid JfrArtifactSet::mark(uintptr_t hash, const char* const str, bool leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
295 |
return _symbol_id->mark(hash, str, leakp); |
50113 | 296 |
} |
297 |
||
298 |
bool JfrArtifactSet::has_klass_entries() const { |
|
299 |
return _klass_list->is_nonempty(); |
|
300 |
} |
|
301 |
||
302 |
int JfrArtifactSet::entries() const { |
|
303 |
return _klass_list->length(); |
|
304 |
} |
|
305 |
||
306 |
void JfrArtifactSet::register_klass(const Klass* k) { |
|
307 |
assert(k != NULL, "invariant"); |
|
308 |
assert(_klass_list != NULL, "invariant"); |
|
309 |
assert(_klass_list->find(k) == -1, "invariant"); |
|
310 |
_klass_list->append(k); |
|
311 |
} |
|
57360 | 312 |
|
313 |
size_t JfrArtifactSet::total_count() const { |
|
314 |
return _total_count; |
|
315 |
} |