Class BaseMachine
- All Implemented Interfaces:
Machine
- Direct Known Subclasses:
ValueAwareMachine
Machine.
Note: For the most part, the documentation for this class
ignores the distinction between Type and TypeBearer.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidaddResult(TypeBearer result) Adds an additional element to the list of results.protected final TypeBearerarg(int n) Gets thenth primary argument.protected final intargCount()Gets the number of primary arguments.protected final intargWidth()Gets the width of the arguments (where a category-2 value counts as two).final voidIndicates that there is an auxiliary (inline, not stack) object argument, with the value based on the given constant.final 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.final voidauxIntArg(int value) Indicates that there is an auxiliary (inline, not stack) argument of typeint, with the given value.final voidauxSwitchArg(SwitchList cases) Indicates that there is an auxiliary (inline, not stack) argument consisting of aswitch*table.final voidauxTargetArg(int target) Indicates that there is an auxiliary (inline, not stack) argument indicating a branch target.final voidIndicates that the salient type of this operation is as given.final voidClears the regular and auxiliary arguments area.protected final voidClears the results.protected final SwitchListGets the switch cases auxiliary argument.protected final ConstantGets the constant auxiliary argument.protected final intGets theintauxiliary argument.protected final intGets the branch target auxiliary argument.protected final TypeGets the type auxiliary argument.Gets the init values auxiliary argument.protected final intGets the last local index accessed.protected final booleanGets whether the loaded local has info in the local variable table.protected final RegisterSpecgetLocalTarget(boolean isMove) Gets the target local register spec of the current operation, if any.Gets the effective prototype of the method that this instance is being used for.final voidLoads the local variable with the given index as the sole argument in the arguments area.final voidlocalInfo(boolean local) Used to specify if a loaded local variable has info in the local variable table.final voidlocalTarget(int idx, Type type, LocalItem local) Indicates that the target of this operation is the given local.final 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.final 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.final 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.final 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.protected final TypeBearerresult(int n) Gets thenth result value.protected final intGets the count of results.protected final intGets the width of the results (where a category-2 value counts as two).protected final voidsetResult(TypeBearer result) Sets the results list to be the given single value.protected final voidstoreResults(Frame frame) Stores the results of the latest operation into the given frame.static voidthrowLocalMismatch(TypeBearer found, TypeBearer local) Throws an exception that indicates a mismatch in local variable types.
-
Constructor Details
-
BaseMachine
Constructs an instance.- Parameters:
prototype-non-null;the prototype for the associated method
-
-
Method Details
-
getPrototype
Gets the effective prototype of the method that this instance is being used for. The effective prototype includes an initialthisargument for instance methods.- Specified by:
getPrototypein interfaceMachine- Returns:
non-null;the method prototype
-
clearArgs
-
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. -
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. -
popArgs
Description copied from interface:MachinePops a value from the stack of the indicated type, and store it in the arguments area, indicating that there are now that many arguments. Also, clear the auxiliary arguments. -
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. -
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. -
localArg
Loads the local variable with the given index as the sole argument in the arguments area. Also, clear the auxiliary arguments. -
localInfo
-
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.) -
auxIntArg
public final 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). -
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. -
auxTargetArg
public final void auxTargetArg(int target) Indicates that there is an auxiliary (inline, not stack) argument indicating a branch target.- Specified by:
auxTargetArgin interfaceMachine- 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
Machine.auxIntArg(int)(which holds the padding).- Specified by:
auxSwitchArgin interfaceMachine- Parameters:
cases-non-null;the list of key-target pairs, plus the default target
-
auxInitValues
Indicates that there is an auxiliary (inline, not stack) argument consisting of a list of initial values for a newly created array.- Specified by:
auxInitValuesin interfaceMachine- Parameters:
initValues-non-null;the list of constant values to initialize the array
-
localTarget
Indicates that the target of this operation is the given local.- Specified by:
localTargetin interfaceMachine- Parameters:
idx->= 0;the local variable indextype-non-null;the type of the locallocal-null-ok;the name and signature of the local, if known
-
argCount
protected final int argCount()Gets the number of primary arguments.- Returns:
>= 0;the number of primary arguments
-
argWidth
protected final int argWidth()Gets the width of the arguments (where a category-2 value counts as two).- Returns:
>= 0;the argument width
-
arg
Gets thenth primary argument.- Parameters:
n->= 0, < argCount();which argument- Returns:
non-null;the indicated argument
-
getAuxType
Gets the type auxiliary argument.- Returns:
null-ok;the salient type
-
getAuxInt
protected final int getAuxInt()Gets theintauxiliary argument.- Returns:
- the argument value
-
getAuxCst
Gets the constant auxiliary argument.- Returns:
null-ok;the argument value
-
getAuxTarget
protected final int getAuxTarget()Gets the branch target auxiliary argument.- Returns:
- the argument value
-
getAuxCases
Gets the switch cases auxiliary argument.- Returns:
null-ok;the argument value
-
getInitValues
-
getLocalIndex
protected final int getLocalIndex()Gets the last local index accessed.- Returns:
>= -1;the salient local index or-1if none was set since the last timeclearArgs()was called
-
getLocalInfo
protected final boolean getLocalInfo()Gets whether the loaded local has info in the local variable table.- Returns:
trueif local arg has info in the local variable table
-
getLocalTarget
Gets the target local register spec of the current operation, if any. The local target spec is the combination of the values indicated by a previous call tolocalTargetwith the type of what should be the sole result set by a call tosetResult(TypeBearer)(or the combinationclearResult()thenaddResult(TypeBearer).- Parameters:
isMove-trueif the operation being performed on the local is a move. This will cause constant values to be propagated to the returned local- Returns:
null-ok;the salient register spec ornullif no local target was set since the last timeclearArgs()was called
-
clearResult
protected final void clearResult()Clears the results. -
setResult
Sets the results list to be the given single value.Note: If there is more than one result value, the others may be added by using
addResult(TypeBearer).- Parameters:
result-non-null;result value
-
addResult
Adds an additional element to the list of results.- Parameters:
result-non-null;result value- See Also:
-
resultCount
protected final int resultCount()Gets the count of results. This throws an exception if results were never set. (Explicitly clearing the results counts as setting them.)- Returns:
>= 0;the count
-
resultWidth
protected final int resultWidth()Gets the width of the results (where a category-2 value counts as two).- Returns:
>= 0;the result width
-
result
Gets thenth result value.- Parameters:
n->= 0, < resultCount();which result- Returns:
non-null;the indicated result value
-
storeResults
Stores the results of the latest operation into the given frame. If there is a local target (seelocalTarget), then the sole result is stored to that target; otherwise any results are pushed onto the stack.- Parameters:
frame-non-null;frame to operate on
-
throwLocalMismatch
Throws an exception that indicates a mismatch in local variable types.- Parameters:
found-non-null;the encountered typelocal-non-null;the local variable's claimed type
-