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 <gpe@openrs2.dev>
Graham 4 years ago
parent c03673a1e8
commit 147744771c
  1. 15
      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<IntValueSet>): Int {
private fun inlineConstantArgs(
classPath: ClassPath,
clazz: ClassNode,
method: MethodNode,
args: Array<IntValueSet>
): 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
}

Loading…
Cancel
Save