-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport annotation scanner parallelization
Related: neoforged/FancyModLoader#32
- Loading branch information
Showing
4 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ain/java/org/embeddedt/blacksmith/impl/transformers/BackgroundScanHandlerTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.embeddedt.blacksmith.impl.transformers; | ||
|
||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.tree.*; | ||
|
||
import java.lang.instrument.IllegalClassFormatException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class BackgroundScanHandlerTransformer implements RuntimeTransformer { | ||
@Override | ||
public List<String> getTransformedClasses() { | ||
return Collections.singletonList("net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler"); | ||
} | ||
|
||
@Override | ||
public void transformClass(ClassNode data) throws IllegalClassFormatException { | ||
for(MethodNode m : data.methods) { | ||
if(m.name.equals("<init>")) { | ||
for(AbstractInsnNode n : m.instructions) { | ||
if(n.getOpcode() == Opcodes.INVOKESTATIC) { | ||
MethodInsnNode mNode = (MethodInsnNode)n; | ||
if(mNode.name.equals("newSingleThreadExecutor")) { | ||
mNode.name = "makeScanningExecutor"; | ||
mNode.owner = RuntimeTransformer.HOOK_CLASS; | ||
System.out.println("Parallelized scanner"); | ||
break; | ||
} | ||
} | ||
} | ||
} else if(m.name.equals("addCompletedFile")) { | ||
/* synchronize */ | ||
m.access |= Opcodes.ACC_SYNCHRONIZED; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters