From 147744771c99788951b24c775622d8c34ac185bc Mon Sep 17 00:00:00 2001 From: Graham Date: Tue, 2 Jun 2020 18:23:39 +0100 Subject: [PATCH] Skip propagation of constant arguments in non-renamable methods Propagating them looks a bit silly, because the arguments are unused. I think this problem mainly occurs in constructors, which the dummy argument obfuscator doesn't touch. Signed-off-by: Graham --- .../deob/transform/ConstantArgTransformer.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt index 349b0d3ca1..7ed3844beb 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt @@ -24,6 +24,7 @@ import dev.openrs2.deob.analysis.IntBranchResult.NEVER_TAKEN import dev.openrs2.deob.analysis.IntInterpreter import dev.openrs2.deob.analysis.IntValueSet import dev.openrs2.deob.filter.ReflectedConstructorFilter +import dev.openrs2.deob.remap.MethodMappingGenerator import dev.openrs2.util.collect.DisjointSet import dev.openrs2.util.collect.removeFirstOrNull import org.objectweb.asm.Opcodes.GOTO @@ -245,7 +246,17 @@ class ConstantArgTransformer @Inject constructor(private val profile: Profile) : return simplified } - private fun inlineConstantArgs(clazz: ClassNode, method: MethodNode, args: Array): Int { + private fun inlineConstantArgs( + classPath: ClassPath, + clazz: ClassNode, + method: MethodNode, + args: Array + ): Int { + val partition = inheritedMethodSets[MemberRef(clazz, method)]!! + if (!MethodMappingGenerator.isRenamable(classPath, profile.excludedMethods, partition)) { + return 0 + } + val analyzer = Analyzer(IntInterpreter(args)) val frames = analyzer.analyze(clazz.name, method) @@ -299,7 +310,7 @@ class ConstantArgTransformer @Inject constructor(private val profile: Profile) : override fun transformCode(classPath: ClassPath, library: Library, clazz: ClassNode, method: MethodNode): Boolean { val args = getArgs(MemberRef(clazz, method)) branchesSimplified += simplifyBranches(clazz, method, args) - constantsInlined += inlineConstantArgs(clazz, method, args) + constantsInlined += inlineConstantArgs(classPath, clazz, method, args) return false }