use of com.jopdesign.dfa.framework.ContextMap in project jop by jop-devel.
the class CallStringReceiverTypes method initial.
public ContextMap<CallString, Set<TypeMapping>> initial(InstructionHandle stmt) {
ContextMap<CallString, Set<TypeMapping>> init = new ContextMap<CallString, Set<TypeMapping>>(new Context(), new LinkedHashMap<CallString, Set<TypeMapping>>());
Set<TypeMapping> s = new LinkedHashSet<TypeMapping>();
s.add(new TypeMapping("com.jopdesign.io.IOFactory.sp", "com.jopdesign.io.SerialPort"));
s.add(new TypeMapping("com.jopdesign.io.IOFactory.sys", "com.jopdesign.io.SysDevice"));
init.put(CallString.EMPTY, s);
return init;
}
use of com.jopdesign.dfa.framework.ContextMap in project jop by jop-devel.
the class LoopBounds method copyResults.
@Override
public void copyResults(MethodInfo newContainer, Map<InstructionHandle, InstructionHandle> newHandles) {
for (Map.Entry<InstructionHandle, InstructionHandle> entry : newHandles.entrySet()) {
InstructionHandle oldHandle = entry.getKey();
InstructionHandle newHandle = entry.getValue();
if (newHandle == null)
continue;
// TODO support updating the callstrings too
// TODO this does NOT update stackPtr,.. in the new context!
ContextMap<CallString, Pair<ValueMapping, ValueMapping>> value = bounds.get(oldHandle);
if (value != null)
bounds.put(newHandle, value.copy(newContainer));
ContextMap<CallString, Interval> value1 = arrayIndices.get(oldHandle);
if (value1 != null)
arrayIndices.put(newHandle, value1.copy(newContainer));
ContextMap<CallString, Integer> value2 = scopes.get(oldHandle);
if (value2 != null)
scopes.put(newHandle, value2.copy(newContainer));
ContextMap<CallString, Interval[]> value3 = sizes.get(oldHandle);
if (value3 != null)
sizes.put(newHandle, value3.copy(newContainer));
ContextMap<CallString, Set<FlowEdge>> old = infeasibles.get(oldHandle);
if (old != null) {
Map<CallString, Set<FlowEdge>> map = new LinkedHashMap<CallString, Set<FlowEdge>>(old.size());
for (CallString cs : old.keySet()) {
Set<FlowEdge> newSet = new LinkedHashSet<FlowEdge>();
for (FlowEdge edge : old.get(cs)) {
InstructionHandle newHead = newHandles.get(edge.getHead());
InstructionHandle newTail = newHandles.get(edge.getTail());
if (newHead != null && newTail != null) {
Context ctx = new Context(edge.getContext());
ctx.setMethodInfo(newContainer);
newSet.add(new FlowEdge(newTail, newHead, edge.getType(), ctx));
}
}
map.put(cs, newSet);
}
Context c = old.getContext();
c.setMethodInfo(newContainer);
ContextMap<CallString, Set<FlowEdge>> edges = new ContextMap<CallString, Set<FlowEdge>>(c, map);
infeasibles.put(newHandle, edges);
}
}
}
use of com.jopdesign.dfa.framework.ContextMap in project jop by jop-devel.
the class SymbolicPointsTo method initial.
public ContextMap<CallString, SymbolicAddressMap> initial(InstructionHandle stmt) {
ContextMap<CallString, SymbolicAddressMap> retval = new ContextMap<CallString, SymbolicAddressMap>(new Context(), new HashMap<CallString, SymbolicAddressMap>());
SymbolicAddressMap init = new SymbolicAddressMap(bsFactory);
// Add symbolic stack names
int stackPtr = 0;
if (!entryMethod.isStatic()) {
init.putStack(stackPtr++, bsFactory.singleton(SymbolicAddress.rootAddress("$this")));
}
String[] args = entryMethod.getArgumentNames();
for (int i = 0; i < args.length; i++) {
Type ty = entryMethod.getArgumentType(i);
if (ty instanceof ReferenceType) {
init.putStack(stackPtr, bsFactory.singleton(SymbolicAddress.rootAddress("$" + args[i])));
}
stackPtr += ty.getSize();
}
retval.put(initialCallString, init);
return retval;
}
use of com.jopdesign.dfa.framework.ContextMap in project jop by jop-devel.
the class SymbolicPointsTo method join.
public ContextMap<CallString, SymbolicAddressMap> join(ContextMap<CallString, SymbolicAddressMap> s1, ContextMap<CallString, SymbolicAddressMap> s2) {
if (s1 == null) {
return new ContextMap<CallString, SymbolicAddressMap>(s2);
}
if (s2 == null) {
return new ContextMap<CallString, SymbolicAddressMap>(s1);
}
// create empty context map, with s1's context
ContextMap<CallString, SymbolicAddressMap> result = new ContextMap<CallString, SymbolicAddressMap>(new Context(s1.getContext()), new HashMap<CallString, SymbolicAddressMap>());
// add both context maps. Note that entries from s2 overwrite those from the s1
result.putAll(s1);
result.putAll(s2);
// a and b are the DF results for the respectively active contexts
SymbolicAddressMap a = s1.get(s1.getContext().callString);
SymbolicAddressMap b = s2.get(s2.getContext().callString);
SymbolicAddressMap merged = a.clone();
merged.join(b);
result.put(s2.getContext().callString, merged);
if (result.getContext().stackPtr < 0) {
result.getContext().stackPtr = s2.getContext().stackPtr;
}
if (result.getContext().syncLevel < 0) {
result.getContext().syncLevel = s2.getContext().syncLevel;
}
result.getContext().threaded = Context.isThreaded();
return result;
}
Aggregations