Skip to content

Commit ea449cf

Browse files
committed
Default ROM to true if we can't find possible return types.
1 parent 68d3c7c commit ea449cf

File tree

1 file changed

+48
-34
lines changed

1 file changed

+48
-34
lines changed

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

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ private void discoverIfReduceOrderingPossiblyMatters(EclipseProjectAnalysisEngin
683683
assert numOfRetVals <= 1 : "How could you possibly return " + numOfRetVals + " values?";
684684

685685
Collection<TypeAbstraction> possibleReturnTypes = null;
686+
Boolean rom = null;
686687

687688
// if it's a non-void method.
688689
if (numOfRetVals > 0) {
@@ -691,49 +692,62 @@ private void discoverIfReduceOrderingPossiblyMatters(EclipseProjectAnalysisEngin
691692
possibleReturnTypes = Util.getPossibleTypesInterprocedurally(block.getNode(), returnValue, engine,
692693
orderingInference);
693694

695+
// if no return types can be found.
696+
if (possibleReturnTypes.isEmpty()) {
697+
// default to true.
698+
rom = true;
699+
700+
LOGGER.warning("Number of returned values are: " + numOfRetVals
701+
+ " but cannot find possible return types for node: " + block.getNode()
702+
+ " and return value:" + returnValue + ". Defaulting ROM to: " + rom + " for block: "
703+
+ block + ".");
704+
}
705+
694706
LOGGER.fine("Possible reduce types are: " + possibleReturnTypes);
695707
} else {
696708
// it's a void method.
697709
possibleReturnTypes = Collections.singleton(JavaPrimitiveType.VOID);
698710
}
699711

700-
Boolean rom = null;
701-
702-
if (isVoid(possibleReturnTypes))
703-
rom = deriveRomForVoidMethod(invokeInstruction);
704-
else {
705-
boolean scalar = Util.isScalar(possibleReturnTypes);
706-
if (scalar)
707-
try {
708-
rom = deriveRomForScalarMethod(invokeInstruction);
709-
} catch (UnknownIfReduceOrderMattersException e) {
710-
// for each possible receiver associated with the terminal block.
711-
OrdinalSet<InstanceKey> receivers = terminalBlockToPossibleReceivers.get(block);
712-
713-
for (InstanceKey instanceKey : receivers) {
714-
// get the stream for the instance key.
715-
Set<InstanceKey> originStreams = computePossibleOriginStreams(instanceKey);
716-
717-
// for each origin stream.
718-
for (InstanceKey origin : originStreams) {
719-
// get the "Stream" representing it.
720-
Stream stream = instanceToStreamMap.get(origin);
721-
722-
if (stream == null)
723-
LOGGER.warning(() -> "Can't find Stream instance for instance key: "
724-
+ instanceKey + " using origin: " + origin);
725-
else {
726-
LOGGER.log(Level.WARNING, "Unable to derive ROM for : " + stream.getCreation(),
727-
e);
728-
stream.addStatusEntry(PreconditionFailure.NON_DETERMINABLE_REDUCTION_ORDERING,
729-
"Cannot derive reduction ordering for stream: " + stream.getCreation()
730-
+ ".");
712+
// if we haven't determined ROM yet.
713+
if (rom == null) {
714+
if (isVoid(possibleReturnTypes))
715+
rom = deriveRomForVoidMethod(invokeInstruction);
716+
else {
717+
boolean scalar = Util.isScalar(possibleReturnTypes);
718+
if (scalar)
719+
try {
720+
rom = deriveRomForScalarMethod(invokeInstruction);
721+
} catch (UnknownIfReduceOrderMattersException e) {
722+
// for each possible receiver associated with the terminal block.
723+
OrdinalSet<InstanceKey> receivers = terminalBlockToPossibleReceivers.get(block);
724+
725+
for (InstanceKey instanceKey : receivers) {
726+
// get the stream for the instance key.
727+
Set<InstanceKey> originStreams = computePossibleOriginStreams(instanceKey);
728+
729+
// for each origin stream.
730+
for (InstanceKey origin : originStreams) {
731+
// get the "Stream" representing it.
732+
Stream stream = instanceToStreamMap.get(origin);
733+
734+
if (stream == null)
735+
LOGGER.warning(() -> "Can't find Stream instance for instance key: "
736+
+ instanceKey + " using origin: " + origin);
737+
else {
738+
LOGGER.log(Level.WARNING,
739+
"Unable to derive ROM for : " + stream.getCreation(), e);
740+
stream.addStatusEntry(
741+
PreconditionFailure.NON_DETERMINABLE_REDUCTION_ORDERING,
742+
"Cannot derive reduction ordering for stream: "
743+
+ stream.getCreation() + ".");
744+
}
731745
}
732746
}
733747
}
734-
}
735-
else // !scalar
736-
rom = deriveRomForNonScalarMethod(possibleReturnTypes, orderingInference);
748+
else // !scalar
749+
rom = deriveRomForNonScalarMethod(possibleReturnTypes, orderingInference);
750+
}
737751
}
738752

739753
// if reduce ordering matters.

0 commit comments

Comments
 (0)