|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjist.runtime.ClassTraversal.Empty
jist.runtime.RewriterTraversalContinuableMethods
class RewriterTraversalContinuableMethods
Traversal object that modifies continuable methods. Continuable needs to be able to pause and resume their execution at various points: at any blocking entity call, or continuable regular method call. Pausing execution means saving both the frame and the program location into a custom state object. Resuming execution means reversing the process.
Static analysis: - data flow: to determine what the frame (stack and locals) looks like at each blocking or continuable execution point - state class: create custom state class (subclass of Event.ContinuationFrame) with fields for locals and stack slots at each execution point Pausing execution: - save frame (locals and stack) to state object before execution and store in additional local variable - execute method invocation - check if we are in save mode - if yes, then push frame information using Controller and return immediately (with some dummy return value, if necessary) Restoring execution: - (at method start) check if we are invoking this method in restore mode - if yes, pop frame information from Controller - switch on program counter - restore frame (locals and stack) slots - jump to pause point
JistAPI
Field Summary | |
---|---|
private org.apache.bcel.generic.ConstantPoolGen |
cpg
class constant pool. |
private RewriterFlow |
flow
data flow analysis object. |
private RewriterFlow.FlowInfoMap |
flowinfo
data flow analysis result. |
private java.util.Vector |
frames
save/restore frames. |
private org.apache.bcel.generic.InstructionFactory |
ifc
class instruction factory. |
private java.util.Vector |
ihs
save/restore instruction handles. |
private int |
pc
program location counter. |
private Rewriter |
rewriter
primary rewriter. |
Constructor Summary | |
---|---|
RewriterTraversalContinuableMethods(Rewriter rewriter)
Create rewriter object that will transform continuable methods to CPS. |
Method Summary | |
---|---|
private static org.apache.bcel.classfile.JavaClass |
createStateClass(org.apache.bcel.generic.MethodGen mg,
int pc,
org.apache.bcel.verifier.structurals.Frame f)
Generate state class for a specific execution point within a method. |
org.apache.bcel.generic.ClassGen |
doClass(org.apache.bcel.generic.ClassGen cg)
Upcall to process class before field and method processing. |
void |
doInstruction(org.apache.bcel.generic.ClassGen cg,
org.apache.bcel.generic.MethodGen mg,
org.apache.bcel.generic.InstructionHandle ih,
org.apache.bcel.generic.Instruction inst)
Upcall to process instruction. Note that instructions can be inserted and deleted directly using the BCEL API, and therefore this method returns void . |
org.apache.bcel.generic.MethodGen |
doMethod(org.apache.bcel.generic.ClassGen cg,
org.apache.bcel.generic.MethodGen mg)
Upcall to process method before instruction processing. |
org.apache.bcel.generic.MethodGen |
doMethodPost(org.apache.bcel.generic.ClassGen cg,
org.apache.bcel.generic.MethodGen mg)
Upcall to process method after instruction processing. |
private static org.apache.bcel.verifier.structurals.Frame |
fixFrame(org.apache.bcel.verifier.structurals.Frame f)
Return BCEL frame with fewer object types (only relevant ones) in order to simplify frame save/restore code. |
private static org.apache.bcel.generic.Type |
fixType(org.apache.bcel.generic.Type t)
Helper method for fixFrame to process individual types within Frame object. |
static boolean |
isNotInit(org.apache.bcel.generic.Type t)
Returns whether Type is Uninitialized. |
private static void |
restoreFrame(org.apache.bcel.generic.MethodGen mg,
java.util.Vector frames,
java.util.Vector ihs,
org.apache.bcel.generic.InstructionFactory ifc)
Insert instructions to restore an execution frame from a state object. |
private static void |
saveFrame(org.apache.bcel.generic.MethodGen mg,
org.apache.bcel.generic.InstructionHandle ih,
int pc,
org.apache.bcel.verifier.structurals.Frame f,
org.apache.bcel.generic.InstructionFactory ifc)
Insert instructions to save an execution frame to state object. |
Methods inherited from class jist.runtime.ClassTraversal.Empty |
---|
doClassPost, doField |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Rewriter rewriter
private RewriterFlow flow
private RewriterFlow.FlowInfoMap flowinfo
private org.apache.bcel.generic.ConstantPoolGen cpg
private org.apache.bcel.generic.InstructionFactory ifc
private int pc
private java.util.Vector frames
private java.util.Vector ihs
Constructor Detail |
---|
public RewriterTraversalContinuableMethods(Rewriter rewriter)
rewriter
- reference to primary rewriterMethod Detail |
---|
public org.apache.bcel.generic.ClassGen doClass(org.apache.bcel.generic.ClassGen cg)
doClass
in interface ClassTraversal.Visitor
doClass
in class ClassTraversal.Empty
cg
- BCEL class generator object to process
public org.apache.bcel.generic.MethodGen doMethod(org.apache.bcel.generic.ClassGen cg, org.apache.bcel.generic.MethodGen mg)
doMethod
in interface ClassTraversal.Visitor
doMethod
in class ClassTraversal.Empty
cg
- BCEL class generator objectmg
- BCEL method generator object to process
public org.apache.bcel.generic.MethodGen doMethodPost(org.apache.bcel.generic.ClassGen cg, org.apache.bcel.generic.MethodGen mg)
doMethodPost
in interface ClassTraversal.Visitor
doMethodPost
in class ClassTraversal.Empty
cg
- BCEL field generator objectmg
- BCEL method generator object to process
public void doInstruction(org.apache.bcel.generic.ClassGen cg, org.apache.bcel.generic.MethodGen mg, org.apache.bcel.generic.InstructionHandle ih, org.apache.bcel.generic.Instruction inst) throws java.lang.ClassNotFoundException
void
.
doInstruction
in interface ClassTraversal.Visitor
doInstruction
in class ClassTraversal.Empty
cg
- BCEL class generator objectmg
- BCEL method generator objectih
- BCEL instruction handle object to processinst
- BCEL instruction object to process
java.lang.ClassNotFoundException
private static org.apache.bcel.verifier.structurals.Frame fixFrame(org.apache.bcel.verifier.structurals.Frame f)
f
- input frame from data flow
private static org.apache.bcel.generic.Type fixType(org.apache.bcel.generic.Type t)
t
- input type from data flow frame
public static boolean isNotInit(org.apache.bcel.generic.Type t)
t
- BCEL type
private static org.apache.bcel.classfile.JavaClass createStateClass(org.apache.bcel.generic.MethodGen mg, int pc, org.apache.bcel.verifier.structurals.Frame f)
mg
- method whose frame is being savedpc
- program location identifierf
- frame to save
private static void saveFrame(org.apache.bcel.generic.MethodGen mg, org.apache.bcel.generic.InstructionHandle ih, int pc, org.apache.bcel.verifier.structurals.Frame f, org.apache.bcel.generic.InstructionFactory ifc)
mg
- method to be savedih
- instruction handle of save pointpc
- program location identifierf
- stack and local typesifc
- class instruction factoryprivate static void restoreFrame(org.apache.bcel.generic.MethodGen mg, java.util.Vector frames, java.util.Vector ihs, org.apache.bcel.generic.InstructionFactory ifc)
mg
- method to be restored onto stackframes
- frames of restoration pointsihs
- instruction handles of restoration pointsifc
- class instruction factory
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |