C:/JavelinDirect/jvmdoc/jvmdoc.hh File Reference


Functions

__ void main ()
_________________________ PUB dumpBytes (addr, len) __ void dumpBytes(addr
__________ PUB start __ void start ()
_________ PUB stop __ void stop ()
____________ PUB jvmInit __ void jvmInit ()
__ int jvmSpinDebug (singlestep)
 GetHeapValue (ptr, index)
 SetHeapValue (ptr, index, val)
 GetHeapDataValue (dataptr, type, len, index)
 SetHeapDataValue (dataptr, type, len, index, val)
 LoadClassInfo (mainMethodBase)
 LookupClassIdIndex (classid)
 LookupClassAtIndex (index)
 LookupMethodIndex (classid, methid)
 LookupMethodClassId (methid)
 doNEW ()
 GetNewClass (classAddr)
 ShowObject (object)
 GetObjectField (objectref, index)
 SetObjectField (objectref, index, value)
 LoadConstant (constantSizeInBytes, tableIndex)
 doGETFIELD ()
 doPUTFIELD ()
 doNEWARRAY ()
 doANEWARRAY ()
 doINVOKEVIRTUAL ()
 doINSTANCEOF ()
 doJazzLib ()
____________ PUB jvmStep __ int jvmStep ()
__________________________ PUB
jvmSingleStepBytecode __ int 
jvmSingleStepBytecode ()
___________ PUB jvmRun __ void jvmRun ()
____________ PUB jvmStop __ void jvmStop ()
___________________________
PUB clearAllJvmBreakpoints __
void 
clearAllJvmBreakpoints ()
______________________________ PUB deleteJvmBreakpoint (bppc) __ int deleteJvmBreakpoint(bppc)
___________________________ PUB setJvmBreakpoint (bppc) __ int setJvmBreakpoint(bppc)
__________________________ PUB getJvmBreakpoint (num) __ int getJvmBreakpoints(num)
_________________________ PUB
getMaxJvmBreakpoints __ int 
getMaxJvmBreakpoints ()
_______________________ PUB isBreakPoint (bppc) __ bool isBreakPoint(pc)
_______________________ PUB
listJvmBreakpoints __ void 
listJvmBreakpoints ()
_______________________ PUB
getJvmAbortPointer __ int 
getJvmAbortPointer ()
_____________ PUB getJvmPC __ int getJvmPC ()
_____________ PUB getJvmSP __ int getJvmSP ()
_____________ PUB getJvmSB __ int getJvmSB ()
_____________ PUB getJvmFP __ int getJvmFP ()
_____________ PUB getJvmMP __ int getJvmMP ()
_____________ PUB getJvmHP __ int getJvmHP ()
____________________ PUB
getJvmHeapStart __ int 
getJvmHeapStart ()
__________________ PUB
getJvmHeapEnd __ int 
getJvmHeapEnd ()

Detailed Description

Note:
Jazzed_JVM_Demo_008.spin Added public front end API. Added debug menu for API testing and JVM debug. Issues: menu command i causes r & c work only once per boot. WorkAround: avoid using i command :).

Jazzed_JVM_Demo_006.spin. Added handling for InvokeVirtual. Added Peter's native method code. Hello World program works :).

Jazzed_JVM_Demo_004.spin. Added support for LDC and siblings. Added support for GETFIELD/PUTFIELD. Added support for INSTANCEOF. Added support for NEW, NEWARRAY, and ANEWARRAY. Added code to InvokeProgram to get us further along.

Jazzed_JVM_Demo_002.spin. Merged debug support with AiChip_JVM_Demo_002.spin.

Object "Jazzed_JVM_Demo_008" Interface:

PUB Main PUB dumpBytes(addr, len) PUB start PUB stop PUB jvmInit PUB jvmStep PUB jvmSingleStepBytecode PUB jvmRun PUB jvmStop PUB clearAllJvmBreakpoints PUB deleteJvmBreakpoint(bppc) PUB setJvmBreakpoint(bppc) PUB getJvmBreakpoint(num) PUB getMaxJvmBreakpoints PUB isBreakPoint(bppc) PUB listJvmBreakpoints PUB getJvmAbortPointer PUB getJvmPC PUB getJvmSP PUB getJvmSB PUB getJvmFP PUB getJvmMP PUB getJvmHP PUB getJvmHeapStart PUB getJvmHeapEnd

Program: 6,165 Longs Variable: 573 Longs

_________ PUB Main


Function Documentation

___________________________ PUB clearAllJvmBreakpoints __ void clearAllJvmBreakpoints (  ) 

