author | mgronlun |
Mon, 02 Sep 2019 19:42:46 +0200 | |
branch | JEP-349-branch |
changeset 57983 | a57907813a83 |
parent 57870 | 00860d9caf4d |
child 57987 | 23e3cd901cb6 |
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 |
static const char* resource_str_to_c_heap_str(const char* resource_str) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
92 |
assert(resource_str != NULL, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
93 |
const size_t length = strlen(resource_str); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
94 |
char* const c_string = JfrCHeapObj::new_array<char>(length + 1); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
95 |
assert(c_string != NULL, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
96 |
strncpy(c_string, resource_str, length + 1); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
97 |
return c_string; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
98 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
99 |
|
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
100 |
void JfrSymbolId::link(const CStringEntry* entry) { |
50113 | 101 |
assert(entry != NULL, "invariant"); |
102 |
assert(entry->id() == 0, "invariant"); |
|
103 |
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
|
104 |
entry->set_list_next(_cstring_list); |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
105 |
const char* const resource_str = entry->literal(); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
106 |
const_cast<CStringEntry*>(entry)->set_literal(resource_str_to_c_heap_str(resource_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
|
107 |
_cstring_list = entry; |
50113 | 108 |
} |
109 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
110 |
bool JfrSymbolId::equals(uintptr_t hash, const CStringEntry* entry) { |
50113 | 111 |
assert(entry != NULL, "invariant"); |
112 |
assert(entry->hash() == hash, "invariant"); |
|
113 |
return true; |
|
114 |
} |
|
115 |
||
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
|
116 |
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
|
117 |
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
|
118 |
if (entry->id() != 1) { |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
119 |
JfrCHeapObj::free(const_cast<char*>(entry->literal()), 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
|
120 |
} |
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
|
121 |
} |
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
|
122 |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
123 |
traceid JfrSymbolId::mark(const Symbol* symbol, bool leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
124 |
assert(symbol != NULL, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
125 |
return mark((uintptr_t)symbol->identity_hash(), symbol, leakp); |
50113 | 126 |
} |
127 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
128 |
static unsigned int last_symbol_hash = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
129 |
static traceid last_symbol_id = 0; |
50113 | 130 |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
131 |
traceid JfrSymbolId::mark(uintptr_t hash, const Symbol* data, bool leakp) { |
50113 | 132 |
assert(data != NULL, "invariant"); |
133 |
assert(_sym_table != NULL, "invariant"); |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
134 |
if (hash == last_symbol_hash) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
135 |
assert(last_symbol_id != 0, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
136 |
return last_symbol_id; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
137 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
} |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
142 |
if (leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
143 |
entry.set_leakp(); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
144 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
145 |
last_symbol_hash = hash; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
146 |
last_symbol_id = entry.id(); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
147 |
return last_symbol_id; |
50113 | 148 |
} |
149 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
150 |
static unsigned int last_cstring_hash = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
151 |
static traceid last_cstring_id = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
152 |
|
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
153 |
traceid JfrSymbolId::mark(uintptr_t hash, const char* str, bool leakp) { |
50113 | 154 |
assert(str != NULL, "invariant"); |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
155 |
assert(_cstring_table != NULL, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
156 |
if (hash == last_cstring_hash) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
157 |
assert(last_cstring_id != 0, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
158 |
return last_cstring_id; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
159 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
160 |
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
|
161 |
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
|
162 |
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
|
163 |
} |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
164 |
if (leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
165 |
entry.set_leakp(); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
166 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
167 |
last_cstring_hash = hash; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
168 |
last_cstring_id = entry.id(); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
169 |
return last_cstring_id; |
50113 | 170 |
} |
171 |
||
172 |
/* |
|
173 |
* jsr292 anonymous classes symbol is the external name + |
|
174 |
* the identity_hashcode slash appended: |
|
175 |
* java.lang.invoke.LambdaForm$BMH/22626602 |
|
176 |
* |
|
177 |
* caller needs ResourceMark |
|
178 |
*/ |
|
179 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
180 |
uintptr_t JfrSymbolId::unsafe_anonymous_klass_name_hash(const InstanceKlass* ik) { |
50113 | 181 |
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
|
182 |
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
|
183 |
const oop mirror = ik->java_mirror_no_keepalive(); |
50113 | 184 |
assert(mirror != NULL, "invariant"); |
185 |
return (uintptr_t)mirror->identity_hash(); |
|
186 |
} |
|
187 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
188 |
static const char* create_unsafe_anonymous_klass_symbol(const InstanceKlass* ik, uintptr_t hash) { |
50113 | 189 |
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
|
190 |
assert(ik->is_unsafe_anonymous(), "invariant"); |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
191 |
assert(hash != 0, "invariant"); |
50113 | 192 |
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
|
193 |
const oop mirror = ik->java_mirror_no_keepalive(); |
50113 | 194 |
assert(mirror != NULL, "invariant"); |
195 |
char hash_buf[40]; |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
196 |
sprintf(hash_buf, "/" UINTX_FORMAT, hash); |
50113 | 197 |
const size_t hash_len = strlen(hash_buf); |
198 |
const size_t result_len = ik->name()->utf8_length(); |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
199 |
anonymous_symbol = NEW_RESOURCE_ARRAY(char, result_len + hash_len + 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
|
200 |
assert(anonymous_symbol != NULL, "invariant"); |
50113 | 201 |
ik->name()->as_klass_external_name(anonymous_symbol, (int)result_len + 1); |
202 |
assert(strlen(anonymous_symbol) == result_len, "invariant"); |
|
203 |
strcpy(anonymous_symbol + result_len, hash_buf); |
|
204 |
assert(strlen(anonymous_symbol) == result_len + hash_len, "invariant"); |
|
205 |
return anonymous_symbol; |
|
206 |
} |
|
207 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
208 |
bool JfrSymbolId::is_unsafe_anonymous_klass(const Klass* k) { |
50113 | 209 |
assert(k != NULL, "invariant"); |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
210 |
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
|
211 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
212 |
|
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
213 |
static unsigned int last_anonymous_hash = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
214 |
static traceid last_anonymous_id = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
215 |
|
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
216 |
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
|
217 |
assert(ik != NULL, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
218 |
assert(ik->is_unsafe_anonymous(), "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
219 |
const uintptr_t hash = unsafe_anonymous_klass_name_hash(ik); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
220 |
if (hash == last_anonymous_hash) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
221 |
assert(last_anonymous_id != 0, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
222 |
return last_anonymous_id; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
223 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
224 |
last_anonymous_hash = hash; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
225 |
last_anonymous_id = mark(hash, create_unsafe_anonymous_klass_symbol(ik, hash), leakp); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
226 |
return last_anonymous_id; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
227 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
228 |
|
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
229 |
traceid JfrSymbolId::mark(const Klass* k, bool leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
230 |
assert(k != NULL, "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
231 |
traceid symbol_id = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
232 |
if (is_unsafe_anonymous_klass(k)) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
233 |
assert(k->is_instance_klass(), "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
234 |
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
|
235 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
236 |
if (0 == symbol_id) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
237 |
Symbol* const sym = k->name(); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
238 |
if (sym != NULL) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
239 |
symbol_id = mark(sym, leakp); |
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 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
242 |
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
|
243 |
return symbol_id; |
50113 | 244 |
} |
245 |
||
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
|
246 |
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
|
247 |
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
|
248 |
assert(!symbol_id->has_entries(), "invariant"); |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
249 |
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
|
250 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
251 |
|
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
252 |
static void reset_symbol_caches() { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
253 |
last_anonymous_hash = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
254 |
last_symbol_hash = 0; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
255 |
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
|
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 |
|
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
|
258 |
JfrArtifactSet::JfrArtifactSet(bool class_unload) : _symbol_id(new JfrSymbolId()), |
57360 | 259 |
_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
|
260 |
_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
|
261 |
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
|
262 |
initialize(class_unload); |
50113 | 263 |
assert(_klass_list != NULL, "invariant"); |
264 |
} |
|
265 |
||
266 |
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
|
267 |
|
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
|
268 |
void JfrArtifactSet::initialize(bool class_unload) { |
50113 | 269 |
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
|
270 |
_symbol_id->set_class_unload(class_unload); |
57360 | 271 |
_total_count = 0; |
50113 | 272 |
// resource allocation |
273 |
_klass_list = new GrowableArray<const Klass*>(initial_class_list_size, false, mtTracing); |
|
274 |
} |
|
275 |
||
276 |
JfrArtifactSet::~JfrArtifactSet() { |
|
277 |
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
|
278 |
delete _symbol_id; |
50113 | 279 |
} |
280 |
||
281 |
void JfrArtifactSet::clear() { |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
282 |
reset_symbol_caches(); |
50113 | 283 |
_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
|
284 |
preload_bootstrap_loader_name(_symbol_id); |
50113 | 285 |
// _klass_list will be cleared by a ResourceMark |
286 |
} |
|
287 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
288 |
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
|
289 |
assert(klass->is_instance_klass(), "invariant"); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
290 |
return _symbol_id->mark_unsafe_anonymous_klass_name((const InstanceKlass*)klass, leakp); |
50113 | 291 |
} |
292 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
293 |
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
|
294 |
return _symbol_id->mark(hash, sym, leakp); |
50113 | 295 |
} |
296 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
297 |
traceid JfrArtifactSet::mark(const Klass* klass, bool leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
298 |
return _symbol_id->mark(klass, leakp); |
50113 | 299 |
} |
300 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
301 |
traceid JfrArtifactSet::mark(const Symbol* symbol, bool leakp) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
302 |
return _symbol_id->mark(symbol, leakp); |
50113 | 303 |
} |
304 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
305 |
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
|
306 |
return _symbol_id->mark(hash, str, leakp); |
50113 | 307 |
} |
308 |
||
309 |
bool JfrArtifactSet::has_klass_entries() const { |
|
310 |
return _klass_list->is_nonempty(); |
|
311 |
} |
|
312 |
||
313 |
int JfrArtifactSet::entries() const { |
|
314 |
return _klass_list->length(); |
|
315 |
} |
|
316 |
||
317 |
void JfrArtifactSet::register_klass(const Klass* k) { |
|
318 |
assert(k != NULL, "invariant"); |
|
319 |
assert(_klass_list != NULL, "invariant"); |
|
320 |
assert(_klass_list->find(k) == -1, "invariant"); |
|
321 |
_klass_list->append(k); |
|
322 |
} |
|
57360 | 323 |
|
324 |
size_t JfrArtifactSet::total_count() const { |
|
325 |
return _total_count; |
|
326 |
} |