Main Page | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

jvmreg.h File Reference


Detailed Description

Registers of the Java Virtual Machine, including the program counter, stack pointer, frame pointer, etc.

Definition of the JVM registers for this real machine implementation, namely, the stack area and program counter. There are a significant number of macros available for navigating push-up stack area, the stack pointer, and stack frame.

Control

$URL: https://svn.apache.org/path/name/jvmreg.h $ $Id: jvmreg.h 0 09/28/2005 dlydick $

Copyright 2005 The Apache Software Foundation or its licensors, as applicable.

Licensed under the Apache License, Version 2.0 ("the License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.

Version:
$LastChangedRevision: 0 $
Date:
$LastChangedDate: 09/28/2005 $
Author:
$LastChangedBy: dlydick $ Original code contributed by Daniel Lydick on 09/28/2005.

Reference

Definition in file jvmreg.h.

Go to the source code of this file.

Data Structures

struct  jvm_pc
 Program counter. More...

Navigate stack frame in depth.

Use these macros to iteratively point up and down the stack from from current fram to bottom of the stack.

Parameters:
thridx Thread index of thread whose stack pointer is to be referenced.
some_fp Stack pointer index of stack frame to be referenced.


#define CHECK_FINAL_STACK_FRAME(thridx)   CHECK_FINAL_STACK_FRAME_GENERIC(thridx, GET_FP(thridx))
#define CHECK_FINAL_STACK_FRAME_GENERIC(thridx, some_fp)
#define CHECK_FINAL_STACK_FRAME_ULTIMATE(thridx)   (JVMCFG_NULL_SP == GET_FP(thridx))
#define FIRST_STACK_FRAME(thridx)   GET_FP(thridx)
#define NEXT_STACK_FRAME(thridx)   NEXT_STACK_FRAME_GENERIC(thridx, GET_FP(thridx))
#define NEXT_STACK_FRAME_GENERIC(thridx, some_fp)   STACK(thridx, some_fp + JVMREG_STACK_FP_OFFSET)

Move the stack pointer up and down.

Increment/decrement SP (N/A to frame pointer).

It is safe to reference SP in the value parameter.

Parameters:
thridx Thread index of thread whose stack pointer is to be referenced.
value (jint) value to change stack pointer by.
Returns:
rvoid


#define DEC_SP(thridx, value)   THREAD(thridx).sp -= (value)
#define INC_SP(thridx, value)   THREAD(thridx).sp += (value)

Navigate the code area of of the current method.

Calculate pointers to several important real machine addresses in the class file of the current method of a specific thread:



#define DEREFERENCE_PC_CODE_ATTRIBUTE(thridx)
 Code_attribute in method table for current program counter on a given thread.
#define DEREFERENCE_PC_CODE_BASE(thridx)   (DEREFERENCE_PC_CODE_ATTRIBUTE(thridx)->code)
 Real address of first opcode of this method in current program counter on a given thread.
#define DEREFERENCE_PC_CODE_CURRENT_OPCODE(thridx)   (&DEREFERENCE_PC_CODE_BASE(thridx)[THIS_PC(thridx)->offset])
 Real address of first opcode of this method in current program counter on a given thread.
#define DEREFERENCE_PC_EXCEPTION_TABLE(thridx)   (DEREFERENCE_PC_CODE_ATTRIBUTE(thridx)->exception_table)
 Real address of exception table of this method in current program counter on a given thread.
#define DEREFERENCE_PC_EXCEPTIONS_ATTRIBUTE(thridx)
 Exceptions_attribute in method table for current program counter on a given thread.
#define DEREFERENCE_PC_GENERIC_ATTRIBUTE(thridx, pc_member)
 Untyped attribute in method table for current program counter on a given thread.
#define THIS_PC(thridx)   (&THREAD(thridx).pc)
 Locate program counter for a given thread.
#define THIS_PCFS(thridx)   (CLASS_OBJECT_LINKAGE(THIS_PC(thridx)->clsidx)->pcfs)
 Locate ClassFile for current program counter on a given thread.

Reading and writing to the stack pointer.

Load/store values from/to the frame pointer.

Parameters:
thridx Thread index of thread whose frame pointer is to be referenced.
value (jvm_sp) value to store into frame pointer.
Returns:
The GET_FP() macros return a (jvm_sp) value of a stack pointer, the others return rvoid.


#define GET_FP(thridx)   (THREAD(thridx).fp)
#define PUT_FP_IMMEDIATE(thridx, value)   THREAD(thridx).fp = (value)

Access the stack frame.

Read and write (jint) values from and to the current stack frame.

Accesses are always as (jint), casting is performed outside of these macros.

Todo:
This implementation is being changed to point local variable zero to the _last_ word of the local variable area instead of the _first_ word. This will create a run-time tradeoff between reversing the stack frame for method calls and a slightly longer expression needed to access local variables. The former (current way) makes for a somewhat more complex method invocation procedure, while the latter (to be done) provides an easy method invocation with a bit more work to access locals. The following warning notice will go away when this is done:
NOTICE THE INDEX IS ***NEGATIVE*** in this implementation! This allows FP to use constant values to each and every element of the frame, including a constant value to point to the first of the local variables. By inverting the frame to have the locals on top, this same thing could be done and the FP could point either to its corresponding inverse location or to the first word of the frame above the old stack contents.

Parameters:
thridx Thread index of thread whose stack pointer is to be referenced.
frmidx Stack frame index (local variable index) of stack frame to be referenced.
cast Arbitrary data type that is of size (jint) or smaller. This includes (jbyte), (jboolean), (jchar), (jshort), (jshort), and (jobject).


#define GET_LOCAL_VAR(thridx, frmidx)   ((jint) (STACK(thridx, GET_FP(thridx) - frmidx)))
 Read a local variable from the stack frame.
#define GET_TYPED_LOCAL_VAR(thridx, frmidx, cast)   ((cast) GET_LOCAL_VAR(thridx, frmidx)))
 Cast a GET_LOCAL_VAR() as any arbitrary data type.
#define JINT_ADDRESS_LOCAL_VAR(thridx, frmidx)   ((jint *) &STACK(thridx, GET_FP(thridx) - frmidx))
 Real machine address of a local variable in the stack frame.
#define PUT_LOCAL_VAR(thridx, frmidx, value)   *JINT_ADDRESS_LOCAL_VAR(thridx, frmidx) = (jint) (value)
 Write a local variable from the stack frame.

Macros for manipulating program counter.

load the program counter and store its contents from/to an arbitrary location, from/to the stack, and load with an immediate value.

Parameters:
_thridx Thread index of thread whose stack pointer is to be referenced.
_source (jvm_pc) value to be loaded into program counter.
_clsidx (jvm_class_index) value to be loaded into program counter class index
_mthidx (jvm_method_index) value to be loaded into program counter class index
_codeatridx (jvm_attribute_index) value to be loaded into program counter class index
_excpatridx (jvm_attribute_index) value to be loaded into program counter class index
_excpatridx (jvm_attribute_index) value to be loaded into program counter class index
_offset (jvm_pc_offset) value to be loaded into program counter class index
_field Field from program counter to extract.
Returns:
(jvm_sp) stack offset value of requested item.


#define GET_PC(_thridx, _target)
#define GET_PC_FIELD(_thridx, _target, _field)   _target = GET_PC_FIELD_IMMEDIATE(_thridx, _field)
#define GET_PC_FIELD_IMMEDIATE(_thridx, _field)   THREAD(_thridx).pc._field
#define POP_PC(_thridx)
#define PUSH_PC(_thridx)
#define PUT_PC(_thridx, _source)
#define PUT_PC_IMMEDIATE(_thridx,_clsidx,_mthidx,_codeatridx,_excpatridx,_offset)

Reading and writing to the stack pointer.

Load/store values from/to the stack pointer itself, not stack memory it points to.

Parameters:
thridx Thread index of thread whose stack pointer is to be referenced.
value (jvm_sp) value to store into stack pointer.
Returns:
The GET_SP() macros return a (jvm_sp) value of a stack pointer, the others return rvoid.


#define GET_SP(thridx)   (THREAD(thridx).sp)
#define PUT_SP_IMMEDIATE(thridx, value)   THREAD(thridx).sp = value

Reading and writing into the stack area.

Parameters:
thridx Thread index of thread whose stack it to be manipulated.
value (jint) value to store into stack location.
Returns:
The GET_SP() macros return a (jint) value from the stack, the others return rvoid.


#define GET_SP_WORD(thridx, idx, cast)   ((cast) (STACK(thridx, GET_SP(thridx) - idx)))
 Read a word at given depth in stack.
#define PUT_SP_WORD(thridx, idx, value)   STACK(thridx, GET_SP(thridx) - idx) = (jint) (value)
 Write a word at given depth in stack.

Locate position in stack frame of its components.

Locate the local storage size, garbage collection pointer, old frame pointer, and start of local storage area.

The current frame pointer always points to the first word of the local storage area of the stack frame.

Parameters:
thridx Thread index of thread whose stack pointer is to be referenced.
Returns:
(jvm_sp) stack offset value of requested item.


#define JVMREG_FRAME_CURRENT_LOCAL_STORAGE_SIZE(thridx)   (GET_FP(thridx) + JVMREG_STACK_LS_OFFSET)
#define JVMREG_FRAME_CURRENT_SCRATCH_AREA(thridx)   GET_FP(thridx)
#define JVMREG_FRAME_GC(thridx)   (GET_FP(thridx) + JVMREG_STACK_GC_OFFSET)
#define JVMREG_FRAME_PREVIOUS_FP(thridx)   (GET_FP(thridx) + JVMREG_STACK_FP_OFFSET)

Stack frame geometry.

Frame height = PC + GC + FP + max_locals (from code atr) + SA (aka max_stack, SA being scratch area, the operand stack). Minimum will be a zero-sized max_locals plus current SA.

#define JVMREG_STACK_FP_HEIGHT   1
#define JVMREG_STACK_FP_OFFSET
#define JVMREG_STACK_GC_HEIGHT   1
#define JVMREG_STACK_GC_OFFSET
#define JVMREG_STACK_LS_HEIGHT   1
#define JVMREG_STACK_LS_OFFSET   JVMREG_STACK_LS_HEIGHT
#define JVMREG_STACK_MIN_FRAME_HEIGHT
#define JVMREG_STACK_PC_HEIGHT   5
#define JVMREG_STACK_PC_OFFSET

Location of the old program counter in the current stack frame.

Warning:
Notice NEGATIVE INDEX used to address the stack frame.


#define JVMREG_STACK_PC_CLSIDX_OFFSET   JVMREG_STACK_PC_OFFSET - 0
#define JVMREG_STACK_PC_CODEATRIDX_OFFSET   JVMREG_STACK_PC_OFFSET - 2
#define JVMREG_STACK_PC_EXCPATRIDX_OFFSET   JVMREG_STACK_PC_OFFSET - 3
#define JVMREG_STACK_PC_MTHIDX_OFFSET   JVMREG_STACK_PC_OFFSET - 1
#define JVMREG_STACK_PC_OFFSET_OFFSET   JVMREG_STACK_PC_OFFSET - 4

Stack push and pop for any 32-bit data type.

Push/pop item to/from stack (MUST be integer size!).

Warning:
DO NOT push/pop any 64-bit item, namely any jlong or jdouble value. The stack pointer is only adjusted by a single 32-bit word. Use two operations to push/pop each half of such types. There are a number of examples in code, both in opcode.c and native.c.

It is not safe to reference SP in the item parameter of POP().

Parameters:
thridx Thread index of thread whose stack pointer is to be referenced.
item (cast) variable to push/pop to/from the stack.
cast Type cast of variable being poped from the stack.
Returns:
PUSH() returns rvoid, POP() returns the requested (jint) value.


#define POP(thridx, item, cast)
#define PUSH(thridx, item)

Stack push and pop of frame pointer.

Push/pop FP to/from stack.

Parameters:
thridx Thread index of thread whose stack pointer is to be referenced.
Returns:
PUSH_FP() returns rvoid, POP_FP() returns the requested (jvm_sp) value.


#define POP_FP(thridx)   POP(thridx, THREAD(thridx).fp, jvm_sp)
#define PUSH_FP(thridx)   PUSH(thridx, THREAD(thridx).fp)

Geometry of a complete stack frame.

A complete stack frame is pushed every time a JVM virtual method is called, where old program counter and old stack state must be saved and a new one created on top of it. The macro PUSH_FRAME() is designed for this use. For example, here is an existing stack frame:

       SP -->  [scratch] (operand stack, >= 0 words)  ... higher address
                 ...                                        ...
               [scratch]                                    ...
               [top of previous frame]                      ...
       FP ->   [locals of previous frame]             ... lower address
  
   

During PUSH_FRAME(n), there are an words of local storage allocated for JVM method scratch area, where n >= 0, up to the maximum stack size less the top few words:

   new SP -->  [PC of next JVM instruction]           ... high address
               [old FP]                                     ...
               [GC pointer for this NEW frame]              ...
               [value 'n', size of LS (local storage) area beneath]
   new FP -->  [local 0]                                    ...
               [local 1]                                    ...
               [local 2]                                    ...
                 ...                                        ...
               [local n-1]                                  ...
  
   --- end of NEW frame ---
  
   old SP ->   [scratch] (same data shown above)            ...
                 ...                                        ...
               [scratch]                                    ...
               [top of previous frame]                      ...
   old FP ->   [locals of previous frame]             ... low address
  
   --- end of OLD frame ---
  
   

POP_FRAME() does the reverse or PUSH_FRAME and removes the top stack frame. The final POP_FRAME() will have a stored (old) frame pointer containing JVMCFG_NULL_SP, so when this frame is popped, opcode_run() will detect that this thread has finished running.

Parameters:
thridx Thread index of thread whose stack pointer is to be referenced.
locals Number of local variables to be reserved in the new stack frame.
Returns:
rvoid.


#define POP_FRAME(thridx)
#define PUSH_FRAME(thridx, locals)

Stack push and pop of garbage collection pointer.

Push/pop GC pointer to/from stack.

Due to the potential for multiple GC implementations in this JVM, the GC pointer here is not related to any one of them. Instead, it is cast here as a simple rvoid pointer so as to support all of them.

Todo:
Verify that the 64-bit real pointer calculations work properly for PUSH_GC() and POP_GC() (namely, where use fo JVMREG_STACK_GC_HEIGHT is involved)
Warning:
WATCH OUT! When invoking POP_GC() you are working with a partially torn down frame, so can't use standard macros to calculate stack offsets!
Parameters:
thridx Thread index of thread whose stack pointer is to be referenced.
Returns:
rvoid


#define POP_GC(thridx)
#define PUSH_GC(thridx, num_locals)

Push and pop of local variables.

Add/remove empty space for local storage to/from stack.

Parameters:
thridx Thread index of thread whose stack pointer is to be referenced.
value (jint) value to change stack pointer by.
Returns:
rvoid


#define POP_LOCAL(thridx, items)   DEC_SP(thridx, items)
#define PUSH_LOCAL(thridx, items)   INC_SP(thridx, items)

Two types of exception tables.

The JVM exception index table (defined by Exceptions attribute) and JVM exception table (defined inside Code attribute) are both simple offsets into their respective tables. Both are bound up directly with the program counter, so are defined here.

typedef u2 jvm_exception_index_table_index
typedef u2 jvm_exception_table_index

Defines

#define GET_GC(thridx)   ((rvoid *) &STACK(thridx, GET_FP(thridx) + JVMREG_STACK_GC_OFFSET))
 Retrieve the stack frame garbage collection pointer.
#define STACK(thridx, stkidx)   THREAD(thridx).stack[stkidx]
 Access structures of stack at certain index.

Typedefs

typedef u1 jvm_virtual_opcode

Functions

 ARCH_COPYRIGHT_APACHE (jvmreg, h,"$URL: https://svn.apache.org/path/name/jvmreg.h $ $Id: jvmreg.h 0 09/28/2005 dlydick $")


Define Documentation

#define STACK thridx,
stkidx   )     THREAD(thridx).stack[stkidx]
 

