int depth) {
StringBuilder currCase = possibleContinuingCase;
if(qualifiesForCaseStatement(node)) {
- if( !prefix.equals("ptr") ) {
- System.out.println("Adding checker, decided "+node+" qualifies for case statement but expected ptr instead of prefix="+prefix);
- }
assert prefix.equals("ptr");
assert !cases.containsKey(node.allocSite);
currCase = new StringBuilder();
//either currCase is continuing off a parent case or is its own.
assert currCase !=null;
+ insertEntriesIntoHashStructure(taint, node, prefix, depth, currCase);
+
+ //Handle conflicts further down.
+ if(node.decendantsConflict()) {
+ int pdepth=depth+1;
+ currCase.append("{\n");
+
+ //Array Case
+ if(node.isArray() && node.decendantsConflict()) {
+ String childPtr = "((struct ___Object___ **)(((char *) &(((struct ArrayObject *)"+ prefix+")->___length___))+sizeof(int)))[i]";
+ String currPtr = "arrayElement" + pdepth;
+
+ currCase.append("{\n int i;\n");
+ currCase.append(" struct ___Object___ * "+currPtr+";\n");
+ currCase.append(" for(i = 0; i<((struct ArrayObject *) " + prefix + " )->___length___; i++ ) {\n");
+
+ //There should be only one field, hence we only take the first field in the keyset.
+ assert node.objectRefs.keySet().size() <= 1;
+ ObjRefList refsAtParticularField = node.objectRefs.get(node.objectRefs.keySet().iterator().next());
+ printObjRefSwitchStatement(taint,cases,pdepth,currCase,refsAtParticularField,childPtr,currPtr);
+ currCase.append(" }}\n");
+ } else {
+ //All other cases
+ String currPtr = "myPtr" + pdepth;
+ currCase.append(" struct ___Object___ * "+currPtr+";\n");
+ for(String field: node.objectRefs.keySet()) {
+ ObjRefList refsAtParticularField = node.objectRefs.get(field);
+
+ if(refsAtParticularField.hasConflicts()) {
+ String childPtr = "((struct "+node.original.getType().getSafeSymbol()+" *)"+prefix +")->___" + field + "___";
+ printObjRefSwitchStatement(taint,cases, pdepth, currCase, refsAtParticularField, childPtr, currPtr);
+ }
+ }
+ }
+
+ currCase.append("}\n"); //For particular top level case statement.
+ }
+ if(qualifiesForCaseStatement(node)) {
+ currCase.append(" }\n break;\n");
+ }
+ }
+
+ private void insertEntriesIntoHashStructure(Taint taint, ConcreteRuntimeObjNode curr,
+ String prefix, int depth, StringBuilder currCase) {
boolean primConfRead=false;
boolean primConfWrite=false;
boolean objConfRead=false;
boolean objConfWrite=false;
//Direct Primitives Test
- for(String field: node.primitiveConflictingFields.keySet()) {
- CombinedObjEffects effect=node.primitiveConflictingFields.get(field);
+ for(String field: curr.primitiveConflictingFields.keySet()) {
+ CombinedObjEffects effect=curr.primitiveConflictingFields.get(field);
primConfRead|=effect.hasReadConflict;
primConfWrite|=effect.hasWriteConflict;
}
//Direct Object Reference Test
- for(String field: node.objectRefs.keySet()) {
- for(ObjRef ref: node.objectRefs.get(field)) {
+ for(String field: curr.objectRefs.keySet()) {
+ for(ObjRef ref: curr.objectRefs.get(field)) {
CombinedObjEffects effect=ref.myEffects;
objConfRead|=effect.hasReadConflict;
objConfWrite|=effect.hasWriteConflict;
if(primConfWrite||objConfWrite) {
int heaprootNum = connectedHRHash.get(taint).id;
assert heaprootNum != -1;
- int allocSiteID = connectedHRHash.get(taint).getWaitingQueueBucketNum(node);
+ int allocSiteID = connectedHRHash.get(taint).getWaitingQueueBucketNum(curr);
int traverserID = doneTaints.get(taint);
currCase.append(" int tmpkey"+depth+"=rcr_generateKey("+prefix+");\n");
if (objConfRead)
} else if (primConfRead||objConfRead) {
int heaprootNum = connectedHRHash.get(taint).id;
assert heaprootNum != -1;
- int allocSiteID = connectedHRHash.get(taint).getWaitingQueueBucketNum(node);
+ int allocSiteID = connectedHRHash.get(taint).getWaitingQueueBucketNum(curr);
int traverserID = doneTaints.get(taint);
currCase.append(" int tmpkey"+depth+"=rcr_generateKey("+prefix+");\n");
if (objConfRead)
if(primConfWrite||objConfWrite||primConfRead||objConfRead) {
currCase.append("if (!(tmpvar"+depth+"&READYMASK)) totalcount--;\n");
}
-
- //Handle conflicts further down.
- if(node.decendantsConflict()) {
- int pdepth=depth+1;
- currCase.append("{\n");
-
- //Array Case
- if(node.isArray() && node.decendantsConflict()) {
- String childPtr = "((struct ___Object___ **)(((char *) &(((struct ArrayObject *)"+ prefix+")->___length___))+sizeof(int)))[i]";
- String currPtr = "arrayElement" + pdepth;
-
- currCase.append("{\n int i;\n");
- currCase.append(" struct ___Object___ * "+currPtr+";\n");
- currCase.append(" for(i = 0; i<((struct ArrayObject *) " + prefix + " )->___length___; i++ ) {\n");
-
- //There should be only one field, hence we only take the first field in the keyset.
- assert node.objectRefs.keySet().size() <= 1;
- ObjRefList refsAtParticularField = node.objectRefs.get(node.objectRefs.keySet().iterator().next());
- printObjRefSwitchStatement(taint,cases,pdepth,currCase,refsAtParticularField,childPtr,currPtr);
- currCase.append(" }}\n");
- } else {
- //All other cases
- String currPtr = "myPtr" + pdepth;
- currCase.append(" struct ___Object___ * "+currPtr+";\n");
- for(String field: node.objectRefs.keySet()) {
- ObjRefList refsAtParticularField = node.objectRefs.get(field);
-
- if(refsAtParticularField.hasConflicts()) {
- String childPtr = "((struct "+node.original.getType().getSafeSymbol()+" *)"+prefix +")->___" + field + "___";
- printObjRefSwitchStatement(taint, cases, depth, currCase, refsAtParticularField, childPtr, currPtr);
- }
- }
- }
-
- currCase.append("}\n"); //For particular top level case statement.
- }
- if(qualifiesForCaseStatement(node)) {
- currCase.append(" }\n break;\n");
- }
}
private void printObjRefSwitchStatement(Taint taint, Hashtable<AllocSite, StringBuilder> cases,
//The hash insert is here because we don't want to enqueue things unless we know it conflicts.
currCase.append(" if (" + queryVistedHashtable +"("+ currPtr + ")) {\n");
- //Either it's an in-lineable case or we're just handling primitive conflicts
- if ((ref.child.getNumOfReachableParents() == 1 && !ref.child.isInsetVar) ||
- (ref.child.hasPrimitiveConflicts() && !qualifiesForCaseStatement(ref.child)))
- {
+ if(qualifiesForCaseStatement(ref.child)){
+ currCase.append(" " + addToQueueInC + childPtr + ");\n ");
+ } else {
addChecker(taint, ref.child, cases, currCase, currPtr, pDepth + 1);
}
- else {
- //if we are going to insert something into the queue,
- //we should be able to resume traverser from it.
- assert qualifiesForCaseStatement(ref.child);
- currCase.append(" " + addToQueueInC + childPtr + ");\n ");
- }
+
currCase.append(" }\n"); //close for queryVistedHashtable
currCase.append("}\n"); //close for internal case statement