Skip to content
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

Add SIMD Support for Java 21 #1499

Merged
merged 8 commits into from
Mar 31, 2024
Merged
4 changes: 2 additions & 2 deletions patches/api/0001-Pufferfish-API-Changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

diff --git a/build.gradle.kts b/build.gradle.kts
index bf01892c248b988531d21d9fb0f74d0adf2205ac..80833c13a2d19e31d6f648e7ef5b3456025e767e 100644
index 66bcd8f9a8fce8f920a0f1dd7ae0a2937da68e80..c43eb3099747b9f1155b918ca818487b63488538 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -51,6 +51,7 @@ dependencies {
Expand Down Expand Up @@ -480,7 +480,7 @@ index eaefbb00e9993d54906cc8cf35cf753c0d6c7707..301e82369603f3dd6e6c1bd380da4bac

if (cloader instanceof PluginClassLoader) {
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index f9b57b872780aa6b9b959494874b57c7a8ff0c53..90953bfc81168068a281be4d2d3942d5e7dd69ff 100644
index 7e4f7cb2afbc145e532285c793573ad107bc3033..12449e18180d604e9cbbc744da74a8b222a18e1f 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -50,6 +50,8 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
Expand Down
13 changes: 13 additions & 0 deletions patches/api/0002-Fix-pufferfish-issues.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ Date: Tue, 4 Jan 2022 23:05:41 -0600
Subject: [PATCH] Fix pufferfish issues


diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
index ab5fea0b03224bf249352ce340e94704ff713345..3441cdad70da1bd523c5933b1a914688718c2657 100644
--- a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
@@ -15,7 +15,7 @@ public class SIMDChecker {
@Deprecated
public static boolean canEnable(Logger logger) {
try {
- if (SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18 && SIMDDetection.getJavaVersion() != 19) {
+ if (SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21) {
return false;
} else {
SIMDDetection.testRun = true;
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
index 88f1ca89fa640a686231b8eec87e70419b2d73ef..d6b91c49a267c89d7df2ddee7ccfe64675d117be 100644
--- a/src/test/java/org/bukkit/AnnotationTest.java
Expand Down
22 changes: 20 additions & 2 deletions patches/server/0003-Fix-pufferfish-issues.patch
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,27 @@ index 7e82d2c6a6085a5ea335ba9ef2a5ec3f5a37e787..32366253c04c493135f2b22d1940f836
+ jvmArgs("-DPaper.isRunDev=true")
}
diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
index f6a3364175476c57a7763a087ff55e1689474800..5e01bfdad663656168604fc878a993dd910bf45b 100644
index f6a3364175476c57a7763a087ff55e1689474800..8b8fe02b9db5192a3adb8d4a3bb3c2105f90544d 100644
--- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
@@ -86,7 +86,7 @@ public class PufferfishConfig {
// Attempt to detect vectorization
try {
SIMDDetection.isEnabled = SIMDDetection.canEnable(PufferfishLogger.LOGGER);
- SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18 && SIMDDetection.getJavaVersion() != 19;
+ SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21;
} catch (NoClassDefFoundError | Exception ignored) {
ignored.printStackTrace();
}
@@ -94,7 +94,7 @@ public class PufferfishConfig {
if (SIMDDetection.isEnabled) {
PufferfishLogger.LOGGER.info("SIMD operations detected as functional. Will replace some operations with faster versions.");
} else if (SIMDDetection.versionLimited) {
- PufferfishLogger.LOGGER.warning("Will not enable SIMD! These optimizations are only safely supported on Java 17, Java 18, and Java 19.");
+ PufferfishLogger.LOGGER.warning("Will not enable SIMD! These optimizations are only safely supported on Java 17 through Java 21.");
} else {
PufferfishLogger.LOGGER.warning("SIMD operations are available for your server, but are not configured!");
PufferfishLogger.LOGGER.warning("To enable additional optimizations, add \"--add-modules=jdk.incubator.vector\" to your startup flags, BEFORE the \"-jar\".");
@@ -232,7 +232,7 @@ public class PufferfishConfig {
public static int activationDistanceMod;

Expand Down Expand Up @@ -62,7 +80,7 @@ index 62ad086b5b07303d920fdb3534a556673ef51f71..15aaa270e51b9194596e7ed5061c85c9

private int currentIceAndSnowTick = 0; protected void resetIceAndSnowTick() { this.currentIceAndSnowTick = this.randomTickRandom.nextInt(16); } // Pufferfish
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index d18296739a833dbe6c3bf45e00d5d5c2e80099ac..d25dd9018eff5f3817c1b56f49632cc0a9388b8e 100644
index 5c5c8fbd562b46f8699be97353447eaab36c007a..385253bddf50c290317b6d0f283331edf515badd 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -825,7 +825,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
Expand Down