Access structures of stack at certain index.

Definition at line 100 of file jvmreg.h.

Referenced by jvmutil_print_errtype_stack(), and jvmutil_print_stack_common().

#define JVMREG_STACK_PC_HEIGHT   5
 

Each of 5 items takes 1 stack word

Definition at line 114 of file jvmreg.h.

#define JVMREG_STACK_FP_HEIGHT   1
 

Frame pointer takes one word

Definition at line 118 of file jvmreg.h.

#define JVMREG_STACK_GC_HEIGHT   1
 

GC real machine 32-bit ptr takes 1 word

Definition at line 127 of file jvmreg.h.

#define JVMREG_STACK_LS_HEIGHT   1
 

Num local storage words takes 1 word

Definition at line 132 of file jvmreg.h.

#define JVMREG_STACK_MIN_FRAME_HEIGHT
 

Value:

Warning:
WATCH OUT! When invoking POP_GC() you are working with a partially torn down frame, so can't use this macro:

Definition at line 138 of file jvmreg.h.

#define JVMREG_STACK_LS_OFFSET   JVMREG_STACK_LS_HEIGHT
 

Offsets from current FP of local storage size word

Definition at line 143 of file jvmreg.h.

#define JVMREG_STACK_GC_OFFSET
 

Value:

Offsets from current FP of garbage collection pointer

