Skip to content

[JDK-8364585] Adapt JDK-8343218: Add option to disable allocating interface and abstract classes in non-class metaspace #11873

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

Merged
merged 2 commits into from
Aug 4, 2025
Merged
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 common.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
"jdks": {
"galahad-jdk": {"name": "jpg-jdk", "version": "26", "build_id": "jdk-26+10-966", "platformspecific": true, "extrabundles": ["static-libs"]},
"galahad-jdk": {"name": "jpg-jdk", "version": "26", "build_id": "jdk-26+10-1012", "platformspecific": true, "extrabundles": ["static-libs"]},

"oraclejdk17": {"name": "jpg-jdk", "version": "17.0.7", "build_id": "jdk-17.0.7+8", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-17": {"name": "labsjdk", "version": "ce-17.0.7+4-jvmci-23.1-b02", "platformspecific": true },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 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 @@ -40,7 +40,7 @@ public class HotSpotCompressedKlassPointerTest extends HotSpotGraalCompilerTest
@Before
public void setUp() {
GraalHotSpotVMConfig config = runtime().getVMConfig();
assumeTrue("compressed class pointers specific tests", config.useCompressedClassPointers);
assumeTrue("compressed class pointers specific tests", config.useCompressedClassPointers && !config.useClassMetaspaceForAllClasses);
}

// Non-abstract class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ public long gcTotalCollectionsAddress() {
// Compressed Oops related values.
public final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class);
public final boolean useCompressedClassPointers = getFlag("UseCompressedClassPointers", Boolean.class);

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

// JDK-8305895 allows storing the compressed class pointer in the upper 22 bits of the mark
// word. This runtime optimization is guarded by the flag UseCompactObjectHeaders. It depends
// on compressed class pointers, meaning that if useCompactObjectHeaders is true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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 @@ -44,7 +44,6 @@
import jdk.vm.ci.meta.Constant;
import jdk.vm.ci.meta.ConstantReflectionProvider;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.ResolvedJavaType;

@NodeInfo(nameTemplate = "{p#op/s}", cycles = CYCLES_2, size = SIZE_2)
public final class HotSpotCompressionNode extends CompressionNode {
Expand Down Expand Up @@ -74,9 +73,7 @@ private static CompressionNode uncompress(ValueNode input, CompressEncoding enco
@Override
public boolean isCompressible(Constant constant) {
if (constant instanceof HotSpotMetaspaceConstant mc) {
ResolvedJavaType type = mc.asResolvedJavaType();
// As of JDK-8338526, interface and abstract types are not compressible.
return type.isArray() || (!type.isAbstract() && !type.isInterface());
return mc.isCompressible();
}
return true;
}
Expand All @@ -103,14 +100,10 @@ protected Constant uncompress(Constant c) {

@Override
public ValueNode reverse(ValueNode input) {
switch (op) {
case Compress:
return uncompress(input, encoding);
case Uncompress:
return compress(input, encoding);
default:
throw GraalError.shouldNotReachHereUnexpectedValue(op); // ExcludeFromJacocoGeneratedReport
}
return switch (op) {
case Compress -> uncompress(input, encoding);
case Uncompress -> compress(input, encoding);
};
}

@Override
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 @@ -30,7 +30,6 @@
import jdk.graal.compiler.core.common.CompressEncoding;
import jdk.graal.compiler.core.common.type.AbstractObjectStamp;
import jdk.graal.compiler.core.common.type.Stamp;
import jdk.graal.compiler.debug.GraalError;
import jdk.graal.compiler.graph.NodeClass;
import jdk.graal.compiler.lir.gen.LIRGeneratorTool;
import jdk.graal.compiler.nodeinfo.NodeInfo;
Expand Down Expand Up @@ -83,26 +82,18 @@ public JavaConstant nullConstant() {

@Override
public Constant convert(Constant c, ConstantReflectionProvider constantReflection) {
switch (op) {
case Compress:
return compress(c);
case Uncompress:
return uncompress(c);
default:
throw GraalError.shouldNotReachHereUnexpectedValue(op); // ExcludeFromJacocoGeneratedReport
}
return switch (op) {
case Compress -> compress(c);
case Uncompress -> uncompress(c);
};
}

@Override
public Constant reverse(Constant c, ConstantReflectionProvider constantReflection) {
switch (op) {
case Compress:
return uncompress(c);
case Uncompress:
return compress(c);
default:
throw GraalError.shouldNotReachHereUnexpectedValue(op); // ExcludeFromJacocoGeneratedReport
}
return switch (op) {
case Compress -> uncompress(c);
case Uncompress -> compress(c);
};
}

/**
Expand Down Expand Up @@ -138,14 +129,12 @@ public boolean isCompressible(Constant constant) {

@Override
public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {
if (forValue.isConstant()) {
ConstantNode constant = (ConstantNode) forValue;
if (forValue instanceof ConstantNode constant) {
if (isCompressible(constant.getValue())) {
return ConstantNode.forConstant(stamp(NodeView.DEFAULT), convert(constant.getValue(), tool.getConstantReflection()), constant.getStableDimension(),
constant.isDefaultStable(), tool.getMetaAccess());
}
} else if (forValue instanceof CompressionNode) {
CompressionNode other = (CompressionNode) forValue;
} else if (forValue instanceof CompressionNode other) {
if (op != other.op && encoding.equals(other.encoding)) {
return other.getValue();
}
Expand All @@ -164,17 +153,10 @@ public void generate(NodeLIRBuilderTool gen) {
}

LIRGeneratorTool tool = gen.getLIRGeneratorTool();
Value result;
switch (op) {
case Compress:
result = tool.emitCompress(gen.operand(value), encoding, nonNull);
break;
case Uncompress:
result = tool.emitUncompress(gen.operand(value), encoding, nonNull);
break;
default:
throw GraalError.shouldNotReachHereUnexpectedValue(op); // ExcludeFromJacocoGeneratedReport
}
Value result = switch (op) {
case Compress -> tool.emitCompress(gen.operand(value), encoding, nonNull);
case Uncompress -> tool.emitUncompress(gen.operand(value), encoding, nonNull);
};

gen.setResult(this, result);
}
Expand Down
Loading