|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.ac.man.cs.rainbow.simulator.RainbowThread | +--uk.ac.man.cs.rainbow.simulator.RASMThread
Rainbow threads that are implemented by executing RASM instructions.
RASMCode
,
RASM
Inner Class Summary | |
class |
RASMThread.CallChain
An encapsulation of the location of a thread. |
static class |
RASMThread.Characterisation
The characterisation of a thread that doesn't specify its own. |
static class |
RASMThread.Exception
Exceptions due to problems during the execution of a thread. |
static class |
RASMThread.InvokationException
Thrown when an exception occurs in some externally referenced code. |
static class |
RASMThread.PopFailureException
Thrown to indicate a problem during a pop operation. |
static class |
RASMThread.ReaderWriter
For saving the activity on channels. |
static class |
RASMThread.RegPair
A tuple of register and creation location. |
static class |
RASMThread.SavedRASMThreadState
This thread's saved state. |
static interface |
RASMThread.TraceListener
Implemented by classes that want to watch what a thread is doing. |
Inner classes inherited from class uk.ac.man.cs.rainbow.simulator.RainbowThread |
RainbowThread.IllegalChannelStateException, RainbowThread.IllegalThreadTerminationException, RainbowThread.SavedRainbowThreadState |
Fields inherited from class uk.ac.man.cs.rainbow.simulator.RainbowThread |
AFTER_CHOICE, BACKWARD, FORWARD, INITIALISE, scheduler |
Constructor Summary | |
RASMThread(Scheduler scheduler,
RASMCode code)
Create a new top-level thread. |
Method Summary | |
void |
addTraceListener(RASMThread.TraceListener tracer)
Attach a trace listener to this object. |
Channel |
chanContext()
Get the channel from the thread context or the stack. |
Data |
characterise()
Characterise this thread and its children. |
void |
consolidateStack()
Trim the space allocated to the stack. |
boolean |
endContext(boolean flag)
Reset the context or repeat the instruction. |
Data |
execExtern(String externString)
Pass a string to the client for external execution. |
protected void |
execute()
Execute this thread according to where it is in its block of code. |
void |
fork(RASMCode.Label[] labels,
Data[] args)
Create a collection of child threads. |
int |
frameSize()
How large is the current stack frame? |
Object |
getContext()
Retrieve the context associated with the current instruction. |
Data |
getIdx(int idx)
Read a value from an offset from the base of the current stack-frame. |
boolean |
haveContext()
Is there any context associated with the current instruction? |
void |
keyRegister(Register reg,
int key)
Allow clients to inspect the given register. |
void |
labelChannel(Channel chan,
String label)
Put a client-determined label on a channel. |
void |
labelThread(Register reg,
String label)
Put a client-determined label on this thread. |
void |
loadState(SavedState saved)
Reload a previously saved state. |
void |
markStaticBase()
Mark the current point on the stack as having only unchanging values below it. |
void |
motionless()
Cause the current instruction to be repeated. |
Channel.Data |
newChannel(String name)
Create a new channel with the given name. |
void |
newFrame()
Create a new stack frame. |
Register.Data |
newRegister(String name)
Create a new register with the given name. |
void |
oldFrame()
Return to an old stack frame. |
Data |
pop()
Pop a single data value off the stack. |
Data[] |
pop(int size)
Pop a vector of data values off the stack. |
boolean |
popBool()
Pop a boolean. |
Channel |
popChannel()
Pop a channel. |
int |
popInt()
Pop an integer. |
RASMCode.Label.Data |
popLabel()
Pop a label. |
Data.List |
popList()
Pop a list. |
Register |
popRegister()
Pop a register. |
StringData |
popString()
Pop a string. |
TypeData |
popType()
Pop a type. |
Data.Union |
popUnion()
Pop a union. |
Data.Word |
popWord()
Pop a word. |
void |
push(boolean bool)
Push a single boolean onto the stack. |
void |
push(Data d)
Push a single data value onto the stack. |
void |
push(Data[] dvec)
Push a list of data values onto the stack. |
void |
push(Data[] dvec,
int from,
int to)
Push part of a list of data values onto the stack. |
void |
push(int i)
Push a single integer onto the stack. |
void |
removeTraceListener(RASMThread.TraceListener tracer)
Detach a trace listener from this object. |
SavedState |
saveState()
Save the state of this thread. |
void |
setContext(Object context)
Set the context associated with the current instruction. |
void |
setIdx(int idx,
Data d)
Set a value at an offset from the base of the current stack-frame. |
void |
setLocation(RASMCode.Label label)
Jump to the given label. |
void |
setStateless(boolean stateless)
Mark this thread as being a stateless thread. |
String |
toString()
|
Methods inherited from class uk.ac.man.cs.rainbow.simulator.RainbowThread |
choice, delay, execute, exitSelf, getChoice, getChoiceRange, getDirection, getFromChannel, getParent, isAvailable, putToChannel, release, scheduleChild, setChoice, signalForward, sleep, stillBusy |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public RASMThread(Scheduler scheduler, RASMCode code)
scheduler
- The scheduler that will determine when this thread executes.code
- The block of code that this thread will start executing. The
entry point is the first instruction in the block of code.Method Detail |
public void fork(RASMCode.Label[] labels, Data[] args)
labels
- The entry points for the child threads.args
- The initial stack contents for the child threads.Parallel
public void setStateless(boolean stateless)
public void motionless()
public void setLocation(RASMCode.Label label)
label
- The label to jump to.public void consolidateStack()
public int frameSize()
public void newFrame()
public void oldFrame() throws RASMThread.Exception
public Data getIdx(int idx) throws RASMThread.Exception
GetArg
public void setIdx(int idx, Data d) throws RASMThread.Exception
PutArg
public void push(Data[] dvec)
dvec
- The array of data values to push.pop(int)
,
push(Data[],int,int)
public void push(Data[] dvec, int from, int to)
dvec
- The array of data values to push part of.from
- The index of the first data value to push.to
- One more than the index of the last data value to push.IndexOutOfBoundsException
- If the indices do not refer to places in the array (or one past)
or if the starting position is beyond the finishing position.pop(int)
,
push(Data[])
public void push(Data d)
d
- The data value to push.public void push(boolean bool)
Data.Word
,
Type.Boolean
public void push(int i)
Data.Word
,
Type.Integer
public Data[] pop(int size) throws RASMThread.Exception
size
- The number of data values to pop.RASMThread.Exception
- If there aren't that many data values in the current stack frame.push(Data[])
,
push(Data[],int,int)
public Data pop() throws RASMThread.Exception
RASMThread.Exception
- If the current stack frame is empty.public int popInt() throws RASMThread.Exception
pop()
public boolean popBool() throws RASMThread.Exception
pop()
public Data.Word popWord() throws RASMThread.Exception
pop()
public Data.List popList() throws RASMThread.Exception
pop()
public Data.Union popUnion() throws RASMThread.Exception
pop()
public TypeData popType() throws RASMThread.Exception
pop()
public StringData popString() throws RASMThread.Exception
pop()
public RASMCode.Label.Data popLabel() throws RASMThread.Exception
pop()
public Channel popChannel() throws RASMThread.Exception
pop()
public Register popRegister() throws RASMThread.Exception
pop()
public Channel.Data newChannel(String name)
public Register.Data newRegister(String name)
public Channel chanContext() throws RASMThread.Exception
public boolean endContext(boolean flag)
public boolean haveContext()
public Object getContext()
public void setContext(Object context)
context
- If this is null then this removes the context.
Otherwise, it ensures that thread does not advance to the
next instruction.public String toString()
toString
in class RainbowThread
public void labelChannel(Channel chan, String label)
public void labelThread(Register reg, String label)
public void keyRegister(Register reg, int key)
Scheduler.readKeyedRegister(int)
public Data execExtern(String externString) throws RainbowException
TclExec
protected void execute() throws RainbowException
execute
in class RainbowThread
RainbowException
- If something goes wrong during the execution.public Data characterise()
characterise
in class RainbowThread
public void addTraceListener(RASMThread.TraceListener tracer)
tracer
- The tracer object to attach.RASMThread.TraceListener
,
removeTraceListener(RASMThread.TraceListener)
public void removeTraceListener(RASMThread.TraceListener tracer)
tracer
- The tracer object to detach.RASMThread.TraceListener
,
addTraceListener(RASMThread.TraceListener)
public void markStaticBase()
public SavedState saveState()
saveState
in class RainbowThread
loadState(SavedState)
public void loadState(SavedState saved)
loadState
in class RainbowThread
saved
- The saved state token to reload.IllegalArgumentException
- If the state token was not created by this thread.saveState()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |