public Alloc getCmdLineArgBytesAlloc() {
return getAllocationSiteFromFlatNew( constructedCmdLineArgBytesNew );
}
+ public Alloc getNewStringLiteralAlloc() {
+ return newStringLiteralAlloc;
+ }
+
///////////////////////////////////////////
//
// end public interface
protected FlatNew constructedCmdLineArgNew;
protected FlatNew constructedCmdLineArgBytesNew;
+
+ // similar to above, the runtime allocates new strings
+ // for literal nodes, so make up an alloc to model that
+ protected TypeDescriptor strLiteralType;
+ protected AllocSite newStringLiteralAlloc;
= state.DISJOINTDEBUGCALLSTOPAFTER;
ReachGraph.debugCallSiteVisitCounter
- = 0; // count visits from 1, is incremented before first visit
+ = 0; // count visits from 1, is incremented before first visit
+
-
if( suppressOutput ) {
allocateStructures();
+ // model the implicit alloction site for new string literals
+ strLiteralType = new TypeDescriptor( typeUtil.getClass( typeUtil.StringClass ) );
+ TempDescriptor throwAway =
+ new TempDescriptor("stringLiteralTemp_dummy",
+ strLiteralType
+ );
+ FlatNew fnStringLiteral =
+ new FlatNew(strLiteralType,
+ throwAway,
+ false // is global
+ );
+ newStringLiteralAlloc
+ = getAllocSiteFromFlatNewPRIVATE( fnStringLiteral );
+
+
+
+
double timeStartAnalysis = (double) System.nanoTime();
// start interprocedural fixed-point computation
}
+
// now, depending on the interprocedural mode for visiting
// methods, set up the needed data structures
}
break;
+
+ case FKind.FlatLiteralNode:
+ // BIG NOTE: this transfer function is only here for
+ // points-to information for String literals. That's it.
+ // Effects and disjoint reachability and all of that don't
+ // care about references to literals.
+ FlatLiteralNode fln = (FlatLiteralNode) fn;
+
+ if( fln.getType().equals( strLiteralType ) ) {
+ rg.assignTempEqualToNewAlloc( fln.getDst(),
+ newStringLiteralAlloc );
+ }
+ break;
+
+
case FKind.FlatSESEEnterNode:
sese = (FlatSESEEnterNode) fn;
public Alloc getCmdLineArgAlloc(); // a String
public Alloc getCmdLineArgBytesAlloc();// an array of char
+
+ // similar to above, new string literals have a runtime alloc site (not in
+ // code explicitly) so make one in your model and return it here
+ public Alloc getNewStringLiteralAlloc(); // a String
+
+
// Use these methods to find out what allocation sites
// the given pointer might point to at or after the
// given program point. In the case of a variable and
case FKind.FlatElementNode:
case FKind.FlatSetElementNode:
case FKind.FlatNew:
+ case FKind.FlatLiteralNode:
case FKind.FlatCall:
case FKind.FlatReturnNode:
case FKind.FlatBackEdge:
public Alloc getCmdLineArgBytesAlloc() {
return null;
}
+ public Alloc getNewStringLiteralAlloc() {
+ return null;
+ }
public Set<Alloc> canPointToAt( TempDescriptor x,
public void additionalIncludesStructsHeader(PrintWriter outstructs) {}
public void additionalCodeAtTopMethodsImplementation(PrintWriter outmethod) {}
public void additionalCodeNewObject(PrintWriter outmethod, String dstVar, FlatNew flatNew) {}
+ public void additionalCodeNewStringLiteral(PrintWriter output, String dstVar) {}
}
outclassdefs.println(" int allocsite;");
}
+
public void additionalCodeForCommandLineArgs(PrintWriter outmethod, String argsVar) {
ClassDescriptor cdString = typeUtil.getClass( typeUtil.StringClass );
outmethod.println("");
}
+
public void additionalCodeNewObject(PrintWriter outmethod, String dstVar, FlatNew flatNew) {
outmethod.println(dstVar+"->allocsite = "+
heapAnalysis.getAllocationSiteFromFlatNew( flatNew ).getUniqueAllocSiteID()+
}
+ public void additionalCodeNewStringLiteral(PrintWriter output, String dstVar) {
+ output.println(dstVar+"->allocsite = "+
+ heapAnalysis.getNewStringLiteralAlloc().getUniqueAllocSiteID()+
+ ";"
+ );
+ }
+
+
+
public void printExtraArrayFields(PrintWriter outclassdefs) {}
public void outputTransCode(PrintWriter output) {}
public void buildCodeSetup() {}
} else {
output.println(generateTemp(fm, fln.getDst())+"=NewStringShort(str"+flncount+" ,"+((String)fln.getValue()).length()+");");
}
+
+ for(BuildCodeExtension bcx: extensions) {
+ bcx.additionalCodeNewStringLiteral(output, generateTemp(fm, fln.getDst()));
+ }
+
output.println("}");
flncount++;
} else if (fln.getType().isBoolean()) {
public void additionalCodePreNode(FlatMethod fm, FlatNode fn, PrintWriter output);
public void additionalCodePostNode(FlatMethod fm, FlatNode fn, PrintWriter output);
public void additionalCodeNewObject(PrintWriter outmethod, String dstVar, FlatNew flatNew);
+ public void additionalCodeNewStringLiteral(PrintWriter output, String dstVar);
}
while(cd2!=null) {
cd2=getSuper(cd2);
if (cd2==possiblesuper)
- return true;
+ return true;
// check cd2's interface ancestors
if(cd2 != null) {