Definition at line 146 of file jvmreg.h.

#define JVMREG_STACK_FP_OFFSET
 

Value:

Offsets from current FP of old frame pointer

Definition at line 150 of file jvmreg.h.

#define JVMREG_STACK_PC_OFFSET
 

Value:

Offsets from current FP of stack pointer

Definition at line 154 of file jvmreg.h.

#define GET_SP thridx   )     (THREAD(thridx).sp)
 

Definition at line 181 of file jvmreg.h.

#define PUT_SP_IMMEDIATE thridx,
value   )     THREAD(thridx).sp = value
 

Definition at line 184 of file jvmreg.h.

#define GET_SP_WORD thridx,
idx,
cast   )     ((cast) (STACK(thridx, GET_SP(thridx) - idx)))
 

Read a word at given depth in stack.

Definition at line 210 of file jvmreg.h.

#define PUT_SP_WORD thridx,
idx,
value   )     STACK(thridx, GET_SP(thridx) - idx) = (jint) (value)
 

Write a word at given depth in stack.

Definition at line 216 of file jvmreg.h.

#define GET_FP thridx   )     (THREAD(thridx).fp)
 

Definition at line 242 of file jvmreg.h.

Referenced by jvmutil_print_errtype_stack(), and jvmutil_print_stack_common().

#define PUT_FP_IMMEDIATE thridx,
value   )     THREAD(thridx).fp = (value)
 

Definition at line 244 of file jvmreg.h.

#define GET_GC thridx   )     ((rvoid *) &STACK(thridx, GET_FP(thridx) + JVMREG_STACK_GC_OFFSET))
 

Retrieve the stack frame garbage collection pointer.

Parameters:
thridx Thread index of thread whose garbage collection pointer is to be referenced.
Returns:
(rvoid *) is a real machine untyped pointer that is stored in a JVM stack location. Adjustments for 32-bit and 64-bit real machine pointers are already considered by JVMREG_STACK_GC_HEIGHT.

Definition at line 264 of file jvmreg.h.

#define INC_SP thridx,
value   )     THREAD(thridx).sp += (value)
 

Definition at line 287 of file jvmreg.h.

#define DEC_SP thridx,
value   )     THREAD(thridx).sp -= (value)
 

Definition at line 288 of file jvmreg.h.

#define PUSH thridx,
item   ) 
 

Value:

INC_SP(thridx, 1); \
                           PUT_SP_WORD(thridx, 0, (item))

Definition at line 328 of file jvmreg.h.

Referenced by native_run_local_return_jdouble(), native_run_local_return_jfloat(), native_run_local_return_jint(), native_run_local_return_jlong(), native_run_local_return_jobject(), and opcode_run().

#define POP thridx,
item,
cast   ) 
 

Value:

item = GET_SP_WORD(thridx, 0, cast); \
                                 DEC_SP(thridx, 1)

Definition at line 331 of file jvmreg.h.

Referenced by opcode_run().

#define PUSH_FP thridx   )     PUSH(thridx, THREAD(thridx).fp)
 

Definition at line 354 of file jvmreg.h.

#define POP_FP thridx   )     POP(thridx, THREAD(thridx).fp, jvm_sp)
 

Definition at line 356 of file jvmreg.h.

#define PUSH_GC thridx,
num_locals   ) 
 

Value:

INC_SP(thridx, JVMREG_STACK_GC_HEIGHT);                            \
    ((rvoid *)                                                         \
     *(&STACK(thridx, THREAD(thridx).sp - JVMREG_STACK_GC_HEIGHT+1))) =\
        GC_STACK_NEW(thridx, num_locals)

Definition at line 390 of file jvmreg.h.

#define POP_GC thridx   ) 
 

Value:

GC_STACK_DELETE(thridx,                                          \
                     ((rvoid **)                                     \
                      &STACK(thridx, THREAD(thridx).sp -             \
                                       JVMREG_STACK_GC_HEIGHT + 1)), \
                     (&STACK(thridx, THREAD(thridx).sp -             \
                                     JVMREG_STACK_GC_HEIGHT + 1 -    \
                                     JVMREG_STACK_LS_HEIGHT - 1)));  \
    DEC_SP(thridx, JVMREG_STACK_GC_HEIGHT)

Definition at line 396 of file jvmreg.h.

#define PUSH_LOCAL thridx,
items   )     INC_SP(thridx, items)
 

Definition at line 427 of file jvmreg.h.

#define POP_LOCAL thridx,
items   )     DEC_SP(thridx, items)
 

Definition at line 428 of file jvmreg.h.

#define JVMREG_FRAME_CURRENT_LOCAL_STORAGE_SIZE thridx   )     (GET_FP(thridx) + JVMREG_STACK_LS_OFFSET)
 

Definition at line 453 of file jvmreg.h.

