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