Class ContinuationGenerators
- java.lang.Object
-
- com.offbynull.coroutines.instrumenter.ContinuationGenerators
-
final class ContinuationGenerators extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.reflect.MethodCONTINUATION_GETMODE_METHODprivate static java.lang.reflect.MethodCONTINUATION_LOADNEXTMETHODSTATE_METHODprivate static java.lang.reflect.MethodCONTINUATION_PUSHNEWMETHODSTATE_METHODprivate static java.lang.reflect.MethodCONTINUATION_SETMODE_METHODprivate static java.lang.reflect.MethodCONTINUATION_UNLOADCURRENTMETHODSTATE_METHODprivate static java.lang.reflect.MethodCONTINUATION_UNLOADMETHODSTATETOBEFORE_METHODprivate static java.lang.reflect.MethodMETHODSTATE_GETCONTINUATIONPOINT_METHODprivate static java.lang.reflect.MethodMETHODSTATE_GETDATA_METHODprivate static java.lang.reflect.MethodMETHODSTATE_GETLOCKSTATE_METHODprivate static java.lang.reflect.Constructor<MethodState>METHODSTATE_INIT_METHOD
-
Constructor Summary
Constructors Modifier Constructor Description privateContinuationGenerators()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.objectweb.asm.tree.InsnListentryPointLoader(MethodAttributes attrs)private static java.lang.StringgetLogPrefix(MethodAttributes attrs)private static org.objectweb.asm.tree.InsnListpopMethodResult(org.objectweb.asm.tree.AbstractInsnNode invokeInsnNode)Generates instructions to pop the result of the method off the stack.static org.objectweb.asm.tree.InsnListrestoreState(MethodAttributes attrs, int idx)private static org.objectweb.asm.tree.InsnListrestoreStateFromInvocationWithinTryCatch(MethodAttributes attrs, int idx)private static org.objectweb.asm.tree.InsnListrestoreStateFromNormalInvocation(MethodAttributes attrs, int idx)private static org.objectweb.asm.tree.InsnListrestoreStateFromSuspend(MethodAttributes attrs, int idx)private static org.objectweb.asm.tree.InsnListreturnDummy(org.objectweb.asm.Type returnType)Generates instructions that returns a dummy value.static org.objectweb.asm.tree.InsnListsaveState(MethodAttributes attrs, int idx)private static org.objectweb.asm.tree.InsnListsaveStateFromInvocationWithinTryCatch(MethodAttributes attrs, int idx)private static org.objectweb.asm.tree.InsnListsaveStateFromNormalInvocation(MethodAttributes attrs, int idx)private static org.objectweb.asm.tree.InsnListsaveStateFromSuspend(MethodAttributes attrs, int idx)
-
-
-
Field Detail
-
CONTINUATION_GETMODE_METHOD
private static final java.lang.reflect.Method CONTINUATION_GETMODE_METHOD
-
CONTINUATION_SETMODE_METHOD
private static final java.lang.reflect.Method CONTINUATION_SETMODE_METHOD
-
CONTINUATION_LOADNEXTMETHODSTATE_METHOD
private static final java.lang.reflect.Method CONTINUATION_LOADNEXTMETHODSTATE_METHOD
-
CONTINUATION_UNLOADCURRENTMETHODSTATE_METHOD
private static final java.lang.reflect.Method CONTINUATION_UNLOADCURRENTMETHODSTATE_METHOD
-
CONTINUATION_UNLOADMETHODSTATETOBEFORE_METHOD
private static final java.lang.reflect.Method CONTINUATION_UNLOADMETHODSTATETOBEFORE_METHOD
-
CONTINUATION_PUSHNEWMETHODSTATE_METHOD
private static final java.lang.reflect.Method CONTINUATION_PUSHNEWMETHODSTATE_METHOD
-
METHODSTATE_INIT_METHOD
private static final java.lang.reflect.Constructor<MethodState> METHODSTATE_INIT_METHOD
-
METHODSTATE_GETCONTINUATIONPOINT_METHOD
private static final java.lang.reflect.Method METHODSTATE_GETCONTINUATIONPOINT_METHOD
-
METHODSTATE_GETDATA_METHOD
private static final java.lang.reflect.Method METHODSTATE_GETDATA_METHOD
-
METHODSTATE_GETLOCKSTATE_METHOD
private static final java.lang.reflect.Method METHODSTATE_GETLOCKSTATE_METHOD
-
-
Method Detail
-
entryPointLoader
public static org.objectweb.asm.tree.InsnList entryPointLoader(MethodAttributes attrs)
-
restoreState
public static org.objectweb.asm.tree.InsnList restoreState(MethodAttributes attrs, int idx)
-
restoreStateFromSuspend
private static org.objectweb.asm.tree.InsnList restoreStateFromSuspend(MethodAttributes attrs, int idx)
-
restoreStateFromNormalInvocation
private static org.objectweb.asm.tree.InsnList restoreStateFromNormalInvocation(MethodAttributes attrs, int idx)
-
restoreStateFromInvocationWithinTryCatch
private static org.objectweb.asm.tree.InsnList restoreStateFromInvocationWithinTryCatch(MethodAttributes attrs, int idx)
-
saveState
public static org.objectweb.asm.tree.InsnList saveState(MethodAttributes attrs, int idx)
-
saveStateFromSuspend
private static org.objectweb.asm.tree.InsnList saveStateFromSuspend(MethodAttributes attrs, int idx)
-
saveStateFromNormalInvocation
private static org.objectweb.asm.tree.InsnList saveStateFromNormalInvocation(MethodAttributes attrs, int idx)
-
saveStateFromInvocationWithinTryCatch
private static org.objectweb.asm.tree.InsnList saveStateFromInvocationWithinTryCatch(MethodAttributes attrs, int idx)
-
returnDummy
private static org.objectweb.asm.tree.InsnList returnDummy(org.objectweb.asm.Type returnType)
Generates instructions that returns a dummy value. Return values are as follows:- void -> no value
- boolean -> false
- byte/short/char/int -> 0
- long -> 0L
- float -> 0.0f
- double -> 0.0
- Object -> null
- Parameters:
returnType- return type of the method this generated bytecode is for- Returns:
- instructions to return a dummy value
- Throws:
java.lang.NullPointerException- if any argument isnulljava.lang.IllegalArgumentException- ifreturnType's sort is ofType.METHOD
-
popMethodResult
private static org.objectweb.asm.tree.InsnList popMethodResult(org.objectweb.asm.tree.AbstractInsnNode invokeInsnNode)
Generates instructions to pop the result of the method off the stack. This will only generate instructions if the method being invoked generates a return value.- Parameters:
invokeInsnNode- instruction for the method that was invoked (can either be of typeMethodInsnNodeorInvokeDynamicInsnNode-- this is used to determine how many items to pop off the stack- Returns:
- instructions for a pop (only if the method being invoked generates a return value)
- Throws:
java.lang.IllegalArgumentException- ifinvokeInsnNodeisn't of typeMethodInsnNodeorInvokeDynamicInsnNodejava.lang.NullPointerException- if any argument isnull
-
getLogPrefix
private static java.lang.String getLogPrefix(MethodAttributes attrs)
-
-