#define JVMREG_FRAME_GC thridx   )     (GET_FP(thridx) + JVMREG_STACK_GC_OFFSET)
 

Definition at line 456 of file jvmreg.h.

#define JVMREG_FRAME_PREVIOUS_FP thridx   )     (GET_FP(thridx) + JVMREG_STACK_FP_OFFSET)
 

Definition at line 459 of file jvmreg.h.

#define JVMREG_FRAME_CURRENT_SCRATCH_AREA thridx   )     GET_FP(thridx)
 

Definition at line 462 of file jvmreg.h.

#define PUT_PC _thridx,
_source   ) 
 

Value:

THREAD(_thridx).pc.clsidx     = (_source).clsidx; \
    THREAD(_thridx).pc.mthidx     = (_source).mthidx; \
    THREAD(_thridx).pc.codeatridx = (_source).atridx; \
    THREAD(_thridx).pc.excpatridx = (_source).atridx; \
    THREAD(_thridx).pc.offset     = (_source).offset

Definition at line 507 of file jvmreg.h.

#define PUT_PC_IMMEDIATE _thridx,
_clsidx,
_mthidx,
_codeatridx,
_excpatridx,
_offset   ) 
 

Value:

THREAD(_thridx).pc.clsidx     = (_clsidx);     \
    THREAD(_thridx).pc.mthidx     = (_mthidx);     \
    THREAD(_thridx).pc.codeatridx = (_codeatridx); \
    THREAD(_thridx).pc.excpatridx = (_excpatridx); \
    THREAD(_thridx).pc.offset     = (_offset)

Definition at line 519 of file jvmreg.h.

Referenced by object_run_method(), opcode_run(), and thread_init().

#define GET_PC _thridx,
_target   ) 
 

Value:

_target.clsidx     = THREAD(_thridx).pc.clsidx     \
    _target.mthidx     = THREAD(_thridx).pc.mthidx     \
    _target.codeatridx = THREAD(_thridx).pc.codeatridx \
    _target.excpatridx = THREAD(_thridx).pc.excpatridx \
    _target.offset     = THREAD(_thridx).pc.offset

Definition at line 526 of file jvmreg.h.

#define GET_PC_FIELD_IMMEDIATE _thridx,
_field   )     THREAD(_thridx).pc._field
 

Definition at line 533 of file jvmreg.h.

#define GET_PC_FIELD _thridx,
_target,
_field   )     _target = GET_PC_FIELD_IMMEDIATE(_thridx, _field)
 

Definition at line 536 of file jvmreg.h.

#define PUSH_PC _thridx   ) 
 

Value:

PUSH(_thridx, THREAD(_thridx).pc.offset);     \
    PUSH(_thridx, THREAD(_thridx).pc.excpatridx); \
    PUSH(_thridx, THREAD(_thridx).pc.codeatridx); \
    PUSH(_thridx, THREAD(_thridx).pc.mthidx);     \
    PUSH(_thridx, THREAD(_thridx).pc.clsidx);

Definition at line 539 of file jvmreg.h.

#define POP_PC _thridx   ) 
 

Value:

POP(_thridx, THREAD(_thridx).pc.clsidx, jvm_class_index); \
    POP(_thridx, THREAD(_thridx).pc.mthidx, u2);              \
    POP(_thridx, THREAD(_thridx).pc.codeatridx, u2);          \
    POP(_thridx, THREAD(_thridx).pc.excpatridx, u2);          \
    POP(_thridx, THREAD(_thridx).pc.offset, jvm_pc_offset);

Definition at line 546 of file jvmreg.h.

#define JVMREG_STACK_PC_CLSIDX_OFFSET   JVMREG_STACK_PC_OFFSET - 0
 

Definition at line 564 of file jvmreg.h.

Referenced by jvmutil_print_errtype_stack(), and jvmutil_print_stack_common().

#define JVMREG_STACK_PC_MTHIDX_OFFSET   JVMREG_STACK_PC_OFFSET - 1
 

Definition at line 565 of file jvmreg.h.

Referenced by jvmutil_print_stack_common().

#define JVMREG_STACK_PC_CODEATRIDX_OFFSET   JVMREG_STACK_PC_OFFSET - 2
 

Definition at line 566 of file jvmreg.h.

#define JVMREG_STACK_PC_EXCPATRIDX_OFFSET   JVMREG_STACK_PC_OFFSET - 3
 

Definition at line 567 of file jvmreg.h.

#define JVMREG_STACK_PC_OFFSET_OFFSET   JVMREG_STACK_PC_OFFSET - 4
 

