|
SandMark version 3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sandmark.watermark.ct.trace.Preprocessor
Field Summary | |
static int |
ADDEDCODESIZE
The amount of code we're adding to each method. |
(package private) ClassFileCollection |
cfc
|
static java.lang.String |
FRAMECOUNTER
Name of static variable in sandmark.watermark.ct.trace.Annotator that holds the current stack ID count. |
(package private) java.util.Properties |
props
|
static java.lang.String |
STACKID
Name of the local variable stored in each method to record the unique ID of that call frame. |
Constructor Summary | |
Preprocessor(java.util.Properties props)
|
Method Summary | |
void |
preprocess()
Go through every method in every class of the program and add the code long sm$stackID = sandmark.watermark.ct.trace.Annotator.stackFrameNumber++; to the very beginning of the method. |
(package private) void |
preprocessClass(EditedClass ec)
Make the modifications to every method of the class. |
(package private) void |
preprocessMethod(EditedClass ec,
de.fub.bytecode.generic.MethodGen mg)
Create a local variable to hold the stack ID. |
void |
save()
Save the edited classfiles under a new name. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
ClassFileCollection cfc
java.util.Properties props
public static final java.lang.String STACKID
public static final java.lang.String FRAMECOUNTER
public static final int ADDEDCODESIZE
GETSTATIC X 3 DUP2 1 LCONST_1 1 LADD 1 GETSTATIC X 3 LSTORE_1 X (or LSTORE) 1 (or 2) (NOP) 0 (or 1)
Constructor Detail |
public Preprocessor(java.util.Properties props) throws java.io.IOException
Method Detail |
public void preprocess() throws java.io.IOException
long sm$stackID = sandmark.watermark.ct.trace.Annotator.stackFrameNumber++;to the very beginning of the method. This will give every stackframe a unique ID.
java.io.IOException
public void save() throws java.io.IOException
java.io.IOException
void preprocessClass(EditedClass ec)
ec
- the class to be editedvoid preprocessMethod(EditedClass ec, de.fub.bytecode.generic.MethodGen mg)
ec
- the class to be editedmg
- the method to be edited
Example:
void P() { ... }The resulting method would look something like this:
void P() { long sm$stackID = sandmark.watermark.ct.trace.Annotator.stackFrameNumber++; ... }Or, in bytecode:
GETSTATIC sandmark.watermark.ct.trace.Annotator.stackFrameNumber DUP2 LCONST_1 LADD GETSTATIC sandmark.watermark.ct.trace.Annotator.stackFrameNumber LSTORE sm$stackID-indexOne complication:
LSTOREcould either be
LSTORE_1or
LSTORE 5In the former case the instruction is 1 byte, in the latter, 2. We want all code sequences we insert to be the same length, so that when mark() is called in the preprocessed bytecode, we can figure out what its "real" offset is (the offset in the unprocessed code). Therefore we add an extra NOP in the case of LSTORE_1.
|
SandMark version 3.0 Wed Jan 29 10:30:05 MST 2003 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |