Skip to content

Commit

Permalink
8341444: Unnecessary check for JSRs in CDS
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, coleenp
  • Loading branch information
Matias Saavedra Silva committed Oct 18, 2024
1 parent 8174cbd commit 28252bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
25 changes: 5 additions & 20 deletions src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2452,11 +2452,11 @@ void InstanceKlass::metaspace_pointers_do(MetaspaceClosure* it) {
#endif
#if INCLUDE_CDS
// For "old" classes with methods containing the jsr bytecode, the _methods array will
// be rewritten during runtime (see Rewriter::rewrite_jsrs()). So setting the _methods to
// be writable. The length check on the _methods is necessary because classes which
// don't have any methods share the Universe::_the_empty_method_array which is in the RO region.
if (_methods != nullptr && _methods->length() > 0 &&
!can_be_verified_at_dumptime() && methods_contain_jsr_bytecode()) {
// be rewritten during runtime (see Rewriter::rewrite_jsrs()) but they cannot be safely
// checked here with ByteCodeStream. All methods that can't be verified are made writable.
// The length check on the _methods is necessary because classes which don't have any
// methods share the Universe::_the_empty_method_array which is in the RO region.
if (_methods != nullptr && _methods->length() > 0 && !can_be_verified_at_dumptime()) {
// To handle jsr bytecode, new Method* maybe stored into _methods
it->push(&_methods, MetaspaceClosure::_writable);
} else {
Expand Down Expand Up @@ -2697,21 +2697,6 @@ bool InstanceKlass::can_be_verified_at_dumptime() const {
}
return true;
}

bool InstanceKlass::methods_contain_jsr_bytecode() const {
Thread* thread = Thread::current();
for (int i = 0; i < _methods->length(); i++) {
methodHandle m(thread, _methods->at(i));
BytecodeStream bcs(m);
while (!bcs.is_last_bytecode()) {
Bytecodes::Code opcode = bcs.next();
if (opcode == Bytecodes::_jsr || opcode == Bytecodes::_jsr_w) {
return true;
}
}
}
return false;
}
#endif // INCLUDE_CDS

#if INCLUDE_JVMTI
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/oops/instanceKlass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,6 @@ class InstanceKlass: public Klass {
void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, PackageEntry* pkg_entry, TRAPS);
void init_shared_package_entry();
bool can_be_verified_at_dumptime() const;
bool methods_contain_jsr_bytecode() const;
void compute_has_loops_flag_for_methods();
#endif

Expand Down

0 comments on commit 28252bb

Please sign in to comment.