This is a debug control command that clears all breakpoints. The breakpoint queue pointer will be 0 upon return.

______________________________ PUB deleteJvmBreakpoint ( bppc   ) 

This is a debug control command that lets the user delete a breakpoint.

Parameters:
bppc is the program counter byte array instruction address.
Returns:
zero if remove breakpoint failed

doANEWARRAY (  ) 

case jem::Jem_NEWARRAY Create new array of operand type ANEWARRAY Meaning: Allocate new array of objects. Description: A new array of the indicated class type and capable of holding size elements is allocated. The result is a reference to the new object. Allocation of an array large enough to contain size elements of the given class type is attempted and all elements of the array are initialized to null. size represents the number of elements in the new array and must be an integer. byte1 and byte2 are used to construct an index into the constant pool of the current class. When the item at that index is resolved, the resulting entry must be a class. The anewarray instruction is used to create a single-dimension array. Note A NegativeArraySizeException is thrown if size is less than 0. An OutOfMemoryError is thrown if there is not enough memory to allocate the array.

Returns:
0 to let case know the function is implemented

doGETFIELD (  ) 

case jem::Jem_GETFIELD Get 16bit field from object. Pop object/Push value

Returns:
0 to let case know the function is implemented

doINSTANCEOF (  ) 

find out if objectref is an instance of a class INSTANCEOF Meaning: Determine if an object is of given type and return result. Description: Determines whether the referenced object can be cast to be a reference to an object of the expected class. This instruction will overwrite the object reference with 1 if the object is an instance of the expected class or one of its superclasses. Otherwise, the object reference is overwritten by 0.

Returns:
0 to let case know the function is implemented

doINVOKEVIRTUAL (  ) 

Will call virtual method when developed. : Make this work :)

Returns:
non-zero for now because it is not compeletely implemented.

doJazzLib (  ) 

Function is called from "notimplemented" function

Returns:
run status 0, of ok other wise no-zero

doNEW (  ) 

See case jem::Jem_NEW comment for basic operation description. Creates a new class object and puts reference on stack.

doNEWARRAY (  ) 

case jem::Jem_NEWARRAY Create new array of operand type NEWARRAY Meaning: Allocate new array. Description: A new array of a specific array type, capable of holding size elements, is allocated. The result is a reference to the new object. Allocation of an array large enough to contain size items of the specific array type is attempted and all elements of the array are initialized to 0. size represents the number of elements in the new array and must be an integer. The result is stored with an internal code that indicates the type of array to allocate. Possible values for the type of array are as follows: T_BOOLEAN(4), T_chAR(5), T_FLOAT(6), T_DOUBLE(7), T_BYTE(8), T_SHORT(9), T_INT(10), and T_LONG(11). Note A NegativeArraySizeException is thrown if size is less than 0. An OutOfMemoryError is thrown if there is not enough memory to allocate the array.

Returns:
0 to let case know the function is implemented

doPUTFIELD (  ) 

case jem::Jem_PUTFIELD Set 16bit field in object. Pop value/Pop object

Returns:
0 to let case know the function is implemented

_________________________ PUB dumpBytes ( addr  ,
len   
)

dump bytes in 8 column table

Parameters:
addr is base address for dump
len is number of bytes to dump

GetHeapDataValue ( dataptr  ,
type  ,
len  ,
index   
)

get value from heap data[index]

Note:
dataptr, type, & len must be previously retrieved with GetHeapInfo
Parameters:
dataptr - the heap data pointer
type - the type stored
len - the number of bytes in this entry
index - the heap dataptr address offset index
Returns:
value at ptr[index]

GetHeapValue ( ptr  ,
index   
)

get value from heap pointer[index]

Parameters:
ptr - the heap pointer
index - the heap address offset data index
Returns:
value at ptr[index]

_______________________ PUB getJvmAbortPointer __ int getJvmAbortPointer (  ) 

This is command lets caller get the abort pointer. This variable would be used to cause an execution abort for debugging.

Returns:
address of the JVM engine's abort variable.

__________________________ PUB getJvmBreakpoint ( num   ) 

This is a debug control command that lets the user get the pc of a breakpoint. If the breakpoint input parameter is 0, get the last breakpoint, else get breakpoint specified. The breakpoint number should be <= maximum allowed breakpoints. If the number is greater than maximum, the breakpoint will be the mod of of the number.

Parameters:
num is the 1-base breakpoint number to get. If num is 0 get the last breakpoint set.
Returns:
pc of selected breakpoint or zero if breakpoint not found.