Definition at line 568 of file jvmreg.h.

#define THIS_PC thridx   )     (&THREAD(thridx).pc)
 

Locate program counter for a given thread.

Parameters:
thridx Thread table index of program counter to locate.
Returns:
address of program counter in this thread table.

Definition at line 621 of file jvmreg.h.

Referenced by opcode_run().

#define THIS_PCFS thridx   )     (CLASS_OBJECT_LINKAGE(THIS_PC(thridx)->clsidx)->pcfs)
 

Locate ClassFile for current program counter on a given thread.

Parameters:
thridx Thread table index of class to locate for current program counter.
Returns:
address of ClassFile structure containing code at current program counter on this thread.

Definition at line 639 of file jvmreg.h.

Referenced by opcode_run().

#define DEREFERENCE_PC_GENERIC_ATTRIBUTE thridx,
pc_member   ) 
 

Value:

((jvm_attribute_index_bad != THIS_PC(thridx)->pc_member) \
     ? (&THIS_PCFS(thridx)->methods[THIS_PC(thridx)->mthidx] \
                            ->attributes[THIS_PC(thridx)->pc_member] \
                              ->ai) \
     : rnull)
Untyped attribute in method table for current program counter on a given thread.

Parameters:
thridx Thread table index of attribute to locate for current program counter.
pc_member jvm_pc member index in current program counter to pick out and examine.
Returns:
Plain attribute address (no special attribute type) of an attribute in method area of the current program counter on this thread, or rnull if a BAD attribute .
Todo:
Watch out for when codeatridx is a BAD index, namely jvm_attribute_index_bad

Definition at line 665 of file jvmreg.h.

#define DEREFERENCE_PC_EXCEPTIONS_ATTRIBUTE thridx   ) 
 

Value:

Exceptions_attribute in method table for current program counter on a given thread.

Parameters:
thridx Thread table index of Exceptions attribute to locate for current program counter.
Returns:
Address of Exceptions attribute in method area of the current program counter on this thread.

Definition at line 688 of file jvmreg.h.

#define DEREFERENCE_PC_CODE_ATTRIBUTE thridx   ) 
 

Value:

Code_attribute in method table for current program counter on a given thread.

Parameters:
thridx Thread table index of Code attribute to locate for current program counter.
Returns:
Address of Code attribute in method area of the current program counter on this thread, or rnull if not present in class file.

Definition at line 709 of file jvmreg.h.

#define DEREFERENCE_PC_EXCEPTION_TABLE thridx   )     (DEREFERENCE_PC_CODE_ATTRIBUTE(thridx)->exception_table)
 

Real address of exception table of this method in current program counter on a given thread.

Parameters:
thridx Thread table index of program counter to locate.
Returns:
address of program counter in this thread table, or rnull if not present in class file.

Definition at line 728 of file jvmreg.h.

#define DEREFERENCE_PC_CODE_BASE thridx   )     (DEREFERENCE_PC_CODE_ATTRIBUTE(thridx)->code)
 

Real address of first opcode of this method in current program counter on a given thread.

Parameters:
thridx Thread table index of opcode to locate for current program counter.
Returns:
Real machine address of first opcode in current program counter on this thread.

Definition at line 747 of file jvmreg.h.

Referenced by opcode_run().

#define DEREFERENCE_PC_CODE_CURRENT_OPCODE thridx   )     (&DEREFERENCE_PC_CODE_BASE(thridx)[THIS_PC(thridx)->offset])
 

Real address of first opcode of this method in current program counter on a given thread.

Parameters:
thridx Thread table index of opcode to locate for current program counter.
Returns:
Real machine address of current opcode in current program counter on this thread.

Definition at line 766 of file jvmreg.h.

#define PUSH_FRAME thridx,
locals   ) 
 

Value:

PUSH_LOCAL(thridx, (locals));                                      \
    PUSH(thridx, (locals));                                            \
    PUSH_GC(thridx, (locals));                                         \
    PUSH_FP(thridx);                                                   \
    PUT_FP_IMMEDIATE(thridx,                                           \
                      GET_SP(thridx) - JVMREG_STACK_MIN_FRAME_HEIGHT); \
    PUSH_PC(thridx);

Definition at line 840 of file jvmreg.h.

Referenced by object_run_method(), and opcode_run().

#define POP_FRAME thridx   ) 
 

Value:

POP_PC(thridx);                                        \
    POP_FP(thridx);                                        \
    POP_GC(thridx);                                        \
    POP_LOCAL(thridx, (1 + GET_SP_WORD(thridx, 0, jint)));

