public Alloc getNewStringLiteralAlloc() {
return newStringLiteralAlloc;
}
+ public Alloc getNewStringLiteralBytesAlloc() {
+ return newStringLiteralBytesAlloc;
+ }
///////////////////////////////////////////
//
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;
+ protected AllocSite newStringLiteralBytesAlloc;
+
+ // both of the above need the descriptor of the field
+ // for the String's value field to reference by the
+ // byte array from the string object
+ protected TypeDescriptor stringType;
+ protected TypeDescriptor stringBytesType;
+ protected FieldDescriptor stringBytesField;
+
+
+ protected void initImplicitStringsModel() {
+
+ ClassDescriptor cdString = typeUtil.getClass( typeUtil.StringClass );
+ assert cdString != null;
+
+
+ stringType =
+ new TypeDescriptor( cdString );
+
+ stringBytesType =
+ new TypeDescriptor(TypeDescriptor.CHAR).makeArray( state );
+
+
+ stringBytesField = null;
+ Iterator sFieldsItr = cdString.getFields();
+ while( sFieldsItr.hasNext() ) {
+ FieldDescriptor fd = (FieldDescriptor) sFieldsItr.next();
+ if( fd.getSymbol().equals( typeUtil.StringClassValueField ) ) {
+ stringBytesField = fd;
+ break;
+ }
+ }
+ assert stringBytesField != null;
+
+
+ TempDescriptor throwAway1 =
+ new TempDescriptor("stringLiteralTemp_dummy1",
+ stringType
+ );
+ FlatNew fnStringLiteral =
+ new FlatNew(stringType,
+ throwAway1,
+ false // is global
+ );
+ newStringLiteralAlloc
+ = getAllocSiteFromFlatNewPRIVATE( fnStringLiteral );
+
+
+ TempDescriptor throwAway2 =
+ new TempDescriptor("stringLiteralTemp_dummy2",
+ stringBytesType
+ );
+ FlatNew fnStringLiteralBytes =
+ new FlatNew(stringBytesType,
+ throwAway2,
+ false // is global
+ );
+ newStringLiteralBytesAlloc
+ = getAllocSiteFromFlatNewPRIVATE( fnStringLiteralBytes );
+ }
+
ReachGraph.typeUtil = typeUtil;
ReachGraph.state = state;
+ ReachGraph.initOutOfScopeTemps();
+
ReachGraph.debugCallSiteVisitStartCapture
= state.DISJOINTDEBUGCALLVISITTOSTART;
-
if( suppressOutput ) {
System.out.println("* Running disjoint reachability analysis with output suppressed! *");
}
- 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 );
+ allocateStructures();
+ initImplicitStringsModel();
// care about references to literals.
FlatLiteralNode fln = (FlatLiteralNode) fn;
- if( fln.getType().equals( strLiteralType ) ) {
- rg.assignTempEqualToNewAlloc( fln.getDst(),
- newStringLiteralAlloc );
+ if( fln.getType().equals( stringType ) ) {
+ rg.assignTempEqualToStringLiteral( fln.getDst(),
+ newStringLiteralAlloc,
+ newStringLiteralBytesAlloc,
+ stringBytesField );
}
break;
// all this jimma jamma to debug call sites is WELL WORTH the
- // effort, so many bugs or buggy info goes crazy through call
+ // effort, so so so many bugs or buggy info appears through call
// sites
boolean debugCallSite = false;
if( state.DISJOINTDEBUGCALLEE != null &&
);
}
+
+
ReachGraph rgMergeOfPossibleCallers = new ReachGraph();
Iterator<MethodDescriptor> mdItr = setPossibleCallees.iterator();
mods.addModifier(Modifiers.STATIC);
TypeDescriptor returnType = new TypeDescriptor(TypeDescriptor.VOID);
-
+
this.mdAnalysisEntry =
new MethodDescriptor(mods,
returnType,
sizeBytes
);
- TypeDescriptor typeBytes =
- new TypeDescriptor(TypeDescriptor.CHAR).makeArray( state );
TempDescriptor strBytes =
new TempDescriptor("analysisEntryTemp_strBytes",
- typeBytes
+ stringBytesType
);
FlatNew fnBytes =
- new FlatNew(typeBytes,
+ new FlatNew(stringBytesType,
strBytes,
//sizeBytes,
false // is global
);
this.constructedCmdLineArgBytesNew = fnBytes;
- ClassDescriptor cdString = argType.getClassDesc();
- assert cdString != null;
- FieldDescriptor argBytes = null;
- Iterator sFieldsItr = cdString.getFields();
- while( sFieldsItr.hasNext() ) {
- FieldDescriptor fd = (FieldDescriptor) sFieldsItr.next();
- if( fd.getSymbol().equals( typeUtil.StringClassValueField ) ) {
- argBytes = fd;
- break;
- }
- }
- assert argBytes != null;
FlatSetFieldNode fsf =
new FlatSetFieldNode(anArg,
- argBytes,
+ stringBytesField,
strBytes
);
protected static final boolean DISABLE_STRONG_UPDATES = false;
protected static final boolean DISABLE_GLOBAL_SWEEP = false;
- // a special out-of-scope temp
- protected static final TempDescriptor tdReturn = new TempDescriptor("_Return___");
+ // a special out-of-scope temps
+ protected static TempDescriptor tdReturn;
+ protected static TempDescriptor tdStrLiteralBytes;
+
+ public static void initOutOfScopeTemps() {
+ tdReturn = new TempDescriptor("_Return___");
+
+ tdStrLiteralBytes =
+ new TempDescriptor("_strLiteralBytes___",
+ new TypeDescriptor(TypeDescriptor.CHAR).makeArray( state )
+ );
+ }
// predicate constants
public static final ExistPred predTrue = ExistPred.factory(); // if no args, true
//
////////////////////////////////////////////////////
+ public void assignTempEqualToStringLiteral(TempDescriptor x,
+ AllocSite asStringLiteral,
+ AllocSite asStringLiteralBytes,
+ FieldDescriptor fdStringBytesField) {
+ // model this to get points-to information right for
+ // pointers to string literals, even though it doesn't affect
+ // reachability paths in the heap
+ assignTempEqualToNewAlloc( x,
+ asStringLiteral );
+
+ assignTempEqualToNewAlloc( tdStrLiteralBytes,
+ asStringLiteralBytes );
+
+ assignTempXFieldFEqualToTempY( x,
+ fdStringBytesField,
+ tdStrLiteralBytes,
+ null );
+ }
+
+
public void assignTempXEqualToTempY(TempDescriptor x,
TempDescriptor y) {
assignTempXEqualToCastedTempY(x, y, null);
BSFLAGS= -64bit -mainclass $(PROGRAM) -heapsize-mb 5000 -garbagestats -joptimize -noloop -optimize -nolock -debug #-nooptimize #src-after-pp
-CHECKPOINTSTO= -disjoint -printlinenum -pointsto-check-v-runtime #-disjoint-write-dots final
+CHECKPOINTSTO= -printlinenum -pointsto-check-v-runtime
DRELEASEMODE=-disjoint-release-mode -disjoint-dvisit-stack-callees-on-top -disjoint-alias-file aliases.txt tabbed
# EX: (skip first 10 visits, capture the next 3, then halt)
# -disjoint-debug-snap-method Remove 10 3 true
-DISJOINTDEBUG= -justanalyze -disjoint -disjoint-k 1 -enable-assertions
-# -disjoint-write-dots final \
-# -disjoint-debug-callsite Demand.add Lateral.compute 1 1000 true
+DISJOINTDEBUG= -disjoint -disjoint-k 1 -enable-assertions \
+ -disjoint-write-dots final \
+ -flatirusermethods
+# -disjoint-debug-callsite String.valueOf Power.main 1 1000 true \
+# -justanalyze
# -disjoint-desire-determinism
+# -disjoint-debug-callsite Demand.add Lateral.compute 1 1000 true
# -disjoint-debug-snap-method ComputeCenterOfMass 6 2 true
# -disjoint-debug-scheduling
-# -flatirusermethods
+
check-pointsto: $(PROGRAM)c.bin
$(PROGRAM)c.bin: $(SOURCE_FILES) ../master-makefile
- $(BUILDSCRIPT) $(BMFLAGS) $(BSFLAGS) $(USECOREPROF) $(CHECKPOINTSTO) -o $(PROGRAM)c -builddir chk $(SOURCE_FILES)
+ $(BUILDSCRIPT) $(BMFLAGS) $(BSFLAGS) $(USECOREPROF) $(DISJOINTDEBUG) $(CHECKPOINTSTO) -o $(PROGRAM)c -builddir chk $(SOURCE_FILES)
protected HeapAnalysis heapAnalysis;
protected ClassDescriptor cdString;
- protected FieldDescriptor argBytes;
+ protected FieldDescriptor strBytes;
public BCXallocsiteObjectField( BuildCode buildCode,
this.buildCode = buildCode;
this.typeUtil = typeUtil;
this.heapAnalysis = heapAnalysis;
- }
-
-
- public void additionalClassObjectFields(PrintWriter outclassdefs) {
- outclassdefs.println(" int allocsite;");
- }
-
-
- public void additionalCodeForCommandLineArgs(PrintWriter outmethod, String argsVar) {
cdString = typeUtil.getClass( typeUtil.StringClass );
assert cdString != null;
- argBytes = null;
+ strBytes = null;
Iterator sFieldsItr = cdString.getFields();
while( sFieldsItr.hasNext() ) {
FieldDescriptor fd = (FieldDescriptor) sFieldsItr.next();
if( fd.getSymbol().equals( typeUtil.StringClassValueField ) ) {
- argBytes = fd;
+ strBytes = fd;
break;
}
}
- assert argBytes != null;
+ assert strBytes != null;
+ }
+
+
+ public void additionalClassObjectFields(PrintWriter outclassdefs) {
+ outclassdefs.println(" int allocsite;");
+ }
+ public void additionalCodeForCommandLineArgs(PrintWriter outmethod, String argsVar) {
+
String argsAccess = "((struct "+cdString.getSafeSymbol()+
" **)(((char *)& "+argsVar+"->___length___)+sizeof(int)))";
";"
);
outmethod.println(" "+argsAccess+"[i]->"+
- argBytes.getSafeSymbol()+
+ strBytes.getSafeSymbol()+
"->allocsite = "+
heapAnalysis.getCmdLineArgBytesAlloc().getUniqueAllocSiteID()+
";"
heapAnalysis.getNewStringLiteralAlloc().getUniqueAllocSiteID()+
";"
);
+
+ output.println(dstVar+"->"+
+ strBytes.getSafeSymbol()+
+ "->allocsite = "+
+ heapAnalysis.getNewStringLiteralBytesAlloc().getUniqueAllocSiteID()+
+ ";"
+ );
}