Changes between Version 2 and Version 3 of HeapCanonicalization
- Timestamp:
- 08/05/14 14:43:28 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
HeapCanonicalization
v2 v3 23 23 - Otherwise, initialize each leaf-node element of the heap object with the symbolic NULL expression (not Java NULL). 24 24 25 * Naming rule: `"H p" + pid + "s" + dyscopeId + "i" + mallocId + "l" + calledId`25 * Naming rule: `"Ho" + "p" + pid + "s" + dyscopeId + "i" + mallocId + "l" + calledId` 26 26 27 27 * Deallocation: a heap object is removed from the heap when a `$free` is called with the corresponding pointer. (Semantics of `$free` follows C11 standards) … … 32 32 33 33 {{{ 34 Map<HeapObject, Integer> reachableHeapObjectsOfState(state){35 Map<HeapObject, Integer> idMap;34 Set<HeapObject> reachableHeapObjectsOfState(state){ 35 Set <HeapObject> reachable; 36 36 37 37 for(dyscope: state.dyscopes()){ 38 38 for(varValue: dyscope.varValues()){ 39 reachableHeapObjectsOfValue(varValue, idMap);39 reachableHeapObjectsOfValue(varValue, reachable); 40 40 } 41 41 } … … 44 44 45 45 //dfs 46 void reachableHeapObjectsOfValue(varValue, idMap){46 void reachableHeapObjectsOfValue(varValue, reachable){ 47 47 if(varValue NOT pointer){ 48 for(element: varValue.elements()){49 reachableHeapObjects(varValue, idMap);50 }48 if() 49 for(element: varValue.elements()) 50 reachableHeapObjects(varValue, reachable); 51 51 }else if(varValue IS heap pointer){ 52 52 object = dereference(varValue); 53 53 54 if(! dMap.containsKey(object)) 55 if(object is SymbolicConstant) 56 idMap.put(object, idMap.size()); 57 else 58 idMap.put(object, -1); 54 if(!reachable.contains(object)) 55 reachable.add(object); 59 56 }else{//other pointer 60 reachableHeapObjects(dereference(varValue), idMap){57 reachableHeapObjects(dereference(varValue), reachable){ 61 58 } 62 59 } 63 60 }}} 64 61 65 TBC 62 ==== Heap Canonicalization ==== 63 64 {{{ 65 State collectHeaps(state, reachable){ 66 int id = 0; 67 Map<Object, Object> oldToNew; 68 69 for(dyscope: state.dyscopes()){ 70 heap = dyscope.heap(); 71 for(object: heap.objects()){ 72 if(reachable.contains(object)) 73 oldToNewNames.put(object, object.rename("Ho"+id)); 74 id++; 75 }else{ 76 heap.remove(object); 77 newHeapObjectPointers(heap, oldToNew); 78 } 79 } 80 return state.substitute(oldToNew); 81 } 82 }}} 83
