SandMark version 3.0


sandmark.watermark.ct.trace.callforest
Class Decorate

java.lang.Object
  |
  +--sandmark.watermark.ct.trace.callforest.Decorate

public class Decorate
extends java.lang.Object


Field Summary
(package private) static int ADD_PARAM_STEALTHY_WEIGHT
           
(package private) static int ADD_RETURN_STEALTHY_WEIGHT
           
(package private)  java.lang.String annotatorClass
           
(package private)  ClassHierarchy classHierarchy
           
(package private) static int EDGE_CALL_WEIGHT
           
(package private) static int EDGE_WEIGHT
           
(package private)  java.util.Vector forest
           
(package private) static int NODE_CANTMODIFY_WEIGHT
           
(package private) static int NODE_JAVA_WEIGHT
           
(package private) static int NODE_MARK_WEIGHT
           
(package private) static int NODE_STEALTHY_WEIGHT
           
(package private) static int NODE_UNSTEALTHY_WEIGHT
           
(package private)  java.util.Properties props
           
(package private)  Stats statistics
           
(package private)  StorageClass[] storageClasses
           
(package private) static double TREE_ORDER_WEIGHT
           
 
Constructor Summary
Decorate(java.util.Vector forest, ClassHierarchy classHierarchy, Stats stats, java.util.Properties props)
           
 
Method Summary
(package private)  double addStats(java.lang.String[] ops, int numberOfBytecodes, double wm_percent, java.util.Hashtable usage)
          Compute the similarity of a set of bytecodes in a method to the type of code we insert.
(package private)  void decorate()
          Add node and edge weights to the information flow graph.
(package private)  void decorateEdge(Graph graph, Edge edge)
          Construct the weight of this edge.
(package private)  void decorateEdges()
          Add weights to all the edges in all the call graphs.
(package private)  void decorateNode(Graph graph, Node node, long minID, long maxID)
          Construct the weight of this node.
(package private)  void decorateNodes()
          Add weights to all the nodes in all the call graphs.
(package private)  boolean okToAddStorageArgument(MethodID method)
          Return true if it OK to add a storage argument to this method.
(package private)  double stealthyToAddReturnValue(MethodID method)
          Return 1.0 if it would be stealthy to add a return value to this method.
(package private)  double stealthyToAddStorageArgument(MethodID method)
          Return true if it would be stealthy to add a storage argument to this method.
(package private)  double stealtyToHoldWatermark(MethodID method)
          Return a number that is a measure of how stealthy it would be to insert watermarking code in this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classHierarchy

ClassHierarchy classHierarchy

statistics

Stats statistics

props

java.util.Properties props

annotatorClass

java.lang.String annotatorClass

storageClasses

StorageClass[] storageClasses

forest

java.util.Vector forest

EDGE_WEIGHT

static final int EDGE_WEIGHT
See Also:
Constant Field Values

EDGE_CALL_WEIGHT

static final int EDGE_CALL_WEIGHT
See Also:
Constant Field Values

ADD_PARAM_STEALTHY_WEIGHT

static final int ADD_PARAM_STEALTHY_WEIGHT
See Also:
Constant Field Values

ADD_RETURN_STEALTHY_WEIGHT

static final int ADD_RETURN_STEALTHY_WEIGHT
See Also:
Constant Field Values

NODE_MARK_WEIGHT

static final int NODE_MARK_WEIGHT
See Also:
Constant Field Values

NODE_STEALTHY_WEIGHT

static final int NODE_STEALTHY_WEIGHT
See Also:
Constant Field Values

NODE_UNSTEALTHY_WEIGHT

static final int NODE_UNSTEALTHY_WEIGHT
See Also:
Constant Field Values

NODE_JAVA_WEIGHT

static final int NODE_JAVA_WEIGHT
See Also:
Constant Field Values

NODE_CANTMODIFY_WEIGHT

static final int NODE_CANTMODIFY_WEIGHT
See Also:
Constant Field Values

TREE_ORDER_WEIGHT

static final double TREE_ORDER_WEIGHT
See Also:
Constant Field Values
Constructor Detail

Decorate

public Decorate(java.util.Vector forest,
                ClassHierarchy classHierarchy,
                Stats stats,
                java.util.Properties props)
Method Detail

decorate

void decorate()
Add node and edge weights to the information flow graph.


decorateNodes

void decorateNodes()
Add weights to all the nodes in all the call graphs.


decorateNode

void decorateNode(Graph graph,
                  Node node,
                  long minID,
                  long maxID)
Construct the weight of this node. A mark node gets the weight NODE_MARK_WEIGHT. A node that calls a mark node represents a method into which we may embed the watermark. If the watermark code fits in, the node's weight will be NODE_STEALTHY_WEIGHT * P, where 0<=P<=1 is a measure of how stealthy the method is.

Parameters:
graph - the call graph
node - the node

stealtyToHoldWatermark

double stealtyToHoldWatermark(MethodID method)
Return a number that is a measure of how stealthy it would be to insert watermarking code in this method.

Parameters:
method - the method
Returns:
a number between 0.0 and 1.0 where 1.0 is a perfect fit.

The bytecodes we insert have approximately this distribution:

     bytecode     percent
     --------------------
     aload*          29
     putfield        10
     astore*          8
     new              7
     invokespecial    7
     dup              7
     getstatic        6
     invokevirtual    6
     iconst*|ldc      5
     ifnull           3
     pop              2
     return           2
     getfield         2
     checkcast        1
     goto             1
 

addStats

double addStats(java.lang.String[] ops,
                int numberOfBytecodes,
                double wm_percent,
                java.util.Hashtable usage)
Compute the similarity of a set of bytecodes in a method to the type of code we insert.

Parameters:
ops - a set of bytecodes
numberOfBytecodes - total number of bytecodes in this method
wm_percent - frequency of these bytecodes in the code we insert
usage - bytecode counts for this method.
Returns:
the ratio.


okToAddStorageArgument

boolean okToAddStorageArgument(MethodID method)
Return true if it OK to add a storage argument to this method. At this point we don't know exactly which type of storage we are going to use, so we'll try all of them.

Parameters:
method - the method

stealthyToAddStorageArgument

double stealthyToAddStorageArgument(MethodID method)
Return true if it would be stealthy to add a storage argument to this method. The stealthiness of adding an argument depends on In general, adding yet another argument to a method that already has several should be good. Also, since we're adding a reference argument it's probably stealthy if the method already has one or more reference parameters.

Parameters:
method - the method
Returns:
a number between 0.0 and 1.0 describing how stealthy it would be to add another reference formal parameter.

stealthyToAddReturnValue

double stealthyToAddReturnValue(MethodID method)
Return 1.0 if it would be stealthy to add a return value to this method.

Parameters:
method - the method
Returns:
a number between 0.0 and 1.0 describing how stealthy it would be to add a return value.

decorateEdges

void decorateEdges()
Add weights to all the edges in all the call graphs.


decorateEdge

void decorateEdge(Graph graph,
                  Edge edge)
Construct the weight of this edge.

Parameters:
graph - the call graph
edge - the edge

SandMark version 3.0

Wed Jan 29 10:30:05 MST 2003