Skip to content

8343218: Add option to disable allocating interface and abstract classes in non-class metaspace #26579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& par
assert(loader_data != nullptr, "invariant");

InstanceKlass* ik;
const bool use_class_space = parser.klass_needs_narrow_id();
const bool use_class_space = UseClassMetaspaceForAllClasses || parser.klass_needs_narrow_id();

// Allocation
if (parser.is_instance_ref_klass()) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/oops/klass.inline.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -182,6 +182,6 @@ inline bool Klass::needs_narrow_id() const {
// never instantiated classes out of class space lessens the class space pressure.
// For more details, see JDK-8338526.
// Note: don't call this function before access flags are initialized.
return !is_abstract() && !is_interface();
return UseClassMetaspaceForAllClasses || (!is_abstract() && !is_interface());
}
#endif // SHARE_OOPS_KLASS_INLINE_HPP
4 changes: 4 additions & 0 deletions src/hotspot/share/runtime/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2000,6 +2000,10 @@ const int ObjectAlignmentInBytes = 8;
develop(uint, BinarySearchThreshold, 16, \
"Minimal number of elements in a sorted collection to prefer" \
"binary search over simple linear search." ) \
\
product(bool, UseClassMetaspaceForAllClasses, false, DIAGNOSTIC, \
"Use the class metaspace for all classes including " \
"abstract and interface classes.") \

// end of RUNTIME_FLAGS

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -95,7 +95,7 @@ public boolean isCompressible() {
}

private boolean canBeStoredInCompressibleMetaSpace() {
if (metaspaceObject instanceof HotSpotResolvedJavaType t && !t.isArray()) {
if (!HotSpotVMConfig.config().useClassMetaspaceForAllClasses && metaspaceObject instanceof HotSpotResolvedJavaType t && !t.isArray()) {
// As of JDK-8338526, interface and abstract types are not stored
// in compressible metaspace.
return !t.isInterface() && !t.isAbstract();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -67,6 +67,8 @@ static String getHostArchitectureName() {

final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class);

final boolean useClassMetaspaceForAllClasses = getFlag("UseClassMetaspaceForAllClasses", Boolean.class);

final int objectAlignment = getFlag("ObjectAlignmentInBytes", Integer.class);

final int klassOffsetInBytes = getFieldValue("CompilerToVM::Data::oopDesc_klass_offset_in_bytes", Integer.class, "int");
Expand Down