Commit 8e714482363c91b886543104d9b9921e5a5fd893

Authored by Mumfrey
1 parent 96db8836

stripping redundant GenProfiler

ant/build_liteloader.xml
... ... @@ -223,7 +223,6 @@
223 223 <exclude name="?.class" />
224 224 <exclude name="??.class" />
225 225 <exclude name="???.class" />
226   - <exclude name="/com/mumfrey/liteloader/core/gen/**" />
227 226 </fileset>
228 227 </copy>
229 228  
... ...
java/client/com/mumfrey/liteloader/client/ClientEvents.java
... ... @@ -6,16 +6,13 @@ import net.minecraft.client.gui.GuiNewChat;
6 6 import net.minecraft.client.gui.ScaledResolution;
7 7 import net.minecraft.client.shader.Framebuffer;
8 8 import net.minecraft.network.play.client.C01PacketChatMessage;
9   -import net.minecraft.profiler.Profiler;
10 9 import net.minecraft.server.integrated.IntegratedServer;
11 10 import net.minecraft.util.Timer;
12 11  
13 12 import org.lwjgl.input.Mouse;
14 13  
15 14 import com.mumfrey.liteloader.*;
16   -import com.mumfrey.liteloader.client.gen.GenProfiler;
17 15 import com.mumfrey.liteloader.client.overlays.IMinecraft;
18   -import com.mumfrey.liteloader.client.util.PrivateFields;
19 16 import com.mumfrey.liteloader.common.LoadingProgress;
20 17 import com.mumfrey.liteloader.core.Events;
21 18 import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate;
... ... @@ -44,14 +41,9 @@ public class ClientEvents extends Events&lt;Minecraft, IntegratedServer&gt;
44 41 /**
45 42 * Flags which keep track of whether hooks have been applied
46 43 */
47   - private boolean lateInitDone, profilerHooked;
  44 + private boolean lateInitDone;
48 45  
49 46 /**
50   - * Profiler hook objects
51   - */
52   - private Profiler genProfiler = null;
53   -
54   - /**
55 47 * ScaledResolution used by the pre-chat and post-chat render callbacks
56 48 */
57 49 private ScaledResolution currentResolution;
... ... @@ -97,17 +89,6 @@ public class ClientEvents extends Events&lt;Minecraft, IntegratedServer&gt;
97 89 ClientEvents.instance = this;
98 90  
99 91 this.engineClient = (GameEngineClient)engine;
100   - try
101   - {
102   - if (properties.getBooleanProperty(LoaderProperties.OPTION_GENERATE_MAPPINGS))
103   - {
104   - this.genProfiler = GenProfiler.class.newInstance();
105   - }
106   - }
107   - catch (Throwable th)
108   - {
109   -// th.printStackTrace();
110   - }
111 92 }
112 93  
113 94 static ClientEvents getInstance()
... ... @@ -136,31 +117,12 @@ public class ClientEvents extends Events&lt;Minecraft, IntegratedServer&gt;
136 117 delegate.registerInterface(OutboundChatFilter.class);
137 118 }
138 119  
139   - /**
140   - * Initialise hooks
  120 + /* (non-Javadoc)
  121 + * @see com.mumfrey.liteloader.api.InterfaceProvider#initProvider()
141 122 */
142 123 @Override
143 124 public void initProvider()
144 125 {
145   - if (this.genProfiler != null)
146   - {
147   - try
148   - {
149   - LiteLoaderLogger.info("Event manager is registering the mapping generator hook");
150   -
151   - // Tick hook
152   - if (!this.profilerHooked)
153   - {
154   - this.profilerHooked = true;
155   - PrivateFields.minecraftProfiler.setFinal(this.engine.getClient(), this.genProfiler);
156   - }
157   - }
158   - catch (Exception ex)
159   - {
160   - LiteLoaderLogger.warning(ex, "Error creating hook");
161   - ex.printStackTrace();
162   - }
163   - }
164 126 }
165 127  
166 128 /**
... ...
java/client/com/mumfrey/liteloader/client/gen/GenProfiler.java deleted 100644 โ†’ 0
1   -package com.mumfrey.liteloader.client.gen;
2   -
3   -import java.util.HashMap;
4   -import java.util.HashSet;
5   -import java.util.LinkedList;
6   -import java.util.Map;
7   -import java.util.NoSuchElementException;
8   -import java.util.Set;
9   -
10   -import net.minecraft.client.Minecraft;
11   -import net.minecraft.profiler.Profiler;
12   -
13   -import com.mumfrey.liteloader.core.exceptions.ProfilerCrossThreadAccessException;
14   -import com.mumfrey.liteloader.core.exceptions.ProfilerStackCorruptionException;
15   -import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
16   -
17   -/**
18   - * Profiler used for generating callback signatures for the callback injector
19   - *
20   - * @author Adam Mummery-Smith
21   - */
22   -public class GenProfiler extends Profiler
23   -{
24   - /**
25   - * Cross-thread sanity check
26   - */
27   - private final Thread minecraftThread;
28   -
29   - /**
30   - * Section list, used as a kind of stack to determine where we are in the profiler stack
31   - */
32   - private LinkedList<String> sectionStack = new LinkedList<String>();
33   -
34   - /**
35   - * Minecraft reference, only set if optifine compatibility is enabled
36   - */
37   - private Minecraft mc;
38   -
39   - private static Map<String, String> eventSignatures = new HashMap<String, String>();
40   -
41   - private static Set<String> conflictedEvents = new HashSet<String>();
42   -
43   - private static String lastEvent = null;
44   -
45   - private static String lastPosition = null;
46   -
47   - /**
48   - * .ctor
49   - *
50   - * @param events LiteLoader object which will get callbacks
51   - * @param logger Logger instance
52   - */
53   - public GenProfiler()
54   - {
55   - this.mc = Minecraft.getMinecraft();
56   -
57   - this.minecraftThread = Thread.currentThread();
58   - }
59   -
60   - /* (non-Javadoc)
61   - * @see net.minecraft.profiler.Profiler#startSection(java.lang.String)
62   - */
63   - @Override
64   - public void startSection(String sectionName)
65   - {
66   - if (Thread.currentThread() != this.minecraftThread)
67   - {
68   - LiteLoaderLogger.severe("Profiler cross thread access detected, this indicates an error with one of your mods.");
69   - throw new ProfilerCrossThreadAccessException(Thread.currentThread().getName());
70   - }
71   -
72   - if ("gameRenderer".equals(sectionName) && "root".equals(this.sectionStack.getLast()))
73   - {
74   - this.debugEvent("onRender", sectionName);
75   - }
76   - else if ("frustrum".equals(sectionName) && "level".equals(this.sectionStack.getLast()))
77   - {
78   - this.debugEvent("onSetupCameraTransform", sectionName);
79   - }
80   - else if ("litParticles".equals(sectionName))
81   - {
82   - this.debugEvent("postRenderEntities", sectionName);
83   - }
84   - else if ("tick".equals(sectionName) && "root".equals(this.sectionStack.getLast()))
85   - {
86   - this.debugEvent("onTimerUpdate", sectionName);
87   - }
88   - else if ("chat".equals(sectionName))
89   - {
90   - this.debugEvent("onRenderChat", sectionName);
91   - }
92   - else if ("gui".equals(sectionName) && "gameRenderer".equals(this.sectionStack.getLast()))
93   - {
94   - this.debugEvent("onRenderHUD", sectionName);
95   - }
96   -
97   - if ("animateTick".equals(sectionName))
98   - {
99   - this.debugEvent("onAnimateTick", sectionName);
100   - }
101   -
102   - this.sectionStack.add(sectionName);
103   - super.startSection(sectionName);
104   - }
105   -
106   - /* (non-Javadoc)
107   - * @see net.minecraft.profiler.Profiler#endSection()
108   - */
109   - @Override
110   - public void endSection()
111   - {
112   - if (Thread.currentThread() != this.minecraftThread)
113   - {
114   - LiteLoaderLogger.severe("Profiler cross thread access detected, this indicates an error with one of your mods.");
115   - throw new ProfilerCrossThreadAccessException(Thread.currentThread().getName());
116   - }
117   -
118   - super.endSection();
119   -
120   - try
121   - {
122   - String endingSection = this.sectionStack.size() > 0 ? this.sectionStack.removeLast() : null;
123   - String nextSection = this.sectionStack.size() > 0 ? this.sectionStack.getLast() : null;
124   - String sectionName = "end[" + endingSection + "] next[" + nextSection + "]";
125   -
126   - if ("gameRenderer".equals(endingSection) && "root".equals(nextSection))
127   - {
128   - this.debugEvent("onTick", sectionName);
129   - }
130   - else
131   - {
132   - if ("gui".equals(endingSection) && "gameRenderer".equals(nextSection) && this.mc.theWorld != null)
133   - {
134   - this.debugEvent("postRenderHUDandGUI", sectionName);
135   - }
136   - else if ("mouse".equals(endingSection) && "gameRenderer".equals(nextSection) && (this.mc.skipRenderWorld || this.mc.theWorld == null))
137   - {
138   - this.debugEvent("preRenderGUI", sectionName);
139   - }
140   - else if ("hand".equals(endingSection) && "level".equals(nextSection))
141   - {
142   - this.debugEvent("postRender", sectionName);
143   - }
144   - else if ("chat".equals(endingSection))
145   - {
146   - this.debugEvent("postRenderChat", sectionName);
147   - }
148   - }
149   - }
150   - catch (NoSuchElementException ex)
151   - {
152   - LiteLoaderLogger.severe("Corrupted Profiler stack detected, this indicates an error with one of your mods.");
153   - throw new ProfilerStackCorruptionException("Corrupted Profiler stack detected");
154   - }
155   - }
156   -
157   - private void debugEvent(String lastEvent, String profilerPos)
158   - {
159   - GenProfiler.lastEvent = lastEvent;
160   - GenProfiler.lastPosition = profilerPos;
161   - }
162   -
163   - public static void storeSignature(String signature)
164   - {
165   - if (GenProfiler.lastEvent == null) return;
166   - if (signature.startsWith("// com")) return;
167   -
168   - if (!GenProfiler.eventSignatures.containsKey(GenProfiler.lastEvent))
169   - {
170   - GenProfiler.eventSignatures.put(GenProfiler.lastEvent, signature);
171   - System.out.println("\n// " + GenProfiler.lastPosition + "\n" + signature.replace("<event>", GenProfiler.lastEvent));
172   - }
173   - else
174   - {
175   - if (!GenProfiler.eventSignatures.get(GenProfiler.lastEvent).equals(signature) && !GenProfiler.conflictedEvents.contains(GenProfiler.lastEvent))
176   - {
177   - GenProfiler.conflictedEvents.add(GenProfiler.lastEvent);
178   - System.out.println("\n// CONFLICT\n// " + GenProfiler.lastPosition + "\n" + signature.replace("<event>", GenProfiler.lastEvent));
179   - }
180   - }
181   - }
182   -}
183 0 \ No newline at end of file
java/client/com/mumfrey/liteloader/client/gen/GenProfilerTransformer.java deleted 100644 โ†’ 0
1   -package com.mumfrey.liteloader.client.gen;
2   -
3   -import java.util.HashMap;
4   -import java.util.Iterator;
5   -import java.util.Map;
6   -import java.util.Map.Entry;
7   -
8   -import org.objectweb.asm.ClassReader;
9   -import org.objectweb.asm.ClassWriter;
10   -import org.objectweb.asm.Opcodes;
11   -import org.objectweb.asm.tree.AbstractInsnNode;
12   -import org.objectweb.asm.tree.ClassNode;
13   -import org.objectweb.asm.tree.LdcInsnNode;
14   -import org.objectweb.asm.tree.MethodInsnNode;
15   -import org.objectweb.asm.tree.MethodNode;
16   -
17   -import com.mumfrey.liteloader.core.runtime.Obf;
18   -
19   -import net.minecraft.launchwrapper.IClassTransformer;
20   -
21   -public class GenProfilerTransformer implements IClassTransformer
22   -{
23   - private Map<String, Integer> references = new HashMap<String, Integer>();
24   -
25   - @Override
26   - public byte[] transform(String name, String transformedName, byte[] basicClass)
27   - {
28   - if (basicClass != null && !Obf.Profiler.name.equals(name) && !Obf.Profiler.obf.equals(name))
29   - {
30   - return this.transformProfilerCalls(basicClass);
31   - }
32   -
33   - return basicClass;
34   - }
35   -
36   - private byte[] transformProfilerCalls(byte[] basicClass)
37   - {
38   - ClassNode classNode = this.readClass(basicClass);
39   -
40   - for (MethodNode method : classNode.methods)
41   - {
42   - String section = null;
43   - Map<MethodInsnNode, String> injectionNodes = new HashMap<MethodInsnNode, String>();
44   -
45   - Iterator<AbstractInsnNode> iter = method.instructions.iterator();
46   - AbstractInsnNode lastInsn = null;
47   - while (iter.hasNext())
48   - {
49   - AbstractInsnNode insn = iter.next();
50   - if (insn.getOpcode() == Opcodes.INVOKEVIRTUAL)
51   - {
52   - MethodInsnNode invokeNode = (MethodInsnNode)insn;
53   - if (Obf.Profiler.ref.equals(invokeNode.owner) || Obf.Profiler.obf.equals(invokeNode.owner))
54   - {
55   - if (lastInsn instanceof LdcInsnNode)
56   - section = ((LdcInsnNode)lastInsn).cst.toString();
57   - else
58   - section = "";
59   -
60   - if ("(Ljava/lang/String;)V".equals(invokeNode.desc) || ("()V".equals(invokeNode.desc) && ("endSection".equals(invokeNode.name) || "b".equals(invokeNode.name))))
61   - {
62   - String signature = this.generateSignature(classNode.name, method.name, method.desc, invokeNode.name, invokeNode.desc, section);
63   -
64   - int refCount = 0;
65   - if (this.references.containsKey(signature))
66   - refCount = this.references.get(signature).intValue();
67   -
68   - String mapping = "// " + signature + "\nthis.addMapping(\"" + classNode.name.replace('/', '.') + "\", \"" + method.name + "\", \"" + method.desc + "\", \"" + invokeNode.name + "\", \"" + section + "\", new Callback(\"<event>\")); // ref " + refCount;
69   - this.references.put(signature, Integer.valueOf(refCount + 1));
70   - injectionNodes.put(invokeNode, mapping);
71   - }
72   - }
73   - }
74   -
75   - lastInsn = insn;
76   - }
77   -
78   - for (Entry<MethodInsnNode, String> node : injectionNodes.entrySet())
79   - {
80   - method.instructions.insert(node.getKey(), new MethodInsnNode(Opcodes.INVOKESTATIC, "com/mumfrey/liteloader/core/gen/GenProfiler", "storeSignature", "(Ljava/lang/String;)V", false));
81   - method.instructions.insert(node.getKey(), new LdcInsnNode(node.getValue()));
82   - }
83   - }
84   -
85   - return this.writeClass(classNode);
86   - }
87   -
88   - /**
89   - * @param basicClass
90   - * @return
91   - */
92   - private ClassNode readClass(byte[] basicClass)
93   - {
94   - ClassReader classReader = new ClassReader(basicClass);
95   - ClassNode classNode = new ClassNode();
96   - classReader.accept(classNode, ClassReader.SKIP_FRAMES);
97   - return classNode;
98   - }
99   -
100   - /**
101   - * @param classNode
102   - * @return
103   - */
104   - private byte[] writeClass(ClassNode classNode)
105   - {
106   - ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
107   - classNode.accept(writer);
108   - return writer.toByteArray();
109   - }
110   -
111   - /**
112   - * @param className
113   - * @param methodName
114   - * @param methodSignature
115   - * @param invokeName
116   - * @param invokeSig
117   - * @param section
118   - * @return
119   - */
120   - private String generateSignature(String className, String methodName, String methodSignature, String invokeName, String invokeSig, String section)
121   - {
122   - return String.format("%s::%s%s@%s%s/%s", className.replace('.', '/'), methodName, methodSignature, invokeName, invokeSig, section);
123   - }
124   -}
java/client/com/mumfrey/liteloader/client/util/PrivateFields.java
... ... @@ -140,7 +140,6 @@ public class PrivateFields&lt;P, T&gt;
140 140 return value;
141 141 }
142 142  
143   - public static final PrivateFields<Minecraft, Profiler> minecraftProfiler = new PrivateFields<Minecraft, Profiler> (Minecraft.class, Obf.minecraftProfiler);
144 143 public static final PrivateFields<RenderManager, Map> entityRenderMap = new PrivateFields<RenderManager, Map> (RenderManager.class, Obf.entityRenderMap);
145 144 public static final PrivateFields<NetHandlerLoginClient, NetworkManager> netManager = new PrivateFields<NetHandlerLoginClient, NetworkManager> (NetHandlerLoginClient.class, Obf.netManager);
146 145 public static final PrivateFields<RegistrySimple, Map> registryObjects = new PrivateFields<RegistrySimple, Map> (RegistrySimple.class, Obf.registryObjects);
... ...
java/common/com/mumfrey/liteloader/launch/LiteLoaderTweaker.java
... ... @@ -28,10 +28,10 @@ public class LiteLoaderTweaker implements ITweaker
28 28 public static final int ENV_TYPE_CLIENT = 0;
29 29 public static final int ENV_TYPE_DEDICATEDSERVER = 1;
30 30  
  31 + // TODO Version - 1.7.10
31 32 public static final String VERSION = "1.7.10";
32 33  
33 34 protected static final String bootstrapClassName = "com.mumfrey.liteloader.core.LiteLoaderBootstrap";
34   - protected static final String genTransformerClassName = "com.mumfrey.liteloader.client.gen.GenProfilerTransformer";
35 35  
36 36 /**
37 37 * Loader startup state
... ... @@ -327,13 +327,6 @@ public class LiteLoaderTweaker implements ITweaker
327 327  
328 328 LiteLoaderTweaker.instance.transformerManager.injectUpstreamTransformers(classLoader);
329 329  
330   - LoaderBootstrap bootstrap = LiteLoaderTweaker.instance.bootstrap;
331   - if (bootstrap instanceof LoaderProperties && ((LoaderProperties)bootstrap).getBooleanProperty(LoaderProperties.OPTION_GENERATE_MAPPINGS))
332   - {
333   - LiteLoaderLogger.info("Injecting gen trasnformer '%s'", LiteLoaderTweaker.genTransformerClassName);
334   - LiteLoaderTweaker.instance.transformerManager.injectTransformer(LiteLoaderTweaker.genTransformerClassName);
335   - }
336   -
337 330 for (String transformerClassName : this.bootstrap.getRequiredDownstreamTransformers())
338 331 {
339 332 LiteLoaderLogger.info("Queuing required class transformer '%s'", transformerClassName);
... ...
java/common/com/mumfrey/liteloader/launch/LoaderProperties.java
... ... @@ -89,7 +89,6 @@ public interface LoaderProperties
89 89  
90 90 // General properties
91 91 public static final String OPTION_SOUND_MANAGER_FIX = "soundManagerFix";
92   - public static final String OPTION_GENERATE_MAPPINGS = "genMappings";
93 92 public static final String OPTION_MOD_INFO_SCREEN = "modInfoScreen";
94 93 public static final String OPTION_NO_HIDE_TAB = "tabAlwaysExpanded";
95 94 public static final String OPTION_BRAND = "brand";
... ...