_____________ PUB getJvmFP __ int getJvmFP (  ) 

This is a debug status command that returns the value of the Frame Pointer. The FP is defined as the beginning of the stack for the currently executing method.

Returns:
value of the frame pointer.

__________________ PUB getJvmHeapEnd __ int getJvmHeapEnd (  ) 

This is a debug status command that returns the current end position of the Heap pointer.

Returns:
value of the heap pointer highest memory location.

____________________ PUB getJvmHeapStart __ int getJvmHeapStart (  ) 

This is a debug status command that returns the current start position of the Heap pointer.

Returns:
value of the heap pointer lowest memory position.

_____________ PUB getJvmHP __ int getJvmHP (  ) 

This is a debug status command that returns the value of the heap start pointer.

Returns:
value of the heap start pointer.

_____________ PUB getJvmMP __ int getJvmMP (  ) 

This is a debug status command that returns the relative bytecode offset value of the currently running Method's start address. This value is is the constant table method start address + the bytecode base address.

Returns:
value of the method pointer.

_____________ PUB getJvmPC __ int getJvmPC (  ) 

This is a debug status command that returns the value of the bytecode offset program counter. This value will be the address in memory of the current PC instruction.

Returns:
value of the program counter.

_____________ PUB getJvmSB __ int getJvmSB (  ) 

This is a debug status command that returns the value of the stack base pointer. This value will be the address in memory of the current SB location. This value is a representation of the JVM's internal BP or base pointer.

Returns:
value of the stack base pointer.

_____________ PUB getJvmSP __ int getJvmSP (  ) 

This is a debug status command that returns the value of the stack pointer. This value will be the address in memory of the current SP location.

Returns:
value of the stack pointer.

_________________________ PUB getMaxJvmBreakpoints __ int getMaxJvmBreakpoints (  ) 

This is a debug control command that tells user maximum number of breakpoints allowed.

Returns:
maximum number of breakpoints.

GetNewClass ( classAddr   ) 

Create a new class object with classAddr resulting in a reference which is a heap pointer with entries populated according to the CON #0 enum above ... ObjectThisClass, ..... Constant table is not loaded in each object ... this could change if necessary ... constant table is a global array of String objects for LDC to access.

Returns:
object reference

GetObjectField ( objectref  ,
index   
)

gets object var field[index] value

Parameters:
object - object pointer
index - index to objects field
Returns:
value to from field[index]

_______________________ PUB isBreakPoint ( bppc   ) 

find out if PC is on a breakpoint

Parameters:
pc the program counter value to check for breakpoint
Returns:
non-zero or true if pc is a breakpoint

____________ PUB jvmInit __ void jvmInit (  ) 

Run the JVM init procedure. This resets the JVM engine.

___________ PUB jvmRun __ void jvmRun (  ) 

This is a debug control command that allows JVM to run the bytecode program without debug control.

__________________________ PUB jvmSingleStepBytecode __ int jvmSingleStepBytecode (  ) 

This is a debug control command that allows JVM to run one bytecode "instruction" (opcode/operand). An instruction is of the form OPCODE+OPERANDS, i.e. "bipush 6" or bytecode sequence $08,$06. Many instructions take information from the stack and/or manipulate stack contents. The state of the stack must be reasonable before many instructions can be executed. The method blocks until the instruction is complete or an error occured.

__ int jvmSpinDebug ( singlestep   ) 

Runs the JVM until a breakpoint is hit or if singlestep is non-zero runs one instruction.

Returns:
0 if function terminates normally.

____________ PUB jvmStep __ int jvmStep (  ) 

native functions adapted from object BS2_functions PUB COUNT (Pin, Duration) : Value only does rising-edge pulses now adapted from object BS2_functions PUB RCTIME (Pin,State):Duration | ClkStart, ClkStop adapted from object BS2_functions PUB PULSIN_Clk(Pin, State) : Duration need to implement timeout adapted from object BS2_functions PUB PULSOUT(Pin,Duration) | clkcycles adapted from object BS2_functions PUB SHIFTIN (Dpin, Cpin, Mode, Bits) : Value | InBit Shift data in, master clock, for mode use BS2::MSBPRE, MSBPOST, LSBPRE, LSBPOST Clock rate is ~16Kbps. Use at 80MHz only is recommended. X := BS2.SHIFTIN(5,6,BS2::MSBPOST,8) is this required ?? adapted from object BS2_functions PUB SHIFTOUT (Dpin, Cpin, Value, Mode, Bits)| bitNum Shift data out, master clock, for mode use ObjName::LSBFIRST, MSBFIRST Clock rate is ~16Kbps. Use at 80MHz only is recommended. BS2.SHIFTOUT(5,6,"B",BS2::LSBFIRST,8) adapted from object BS2_functions Pub Read(address, size) adapted from object BS2_functions Pub Write(address, value, size) adapted from object BS2_functions Pub PWM_Set(Pin, Duty, Resolution) | Scale Produces constant PWM on the specified pin Needs to calculate scale Need to update ctra and frqa Need some 8bit DAC routine Need some 8bit ADC routine * This is a debug control command that allows JVM to run until a breakpoint is hit.

Returns:
zero if break happened normally.

____________ PUB jvmStop __ void jvmStop (  ) 

This is a debug control command. Stop the JVM from executing the next instruction and abort the current one if possible. Hmm. This wont work unless jvm is running in a COG .....

_______________________ PUB listJvmBreakpoints __ void listJvmBreakpoints (  ) 

list all breakpoints

LoadClassInfo ( mainMethodBase   ) 

Load a class info from the jem code binary file class table. This is an embedded implementation so we don't look for files; everything is in the binary. This table is used for classid lookup. ANEWARRAY is one code that needs this.

The method builds two arrays: classid array and methodid array The classid array is a list of class id's arranged by order found. The methodid array is a list of arrays where each array is bound to a class by classid index and contains method id's.

Parameters:
mainMethodBase - this is pc address of the main method
Returns:
pointer to classlist heap "array"

LoadConstant ( constantSizeInBytes  ,
tableIndex   
)

This loads a constant ....

Todo:
evaluate how int, long, and double will be treated etc....
Parameters:
constantSizeInBytes - using one of two methods .... If constant size == 1, load the String object from global constant table at tableIndex. If constant size > 1, load the constant offset value. LIKELY BROKEN.
tableIndex - index of constant to load.
Returns:
0 to let case know the function is implemented

LookupClassAtIndex ( index   ) 

Get classid array index.

Parameters:
index - class index of classid
Returns:
classid at index or 0 on failure

LookupClassIdIndex ( classid   ) 

Get classid array index.

Parameters:
classid - classid is hex 4 signature at class bytecode address
Returns:
classid's 0..classnum or -1 on failure

LookupMethodClassId ( methid   ) 

Get method's class id ... class id is bytecode offset of class definition.

Parameters:
methid - methid is hex 4 signature at method bytecode address
Returns:
classid's method num 0..methonum or -1 on failure

LookupMethodIndex ( classid  ,
methid   
)

Get method array index in a class

Parameters:
classid - classid is hex 4 signature at class bytecode address
methid - methid is hex 4 signature at method bytecode address
Returns:
classid's method num 0..methonum or -1 on failure

__ void main (  ) 

Main entry point for standalone jvm testing.

SetHeapDataValue ( dataptr  ,
type  ,
len  ,
index  ,
val   
)

set value at heap dataptr[index]

Note:
dataptr, type, & len must be previously retrieved with GetHeapInfo
Parameters:
dataptr - the heap data pointer
type - the type stored
len - the number of bytes in this entry
index - the heap dataptr address offset index
value - the value to set at dataptr[index]

SetHeapValue ( ptr  ,
index  ,
val   
)

set value at heap pointer[index]

Parameters:
ptr - the heap pointer
index - the heap address offset data index
value - value to set at ptr[index]

___________________________ PUB setJvmBreakpoint ( bppc   ) 

This is a debug control command that lets the user set one breakpoint. The breakpoint list is an array of BREAKPOINT_SIZE words that behaves like a queue. Only BREAKPOINT_SIZE entries are allowed at one time. The newest entry will replace the oldest entry.

Parameters:
pc is the program counter byte array instruction address.
Returns:
position of last breakpoint in queue

SetObjectField ( objectref  ,
index  ,
value   
)

sets object var field[index] = value

Parameters:
object - object pointer
index - index to objects field
value - value to store in field[index]

ShowObject ( object   ) 

This displays all of objects contents if jazzDebug is enabled. ObjectThisClass, ObjectSuperClass, ObjectFields ... from enum are displayed

Parameters:
object - object pointer

__________ PUB start __ void start (  ) 

This is the startup point for module using the JVM A new COG is not initialized for this today.

_________ PUB stop __ void stop (  ) 

This is a compatibility stop function. A new COG is not initialized for the module, so nothing is stopped.


Generated on Wed Feb 6 19:57:35 2008 for JavaProp JVM by  doxygen 1.5.4