Commit 58d95b2c authored by Carlos Galindo's avatar Carlos Galindo
Browse files

Work-list based and Reps tabular slicing for recursive programs.

- Worklist approach implemented through a Config flag in SummaryTable.
- Unconstrained and constrained variantes (TabularAlgorithm & ConstrainedTabularAlgorithm). The constrained version features a limit to the size of the stack.
- Constrained subsumed variant for efficiency (ConstrainedSubsumedTabularAlgorithm).
- Efficient EdgeList (linked-list) to store edges visited through a traversal.
- Bump language level to 16.
- eKnife cli: added switch to use tabular algorithms.
- Moved benchmarks out of eKnife and BencherTest.
parent 4d630beb
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -5,6 +5,18 @@
    <modelVersion>4.0.0</modelVersion>

    <artifactId>EDG</artifactId>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>16</source>
                    <target>16</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <parent>
        <artifactId>e-knife-parent</artifactId>
+2 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ public final class Config extends misc.Config
	/********************************************************************************************************************************/
	private static final Config config = new Config();
	public static final int MAX_PRODUCTION_DEPTH = 5;
	public static final int MAX_STACK_SIZE = 20;
	public static final int MAX_STACK_SIZE = Integer.parseInt(System.getProperty("maxStackSize", "20"));
	public static final LAST.Direction SLICE_DIRECTION = LAST.Direction.Backwards;
	public static final boolean GLOBAL_VARIABLES = false;
	public static final boolean PDG = true;
@@ -35,6 +35,7 @@ public final class Config extends misc.Config
	public static final boolean PPDG = false;
	public static final boolean summaries = false;
	public static final boolean tabulatedSlicing = true;
	public static boolean programIsRecursive = false;
	public static Config getConfig()
	{
		return Config.config;
+6 −5
Original line number Diff line number Diff line
@@ -65,11 +65,12 @@ public abstract class EdgeConstraint extends Constraint
	}
	protected Constraints push(Phase phase, Constraints constraints)
	{
		// STACK IS FULL AND EXCEPTION IS RAISED
		if (phase.isInstanceof(Phase.Slicing) && constraints.sizeEdgeConstraints() == Config.MAX_STACK_SIZE)
		if (constraints.sizeEdgeConstraints() == Config.MAX_STACK_SIZE) {
			if (phase == Phase.Tabular)
				constraints.edgeConstraints.remove(0);
			else if (phase.isInstanceof(Phase.Slicing))
				throw new StackOverflowError();
//if (phase.isInstanceof(Phase.SummaryGeneration) && constraints.sizeEdgeConstraints() == this.config.maxStackSize)
//	throw new StackOverflowError();
		}
		constraints.pushEdgeConstraint(this);

		return constraints;
+0 −5
Original line number Diff line number Diff line
package edg.graph;

import edg.constraint.Constraints;
import edg.constraint.GrammarConstraint;
import edg.slicing.SlicingCriterion;
import edg.slicing.SummaryTable;
@@ -33,10 +32,6 @@ public class EDG extends LAST {
		this.getGenerationTime().setCompositeTime(last.getCompositeStructureTime());
	}

	public List<SummaryTable.Value> getTableSummary(Node actualOut, Constraints stack) {
		return summaryTable.get(actualOut, stack);
	}

	public SummaryTable getSummaryTable() {
		return summaryTable;
	}
+11 −3
Original line number Diff line number Diff line
@@ -85,7 +85,12 @@ public class ConstrainedAlgorithm implements SlicingAlgorithm

		if (Config.tabulatedSlicing && isArgumentOut(currentNode)) {
			edges.removeIf(e -> e.getType() == Edge.Type.Summary);
			for (SummaryTable.Value v : edg.getTableSummary(currentNode, constraints))
			List<SummaryTable.Value> values;
			if (phase == Phase.SummaryGeneration && Config.programIsRecursive)
				values = edg.getSummaryTable().getOrQueue(currentNode, constraints);
			else
				values = edg.getSummaryTable().getOrCompute(currentNode, constraints);
			for (SummaryTable.Value v : values)
				newWorks.add(v.createWork(initialNode, work.getTraversedEdges()));
		}

@@ -103,7 +108,7 @@ public class ConstrainedAlgorithm implements SlicingAlgorithm
		final Constraints constraintsClone = (Constraints) constraints.clone();
		constraintsClone.clearNodeConstraints();
		for (Edge edge : edges)
			newWorks.add(new EdgeWork(edg, initialNode, edge, constraintsClone));
			newWorks.add(new EdgeWork(edg, initialNode, edge, work.getTraversedEdges(), constraintsClone));

		return newWorks;
	}
@@ -138,6 +143,9 @@ public class ConstrainedAlgorithm implements SlicingAlgorithm
			final List<Constraints> newConstraintsList = constraint.resolve(phase, edg, currentEdge, constraintsClone, topConstraint, 0);

			for (Constraints newConstraints : newConstraintsList)
				if (phase == Phase.SummaryGeneration && Config.programIsRecursive)
					newWorks.add(new NodeWork(initialNode, nextNode, new EdgeList(work.getTraversedEdges(), currentEdge), newConstraints, edgeType));
				else
					newWorks.add(new NodeWork(initialNode, nextNode, newConstraints, edgeType));

			return newWorks;
Loading