Skip to content

8351268: [JVMCI] Enhance JVMCI by leveraging modern Java features #25442

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

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion src/java.base/share/classes/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@
jdk.management,
jdk.net,
jdk.sctp,
jdk.crypto.cryptoki;
jdk.crypto.cryptoki,
jdk.internal.vm.ci;
exports jdk.internal.classfile.components to
jdk.jfr;
exports jdk.internal.foreign to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,15 @@ public EnumSet<CPUFeature> getFeatures() {

@Override
public PlatformKind getPlatformKind(JavaKind javaKind) {
switch (javaKind) {
case Boolean:
case Byte:
return AArch64Kind.BYTE;
case Short:
case Char:
return AArch64Kind.WORD;
case Int:
return AArch64Kind.DWORD;
case Long:
case Object:
return AArch64Kind.QWORD;
case Float:
return AArch64Kind.SINGLE;
case Double:
return AArch64Kind.DOUBLE;
default:
return null;
}
return switch (javaKind) {
case Boolean, Byte -> AArch64Kind.BYTE;
case Short, Char -> AArch64Kind.WORD;
case Int -> AArch64Kind.DWORD;
case Long, Object -> AArch64Kind.QWORD;
case Float -> AArch64Kind.SINGLE;
case Double -> AArch64Kind.DOUBLE;
default -> null;
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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 @@ -87,67 +87,32 @@ public Key getKey() {
}

public boolean isInteger() {
switch (this) {
case BYTE:
case WORD:
case DWORD:
case QWORD:
return true;
default:
return false;
}
return switch (this) {
case BYTE, WORD, DWORD, QWORD -> true;
default -> false;
};
}

public boolean isSIMD() {
switch (this) {
case SINGLE:
case DOUBLE:
case V32_BYTE:
case V32_WORD:
case V64_BYTE:
case V64_WORD:
case V64_DWORD:
case V128_BYTE:
case V128_WORD:
case V128_DWORD:
case V128_QWORD:
case V128_SINGLE:
case V128_DOUBLE:
return true;
default:
return false;
}
return switch (this) {
case SINGLE, DOUBLE, V32_BYTE, V32_WORD, V64_BYTE, V64_WORD, V64_DWORD, V128_BYTE, V128_WORD, V128_DWORD,
V128_QWORD, V128_SINGLE, V128_DOUBLE -> true;
default -> false;
};
}

@Override
public char getTypeChar() {
switch (this) {
case BYTE:
return 'b';
case WORD:
return 'w';
case DWORD:
return 'd';
case QWORD:
return 'q';
case SINGLE:
return 'S';
case DOUBLE:
return 'D';
case V32_BYTE:
case V32_WORD:
case V64_BYTE:
case V64_WORD:
case V64_DWORD:
case V128_BYTE:
case V128_WORD:
case V128_DWORD:
case V128_QWORD:
case V128_SINGLE:
case V128_DOUBLE:
return 'v';
default:
return '-';
}
return switch (this) {
case BYTE -> 'b';
case WORD -> 'w';
case DWORD -> 'd';
case QWORD -> 'q';
case SINGLE -> 'S';
case DOUBLE -> 'D';
case V32_BYTE, V32_WORD, V64_BYTE, V64_WORD, V64_DWORD, V128_BYTE, V128_WORD, V128_DWORD, V128_QWORD,
V128_SINGLE, V128_DOUBLE -> 'v';
default -> '-';
};
}
}
28 changes: 9 additions & 19 deletions src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,25 +339,15 @@ public List<Register> getAvailableValueRegisters() {

@Override
public PlatformKind getPlatformKind(JavaKind javaKind) {
switch (javaKind) {
case Boolean:
case Byte:
return AMD64Kind.BYTE;
case Short:
case Char:
return AMD64Kind.WORD;
case Int:
return AMD64Kind.DWORD;
case Long:
case Object:
return AMD64Kind.QWORD;
case Float:
return AMD64Kind.SINGLE;
case Double:
return AMD64Kind.DOUBLE;
default:
return null;
}
return switch (javaKind) {
case Boolean, Byte -> AMD64Kind.BYTE;
case Short, Char -> AMD64Kind.WORD;
case Int -> AMD64Kind.DWORD;
case Long, Object -> AMD64Kind.QWORD;
case Float -> AMD64Kind.SINGLE;
case Double -> AMD64Kind.DOUBLE;
default -> null;
};
}

@Override
Expand Down
126 changes: 29 additions & 97 deletions src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64Kind.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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 @@ -108,111 +108,43 @@ public Key getKey() {
}

public boolean isInteger() {
switch (this) {
case BYTE:
case WORD:
case DWORD:
case QWORD:
return true;
default:
return false;
}
return switch (this) {
case BYTE, WORD, DWORD, QWORD -> true;
default -> false;
};
}

public boolean isXMM() {
switch (this) {
case SINGLE:
case DOUBLE:
case V32_BYTE:
case V32_WORD:
case V64_BYTE:
case V64_WORD:
case V64_DWORD:
case V128_BYTE:
case V128_WORD:
case V128_DWORD:
case V128_QWORD:
case V128_SINGLE:
case V128_DOUBLE:
case V256_BYTE:
case V256_WORD:
case V256_DWORD:
case V256_QWORD:
case V256_SINGLE:
case V256_DOUBLE:
case V512_BYTE:
case V512_WORD:
case V512_DWORD:
case V512_QWORD:
case V512_SINGLE:
case V512_DOUBLE:
return true;
default:
return false;
}
return switch (this) {
case SINGLE, DOUBLE, V32_BYTE, V32_WORD, V64_BYTE, V64_WORD, V64_DWORD, V128_BYTE, V128_WORD, V128_DWORD,
V128_QWORD, V128_SINGLE, V128_DOUBLE, V256_BYTE, V256_WORD, V256_DWORD, V256_QWORD, V256_SINGLE,
V256_DOUBLE, V512_BYTE, V512_WORD, V512_DWORD, V512_QWORD, V512_SINGLE, V512_DOUBLE -> true;
default -> false;
};
}

public boolean isMask() {
switch (this) {
case MASK8:
case MASK16:
case MASK32:
case MASK64:
return true;
default:
return false;
}
return switch (this) {
case MASK8, MASK16, MASK32, MASK64 -> true;
default -> false;
};
}

@Override
public char getTypeChar() {
switch (this) {
case BYTE:
return 'b';
case WORD:
return 'w';
case DWORD:
return 'd';
case QWORD:
return 'q';
case SINGLE:
return 'S';
case DOUBLE:
return 'D';
case V32_BYTE:
case V32_WORD:
case V64_BYTE:
case V64_WORD:
case V64_DWORD:
return 'v';
case V128_BYTE:
case V128_WORD:
case V128_DWORD:
case V128_QWORD:
case V128_SINGLE:
case V128_DOUBLE:
return 'x';
case V256_BYTE:
case V256_WORD:
case V256_DWORD:
case V256_QWORD:
case V256_SINGLE:
case V256_DOUBLE:
return 'y';
case V512_BYTE:
case V512_WORD:
case V512_DWORD:
case V512_QWORD:
case V512_SINGLE:
case V512_DOUBLE:
return 'z';
case MASK8:
case MASK16:
case MASK32:
case MASK64:
return 'k';
default:
return '-';
}
return switch (this) {
case BYTE -> 'b';
case WORD -> 'w';
case DWORD -> 'd';
case QWORD -> 'q';
case SINGLE -> 'S';
case DOUBLE -> 'D';
case V32_BYTE, V32_WORD, V64_BYTE, V64_WORD, V64_DWORD -> 'v';
case V128_BYTE, V128_WORD, V128_DWORD, V128_QWORD, V128_SINGLE, V128_DOUBLE -> 'x';
case V256_BYTE, V256_WORD, V256_DWORD, V256_QWORD, V256_SINGLE, V256_DOUBLE -> 'y';
case V512_BYTE, V512_WORD, V512_DWORD, V512_QWORD, V512_SINGLE, V512_DOUBLE -> 'z';
case MASK8, MASK16, MASK32, MASK64 -> 'k';
default -> '-';
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ protected Architecture(String name, PlatformKind wordKind, ByteOrder byteOrder,
int returnAddressSize) {
// registers is expected to mention all registers in order of their encoding.
for (int i = 0; i < registers.size(); ++i) {
if (registers.get(i).number != i) {
if (registers.get(i).number() != i) {
Register reg = registers.get(i);
throw new JVMCIError("%s: %d != %d", reg, reg.number, i);
throw new JVMCIError("%s: %d != %d", reg, reg.number(), i);
}
}
this.name = name;
Expand Down Expand Up @@ -222,8 +222,7 @@ public final boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof Architecture) {
Architecture that = (Architecture) obj;
if (obj instanceof Architecture that) {
if (this.name.equals(that.name)) {
assert this.byteOrder.equals(that.byteOrder);
assert this.implicitMemoryBarriers == that.implicitMemoryBarriers;
Expand Down
Loading