Skip to content
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
1 change: 1 addition & 0 deletions src/hotspot/share/jvmci/jvmciCodeInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ narrowKlass CodeInstaller::record_narrow_metadata_reference(CodeSection* section
int index = _oop_recorder->find_index(klass);
section->relocate(dest, metadata_Relocation::spec(index));
JVMCI_event_3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string());
guarantee(CompressedKlassPointers::is_encodable(klass), "klass cannot be compressed: %s", klass->external_name());
return CompressedKlassPointers::encode(klass);
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ private DirectHotSpotObjectConstantImpl(Object object, boolean compressed) {

@Override
public JavaConstant compress() {
assert !compressed;
if (compressed) {
throw new IllegalArgumentException("already compressed: " + this);
}
return new DirectHotSpotObjectConstantImpl(object, true);
}

@Override
public JavaConstant uncompress() {
assert compressed;
if (!compressed) {
throw new IllegalArgumentException("not compressed: " + this);
}
return new DirectHotSpotObjectConstantImpl(object, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ public boolean isCompressed() {
return true;
}

@Override
public boolean isCompressible() {
return false;
}

@Override
public Constant compress() {
throw new IllegalArgumentException();
throw new IllegalArgumentException("not compressible");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,34 @@
import jdk.vm.ci.meta.Constant;

/**
* Marker interface for hotspot specific constants.
* A value in a space managed by Hotspot (e.g. heap or metaspace).
* Some of these values can be referenced with a compressed pointer
* instead of a full word-sized pointer.
*/
public interface HotSpotConstant extends Constant {

/**
* Determines if this constant is compressed.
*/
boolean isCompressed();

/**
* Determines if this constant is compressible.
*/
boolean isCompressible();

/**
* Gets a compressed version of this uncompressed constant.
*
* @throws IllegalArgumentException if this constant is not compressible
*/
Constant compress();

/**
* Gets an uncompressed version of this compressed constant.
*
* @throws IllegalArgumentException if this is an uncompressed constant
* or this constant is not compressible
*/
Constant uncompress();
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ static MetaspaceObject getMetaspaceObject(Constant constant) {
private HotSpotMetaspaceConstantImpl(MetaspaceObject metaspaceObject, boolean compressed) {
this.metaspaceObject = metaspaceObject;
this.compressed = compressed;
if (compressed && !canBeStoredInCompressibleMetaSpace()) {
throw new IllegalArgumentException("constant cannot be compressed: " + metaspaceObject);
}
}

@Override
Expand Down Expand Up @@ -83,17 +86,38 @@ public boolean isCompressed() {
return compressed;
}

@Override
public boolean isCompressible() {
if (compressed) {
return false;
}
return canBeStoredInCompressibleMetaSpace();
}

private boolean canBeStoredInCompressibleMetaSpace() {
if (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();
}
return true;
}

@Override
public Constant compress() {
assert !isCompressed();
if (compressed) {
throw new IllegalArgumentException("already compressed: " + this);
}
HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(metaspaceObject, true);
assert res.isCompressed();
return res;
}

@Override
public Constant uncompress() {
assert isCompressed();
if (!compressed) {
throw new IllegalArgumentException("not compressed: " + this);
}
HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(metaspaceObject, false);
assert !res.isCompressed();
return res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public boolean isCompressed() {
return compressed;
}

@Override
public boolean isCompressible() {
return !compressed;
}

@Override
public abstract JavaConstant compress();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,17 @@ static void clearHandle(long handle) {

@Override
public JavaConstant compress() {
assert !compressed;
if (compressed) {
throw new IllegalArgumentException("already compressed: " + this);
}
return new IndirectHotSpotObjectConstantImpl(this, true);
}

@Override
public JavaConstant uncompress() {
assert compressed;
if (!compressed) {
throw new IllegalArgumentException("not compressed: " + this);
}
return new IndirectHotSpotObjectConstantImpl(this, false);
}

Expand Down