Changes between Version 2 and Version 3 of HeapCanonicalization


Ignore:
Timestamp:
08/05/14 14:43:28 (12 years ago)
Author:
zmanchun
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HeapCanonicalization

    v2 v3  
    2323  - Otherwise, initialize each leaf-node element of the heap object with the symbolic NULL expression (not Java NULL).
    2424
    25 * Naming rule: `"Hp" + pid + "s" + dyscopeId + "i" + mallocId + "l" + calledId`
     25* Naming rule: `"Ho" + "p" + pid + "s" + dyscopeId + "i" + mallocId + "l" + calledId`
    2626
    2727* Deallocation: a heap object is removed from the heap when a `$free` is called with the corresponding pointer. (Semantics of `$free` follows C11 standards)
     
    3232
    3333{{{
    34 Map<HeapObject, Integer> reachableHeapObjectsOfState(state){
    35   Map<HeapObject, Integer> idMap;
     34Set<HeapObject> reachableHeapObjectsOfState(state){
     35  Set <HeapObject> reachable;
    3636
    3737  for(dyscope: state.dyscopes()){
    3838    for(varValue: dyscope.varValues()){
    39       reachableHeapObjectsOfValue(varValue, idMap);
     39      reachableHeapObjectsOfValue(varValue, reachable);
    4040    }
    4141  }
     
    4444
    4545//dfs
    46 void reachableHeapObjectsOfValue(varValue, idMap){
     46void reachableHeapObjectsOfValue(varValue, reachable){
    4747  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);
    5151  }else if(varValue IS heap pointer){
    5252    object = dereference(varValue);
    5353   
    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);
    5956  }else{//other pointer
    60     reachableHeapObjects(dereference(varValue), idMap){
     57    reachableHeapObjects(dereference(varValue), reachable){
    6158  }
    6259}
    6360}}}
    6461
    65 TBC
     62==== Heap Canonicalization ====
     63
     64{{{
     65State 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