Minor refactoring: analyze-method added

This commit is contained in:
Denis Zharkov
2014-07-08 17:06:08 +04:00
committed by Alexander Udalov
parent a412a96ff3
commit 498e5ec192
3 changed files with 13 additions and 13 deletions
@@ -26,7 +26,6 @@ import org.jetbrains.org.objectweb.asm.Opcodes;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.org.objectweb.asm.tree.*;
import org.jetbrains.org.objectweb.asm.tree.analysis.Analyzer;
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue;
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame;
@@ -40,9 +39,8 @@ public class RedundantBoxingMethodTransformer extends MethodTransformer {
@Override
public void transform(@NotNull String internalClassName, @NotNull MethodNode node) {
RedundantBoxingInterpreter interpreter = new RedundantBoxingInterpreter(node.instructions);
Frame<BasicValue>[] frames = runAnalyzer(
new Analyzer<BasicValue>(interpreter),
internalClassName, node
Frame<BasicValue>[] frames = analyze(
internalClassName, node, interpreter
);
interpretPopInstructionsForBoxedValues(interpreter, node, frames);
@@ -44,11 +44,9 @@ public class RedundantNullCheckMethodTransformer extends MethodTransformer {
private static boolean removeRedundantNullCheckPass(@NotNull String internalClassName, @NotNull MethodNode methodNode) {
InsnList insnList = methodNode.instructions;
Frame<BasicValue>[] frames = runAnalyzer(
new Analyzer<BasicValue>(
new BoxingInterpreter(insnList)
),
internalClassName, methodNode
Frame<BasicValue>[] frames = analyze(
internalClassName, methodNode,
new BoxingInterpreter(insnList)
);
List<AbstractInsnNode> insnsToOptimize = new ArrayList<AbstractInsnNode>();
@@ -18,10 +18,7 @@ package org.jetbrains.jet.codegen.optimization.transformer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.org.objectweb.asm.tree.MethodNode;
import org.jetbrains.org.objectweb.asm.tree.analysis.Analyzer;
import org.jetbrains.org.objectweb.asm.tree.analysis.AnalyzerException;
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame;
import org.jetbrains.org.objectweb.asm.tree.analysis.Value;
import org.jetbrains.org.objectweb.asm.tree.analysis.*;
public abstract class MethodTransformer {
private final MethodTransformer delegate;
@@ -42,6 +39,13 @@ public abstract class MethodTransformer {
throw new RuntimeException(e);
}
}
protected static <V extends Value> Frame<V>[] analyze(
@NotNull String internalClassName,
@NotNull MethodNode node,
@NotNull Interpreter<V> interpreter
) {
return runAnalyzer(new Analyzer<V>(interpreter), internalClassName, node);
}
public void transform(@NotNull String internalClassName, @NotNull MethodNode methodNode) {
if (delegate != null) {