Commit 00b871b7 authored by Lukáš Marek's avatar Lukáš Marek

Again refactored weaving info in the marker

Warn: HEAD still not working
parent 9a5ea6c7
......@@ -6,16 +6,15 @@ import org.objectweb.asm.tree.MethodNode;
import ch.usi.dag.disl.marker.AbstractMarker.MarkedRegion;
public abstract class AbstractBranchSkipMarker {
public abstract class AbstractDWRMarker {
public List<MarkedRegion> mark(MethodNode methodNode) {
List<MarkedRegion> mrs = markWithABSWithAAT(methodNode);
List<MarkedRegion> mrs = markWithDefaultWeavingReg(methodNode);
// automatic branch skipping and after throw region computation
// automatically compute default weaving region
for(MarkedRegion mr : mrs) {
mr.computeAfterThrow(methodNode);
mr.skipBranchesAtTheEnds();
mr.setWeavingRegion(mr.computeDefaultWeavingRegion(methodNode));
}
return mrs;
......@@ -27,5 +26,6 @@ public abstract class AbstractBranchSkipMarker {
* The regions will get automatic after throw computation
* The regions will get automatic branch skipping at the end
*/
public abstract List<MarkedRegion> markWithABSWithAAT(MethodNode methodNode);
public abstract List<MarkedRegion> markWithDefaultWeavingReg(
MethodNode methodNode);
}
......@@ -11,6 +11,7 @@ import org.objectweb.asm.tree.MethodNode;
import ch.usi.dag.disl.exception.MarkerException;
import ch.usi.dag.disl.snippet.Shadow;
import ch.usi.dag.disl.snippet.Shadow.WeavingRegion;
import ch.usi.dag.disl.snippet.Snippet;
public abstract class AbstractMarker implements Marker {
......@@ -21,37 +22,32 @@ public abstract class AbstractMarker implements Marker {
private AbstractInsnNode start;
private List<AbstractInsnNode> ends;
private AbstractInsnNode afterThrowStart;
private AbstractInsnNode afterThrowEnd;
private WeavingRegion weavingRegion;
public AbstractInsnNode getStart() {
return start;
}
public void setStart(AbstractInsnNode start) {
this.start = start;
}
public List<AbstractInsnNode> getEnds() {
return ends;
}
public AbstractInsnNode getAfterThrowStart() {
return afterThrowStart;
}
public AbstractInsnNode getAfterThrowEnd() {
return afterThrowEnd;
}
public void setStart(AbstractInsnNode start) {
this.start = start;
public void addExitPoint(AbstractInsnNode exitpoint) {
this.ends.add(exitpoint);
}
public void setAfterThrowStart(AbstractInsnNode afterThrowStart) {
this.afterThrowStart = afterThrowStart;
public WeavingRegion getWeavingRegion() {
return weavingRegion;
}
public void setAfterThrowEnd(AbstractInsnNode afterThrowEnd) {
this.afterThrowEnd = afterThrowEnd;
public void setWeavingRegion(WeavingRegion weavingRegion) {
this.weavingRegion = weavingRegion;
}
public MarkedRegion(AbstractInsnNode start) {
this.start = start;
this.ends = new LinkedList<AbstractInsnNode>();
......@@ -67,20 +63,29 @@ public abstract class AbstractMarker implements Marker {
this.start = start;
this.ends = ends;
}
public void addExitPoint(AbstractInsnNode exitpoint) {
this.ends.add(exitpoint);
}
public MarkedRegion(AbstractInsnNode start,
List<AbstractInsnNode> ends, WeavingRegion weavingRegion) {
super();
this.start = start;
this.ends = ends;
this.weavingRegion = weavingRegion;
}
public boolean valid() {
return start != null && ends != null
&& afterThrowStart != null && afterThrowEnd != null;
return start != null && ends != null && weavingRegion != null;
}
public void computeAfterThrow(MethodNode methodNode) {
public WeavingRegion computeDefaultWeavingRegion(MethodNode methodNode) {
// TODO ! skip branch instruction at the end
AbstractInsnNode wstart = null;
// can be null - see WeavingRegion for details
List<AbstractInsnNode> wends = null;
// set start
afterThrowStart = start;
AbstractInsnNode afterThrowStart = start;
AbstractInsnNode afterThrowEnd = null;
// get end that is the latest in the method instructions
Set<AbstractInsnNode> endsSet = new HashSet<AbstractInsnNode>(ends);
......@@ -96,11 +101,9 @@ public abstract class AbstractMarker implements Marker {
instr.getPrevious();
}
}
public void skipBranchesAtTheEnds() {
// TODO ! markers
return new WeavingRegion(wstart, wends, afterThrowStart,
afterThrowEnd);
}
}
......@@ -123,8 +126,7 @@ public abstract class AbstractMarker implements Marker {
}
result.add(new Shadow(classNode, methodNode, snippet,
mr.getStart(), mr.getEnds(), mr.getAfterThrowStart(),
mr.getAfterThrowEnd()));
mr.getStart(), mr.getEnds(), mr.getWeavingRegion()));
}
return result;
......
......@@ -16,23 +16,65 @@ public class Shadow {
private AbstractInsnNode regionStart;
private List<AbstractInsnNode> regionEnds;
private AbstractInsnNode afterThrowStart;
private AbstractInsnNode afterThrowEnd;
private WeavingRegion weavingRegion;
public static class WeavingRegion {
// NOTE: "ends" can be null. This means, that we have the special case
// where we need to generate before and after snippets on the same
// position.
// This is for example case of putting snippets before and after
// region that includes only return instruction.
// In this case, after has to be generated also before the return
// instruction otherwise is newer invoked.
// "ends" containing null notifies the weaver about this situation.
private AbstractInsnNode start;
private List<AbstractInsnNode> ends;
private AbstractInsnNode afterThrowStart;
private AbstractInsnNode afterThrowEnd;
public WeavingRegion(AbstractInsnNode start,
List<AbstractInsnNode> ends, AbstractInsnNode afterThrowStart,
AbstractInsnNode afterThrowEnd) {
super();
this.start = start;
this.ends = ends;
this.afterThrowStart = afterThrowStart;
this.afterThrowEnd = afterThrowEnd;
}
public AbstractInsnNode getStart() {
return start;
}
public List<AbstractInsnNode> getEnds() {
return ends;
}
public AbstractInsnNode getAfterThrowStart() {
return afterThrowStart;
}
public AbstractInsnNode getAfterThrowEnd() {
return afterThrowEnd;
}
}
public Shadow(ClassNode classNode, MethodNode methodNode, Snippet snippet,
AbstractInsnNode regionStart, List<AbstractInsnNode> regionEnds,
AbstractInsnNode afterThrowStart, AbstractInsnNode afterThrowEnd) {
WeavingRegion weavingRegion) {
super();
this.classNode = classNode;
this.methodNode = methodNode;
this.snippet = snippet;
this.regionStart = regionStart;
this.regionEnds = regionEnds;
this.afterThrowStart = afterThrowStart;
this.afterThrowEnd = afterThrowEnd;
this.weavingRegion = weavingRegion;
}
// special constructor for caching support
// special copy constructor for caching support
public Shadow(Shadow sa) {
this.classNode = sa.classNode;
......@@ -40,6 +82,7 @@ public class Shadow {
this.snippet = sa.snippet;
this.regionStart = sa.regionStart;
this.regionEnds = sa.regionEnds;
this.weavingRegion = sa.weavingRegion;
}
public ClassNode getClassNode() {
......@@ -62,11 +105,7 @@ public class Shadow {
return regionEnds;
}
public AbstractInsnNode getAfterThrowStart() {
return afterThrowStart;
}
public AbstractInsnNode getAfterThrowEnd() {
return afterThrowEnd;
public WeavingRegion getWeavingRegion() {
return weavingRegion;
}
}
......@@ -5,6 +5,7 @@ import java.util.List;
import org.objectweb.asm.tree.AbstractInsnNode;
import ch.usi.dag.disl.staticcontext.customdatacache.MethodCDCache;
import ch.usi.dag.disl.util.AsmHelper;
import ch.usi.dag.disl.util.cfg.CtrlFlowGraph;
public class BasicBlockStaticContext extends
......@@ -25,7 +26,7 @@ public class BasicBlockStaticContext extends
while (!ends.contains(start)) {
if (start.getOpcode() != 1) {
if (! AsmHelper.isVirtualInstr(start)) {
count++;
}
......
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