SandMark version 3.0


sandmark.util.controlflowgraph
Class ControlFlowSynthesizer

java.lang.Object
  |
  +--sandmark.util.controlflowgraph.ControlFlowSynthesizer
Direct Known Subclasses:
IntFuncSynthesizer, VoidMethodSynthesizer

public abstract class ControlFlowSynthesizer
extends java.lang.Object

Family of classes that generate code to match a control flow graph. The parent class also contains utility functions and a random number stream for use by subclasses.


Field Summary
protected  java.util.Random rng
           
 
Constructor Summary
protected ControlFlowSynthesizer()
          Constructs a new ControlFlowSynthesizer with its own private random number stream initialized from the Math.random stream.
 
Method Summary
abstract  MethodCFG generate(Graph g, de.fub.bytecode.generic.ConstantPoolGen cpg)
          Generates a method that corresponds to the given graph.
(package private)  de.fub.bytecode.generic.InstructionHandle[] makeNOPs(de.fub.bytecode.generic.InstructionList inslist, Graph graph, Dfs dfs)
          Traverses a graph and creates a NOP instruction for each node, returning an array of handles indexed by node numbers.
protected  int randomIn(int m, int n)
          Returns a random r such that m <= r <= n.
 void setSeed(long seed)
          Sets the random number seed to force reproducible behavior.
(package private)  void test(java.lang.String[] args)
          Tests this synthesizer using a radix-encoded watermark.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rng

protected java.util.Random rng
Constructor Detail

ControlFlowSynthesizer

protected ControlFlowSynthesizer()
Constructs a new ControlFlowSynthesizer with its own private random number stream initialized from the Math.random stream.

Method Detail

setSeed

public void setSeed(long seed)
Sets the random number seed to force reproducible behavior.


randomIn

protected int randomIn(int m,
                       int n)
Returns a random r such that m <= r <= n.


generate

public abstract MethodCFG generate(Graph g,
                                   de.fub.bytecode.generic.ConstantPoolGen cpg)
Generates a method that corresponds to the given graph. Some concrete implementations may require specific graph forms and throw java.lang.IllegalArgumentException for an unacceptable graph.

The abstract


makeNOPs

de.fub.bytecode.generic.InstructionHandle[] makeNOPs(de.fub.bytecode.generic.InstructionList inslist,
                                                     Graph graph,
                                                     Dfs dfs)
Traverses a graph and creates a NOP instruction for each node, returning an array of handles indexed by node numbers. Because these are 1-based, there is an extra handle[0] left null.


test

void test(java.lang.String[] args)
    throws java.lang.Exception
Tests this synthesizer using a radix-encoded watermark. Called from static main methods in concrete subclasses.

Usage: java classname [-r] [watermark [classname]]
-r specifies randomized (irreproducible) behavior
watermark is the string to encode; the default is "31416"
classname, if present, causes generation of a .class file

java.lang.Exception

SandMark version 3.0

Wed Jan 29 10:30:05 MST 2003