ptolemy.copernicus.java
Class HSPortInliner

java.lang.Object
  extended by ptolemy.copernicus.java.HSPortInliner
All Implemented Interfaces:
PortInliner

public class HSPortInliner
extends java.lang.Object
implements PortInliner

A class that inlines methods on ports for HS models. This class creates a set of appropriately sized circular buffers for each channel in a particular composite actor. These buffers are referred to by static fields of the model. Inside each actor in the composite, an array of integer indexes into the circular buffer is generated for each port. Port method invocations where the channel index can be statically determined are replaced with references to the appropriate buffer in the model, and an index update instructions for the appropriate index in the actor. In cases where the channel cannot be statically determined for a given invocation point, e.g. a for loop over all of the channels of a trigger input port to read and discard the data, a second reference to each buffer exists in the actors. These references are in a array that can be indexed by the channel of a port, and are called "buffer references". Additionally, index fields and buffer references are also created for each port in the model for handling "inside" port methods... FIXME: currently we try to speed things up if the buffersize is only one by removing the index update overhead. Note that there are other optimizations that can be made here (for instance, if we can statically determine all the channel references (which is trivially true if there is only one channel), then there is no need to have the index or portbuffer arrays.

Since:
Ptolemy II 2.0
Version:
$Id: HSPortInliner.java,v 1.36 2006/09/21 15:39:48 cxh Exp $
Author:
Stephen Neuendorffer
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Constructor Summary
HSPortInliner(soot.SootClass modelClass, CompositeActor model, java.util.Map options)
          Construct a new transformer
 
Method Summary
 void initialize()
          Initialize the inliner.
 void inlineBroadcast(soot.jimple.JimpleBody body, soot.jimple.Stmt stmt, soot.jimple.InvokeExpr expr, TypedIOPort port)
          Replace the broadcast invocation in the given box at the given unit in the given body with a circular array reference.
 void inlineGet(soot.jimple.JimpleBody body, soot.jimple.Stmt stmt, soot.ValueBox box, soot.jimple.InvokeExpr expr, TypedIOPort port)
          Replace the get invocation in the given box at the given unit in the given body with a circular array reference.
 void inlineGetInside(soot.jimple.JimpleBody body, soot.jimple.Stmt stmt, soot.ValueBox box, soot.jimple.InvokeExpr expr, TypedIOPort port)
          Replace the getInside invocation in the given box at the given unit in the given body with a circular array reference.
 void inlineSend(soot.jimple.JimpleBody body, soot.jimple.Stmt stmt, soot.jimple.InvokeExpr expr, TypedIOPort port)
          Replace the send command at the given unit in the given body with a circular array reference.
 void inlineSendInside(soot.jimple.JimpleBody body, soot.jimple.Stmt stmt, soot.jimple.InvokeExpr expr, TypedIOPort port)
          Replace the send command at the given unit in the given body with a circular array reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HSPortInliner

public HSPortInliner(soot.SootClass modelClass,
                     CompositeActor model,
                     java.util.Map options)
Construct a new transformer

Method Detail

initialize

public void initialize()
Initialize the inliner. Create one place buffers for each relation.

Specified by:
initialize in interface PortInliner

inlineBroadcast

public void inlineBroadcast(soot.jimple.JimpleBody body,
                            soot.jimple.Stmt stmt,
                            soot.jimple.InvokeExpr expr,
                            TypedIOPort port)
Replace the broadcast invocation in the given box at the given unit in the given body with a circular array reference.

Specified by:
inlineBroadcast in interface PortInliner

inlineGet

public void inlineGet(soot.jimple.JimpleBody body,
                      soot.jimple.Stmt stmt,
                      soot.ValueBox box,
                      soot.jimple.InvokeExpr expr,
                      TypedIOPort port)
Replace the get invocation in the given box at the given unit in the given body with a circular array reference.

Specified by:
inlineGet in interface PortInliner

inlineGetInside

public void inlineGetInside(soot.jimple.JimpleBody body,
                            soot.jimple.Stmt stmt,
                            soot.ValueBox box,
                            soot.jimple.InvokeExpr expr,
                            TypedIOPort port)
Replace the getInside invocation in the given box at the given unit in the given body with a circular array reference.

Specified by:
inlineGetInside in interface PortInliner

inlineSend

public void inlineSend(soot.jimple.JimpleBody body,
                       soot.jimple.Stmt stmt,
                       soot.jimple.InvokeExpr expr,
                       TypedIOPort port)
Replace the send command at the given unit in the given body with a circular array reference.

Specified by:
inlineSend in interface PortInliner

inlineSendInside

public void inlineSendInside(soot.jimple.JimpleBody body,
                             soot.jimple.Stmt stmt,
                             soot.jimple.InvokeExpr expr,
                             TypedIOPort port)
Replace the send command at the given unit in the given body with a circular array reference.

Specified by:
inlineSendInside in interface PortInliner