Interface Machine
- All Known Implementing Classes:
BaseMachine, ValueAwareMachine
public interface Machine
Interface for machines capable of executing bytecode by acting
upon a
Frame. A machine conceptually contains four arbitrary-value
argument slots, slots for several literal-value arguments, and slots for
branch target information.-
Method Summary
Modifier and TypeMethodDescriptionvoidIndicates that there is an auxiliary (inline, not stack) object argument, with the value based on the given constant.voidauxInitValues(ArrayList<Constant> initValues) Indicates that there is an auxiliary (inline, not stack) argument consisting of a list of initial values for a newly created array.voidauxIntArg(int value) Indicates that there is an auxiliary (inline, not stack) argument of typeint, with the given value.voidauxSwitchArg(SwitchList cases) Indicates that there is an auxiliary (inline, not stack) argument consisting of aswitch*table.voidauxTargetArg(int target) Indicates that there is an auxiliary (inline, not stack) argument indicating a branch target.voidIndicates that the salient type of this operation is as given.voidClears the regular and auxiliary arguments area.Gets the effective prototype of the method that this instance is being used for.voidLoads the local variable with the given index as the sole argument in the arguments area.voidlocalInfo(boolean local) Used to specify if a loaded local variable has info in the local variable table.voidlocalTarget(int idx, Type type, LocalItem local) Indicates that the target of this operation is the given local.voidPops the given number of values from the stack (of either category), and store them in the arguments area, indicating that there are now that many arguments.voidPops values from the stack of the types indicated by the givenPrototype(popped in reverse of the argument order, so the first prototype argument type is for the deepest element of the stack), and store them in the arguments area, indicating that there are now that many arguments.voidPops a value from the stack of the indicated type, and store it in the arguments area, indicating that there are now that many arguments.voidPops values from the stack of the indicated types (popped in reverse argument order, so the first indicated type is for the deepest element of the stack), and store them in the arguments area, indicating that there are now that many arguments.voidPops values from the stack of the indicated types (popped in reverse argument order, so the first indicated type is for the deepest element of the stack), and store them in the arguments area, indicating that there are now that many arguments.void"Runs" the indicated opcode in an appropriate way, using the arguments area as appropriate, and modifying the given frame in response.
-
Method Details
-
getPrototype
Prototype getPrototype()Gets the effective prototype of the method that this instance is being used for. The effective prototype includes an initialthisargument for instance methods.- Returns:
non-null;the method prototype
-
clearArgs
void clearArgs()Clears the regular and auxiliary arguments area. -
popArgs
Pops the given number of values from the stack (of either category), and store them in the arguments area, indicating that there are now that many arguments. Also, clear the auxiliary arguments.- Parameters:
frame-non-null;frame to operate oncount->= 0;number of values to pop
-
popArgs
Pops values from the stack of the types indicated by the givenPrototype(popped in reverse of the argument order, so the first prototype argument type is for the deepest element of the stack), and store them in the arguments area, indicating that there are now that many arguments. Also, clear the auxiliary arguments.- Parameters:
frame-non-null;frame to operate onprototype-non-null;prototype indicating arguments to pop
-
popArgs
-
popArgs
Pops values from the stack of the indicated types (popped in reverse argument order, so the first indicated type is for the deepest element of the stack), and store them in the arguments area, indicating that there are now that many arguments. Also, clear the auxiliary arguments.- Parameters:
frame-non-null;frame to operate ontype1-non-null;type of the first argumenttype2-non-null;type of the second argument
-
popArgs
Pops values from the stack of the indicated types (popped in reverse argument order, so the first indicated type is for the deepest element of the stack), and store them in the arguments area, indicating that there are now that many arguments. Also, clear the auxiliary arguments.- Parameters:
frame-non-null;frame to operate ontype1-non-null;type of the first argumenttype2-non-null;type of the second argumenttype3-non-null;type of the third argument
-
localArg
Loads the local variable with the given index as the sole argument in the arguments area. Also, clear the auxiliary arguments.- Parameters:
frame-non-null;frame to operate onidx->= 0;the local variable index
-
localInfo
void localInfo(boolean local) Used to specify if a loaded local variable has info in the local variable table.- Parameters:
local-trueif local arg has info in local variable table
-
auxType
Indicates that the salient type of this operation is as given. This differentiates between, for example, the various arithmetic opcodes, which, by the time they hit aMachineare collapsed to theintvariant. (SeeBytecodeArray.parseInstruction(int, BytecodeArray.Visitor)for details.)- Parameters:
type-non-null;the salient type of the upcoming operation
-
auxIntArg
void auxIntArg(int value) Indicates that there is an auxiliary (inline, not stack) argument of typeint, with the given value.Note: Perhaps unintuitively, the stack manipulation ops (e.g.,
dupandswap) use this to indicate the result stack pattern with a straightforward hex encoding of the push order starting with least-significant nibbles getting pushed first). For example, an all-category-1dup2_x1sets this to0x12312, and the other form of that op sets this to0x121.Also Note: For
switch*instructions, this is used to indicate the padding value (which is only useful for verification).- Parameters:
value- the argument value
-
auxCstArg
Indicates that there is an auxiliary (inline, not stack) object argument, with the value based on the given constant.Note: Some opcodes use both
intand constant auxiliary arguments.- Parameters:
cst-non-null;the constant containing / referencing the value
-
auxTargetArg
void auxTargetArg(int target) Indicates that there is an auxiliary (inline, not stack) argument indicating a branch target.- Parameters:
target- the argument value
-
auxSwitchArg
Indicates that there is an auxiliary (inline, not stack) argument consisting of aswitch*table.Note: This is generally used in conjunction with
auxIntArg(int)(which holds the padding).- Parameters:
cases-non-null;the list of key-target pairs, plus the default target
-
auxInitValues
-
localTarget
-
run
"Runs" the indicated opcode in an appropriate way, using the arguments area as appropriate, and modifying the given frame in response.- Parameters:
frame-non-null;frame to operate onoffset->= 0;byte offset in the method to the opcode being runopcode->= 0;the opcode to run
-