Definition at line 849 of file jvmreg.h.

Referenced by opcode_run().

#define GET_LOCAL_VAR thridx,
frmidx   )     ((jint) (STACK(thridx, GET_FP(thridx) - frmidx)))
 

Read a local variable from the stack frame.

Note:
For (jlong) and (jdouble) local variables, there are two accesses required per JVM spec to retrieve the two (jint) words of such a data type. Use bytegames_combine_long() and bytegames_combine_double(), respectively, to combine the two words into a single variable. The parameters may be read directly from the stack frame with this macro.
Returns:
(jint) value of a local variable in the stack frame.

Definition at line 912 of file jvmreg.h.

#define GET_TYPED_LOCAL_VAR thridx,
frmidx,
cast   )     ((cast) GET_LOCAL_VAR(thridx, frmidx)))
 

Cast a GET_LOCAL_VAR() as any arbitrary data type.

Note:
This macro is not appropriate for (jlong) and (jdouble) data types since they require two (jint) local variable stack frame accesses.
Returns:
(cast) value of (jint) local variable.

Definition at line 926 of file jvmreg.h.

#define JINT_ADDRESS_LOCAL_VAR thridx,
frmidx   )     ((jint *) &STACK(thridx, GET_FP(thridx) - frmidx))
 

Real machine address of a local variable in the stack frame.

Returns:
Real machine (jint *) address of a (jint) local variable in the stack frame.

Definition at line 938 of file jvmreg.h.

#define PUT_LOCAL_VAR thridx,
frmidx,
value   )     *JINT_ADDRESS_LOCAL_VAR(thridx, frmidx) = (jint) (value)
 

Write a local variable from the stack frame.

Note:
For (jlong) and (jdouble) local variables, there are two accesses required per JVM spec to store the two (jint) words of such a data type. Use bytegames_split_long() and bytegames_split_double(), respectively, to split a single variable into its two words. The parameters may be written directly into the stack frame with this macro.
Returns:
(jint) value of a local variable in the stack frame.

Definition at line 956 of file jvmreg.h.

#define NEXT_STACK_FRAME_GENERIC thridx,
some_fp   )     STACK(thridx, some_fp + JVMREG_STACK_FP_OFFSET)
 

Returns:
Requested frame pointer

Definition at line 982 of file jvmreg.h.

Referenced by jlThread_isAlive(), and jvmutil_print_stack_common().

#define CHECK_FINAL_STACK_FRAME_GENERIC thridx,
some_fp   ) 
 

Value:

((JVMCFG_NULL_SP == NEXT_STACK_FRAME_GENERIC(thridx, some_fp)) \
     ? rtrue                                                       \
     : rfalse)
Returns:
rtrue if some_fp now points to the bottom of the stack frame.

Definition at line 990 of file jvmreg.h.

Referenced by jlThread_isAlive(), and jvmutil_print_stack_common().

#define FIRST_STACK_FRAME thridx   )     GET_FP(thridx)
 

Definition at line 995 of file jvmreg.h.

Referenced by jlThread_isAlive(), and jvmutil_print_stack_common().

#define NEXT_STACK_FRAME thridx   )     NEXT_STACK_FRAME_GENERIC(thridx, GET_FP(thridx))
 

Definition at line 997 of file jvmreg.h.

#define CHECK_FINAL_STACK_FRAME thridx   )     CHECK_FINAL_STACK_FRAME_GENERIC(thridx, GET_FP(thridx))
 

Definition at line 1000 of file jvmreg.h.

#define CHECK_FINAL_STACK_FRAME_ULTIMATE thridx   )     (JVMCFG_NULL_SP == GET_FP(thridx))
 

Definition at line 1003 of file jvmreg.h.

Referenced by opcode_run().


Typedef Documentation

typedef u1 jvm_virtual_opcode
 

The JVM's virtual operation codes are defined as single bytes. This type definition is used to address them.

Definition at line 77 of file jvmreg.h.

typedef u2 jvm_exception_table_index
 

Definition at line 90 of file jvmreg.h.

typedef u2 jvm_exception_index_table_index
 

Definition at line 91 of file jvmreg.h.


Function Documentation

ARCH_COPYRIGHT_APACHE jvmreg  ,
,
"$URL: https://svn.apache.org/path/name/jvmreg.h $ $Id: jvmreg.h 0 09/28/2005 dlydick $" 
 


Generated on Fri Sep 30 19:00:27 2005 by  doxygen 1.4.4