// for injecting code before and/or after a flat node
public class CodePlan {
- private FlatSESEEnterNode seseToIssue;
-
-
+ private Set<VariableSourceToken> writeToDynamicSrc;
+
public CodePlan() {
- seseToIssue = null;
+ writeToDynamicSrc = null;
}
-
- public void setSESEtoIssue( FlatSESEEnterNode sese ) {
- seseToIssue = sese;
+ public void setWriteToDynamicSrc(
+ Set<VariableSourceToken> writeToDynamicSrc
+ ) {
+ this.writeToDynamicSrc = writeToDynamicSrc;
}
- public FlatSESEEnterNode getSESEtoIssue() {
- return seseToIssue;
+ public Set<VariableSourceToken> getWriteToDynamicSrc() {
+ return writeToDynamicSrc;
}
-
public boolean equals( Object o ) {
if( o == null ) {
return false;
CodePlan cp = (CodePlan) o;
- boolean issueEq;
- if( seseToIssue == null ) {
- issueEq = (cp.seseToIssue == null);
+ boolean dynamicSetEq;
+ if( writeToDynamicSrc == null ) {
+ dynamicSetEq = (cp.writeToDynamicSrc == null);
} else {
- issueEq = (seseToIssue.equals( cp.seseToIssue ));
+ dynamicSetEq = (writeToDynamicSrc.equals( cp.writeToDynamicSrc ));
}
- return issueEq;
+ return dynamicSetEq;
}
public int hashCode() {
- int issueHC = 1;
- if( seseToIssue != null ) {
- issueHC = seseToIssue.hashCode();
+ int dynamicSetHC = 1;
+ if( writeToDynamicSrc != null ) {
+ dynamicSetHC = writeToDynamicSrc.hashCode();
}
- return issueHC;
+ return dynamicSetHC;
}
public String toString() {
String s = "";
- if( seseToIssue != null ) {
- s += "[ISSUE "+seseToIssue.getPrettyIdentifier()+"]";
+ if( writeToDynamicSrc != null ) {
+ s += "[WRITE DYN";
+
+ Iterator<VariableSourceToken> vstItr = writeToDynamicSrc.iterator();
+ while( vstItr.hasNext() ) {
+ VariableSourceToken vst = vstItr.next();
+ s += ", "+vst;
+ }
+
+ s += "]";
}
return s;
import Analysis.Loops.GlobalFieldType;
import Analysis.Locality.TypeAnalysis;
import Analysis.MLP.MLPAnalysis;
+import Analysis.MLP.VariableSourceToken;
+import Analysis.MLP.CodePlan;
public class BuildCode {
State state;
outmethod.println(" ((void **)(((char *)& stringarray->___length___)+sizeof(int)))[i-1]=newstring;");
outmethod.println(" }");
- if (state.MLP) {
- FlatSESEEnterNode rootSESE = mlpa.getRootSESE();
- outmethod.println(" mlpInit();");
-
- outmethod.print(" rootsese = mlpCreateSESErecord(");
- outmethod.print(rootSESE.getIdentifier()+", 0, NULL, 0, NULL");
- outmethod.println(");");
-
- outmethod.println(" ");
- }
-
MethodDescriptor md=typeutil.getMain();
ClassDescriptor cd=typeutil.getMainClass();
outmethod.println("#include <stdlib.h>");
outmethod.println("#include <stdio.h>");
outmethod.println("#include \"mlp_runtime.h\"");
- outmethod.println("/* GET RID OF THIS LATER */");
- outmethod.println("SESErecord* tempSESE;");
- outmethod.println("SESErecord* tempParentSESE;");
- outmethod.println("invokeSESEargs* tempSESEargs;");
}
FlatSESEExitNode stop,
PrintWriter output) {
+ // for any method, allocate temps to use when
+ // issuing a new SESE sometime during the execution
+ // of that method, whether it be a user-defined method
+ // or a method representing the body of an SESE
+ // TODO: only do this if we know the method actually
+ // contains an SESE issue, not currently an annotation
+ if( state.MLP ) {
+ output.println(" SESErecord* tempSESE;");
+ output.println(" SESErecord* tempParentSESE;");
+ output.println(" invokeSESEargs* tempSESEargs;");
+ }
+
/* Assign labels to FlatNode's if necessary.*/
Hashtable<FlatNode, Integer> nodetolabel=assignLabels(first, stop);
}
protected void generateFlatNode(FlatMethod fm, LocalityBinding lb, FlatNode fn, PrintWriter output) {
+
switch(fn.kind()) {
+
case FKind.FlatAtomicEnterNode:
generateFlatAtomicEnterNode(fm, lb, (FlatAtomicEnterNode) fn, output);
- return;
+ break;
case FKind.FlatAtomicExitNode:
generateFlatAtomicExitNode(fm, lb, (FlatAtomicExitNode) fn, output);
- return;
+ break;
case FKind.FlatInstanceOfNode:
generateFlatInstanceOfNode(fm, lb, (FlatInstanceOfNode)fn, output);
- return;
+ break;
case FKind.FlatSESEEnterNode:
generateFlatSESEEnterNode(fm, lb, (FlatSESEEnterNode)fn, output);
- return;
+ break;
case FKind.FlatSESEExitNode:
generateFlatSESEExitNode(fm, lb, (FlatSESEExitNode)fn, output);
- return;
+ break;
case FKind.FlatGlobalConvNode:
generateFlatGlobalConvNode(fm, lb, (FlatGlobalConvNode) fn, output);
- return;
+ break;
case FKind.FlatTagDeclaration:
generateFlatTagDeclaration(fm, lb, (FlatTagDeclaration) fn,output);
- return;
+ break;
case FKind.FlatCall:
generateFlatCall(fm, lb, (FlatCall) fn,output);
- return;
+ break;
case FKind.FlatFieldNode:
generateFlatFieldNode(fm, lb, (FlatFieldNode) fn,output);
- return;
+ break;
case FKind.FlatElementNode:
generateFlatElementNode(fm, lb, (FlatElementNode) fn,output);
- return;
+ break;
case FKind.FlatSetElementNode:
generateFlatSetElementNode(fm, lb, (FlatSetElementNode) fn,output);
- return;
+ break;
case FKind.FlatSetFieldNode:
generateFlatSetFieldNode(fm, lb, (FlatSetFieldNode) fn,output);
- return;
+ break;
case FKind.FlatNew:
generateFlatNew(fm, lb, (FlatNew) fn,output);
- return;
+ break;
case FKind.FlatOpNode:
generateFlatOpNode(fm, lb, (FlatOpNode) fn,output);
- return;
+ break;
case FKind.FlatCastNode:
generateFlatCastNode(fm, lb, (FlatCastNode) fn,output);
- return;
+ break;
case FKind.FlatLiteralNode:
generateFlatLiteralNode(fm, lb, (FlatLiteralNode) fn,output);
- return;
+ break;
case FKind.FlatReturnNode:
generateFlatReturnNode(fm, lb, (FlatReturnNode) fn,output);
- return;
+ break;
case FKind.FlatNop:
output.println("/* nop */");
- return;
+ break;
case FKind.FlatExit:
output.println("/* exit */");
- return;
+ break;
case FKind.FlatBackEdge:
if ((state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC) {
output.println("if (needtocollect) checkcollect(&"+localsprefix+");");
} else
output.println("/* nop */");
- return;
+ break;
case FKind.FlatCheckNode:
generateFlatCheckNode(fm, lb, (FlatCheckNode) fn, output);
- return;
+ break;
case FKind.FlatFlagActionNode:
generateFlatFlagActionNode(fm, lb, (FlatFlagActionNode) fn, output);
- return;
+ break;
case FKind.FlatPrefetchNode:
generateFlatPrefetchNode(fm,lb, (FlatPrefetchNode) fn, output);
- return;
+ break;
case FKind.FlatOffsetNode:
generateFlatOffsetNode(fm, lb, (FlatOffsetNode)fn, output);
- return;
+ break;
+
+ default:
+ throw new Error();
+ }
+
+ if( state.MLP ) {
+
+ CodePlan cp = mlpa.getCodePlan( fn );
+ if( cp != null ) {
+
+ Set<VariableSourceToken> writeDynamic = cp.getWriteToDynamicSrc();
+ if( writeDynamic != null ) {
+
+ }
+ }
}
- throw new Error();
}
public void generateFlatOffsetNode(FlatMethod fm, LocalityBinding lb, FlatOffsetNode fofn, PrintWriter output) {