Commit 829c53aa authored by Lubomir Bulej's avatar Lubomir Bulej

DiSL: AsmHelper: made cloneCode() a factory method in ClonedCode

DiSL: AsmHelper: made return types of insn factories more specific
DiSL: AsmHelper: split getClassType() into getTypeConstOperand(), isTypeConstLoadInsn(), and getOwnerBoxedType() (the code in the last does not seem to be used)
DiSL: AsmHelper: added several utility and factory methods
DiSL: AsmHelper: cleaned up the code of many methods
DiSL: Updated Code, SnippetCode, WeavingCode, CodeMerger, and ProcCode to use cloneCode() from ClonedCode
parent bfa40f6a
......@@ -9,7 +9,6 @@ import org.objectweb.asm.tree.TryCatchBlockNode;
import ch.usi.dag.disl.localvar.SyntheticLocalVar;
import ch.usi.dag.disl.localvar.ThreadLocalVar;
import ch.usi.dag.disl.util.AsmHelper;
import ch.usi.dag.disl.util.AsmHelper.ClonedCode;
/**
......@@ -106,15 +105,15 @@ public class Code {
}
public Code clone() {
// clone code first
ClonedCode cc =
AsmHelper.cloneCode(instructions, tryCatchBlocks);
ClonedCode cc = ClonedCode.create (instructions, tryCatchBlocks);
return new Code(cc.getInstructions(), cc.getTryCatchBlocks(),
new HashSet<SyntheticLocalVar>(referencedSLVs),
new HashSet<ThreadLocalVar>(referencedTLVs),
new HashSet<StaticContextMethod>(staticContexts),
usesDynamicContext, usesClassContext, containsHandledException);
return new Code (
cc.getInstructions (), cc.getTryCatchBlocks (),
new HashSet <SyntheticLocalVar> (referencedSLVs),
new HashSet <ThreadLocalVar> (referencedTLVs),
new HashSet <StaticContextMethod> (staticContexts),
usesDynamicContext, usesClassContext, containsHandledException
);
}
}
......@@ -11,7 +11,6 @@ import ch.usi.dag.disl.coderep.Code;
import ch.usi.dag.disl.coderep.StaticContextMethod;
import ch.usi.dag.disl.localvar.SyntheticLocalVar;
import ch.usi.dag.disl.localvar.ThreadLocalVar;
import ch.usi.dag.disl.util.AsmHelper;
import ch.usi.dag.disl.util.AsmHelper.ClonedCode;
public class ProcCode extends Code {
......@@ -40,18 +39,16 @@ public class ProcCode extends Code {
}
public ProcCode clone() {
// clone code first
ClonedCode cc =
AsmHelper.cloneCode(getInstructions(), getTryCatchBlocks());
return new ProcCode(cc.getInstructions(), cc.getTryCatchBlocks(),
new HashSet<SyntheticLocalVar>(getReferencedSLVs()),
new HashSet<ThreadLocalVar>(getReferencedTLVs()),
containsHandledException(),
new HashSet<StaticContextMethod>(getStaticContexts()),
usesDynamicContext(),
usesClassContext(),
usesArgumentContext);
ClonedCode cc = ClonedCode.create (getInstructions (), getTryCatchBlocks ());
return new ProcCode (
cc.getInstructions (), cc.getTryCatchBlocks (),
new HashSet <SyntheticLocalVar> (getReferencedSLVs ()),
new HashSet <ThreadLocalVar> (getReferencedTLVs ()),
containsHandledException (),
new HashSet <StaticContextMethod> (getStaticContexts ()),
usesDynamicContext (), usesClassContext (), usesArgumentContext
);
}
}
......@@ -13,7 +13,6 @@ import ch.usi.dag.disl.coderep.Code;
import ch.usi.dag.disl.coderep.StaticContextMethod;
import ch.usi.dag.disl.localvar.SyntheticLocalVar;
import ch.usi.dag.disl.localvar.ThreadLocalVar;
import ch.usi.dag.disl.util.AsmHelper;
import ch.usi.dag.disl.util.AsmHelper.ClonedCode;
/**
......@@ -52,20 +51,19 @@ public class SnippetCode extends Code {
return invokedProcessors;
}
public SnippetCode clone() {
public SnippetCode clone () {
// clone code first
ClonedCode cc =
AsmHelper.cloneCode(getInstructions(), getTryCatchBlocks());
ClonedCode cc = ClonedCode.create (getInstructions (), getTryCatchBlocks ());
return new SnippetCode(cc.getInstructions(), cc.getTryCatchBlocks(),
new HashSet<SyntheticLocalVar>(getReferencedSLVs()),
new HashSet<ThreadLocalVar>(getReferencedTLVs()),
containsHandledException(),
new HashSet<StaticContextMethod>(getStaticContexts()),
usesDynamicContext(),
usesClassContext(),
usesProcessorContext,
new HashMap<Integer, ProcInvocation>(invokedProcessors));
return new SnippetCode (
cc.getInstructions (), cc.getTryCatchBlocks (),
new HashSet <SyntheticLocalVar> (getReferencedSLVs ()),
new HashSet <ThreadLocalVar> (getReferencedTLVs ()),
containsHandledException (),
new HashSet <StaticContextMethod> (getStaticContexts ()),
usesDynamicContext (), usesClassContext (), usesProcessorContext,
new HashMap <Integer, ProcInvocation> (invokedProcessors)
);
}
}
This diff is collapsed.
......@@ -16,7 +16,6 @@ import org.objectweb.asm.tree.TryCatchBlockNode;
import ch.usi.dag.disl.dynamicbypass.DynamicBypassCheck;
import ch.usi.dag.disl.exception.DiSLFatalException;
import ch.usi.dag.disl.util.AsmHelper;
import ch.usi.dag.disl.util.AsmHelper.ClonedCode;
public abstract class CodeMerger {
......@@ -68,15 +67,14 @@ public abstract class CodeMerger {
// crate copy of the original instruction list
// this copy will be destroyed during merging
// we need the original code if the method is too long
ClonedCode origCodeCopy = AsmHelper.cloneCode(origMN.instructions,
origMN.tryCatchBlocks);
ClonedCode origCodeCopy = ClonedCode.create (
origMN.instructions, origMN.tryCatchBlocks
);
// create copy of the lists for splitting
ClonedCode splitCopy = null;
if(splitLongMethods) {
splitCopy = AsmHelper.cloneCode(ilist, tcblist);
if (splitLongMethods) {
splitCopy = ClonedCode.create (ilist, tcblist);
}
// add reference to the original code
......
......@@ -189,7 +189,7 @@ public class WeavingCode {
}
// second operand test
if (AsmHelper.getClassType(secondOperand) == null) {
if (! AsmHelper.isTypeConstLoadInsn (secondOperand)) {
throw new DynamicContextException("In snippet "
+ snippet.getOriginClassName() + "."
+ snippet.getOriginMethodName()
......@@ -282,7 +282,7 @@ public class WeavingCode {
// [checkcast]
// [invoke]
int operand = AsmHelper.getIntConstOperand(prev.getPrevious());
Type t = AsmHelper.getClassType(prev);
Type t = AsmHelper.getTypeConstOperand(prev);
if (invoke.name.equals("getStackValue")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment