public final class RegisterOperand extends Operand
TODO: This class is due for a refactor into subclasses to split out the symbolic & physical registers and to create special behavior for symbolic registers used as phi operands and as validation (guard) operands.
Operand
Modifier and Type | Field and Description |
---|---|
private static byte |
BOUNDS_CHECK
Guard operand that originates from a bounds-check
|
private boolean |
convertedFromRef
Converted from a reference?
|
private static int |
DECLARED_TYPE
The type has been declared as obtained from a getfield,
getstatic, putfield, putstatic, array load
|
private static byte |
EXTANT
is this an extant object?
|
private byte |
flags
Type of a RegisterOperand can be in one of three states:
a- declared: the type obtained from a
getfield,getstatic,putfield,putstatic,array load
b- precise: obtained from a NEW.
|
private byte |
flags2
Some bits used to characterize guards.
|
private Operand |
guard
The guard associated with a RegisterOperand.
|
private RegisterOperand |
nextInDefUseList
Used to maintain def and use lists.
|
private static byte |
NON_VOLATILE
is this a non-volatile physical register?
|
private static byte |
NOT_TAKEN
guard operand that represents a not taken branch
|
private static byte |
NULL_CHECK
Guard operand that originates from a null-check
|
private static byte |
PARAMETER
the register operand is for a parameter
|
private static int |
POSITIVE
Is the contents of the int-like register always positive?
|
private static int |
PRECISE_TYPE
We know precisely the type as it was create by a NEW
|
private Register |
register
Register object that this operand uses.
|
private static byte |
TAKEN
guard operand that represents a taken branch
|
private TypeReference |
type
Inferred data type of the contents of the register.
|
instruction
Constructor and Description |
---|
RegisterOperand(Register reg,
TypeReference typ)
Constructs a new register operand with the given register and data type.
|
RegisterOperand(Register reg,
TypeReference typ,
byte inFlags,
boolean isPrecise,
boolean isDeclared)
Constructs a new register operand with the given register, data type and flags.
|
Modifier and Type | Method and Description |
---|---|
void |
addFlags(byte inFlag)
Merges two sets of register flags.
|
void |
clearBoundsCheck() |
void |
clearDeclaredType() |
void |
clearExtant() |
void |
clearFlags() |
void |
clearNonVolatile() |
void |
clearNotTaken()
Clear this from being a guard operand from a not taken branch
|
void |
clearNullCheck() |
void |
clearParameter() |
void |
clearPreciseType() |
void |
clearTaken()
Clear this from being a guard operand from a taken branch
|
boolean |
convertedFromRef() |
Operand |
copy()
Returns a copy of this register operand as an operand
|
RegisterOperand |
copyD2D() |
RegisterOperand |
copyD2U() |
RegisterOperand |
copyRO()
Returns a copy of this register operand as a register operand.
|
void |
copyTypeFrom(RegisterOperand rhs)
Copy type information from the given operand into this one
including flag information on whether this is a precise type or
not
|
RegisterOperand |
copyU2D() |
RegisterOperand |
copyU2U() |
void |
flagAsConvertedFromRef() |
byte |
getFlags() |
Operand |
getGuard() |
RegisterOperand |
getNext() |
Register |
getRegister() |
TypeReference |
getType()
Return the
TypeReference of the value represented by the operand. |
boolean |
hasLessConservativeFlags(RegisterOperand other) |
boolean |
isAddress()
Does the operand represent a value of the address data type?
|
boolean |
isBoundsCheck() |
boolean |
isDeclaredOrPreciseType() |
boolean |
isDeclaredType() |
boolean |
isDefinitelyNull()
Does the operand definitely represent
null ? |
boolean |
isDouble()
Does the operand represent a value of the double data type?
|
boolean |
isExtant()
Is this register known to contain either NULL or an object whose class was fully loaded
before the current method was called?
|
boolean |
isFloat()
Does the operand represent a value of the float data type?
|
boolean |
isInt()
Does the operand represent a value of the int data type?
|
boolean |
isIntLike()
Does the operand represent a value of an int-like data type?
|
boolean |
isLong()
Does the operand represent a value of the long data type?
|
boolean |
isNonVolatile() |
boolean |
isNotTaken() |
boolean |
isNullCheck() |
boolean |
isParameter() |
boolean |
isPositiveInt() |
boolean |
isPreciseType() |
boolean |
isRef()
Does the operand represent a value of the reference data type?
|
boolean |
isTaken() |
void |
meetInheritableFlags(RegisterOperand other)
Currently all flags are "meetable", so mask flags together.
|
void |
refine(TypeReference t)
Refine the type of the register to t if t is a more precise type than the
register currently holds
|
boolean |
sameRegisterPropertiesAs(RegisterOperand other)
Note: This method is currently used only by test cases.
|
boolean |
sameRegisterPropertiesAsExceptForGuardWhichIsSimilar(RegisterOperand other)
Note: This method is currently used only by test cases.
|
void |
setBoundsCheck() |
void |
setDeclaredType() |
void |
setExtant()
Sets this register as holding an extant object (or NULL)
(ie, an object whose class was fully loaded before the current method was called).
|
void |
setGuard(Operand guard) |
void |
setInheritableFlags(RegisterOperand src)
Currently all flags are inheritable, so copy all flags from src.
|
void |
setNext(RegisterOperand next)
Sets the next register operand in the def/use list.
|
void |
setNonVolatile() |
void |
setNotTaken()
Set this a guard operand from a not taken branch
|
void |
setNullCheck() |
void |
setParameter() |
void |
setPositiveInt() |
void |
setPreciseType() |
void |
setPreciseType(TypeReference t)
Set the
TypeReference of the value represented by the operand and
make the type precise. |
void |
setRegister(Register register) |
void |
setTaken()
Set this a guard operand from a taken branch
|
void |
setType(TypeReference t)
Set the
TypeReference of the value represented by the operand. |
boolean |
similar(Operand op)
Are two operands semantically equivalent?
|
String |
toString() |
private void |
verifyPreciseType() |
asAddressConstant, asBlock, asBranch, asClassConstant, asCondition, asDoubleConstant, asFloatConstant, asIntConstant, asLocation, asLongConstant, asMemory, asMethod, asNullConstant, asObjectConstant, asRegister, asStackLocation, asStringConstant, asTIBConstant, asType, conservativelyApproximates, getIndexInInstruction, isAddressConstant, isBlock, isBranch, isClassConstant, isConstant, isDoubleConstant, isFloatConstant, isIntConstant, isLocation, isLongConstant, isMemory, isMethod, isMovableObjectConstant, isNullConstant, isObjectConstant, isRegister, isStackLocation, isStringConstant, isTIBConstant, isTrueGuard, isType, meet
private boolean convertedFromRef
private TypeReference type
private RegisterOperand nextInDefUseList
private Operand guard
Used in the construction of the high-level intermediate representation.
private byte flags
private static final int DECLARED_TYPE
private static final int PRECISE_TYPE
private static final int POSITIVE
private static final byte PARAMETER
private static final byte NON_VOLATILE
private static final byte EXTANT
private byte flags2
private static final byte TAKEN
private static final byte NOT_TAKEN
private static final byte BOUNDS_CHECK
private static final byte NULL_CHECK
public RegisterOperand(Register reg, TypeReference typ)
reg
- register objecttyp
- data typepublic RegisterOperand(Register reg, TypeReference typ, byte inFlags, boolean isPrecise, boolean isDeclared)
reg
- register objecttyp
- data typeinFlags
- to set for this registerisPrecise
- is this a precise typeisDeclared
- is this a declared typepublic RegisterOperand copyRO()
NOTE: preserves the flags, guards and def/use lists.
public RegisterOperand copyU2U()
public RegisterOperand copyD2U()
public RegisterOperand copyU2D()
public RegisterOperand copyD2D()
public boolean similar(Operand op)
Operand
public void copyTypeFrom(RegisterOperand rhs)
rhs
- the type to copy information frompublic boolean isIntLike()
Operand
isIntLike
in class Operand
true
if the data type of this
is int-like as defined by TypeReference.isIntLikeType()
or false
if it is not.public boolean isInt()
Operand
isInt
in class Operand
true
if the data type of this
is an int as defined by TypeReference.isIntType()
or false
if it is not.public boolean isLong()
Operand
isLong
in class Operand
true
if the data type of this
is a long as defined by TypeReference.isLongType()
or false
if it is not.public boolean isFloat()
Operand
isFloat
in class Operand
true
if the data type of this
is a float as defined by TypeReference.isFloatType()
or false
if it is not.public boolean isDouble()
Operand
isDouble
in class Operand
true
if the data type of this
is a double as defined by TypeReference.isDoubleType()
or false
if it is not.public boolean isRef()
Operand
isRef
in class Operand
true
if the data type of this
is a reference as defined by TypeReference.isReferenceType()
or false
if it is not.public boolean isAddress()
Operand
isAddress
in class Operand
true
if the data type of this
is an address as defined by TypeReference.isAddressType()
or false
if it is not.public boolean isDefinitelyNull()
Operand
null
?isDefinitelyNull
in class Operand
true
if the operand definitely represents
null
or false
if it does not.public boolean isParameter()
public void setParameter()
public void clearParameter()
public boolean isNonVolatile()
public void setNonVolatile()
public void clearNonVolatile()
public boolean isExtant()
true
if this register is extant (see above)public void setExtant()
public void clearExtant()
public boolean isDeclaredType()
public void setDeclaredType()
public void clearDeclaredType()
private void verifyPreciseType()
public boolean isPreciseType()
public void setPreciseType()
public void clearPreciseType()
public boolean isDeclaredOrPreciseType()
public boolean isPositiveInt()
public void setPositiveInt()
public byte getFlags()
public void clearFlags()
public void addFlags(byte inFlag)
inFlag
- the flags to merge to this register's flagspublic void setInheritableFlags(RegisterOperand src)
src
- the operand to copy the flags frompublic void meetInheritableFlags(RegisterOperand other)
other
- the operand to use for computing the meetpublic boolean hasLessConservativeFlags(RegisterOperand other)
other
- operand to compare withtrue
if we have any bits set (flag true) that other
doesn't. It's ok for other to have bits set true that we have set
to false.public boolean isTaken()
true
if this is a guard operand from a taken branchpublic void setTaken()
public void clearTaken()
public boolean isNotTaken()
true
if this is a guard operand from a not taken branchpublic void setNotTaken()
public void clearNotTaken()
public boolean isBoundsCheck()
public void setBoundsCheck()
public void clearBoundsCheck()
public boolean isNullCheck()
public void setNullCheck()
public void clearNullCheck()
public void setNext(RegisterOperand next)
next
- next register operand in the listpublic RegisterOperand getNext()
public void setRegister(Register register)
public Register getRegister()
public void setType(TypeReference t)
TypeReference
of the value represented by the operand.t
- the inferred data type of the contents of the registerpublic void setPreciseType(TypeReference t)
TypeReference
of the value represented by the operand and
make the type precise.t
- the inferred data type of the contents of the registerpublic TypeReference getType()
TypeReference
of the value represented by the operand.public void flagAsConvertedFromRef()
public boolean convertedFromRef()
public void refine(TypeReference t)
t
- type to try to refine topublic boolean sameRegisterPropertiesAs(RegisterOperand other)
Does this operand have the same properties as the given Operand? This method checks only the properties specific to RegisterOperand.
other
- the operand to compare withpublic boolean sameRegisterPropertiesAsExceptForGuardWhichIsSimilar(RegisterOperand other)
Does this operand have the same properties as the given Operand? This method checks only the properties specific to RegisterOperand. For guards, similarity of operands is sufficient.
other
- the operand to compare with