CodeStackTracker is a CodeTransform tracking stack content
and calculating max stack size.
Sample use:
var stackTracker = CodeStackTracker.of(); codeBuilder.transforming(stackTracker, trackedBuilder -> { trackedBuilder.aload(0); trackedBuilder.lconst_0(); trackedBuilder.ifThen(...); ... var stack = stackTracker.stack().get(); int maxStack = stackTracker.maxStackSize().get(); });
| Modifier and Type | Method and Description |
|---|---|
| public Optional | Returns: tracked max stack size, or an empty Optional if tracking has been lostReturns tracked max stack size. |
| public static CodeStackTracker | Returns: new instance ofCodeStackTrackerinitial stack content initialStack)Creates new instance of |
| public Optional | Returns: actual stack content, or an empty Optional if unknownReturns Collection of TypeKind representing current stack. |
| maxStackSize | back to summary |
|---|---|
| public Optional Returns tracked max stack size. Returns an empty Optional when max stack size tracking has been lost. Max stack size tracking is permanently lost when a stack instruction appears and the actual stack content is unknown. | |
| of | back to summary |
|---|---|
| public static CodeStackTracker of(TypeKind... initialStack) Creates new instance of
| |
| stack | back to summary |
|---|---|
| public Optional Returns Collection of TypeKind representing current stack.
Returns an empty Optional when the Stack content is unknown
(right after Temporary unknown stack content can be recovered by binding of a Label used as target of a branch instruction from existing code with known stack (forward branch target), or by binding of a Label defining an exception handler (exception handler code start).
| |