Skip to content

Commit f1317ca

Browse files
committed
Some work on #148.
1 parent e27c313 commit f1317ca

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis/Stream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public InstanceKey getInstanceKey(Collection<InstanceKey> trackedInstances,
409409
instanceKey = this.getInstructionForCreation(engine)
410410
.flatMap(instruction -> trackedInstances.stream()
411411
.filter(ik -> instanceKeyCorrespondsWithInstantiationInstruction(ik, instruction,
412-
engine.getCallGraph()))
412+
this.getEnclosingMethodReference(), engine.getCallGraph()))
413413
.findFirst())
414414
.orElseThrow(() -> new InstanceKeyNotFoundException("Can't find instance key for: "
415415
+ this.getCreation() + " using tracked instances: " + trackedInstances));

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis/StreamStateMachine.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,7 @@ private void fillInstanceToPredecessorMap(EclipseProjectAnalysisEngine<InstanceK
11661166

11671167
private void fillInstanceToStreamMap(Set<Stream> streamSet, EclipseProjectAnalysisEngine<InstanceKey> engine)
11681168
throws InvalidClassFileException, IOException, CoreException {
1169+
int skippedStreams = 0;
11691170
for (Stream stream : streamSet) {
11701171
InstanceKey instanceKey = null;
11711172
try {
@@ -1182,13 +1183,14 @@ private void fillInstanceToStreamMap(Set<Stream> streamSet, EclipseProjectAnalys
11821183
"Either pivital code isn't reachable for stream: " + stream.getCreation()
11831184
+ " or entry points are misconfigured.");
11841185
}
1186+
++skippedStreams;
11851187
continue; // next stream.
11861188
}
11871189
instanceToStreamMap.put(instanceKey, stream);
11881190
} // end each stream.
11891191

11901192
// sanity check since it's a bijection.
1191-
if (instanceToStreamMap.size() != streamSet.size())
1193+
if (instanceToStreamMap.size() != streamSet.size() - skippedStreams)
11921194
throw new IllegalArgumentException("Stream set does not produce a bijection of instance keys.");
11931195
}
11941196

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/safe/Util.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.Iterator;
44

55
import com.ibm.wala.classLoader.CallSiteReference;
6+
import com.ibm.wala.classLoader.IMethod;
67
import com.ibm.wala.classLoader.NewSiteReference;
78
import com.ibm.wala.ipa.callgraph.CGNode;
89
import com.ibm.wala.ipa.callgraph.CallGraph;
@@ -37,7 +38,7 @@ private Util() {
3738
* instance key according to the given call graph.
3839
*/
3940
public static boolean instanceKeyCorrespondsWithInstantiationInstruction(InstanceKey instanceKey,
40-
SSAInvokeInstruction instruction, CallGraph callGraph) {
41+
SSAInvokeInstruction instruction, MethodReference instructionEnclosingMethod, CallGraph callGraph) {
4142
// Creation sites for the instance with the given key in the given call
4243
// graph.
4344
Iterator<Pair<CGNode, NewSiteReference>> creationSites = instanceKey.getCreationSites(callGraph);
@@ -53,13 +54,22 @@ public static boolean instanceKeyCorrespondsWithInstantiationInstruction(Instanc
5354
// get the call site references corresponding to the call string.
5455
CallSiteReference[] callSiteRefs = callString.getCallSiteRefs();
5556

57+
// get the methods corresponding to the call string.
58+
IMethod[] methods = callString.getMethods();
59+
60+
// check sanity.
61+
assert callSiteRefs.length == methods.length : "Call sites and methods should correlate.";
62+
5663
// for each call site reference.
57-
for (CallSiteReference callSiteReference : callSiteRefs) {
64+
for (int i = 0; i < callSiteRefs.length; i++) {
65+
CallSiteReference callSiteReference = callSiteRefs[i];
66+
IMethod method = methods[i];
5867
CallSiteReference instructionCallSite = instruction.getCallSite();
5968

6069
// if the call site reference equals the call site corresponding
6170
// to the creation instruction.
62-
if (callSiteReference.equals(instructionCallSite))
71+
if (callSiteReference.equals(instructionCallSite)
72+
&& method.getReference().getSignature().equals(instructionEnclosingMethod.getSignature()))
6373
return true;
6474
// workaround #80.
6575
else if (callSiteReference.getProgramCounter() == instructionCallSite.getProgramCounter()) {

edu.cuny.hunter.streamrefactoring.eval/Stream Refactoring Evaluation.launch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
<booleanAttribute key="generateProfile" value="true"/>
108108
<booleanAttribute key="includeOptional" value="true"/>
109109
<stringAttribute key="location" value="${workspace_loc}/../Experiments"/>
110+
<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="${workspace_loc}/../Experiments/results/run.log"/>
110111
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
111112
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
112113
</listAttribute>

0 commit comments

Comments
 (0)