author | mgronlun |
Sat, 14 Sep 2019 14:40:09 +0200 | |
changeset 58132 | caa25ab47aca |
parent 53176 | 6af596144294 |
child 58157 | 9dca61a7df19 |
child 58786 | 7909763ad193 |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
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 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
31 |
static JfrSymbolId::CStringEntry* bootstrap = NULL; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
32 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
33 |
JfrSymbolId::JfrSymbolId() : |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
34 |
_sym_table(new SymbolTable(this)), |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
35 |
_cstring_table(new CStringTable(this)), |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
36 |
_sym_list(NULL), |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
37 |
_cstring_list(NULL), |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
38 |
_symbol_id_counter(1), |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
39 |
_class_unload(false) { |
50113 | 40 |
assert(_sym_table != NULL, "invariant"); |
41 |
assert(_cstring_table != NULL, "invariant"); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
42 |
bootstrap = new CStringEntry(0, (const char*)&BOOTSTRAP_LOADER_NAME); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
43 |
assert(bootstrap != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
44 |
bootstrap->set_id(1); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
45 |
_cstring_list = bootstrap; |
50113 | 46 |
} |
47 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
48 |
JfrSymbolId::~JfrSymbolId() { |
50113 | 49 |
clear(); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
50 |
delete _sym_table; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
51 |
delete _cstring_table; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
52 |
delete bootstrap; |
50113 | 53 |
} |
54 |
||
55 |
void JfrSymbolId::clear() { |
|
56 |
assert(_sym_table != NULL, "invariant"); |
|
57 |
if (_sym_table->has_entries()) { |
|
58 |
_sym_table->clear_entries(); |
|
59 |
} |
|
60 |
assert(!_sym_table->has_entries(), "invariant"); |
|
61 |
||
62 |
assert(_cstring_table != NULL, "invariant"); |
|
63 |
if (_cstring_table->has_entries()) { |
|
64 |
_cstring_table->clear_entries(); |
|
65 |
} |
|
66 |
assert(!_cstring_table->has_entries(), "invariant"); |
|
67 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
68 |
_sym_list = NULL; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
69 |
_cstring_list = NULL; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
70 |
_symbol_id_counter = 1; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
71 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
72 |
assert(bootstrap != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
73 |
bootstrap->reset(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
74 |
_cstring_list = bootstrap; |
50113 | 75 |
} |
76 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
77 |
void JfrSymbolId::set_class_unload(bool class_unload) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
78 |
_class_unload = class_unload; |
50113 | 79 |
} |
80 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
81 |
void JfrSymbolId::on_link(const SymbolEntry* entry) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
82 |
assert(entry != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
83 |
const_cast<Symbol*>(entry->literal())->increment_refcount(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
84 |
assert(entry->id() == 0, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
85 |
entry->set_id(++_symbol_id_counter); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
86 |
entry->set_list_next(_sym_list); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
87 |
_sym_list = entry; |
50113 | 88 |
} |
89 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
90 |
bool JfrSymbolId::on_equals(uintptr_t hash, const SymbolEntry* entry) { |
50113 | 91 |
// query might be NULL |
92 |
assert(entry != NULL, "invariant"); |
|
93 |
assert(entry->hash() == hash, "invariant"); |
|
94 |
return true; |
|
95 |
} |
|
96 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
97 |
void JfrSymbolId::on_unlink(const SymbolEntry* entry) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
98 |
assert(entry != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
99 |
const_cast<Symbol*>(entry->literal())->decrement_refcount(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
100 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
101 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
102 |
void JfrSymbolId::on_link(const CStringEntry* entry) { |
50113 | 103 |
assert(entry != NULL, "invariant"); |
104 |
assert(entry->id() == 0, "invariant"); |
|
105 |
entry->set_id(++_symbol_id_counter); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
106 |
entry->set_list_next(_cstring_list); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
107 |
_cstring_list = entry; |
50113 | 108 |
} |
109 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
110 |
bool JfrSymbolId::on_equals(uintptr_t hash, const CStringEntry* entry) { |
50113 | 111 |
assert(entry != NULL, "invariant"); |
112 |
assert(entry->hash() == hash, "invariant"); |
|
113 |
return true; |
|
114 |
} |
|
115 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
116 |
void JfrSymbolId::on_unlink(const CStringEntry* entry) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
117 |
assert(entry != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
118 |
JfrCHeapObj::free(const_cast<char*>(entry->literal()), strlen(entry->literal() + 1)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
119 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
120 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
121 |
traceid JfrSymbolId::bootstrap_name(bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
122 |
assert(bootstrap != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
123 |
if (leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
124 |
bootstrap->set_leakp(); |
50113 | 125 |
} |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
126 |
return 1; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
127 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
128 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
129 |
traceid JfrSymbolId::mark(const Symbol* symbol, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
130 |
assert(symbol != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
131 |
return mark((uintptr_t)symbol->identity_hash(), symbol, leakp); |
50113 | 132 |
} |
133 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
134 |
static unsigned int last_symbol_hash = 0; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
135 |
static traceid last_symbol_id = 0; |
50113 | 136 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
137 |
traceid JfrSymbolId::mark(uintptr_t hash, const Symbol* data, bool leakp) { |
50113 | 138 |
assert(data != NULL, "invariant"); |
139 |
assert(_sym_table != NULL, "invariant"); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
140 |
if (hash == last_symbol_hash) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
141 |
assert(last_symbol_id != 0, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
142 |
return last_symbol_id; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
143 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
144 |
const SymbolEntry& entry = _sym_table->lookup_put(hash, data); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
145 |
if (_class_unload) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
146 |
entry.set_unloading(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
147 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
148 |
if (leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
149 |
entry.set_leakp(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
150 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
151 |
last_symbol_hash = hash; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
152 |
last_symbol_id = entry.id(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
153 |
return last_symbol_id; |
50113 | 154 |
} |
155 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
156 |
static unsigned int last_cstring_hash = 0; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
157 |
static traceid last_cstring_id = 0; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
158 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
159 |
traceid JfrSymbolId::mark(uintptr_t hash, const char* str, bool leakp) { |
50113 | 160 |
assert(str != NULL, "invariant"); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
161 |
assert(_cstring_table != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
162 |
if (hash == last_cstring_hash) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
163 |
assert(last_cstring_id != 0, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
164 |
return last_cstring_id; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
165 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
166 |
const CStringEntry& entry = _cstring_table->lookup_put(hash, str); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
167 |
if (_class_unload) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
168 |
entry.set_unloading(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
169 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
170 |
if (leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
171 |
entry.set_leakp(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
172 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
173 |
last_cstring_hash = hash; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
174 |
last_cstring_id = entry.id(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
175 |
return last_cstring_id; |
50113 | 176 |
} |
177 |
||
178 |
/* |
|
179 |
* jsr292 anonymous classes symbol is the external name + |
|
180 |
* the identity_hashcode slash appended: |
|
181 |
* java.lang.invoke.LambdaForm$BMH/22626602 |
|
182 |
* |
|
183 |
* caller needs ResourceMark |
|
184 |
*/ |
|
185 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
186 |
uintptr_t JfrSymbolId::unsafe_anonymous_klass_name_hash(const InstanceKlass* ik) { |
50113 | 187 |
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
|
188 |
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
|
189 |
const oop mirror = ik->java_mirror_no_keepalive(); |
50113 | 190 |
assert(mirror != NULL, "invariant"); |
191 |
return (uintptr_t)mirror->identity_hash(); |
|
192 |
} |
|
193 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
194 |
static const char* create_unsafe_anonymous_klass_symbol(const InstanceKlass* ik, uintptr_t hash) { |
50113 | 195 |
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
|
196 |
assert(ik->is_unsafe_anonymous(), "invariant"); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
197 |
assert(hash != 0, "invariant"); |
50113 | 198 |
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
|
199 |
const oop mirror = ik->java_mirror_no_keepalive(); |
50113 | 200 |
assert(mirror != NULL, "invariant"); |
201 |
char hash_buf[40]; |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
202 |
sprintf(hash_buf, "/" UINTX_FORMAT, hash); |
50113 | 203 |
const size_t hash_len = strlen(hash_buf); |
204 |
const size_t result_len = ik->name()->utf8_length(); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
205 |
anonymous_symbol = JfrCHeapObj::new_array<char>(result_len + hash_len + 1); |
50113 | 206 |
ik->name()->as_klass_external_name(anonymous_symbol, (int)result_len + 1); |
207 |
assert(strlen(anonymous_symbol) == result_len, "invariant"); |
|
208 |
strcpy(anonymous_symbol + result_len, hash_buf); |
|
209 |
assert(strlen(anonymous_symbol) == result_len + hash_len, "invariant"); |
|
210 |
return anonymous_symbol; |
|
211 |
} |
|
212 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
213 |
bool JfrSymbolId::is_unsafe_anonymous_klass(const Klass* k) { |
50113 | 214 |
assert(k != NULL, "invariant"); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
215 |
return k->is_instance_klass() && ((const InstanceKlass*)k)->is_unsafe_anonymous(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
216 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
217 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
218 |
static unsigned int last_anonymous_hash = 0; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
219 |
static traceid last_anonymous_id = 0; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
220 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
221 |
traceid JfrSymbolId::mark_unsafe_anonymous_klass_name(const InstanceKlass* ik, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
222 |
assert(ik != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
223 |
assert(ik->is_unsafe_anonymous(), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
224 |
const uintptr_t hash = unsafe_anonymous_klass_name_hash(ik); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
225 |
if (hash == last_anonymous_hash) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
226 |
assert(last_anonymous_id != 0, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
227 |
return last_anonymous_id; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
228 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
229 |
last_anonymous_hash = hash; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
230 |
const CStringEntry* const entry = _cstring_table->lookup_only(hash); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
231 |
last_anonymous_id = entry != NULL ? entry->id() : mark(hash, create_unsafe_anonymous_klass_symbol(ik, hash), leakp); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
232 |
return last_anonymous_id; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
233 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
234 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
235 |
traceid JfrSymbolId::mark(const Klass* k, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
236 |
assert(k != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
237 |
traceid symbol_id = 0; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
238 |
if (is_unsafe_anonymous_klass(k)) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
239 |
assert(k->is_instance_klass(), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
240 |
symbol_id = mark_unsafe_anonymous_klass_name((const InstanceKlass*)k, leakp); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
241 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
242 |
if (0 == symbol_id) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
243 |
Symbol* const sym = k->name(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
244 |
if (sym != NULL) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
245 |
symbol_id = mark(sym, leakp); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
246 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
247 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
248 |
assert(symbol_id > 0, "a symbol handler must mark the symbol for writing"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
249 |
return symbol_id; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
250 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
251 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
252 |
static void reset_symbol_caches() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
253 |
last_anonymous_hash = 0; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
254 |
last_symbol_hash = 0; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
255 |
last_cstring_hash = 0; |
50113 | 256 |
} |
257 |
||
258 |
JfrArtifactSet::JfrArtifactSet(bool class_unload) : _symbol_id(new JfrSymbolId()), |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
259 |
_klass_list(NULL), |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
260 |
_total_count(0) { |
50113 | 261 |
initialize(class_unload); |
262 |
assert(_klass_list != NULL, "invariant"); |
|
263 |
} |
|
264 |
||
265 |
static const size_t initial_class_list_size = 200; |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
266 |
|
50113 | 267 |
void JfrArtifactSet::initialize(bool class_unload) { |
268 |
assert(_symbol_id != NULL, "invariant"); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
269 |
_symbol_id->set_class_unload(class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
270 |
_total_count = 0; |
50113 | 271 |
// resource allocation |
272 |
_klass_list = new GrowableArray<const Klass*>(initial_class_list_size, false, mtTracing); |
|
273 |
} |
|
274 |
||
275 |
JfrArtifactSet::~JfrArtifactSet() { |
|
276 |
clear(); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
277 |
delete _symbol_id; |
50113 | 278 |
} |
279 |
||
280 |
void JfrArtifactSet::clear() { |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
281 |
reset_symbol_caches(); |
50113 | 282 |
_symbol_id->clear(); |
283 |
// _klass_list will be cleared by a ResourceMark |
|
284 |
} |
|
285 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
286 |
traceid JfrArtifactSet::bootstrap_name(bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
287 |
return _symbol_id->bootstrap_name(leakp); |
50113 | 288 |
} |
289 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
290 |
traceid JfrArtifactSet::mark_unsafe_anonymous_klass_name(const Klass* klass, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
291 |
assert(klass->is_instance_klass(), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
292 |
return _symbol_id->mark_unsafe_anonymous_klass_name((const InstanceKlass*)klass, leakp); |
50113 | 293 |
} |
294 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
295 |
traceid JfrArtifactSet::mark(uintptr_t hash, const Symbol* sym, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
296 |
return _symbol_id->mark(hash, sym, leakp); |
50113 | 297 |
} |
298 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
299 |
traceid JfrArtifactSet::mark(const Klass* klass, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
300 |
return _symbol_id->mark(klass, leakp); |
50113 | 301 |
} |
302 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
303 |
traceid JfrArtifactSet::mark(const Symbol* symbol, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
304 |
return _symbol_id->mark(symbol, leakp); |
50113 | 305 |
} |
306 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
307 |
traceid JfrArtifactSet::mark(uintptr_t hash, const char* const str, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
308 |
return _symbol_id->mark(hash, str, leakp); |
50113 | 309 |
} |
310 |
||
311 |
bool JfrArtifactSet::has_klass_entries() const { |
|
312 |
return _klass_list->is_nonempty(); |
|
313 |
} |
|
314 |
||
315 |
int JfrArtifactSet::entries() const { |
|
316 |
return _klass_list->length(); |
|
317 |
} |
|
318 |
||
319 |
void JfrArtifactSet::register_klass(const Klass* k) { |
|
320 |
assert(k != NULL, "invariant"); |
|
321 |
assert(_klass_list != NULL, "invariant"); |
|
322 |
assert(_klass_list->find(k) == -1, "invariant"); |
|
323 |
_klass_list->append(k); |
|
324 |
} |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
325 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
326 |
size_t JfrArtifactSet::total_count() const { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
327 |
return _total_count; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53176
diff
changeset
|
328 |
} |