From e0c7aac61a8cd39ef64daa06ffd881193e8fa164 Mon Sep 17 00:00:00 2001 From: gudenau Date: Fri, 21 Aug 2020 14:58:16 -0500 Subject: [PATCH] Fixed ASM frame calculations; fixing forEach removal --- gradle.properties | 2 +- logs/latest.log | 0 src/main/java/net/gudenau/minecraft/fps/GudFPS.java | 3 ++- .../java/net/gudenau/minecraft/fps/mixin/Plugin.java | 1 + .../minecraft/fps/transformer/ForEachRemover.java | 1 + .../minecraft/fps/transformer/Transformers.java | 12 +++++++++++- 6 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 logs/latest.log diff --git a/gradle.properties b/gradle.properties index 7c1d721..ae9a1fa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.9.1+build.205 # Mod Properties - mod_version = 0.0.2 + mod_version = 0.0.3 maven_group = net.gudenau.minecraft archives_base_name = gud_fps diff --git a/logs/latest.log b/logs/latest.log new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/net/gudenau/minecraft/fps/GudFPS.java b/src/main/java/net/gudenau/minecraft/fps/GudFPS.java index c5a0e31..6b5e49c 100644 --- a/src/main/java/net/gudenau/minecraft/fps/GudFPS.java +++ b/src/main/java/net/gudenau/minecraft/fps/GudFPS.java @@ -47,6 +47,7 @@ public void onInitialize(){ }catch(IOException | URISyntaxException ignored){ System.err.println("Failed to force load classes"); } + System.exit(0); } } @@ -135,7 +136,7 @@ private static Config loadConfig(){ } public static final class Config{ - public final Option removeForEach = new BooleanOption("removeForEach", false); + public final Option removeForEach = new BooleanOption("removeForEach", true); public final Option removeBlockPos = new BooleanOption("removeBlockPos", true); public final Option precomputeConstants = new BooleanOption("precomputeConstants", true); public final Option optimizeMath = new BooleanOption("optimizeMath", true); diff --git a/src/main/java/net/gudenau/minecraft/fps/mixin/Plugin.java b/src/main/java/net/gudenau/minecraft/fps/mixin/Plugin.java index 0a07804..bfa7481 100644 --- a/src/main/java/net/gudenau/minecraft/fps/mixin/Plugin.java +++ b/src/main/java/net/gudenau/minecraft/fps/mixin/Plugin.java @@ -56,6 +56,7 @@ public class Plugin implements IMixinConfigPlugin{ } ClassLoader classLoader = Plugin.class.getClassLoader(); + Transformers.setClassLoader(classLoader); try{ // Get all of the non-public classes diff --git a/src/main/java/net/gudenau/minecraft/fps/transformer/ForEachRemover.java b/src/main/java/net/gudenau/minecraft/fps/transformer/ForEachRemover.java index 727a0b7..46d2d14 100644 --- a/src/main/java/net/gudenau/minecraft/fps/transformer/ForEachRemover.java +++ b/src/main/java/net/gudenau/minecraft/fps/transformer/ForEachRemover.java @@ -1,6 +1,7 @@ package net.gudenau.minecraft.fps.transformer; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/src/main/java/net/gudenau/minecraft/fps/transformer/Transformers.java b/src/main/java/net/gudenau/minecraft/fps/transformer/Transformers.java index 565871f..4b7539a 100644 --- a/src/main/java/net/gudenau/minecraft/fps/transformer/Transformers.java +++ b/src/main/java/net/gudenau/minecraft/fps/transformer/Transformers.java @@ -30,6 +30,7 @@ public class Transformers{ private static final boolean verifyClasses = GudFPS.CONFIG.verify.get(); private static final Stats transformerStats = Stats.getStats("Transformer"); private static final Stats dumperStats = Stats.getStats("Dump"); + private static ClassLoader classLoader; static { GudFPS.Config config = GudFPS.CONFIG; @@ -100,7 +101,12 @@ private static byte[] doTransform(String name, String transformedName, byte[] ba transformerStats.incrementStat(transformer.getClass().getSimpleName()); } - ClassWriter classWriter = new ClassWriter(flags.getFlags()); + ClassWriter classWriter = new ClassWriter(flags.getFlags()){ + @Override + protected ClassLoader getClassLoader(){ + return classLoader; + } + }; classNode.accept(classWriter); byte[] newClass = classWriter.toByteArray(); if(dumpClasses){ @@ -160,4 +166,8 @@ private static void dumpClass(ClassNode node, byte[] bytecode){ } }); } + + public static void setClassLoader(ClassLoader classLoader){ + Transformers.classLoader = classLoader; + } }