Class FoldedState
- All Implemented Interfaces:
PcodeExecutorState<MaskedBytes>, PcodeExecutorStatePiece<MaskedBytes, MaskedBytes>
MaskedBytes.
This is used as the state for interpretation when computing folded constants. Because the JIT
only elides passage through registers and uniques, those are the only spaces we actually store
here. Otherwise, this is roughly equivalent to BytesPcodeExecutorState, but we store both
the values and masks of the MaskedBytes into the backing byte arrays.
-
Nested Class Summary
Nested classes/interfaces inherited from interface PcodeExecutorStatePiece
PcodeExecutorStatePiece.Reason -
Constructor Summary
ConstructorsConstructorDescriptionFoldedState(Language language) Construct a constant-folding state for the given language -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Erase the entire state or piecefork()Fork this state, without callbacks, because they're not supported here.Create a deep copy of this stateGet the arithmetic used to manipulate values of the type stored by this stategetConcreteBuffer(Address address, PcodeArithmetic.Purpose purpose) Bind a buffer of concrete bytes at the given start addressGet the language defining the address spaces of this state pieceGet all register values known to this stategetVar(AddressSpace space, MaskedBytes offset, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason) Get the value of a variablegetVarInternal(AddressSpace space, MaskedBytes offset, int size, PcodeExecutorStatePiece.Reason reason) Get the value of a variable without issuing callbacksbooleanintersectInPlace(FoldedState that) Merge the given state into this one, modifying this state in placevoidsetVar(AddressSpace space, MaskedBytes offset, int size, boolean quantize, MaskedBytes val) Set the value of a variablevoidsetVarInternal(AddressSpace space, MaskedBytes offset, int size, MaskedBytes val) Set the value of a variable without issuing callbacksStream over the pieces within.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PcodeExecutorState
getAddressArithmetic, pairedMethods inherited from interface PcodeExecutorStatePiece
checkRange, getNextEntryInternal, getNextEntryInternal, getVar, getVar, getVar, getVar, getVarInternal, inspectBigInteger, inspectByte, inspectConcrete, inspectInt, inspectLong, inspectRegisterValue, inspectShort, quantizeOffset, setBigInteger, setByte, setConcrete, setInt, setLong, setRegisterValue, setRegisterValue, setShort, setVar, setVar, setVar, setVar, setVarInternal
-
Constructor Details
-
FoldedState
Construct a constant-folding state for the given language- Parameters:
language- the language
-
-
Method Details
-
getLanguage
Description copied from interface:PcodeExecutorStatePieceGet the language defining the address spaces of this state piece- Specified by:
getLanguagein interfacePcodeExecutorStatePiece<MaskedBytes, MaskedBytes>- Returns:
- the language
-
getArithmetic
Description copied from interface:PcodeExecutorStatePieceGet the arithmetic used to manipulate values of the type stored by this state- Specified by:
getArithmeticin interfacePcodeExecutorStatePiece<MaskedBytes, MaskedBytes>- Returns:
- the arithmetic
-
streamPieces
Description copied from interface:PcodeExecutorStatePieceStream over the pieces within.If this piece is not a composition of others, then simply stream this piece in a singleton. Otherwise, stream the component pieces. (Do not include the composition itself, just the component pieces.)
- Specified by:
streamPiecesin interfacePcodeExecutorStatePiece<MaskedBytes, MaskedBytes>- Returns:
- the stream
-
setVar
public void setVar(AddressSpace space, MaskedBytes offset, int size, boolean quantize, MaskedBytes val) Description copied from interface:PcodeExecutorStatePieceSet the value of a variable- Specified by:
setVarin interfacePcodeExecutorStatePiece<MaskedBytes, MaskedBytes>- Parameters:
space- the address spaceoffset- the offset within the spacesize- the size of the variablequantize- true to quantize to the language's "addressable unit"val- the value
-
setVarInternal
Description copied from interface:PcodeExecutorStatePieceSet the value of a variable without issuing callbacks- Specified by:
setVarInternalin interfacePcodeExecutorStatePiece<MaskedBytes, MaskedBytes>- Parameters:
space- the address spaceoffset- the offset within the spacesize- the size of the variableval- the value
-
getVar
public MaskedBytes getVar(AddressSpace space, MaskedBytes offset, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason) Description copied from interface:PcodeExecutorStatePieceGet the value of a variable- Specified by:
getVarin interfacePcodeExecutorStatePiece<MaskedBytes, MaskedBytes>- Parameters:
space- the address spaceoffset- the offset within the spacesize- the size of the variablequantize- true to quantize to the language's "addressable unit"reason- the reason for reading the variable- Returns:
- the value
-
getVarInternal
public MaskedBytes getVarInternal(AddressSpace space, MaskedBytes offset, int size, PcodeExecutorStatePiece.Reason reason) Description copied from interface:PcodeExecutorStatePieceGet the value of a variable without issuing callbacks- Specified by:
getVarInternalin interfacePcodeExecutorStatePiece<MaskedBytes, MaskedBytes>- Parameters:
space- the address spaceoffset- the offset within the spacesize- the size of the variablereason- the reason for reading the variable- Returns:
- the value
-
getRegisterValues
Description copied from interface:PcodeExecutorStatePieceGet all register values known to this stateWhen the state acts as a cache, it should only return those cached.
- Specified by:
getRegisterValuesin interfacePcodeExecutorStatePiece<MaskedBytes, MaskedBytes>- Returns:
- a map of registers and their values
-
getConcreteBuffer
Description copied from interface:PcodeExecutorStatePieceBind a buffer of concrete bytes at the given start address- Specified by:
getConcreteBufferin interfacePcodeExecutorStatePiece<MaskedBytes, MaskedBytes>- Parameters:
address- the start addresspurpose- the reason why the emulator needs a concrete value- Returns:
- a buffer
-
clear
public void clear()Description copied from interface:PcodeExecutorStatePieceErase the entire state or pieceThis is generally only useful when the state is itself a cache to another object. This will ensure the state is reading from that object rather than a stale cache. If this is not a cache, this could in fact clear the whole state, and the machine using it will be left in the dark.
- Specified by:
clearin interfacePcodeExecutorStatePiece<MaskedBytes, MaskedBytes>
-
fork
Fork this state, without callbacks, because they're not supported here.- Returns:
- the copy
-
fork
Description copied from interface:PcodeExecutorStatePieceCreate a deep copy of this state- Specified by:
forkin interfacePcodeExecutorState<MaskedBytes>- Specified by:
forkin interfacePcodeExecutorStatePiece<MaskedBytes, MaskedBytes>- Parameters:
cb- callbacks to receive emulation events- Returns:
- the copy
-
intersectInPlace
Merge the given state into this one, modifying this state in placeThis is the merging operation used by
FoldRevalidator. Where we have known values (1-bits in the mask) the other must also have known values, or else we erase our mask (and value) bits. If the other also has known values at the same offset, the values must match, or else we erase. These checks and erasures are applied with bit-level granularity. Any erasure results in a return oftrue(without short circuiting).- Parameters:
that- the other state- Returns:
- true if this state changed as a result of this intersection
-