Commit 1ce50ba6 authored by Vít Kabele's avatar Vít Kabele

Weaver and weaver-pe packages merged

parent f1985a33
Pipeline #3378 passed with stages
in 2 minutes and 56 seconds
......@@ -20,6 +20,8 @@
<classpathentry kind="src" path="disl/src/src-staticcontext"/>
<classpathentry kind="src" path="disl/src/src-staticcontext-uid"/>
<classpathentry kind="src" path="disl/src/src-marker"/>
<classpathentry kind="src" path="disl/src/src-weaver"/>
<classpathentry kind="src" path="disl/src/src-weaver-pe"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="output/lib/disl-bypass.jar"/>
<classpathentry kind="lib" path="lib/disl/log4j.jar" sourcepath="lib/devel/log4j-source.jar"/>
......
......@@ -19,6 +19,8 @@ src.disl.localvar=src-localvar
src.disl.exception=src-exception
src.disl.scope=src-scope
src.disl.marker=src-marker
src.disl.weaver=src-weaver
src.disl.weaver-pe=src-weaver-pe
src.disl.staticcontext=src-staticcontext
src.disl.staticcontext-uid=src-staticcontext-uid
src.disl.bypass=src-disl-bypass
......
......@@ -485,6 +485,8 @@
<src path="${src.disl.prefix}/src/${src.disl.guard}"/>
<src path="${src.disl.prefix}/src/${src.disl.scope}"/>
<src path="${src.disl.prefix}/src/${src.disl.marker}"/>
<src path="${src.disl.prefix}/src/${src.disl.weaver}"/>
<src path="${src.disl.prefix}/src/${src.disl.weaver-pe}"/>
<src path="${src.disl.prefix}/src/${src.disl.localvar}"/>
<src path="${src.disl.prefix}/src/${src.disl.staticcontext}"/>
<src path="${src.disl.prefix}/src/${src.disl.staticcontext-uid}"/>
......
package ch.usi.dag.disl;
import ch.usi.dag.disl.weaver.Weaver;
import ch.usi.dag.util.asm.ClassNodeHelper;
import ch.usi.dag.util.logging.Logger;
import org.objectweb.asm.Opcodes;
......
package ch.usi.dag.disl.weaver.pe;
package ch.usi.dag.disl;
import java.util.HashSet;
import java.util.List;
......@@ -9,7 +9,7 @@ import org.objectweb.asm.tree.MethodInsnNode;
public class ClassHelper {
public static final HashSet<String> VALUE_TYPES = new HashSet<String>();
static final HashSet<String> VALUE_TYPES = new HashSet<String>();
static {
VALUE_TYPES.add("java/lang/Boolean");
......@@ -23,7 +23,7 @@ public class ClassHelper {
VALUE_TYPES.add("java/lang/String");
}
public static Class<?> getClassFromType(Type type) {
static Class<?> getClassFromType(Type type) {
switch (type.getSort()) {
......@@ -56,7 +56,7 @@ public class ClassHelper {
}
}
public static boolean isValueType(Type type) {
static boolean isValueType(Type type) {
switch (type.getSort()) {
......@@ -78,7 +78,7 @@ public class ClassHelper {
}
}
public static Class<?>[] getClasses(String desc)
static Class<?>[] getClasses(String desc)
throws ClassNotFoundException {
Type[] types = Type.getArgumentTypes(desc);
......@@ -96,7 +96,7 @@ public class ClassHelper {
return classes;
}
public static Object i2wrapper(Integer obj, Class<?> clazz) {
static Object i2wrapper(Integer obj, Class<?> clazz) {
int i = obj.intValue();
......@@ -119,7 +119,7 @@ public class ClassHelper {
return obj;
}
public static Object wrapper2i(Object obj, Class<?> clazz) {
static Object wrapper2i(Object obj, Class<?> clazz) {
if (clazz.equals(Boolean.class) || clazz.equals(boolean.class)) {
return ((Boolean) obj) ? 1 : 0;
......@@ -140,7 +140,7 @@ public class ClassHelper {
return obj;
}
public static Object dereference(Object obj) {
static Object dereference(Object obj) {
if (obj instanceof Reference) {
return ((Reference) obj).getObj();
......@@ -149,7 +149,7 @@ public class ClassHelper {
}
}
public static Object dereference(Object obj, Class<?> type) {
static Object dereference(Object obj, Class<?> type) {
if (obj instanceof Integer) {
return ClassHelper.i2wrapper((Integer) obj, type);
......@@ -167,7 +167,7 @@ public class ClassHelper {
}
}
public static Object getCaller(MethodInsnNode instr,
static Object getCaller(MethodInsnNode instr,
List<? extends ConstValue> values) {
if (instr.getOpcode() == Opcodes.INVOKESTATIC) {
......@@ -177,7 +177,7 @@ public class ClassHelper {
}
}
public static Object[] getArgs(MethodInsnNode instr,
static Object[] getArgs(MethodInsnNode instr,
List<? extends ConstValue> values, Class<?>[] parameters) {
if (instr.getOpcode() == Opcodes.INVOKESTATIC) {
......
package ch.usi.dag.disl.weaver.pe;
package ch.usi.dag.disl;
import java.util.List;
......@@ -88,7 +88,7 @@ public class ConstInterpreter extends Interpreter<ConstValue> {
return new ConstValue(value.getSize(), value.cst);
}
public static boolean mightBeUnaryConstOperation(final AbstractInsnNode insn) {
static boolean mightBeUnaryConstOperation(final AbstractInsnNode insn) {
switch (insn.getOpcode()) {
case Opcodes.INEG:
......@@ -265,7 +265,7 @@ public class ConstInterpreter extends Interpreter<ConstValue> {
}
}
public static boolean mightBeBinaryConstOperation(
static boolean mightBeBinaryConstOperation(
final AbstractInsnNode insn) {
switch (insn.getOpcode()) {
......
package ch.usi.dag.disl.weaver.pe;
package ch.usi.dag.disl;
import org.objectweb.asm.tree.analysis.Value;
......@@ -11,13 +11,13 @@ public class ConstValue implements Value {
*/
public final int size;
public Object cst;
Object cst;
public ConstValue(int size) {
ConstValue(int size) {
this(size, null);
}
public ConstValue(int size, Object cst) {
ConstValue(int size, Object cst) {
this.size = size;
this.cst = cst;
}
......
package ch.usi.dag.disl.weaver.pe;
package ch.usi.dag.disl;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
......@@ -9,13 +9,12 @@ import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.MethodInsnNode;
import ch.usi.dag.disl.JavaNames;
public class InvocationInterpreter {
private HashSet<String> registeredMethods;
public InvocationInterpreter() {
InvocationInterpreter() {
registeredMethods = new HashSet<String>();
}
......@@ -115,7 +114,7 @@ public class InvocationInterpreter {
return JavaNames.methodUniqueName (min.owner, min.name, min.desc);
}
public boolean isRegistered(MethodInsnNode min) {
boolean isRegistered(MethodInsnNode min) {
return registeredMethods.contains(getMethodID(min));
}
......
package ch.usi.dag.disl.weaver.pe;
package ch.usi.dag.disl;
import java.util.List;
......@@ -45,7 +45,7 @@ public class MaxCalculator {
SIZE = b;
}
public static int getMaxLocal(InsnList ilist, String desc, int access) {
static int getMaxLocal(InsnList ilist, String desc, int access) {
int maxLocals = (Type.getArgumentsAndReturnSizes(desc) >> 2);
......@@ -164,7 +164,7 @@ public class MaxCalculator {
return maxStack;
}
public static int getMaxStack(InsnList ilist,
static int getMaxStack(InsnList ilist,
List<TryCatchBlockNode> tryCatchBlocks) {
CtrlFlowGraph cfg = CtrlFlowGraph.build(ilist, tryCatchBlocks);
......
package ch.usi.dag.disl.weaver.pe;
package ch.usi.dag.disl;
import java.util.HashSet;
import java.util.LinkedList;
......@@ -24,18 +24,15 @@ import org.objectweb.asm.tree.analysis.Analyzer;
import org.objectweb.asm.tree.analysis.Frame;
import org.objectweb.asm.tree.analysis.SourceValue;
import ch.usi.dag.disl.AsmHelper;
import ch.usi.dag.disl.AsmHelper.Insns;
import ch.usi.dag.disl.FrameHelper;
import ch.usi.dag.disl.BasicBlock;
import ch.usi.dag.disl.CtrlFlowGraph;
public class PartialEvaluator {
class PartialEvaluator {
private MethodNode method;
private InsnList ilist;
public PartialEvaluator(InsnList instructions,
PartialEvaluator(InsnList instructions,
List<TryCatchBlockNode> tryCatchBlocks, String desc, int access) {
ilist = instructions;
......@@ -722,7 +719,7 @@ public class PartialEvaluator {
return isOptimized;
}
public boolean evaluate() {
boolean evaluate() {
ilist.add(new InsnNode(Opcodes.RETURN));
Analyzer<ConstValue> constAnalyzer = new Analyzer<ConstValue>(
......
package ch.usi.dag.disl.weaver.pe;
package ch.usi.dag.disl;
public class Reference {
private Object obj;
......
package ch.usi.dag.disl.weaver;
package ch.usi.dag.disl;
import java.util.Collections;
import java.util.Comparator;
......@@ -7,13 +7,11 @@ import org.objectweb.asm.commons.TryCatchBlockSorter;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TryCatchBlockNode;
import ch.usi.dag.disl.DiSLFatalException;
import ch.usi.dag.disl.AsmHelper;
import ch.usi.dag.disl.AsmHelper.Insns;
public class AdvancedSorter extends TryCatchBlockSorter {
public AdvancedSorter(MethodNode method) {
AdvancedSorter(MethodNode method) {
super(null, method.access, method.name, method.desc, method.signature,
null);
......@@ -21,7 +19,7 @@ public class AdvancedSorter extends TryCatchBlockSorter {
this.tryCatchBlocks = method.tryCatchBlocks;
}
public void validate() {
void validate() {
TryCatchBlockNode[] tcbs = new TryCatchBlockNode[tryCatchBlocks.size()];
tcbs = tryCatchBlocks.toArray(tcbs);
......
package ch.usi.dag.disl.weaver;
package ch.usi.dag.disl;
import java.util.List;
import java.util.Set;
......@@ -29,7 +29,7 @@ final class RewriteThreadLocalVarAccessesCodeTransformer implements CodeTransfor
//
public RewriteThreadLocalVarAccessesCodeTransformer (final Set <ThreadLocalVar> tlvs) {
RewriteThreadLocalVarAccessesCodeTransformer (final Set <ThreadLocalVar> tlvs) {
//
// Generate a set of TLV identifiers for faster lookup.
//
......
package ch.usi.dag.disl.weaver;
package ch.usi.dag.disl;
import java.util.List;
import java.util.Map;
......@@ -20,18 +20,9 @@ import ch.usi.dag.disl.annotation.AfterReturning;
import ch.usi.dag.disl.annotation.AfterThrowing;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.annotation.SyntheticLocal.Initialize;
import ch.usi.dag.disl.InvalidContextUsageException;
import ch.usi.dag.disl.SyntheticLocalVar;
import ch.usi.dag.disl.ThreadLocalVar;
import ch.usi.dag.disl.PIResolver;
import ch.usi.dag.disl.Shadow;
import ch.usi.dag.disl.Shadow.WeavingRegion;
import ch.usi.dag.disl.Snippet;
import ch.usi.dag.disl.SnippetCode;
import ch.usi.dag.disl.SCGenerator;
import ch.usi.dag.disl.AsmHelper;
import ch.usi.dag.disl.AsmHelper.Insns;
import ch.usi.dag.disl.CodeTransformer;
// The weaver instruments byte-codes into java class.
public class Weaver {
......@@ -176,7 +167,7 @@ public class Weaver {
// generate a try catch block node given the scope of the handler
public static TryCatchBlockNode getTryCatchBlock (
static TryCatchBlockNode getTryCatchBlock (
final MethodNode methodNode,
AbstractInsnNode start, AbstractInsnNode end
) {
......
package ch.usi.dag.disl.weaver;
package ch.usi.dag.disl;
import java.util.List;
import java.util.Set;
......@@ -20,28 +20,12 @@ import org.objectweb.asm.tree.analysis.Frame;
import org.objectweb.asm.tree.analysis.SourceValue;
import ch.usi.dag.disl.classcontext.ClassContext;
import ch.usi.dag.disl.Code;
import ch.usi.dag.disl.dynamiccontext.DynamicContext;
import ch.usi.dag.disl.DiSLFatalException;
import ch.usi.dag.disl.InvalidContextUsageException;
import ch.usi.dag.disl.PIResolver;
import ch.usi.dag.disl.ProcInstance;
import ch.usi.dag.disl.ProcMethodInstance;
import ch.usi.dag.disl.processorcontext.ArgumentContext;
import ch.usi.dag.disl.processorcontext.ArgumentProcessorContext;
import ch.usi.dag.disl.processorcontext.ArgumentProcessorMode;
import ch.usi.dag.disl.Shadow;
import ch.usi.dag.disl.Snippet;
import ch.usi.dag.disl.SnippetCode;
import ch.usi.dag.disl.StaticContext;
import ch.usi.dag.disl.SCGenerator;
import ch.usi.dag.disl.AsmHelper;
import ch.usi.dag.disl.AsmHelper.Insns;
import ch.usi.dag.disl.FrameHelper;
import ch.usi.dag.disl.Insn;
import ch.usi.dag.disl.JavaNames;
import ch.usi.dag.disl.weaver.pe.MaxCalculator;
import ch.usi.dag.disl.weaver.pe.PartialEvaluator;
public class WeavingCode {
......@@ -62,7 +46,7 @@ public class WeavingCode {
//
public WeavingCode(
WeavingCode(
final WeavingInfo weavingInfo, final MethodNode method, final SnippetCode src,
final Snippet snippet, final Shadow shadow, final AbstractInsnNode loc
) {
......
package ch.usi.dag.disl.weaver;
package ch.usi.dag.disl;
import java.util.ArrayList;
import java.util.Collections;
......@@ -23,7 +23,7 @@ import ch.usi.dag.disl.AsmHelper;
import ch.usi.dag.disl.AsmHelper.Insns;
import ch.usi.dag.disl.FrameHelper;
public class WeavingInfo {
class WeavingInfo {
private ArrayList<Snippet> sortedSnippets;
......@@ -32,7 +32,7 @@ public class WeavingInfo {
private Frame<BasicValue> retFrame;
public WeavingInfo(ClassNode classNode, MethodNode methodNode,
WeavingInfo(ClassNode classNode, MethodNode methodNode,
Map<Snippet, List<Shadow>> snippetMarkings) {
sortedSnippets = new ArrayList<Snippet>(snippetMarkings.keySet());
......@@ -121,35 +121,35 @@ public class WeavingInfo {
retFrame = basicFrameMap.get(last);
}
public ArrayList<Snippet> getSortedSnippets() {
ArrayList<Snippet> getSortedSnippets() {
return sortedSnippets;
}
public Frame<BasicValue> getBasicFrame(AbstractInsnNode instr) {
Frame<BasicValue> getBasicFrame(AbstractInsnNode instr) {
return basicFrameMap.get(instr);
}
public Frame<BasicValue> getRetFrame() {
Frame<BasicValue> getRetFrame() {
return retFrame;
}
public Frame<SourceValue> getSourceFrame(AbstractInsnNode instr) {
Frame<SourceValue> getSourceFrame(AbstractInsnNode instr) {
return sourceFrameMap.get(instr);
}
public boolean stackNotEmpty(AbstractInsnNode loc) {
boolean stackNotEmpty(AbstractInsnNode loc) {
return basicFrameMap.get(loc).getStackSize() > 0;
}
public InsnList backupStack(AbstractInsnNode loc, int startFrom) {
InsnList backupStack(AbstractInsnNode loc, int startFrom) {
return FrameHelper.enter(basicFrameMap.get(loc), startFrom);
}
public InsnList restoreStack(AbstractInsnNode loc, int startFrom) {
InsnList restoreStack(AbstractInsnNode loc, int startFrom) {
return FrameHelper.exit(basicFrameMap.get(loc), startFrom);
}
public int getStackHeight(AbstractInsnNode loc) {
int getStackHeight(AbstractInsnNode loc) {
return FrameHelper.getOffset(basicFrameMap.get(loc));
}
......
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