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

object.h File Reference


Detailed Description

Definition of the java.lang.Object structure in this real machine implementation.

When initializing an object, the following activities happen in the object array:

(1) Its jvm_object_hash is used to address an empty slot in the object storage area.

(2) Its ACC_xxx flags from the class file are stored into access_flags.

(3) Its mlock_thridx is cleared, that is, no thread holds its monitor lock.

(4) Since it is not a jvm_object_hash_null value, its status is set to OBJECT_STATUS_INUSE. All other bits are clear.

(5) Declare to garbage collection that this object is now referenced.

(6) The data value(s) are stored in the array object_instance_field_data according to their various types. Since this array is a (jvalue), fields of any mixed type may be stored here. For example, An (int) is stored in object_instance_field_data._jint), while an object reference is stored in object_instance_field_data._jobjhash. Notice that a java.lang.Integer is not an (int), and has its several fields stored in this array as their normal types.

Control

$URL: https://svn.apache.org/path/name/object.h $ $Id: object.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 object.h.

Go to the source code of this file.

Data Structures

struct  jvm_table_linkage
 Type definition for references to Java classes, enums, interfaces. More...
struct  robject
 General object slot definition. More...

Object status bits

Bitwise status bits for the status of an object slot.

These object status bits have direct CLASS_STATUS_xxx equivalents and a few THREAD_STATUS_xxx equivalents also. There are no overloaded bit positions between them (for ease of diagnostics).

#define OBJECT_STATUS_2000   0x2000
 not used
#define OBJECT_STATUS_4000   0x4000
 not used
#define OBJECT_STATUS_8000   0x8000
 not used
#define OBJECT_STATUS_ARRAY   0x0004
 Object is an array instead of an object instance.
#define OBJECT_STATUS_CLASS   0x0020
 This object is a class definition instead of an object instance.
#define OBJECT_STATUS_EMPTY   0x0000
 This slot is available for use.
#define OBJECT_STATUS_GCREQ   0x0008
 Object may be garbage collected.
#define OBJECT_STATUS_INUSE   0x0001
 This slot contains an object.
#define OBJECT_STATUS_MLOCK   0x0100
 Object monitor locked by mlock_thridx.
#define OBJECT_STATUS_NULL   0x0002
 NULL object (only 1 exists in normal use, any else besides the JVMCFG_NULL_OBJECT is an object slot now being initialized.
#define OBJECT_STATUS_REFERENCE   0x0080
 Object instance variable is a reference.
#define OBJECT_STATUS_SUBARRAY   0x0020
 This is a subset of an array, that is, of smaller dimension.
#define OBJECT_STATUS_THREAD   0x0040
 Object is a java/Lang/Thread.

Defines

#define LOCAL_STATUS_REFERENCE   OBJECT_STATUS_REFERENCE
 Reserved symbol for garbage collection of local variables, distinguishing primatives from reference types.
#define OBJECT(objhash)   pjvm->object[objhash]
 Access structures of object table at certain index.

Functions

 ARCH_COPYRIGHT_APACHE (object, h,"$URL: https://svn.apache.org/path/name/object.h $ $Id: object.h 0 09/28/2005 dlydick $")
rvoid object_init (rvoid)
jvm_object_hash object_instance_delete (jvm_object_hash objhash, rboolean rmref)
 Un-reserve a slot from the object area.
rvoid object_instance_finalize (jvm_object_hash objhash, jvm_thread_index thridx)
 Finalize an object instance before deletion.
jvm_object_hash object_instance_new (rushort special_obj, ClassFile *pcfs, jvm_class_index clsidx, jvm_array_dim arraydims, jint *arraylength, rboolean run_init_, jvm_thread_index thridx)
 Create a Java new object instance of a class and optionally run its <init> method with default parameters (none).
rvoid object_new_setup (jvm_object_hash objhash)
 Set up an empty object in a given object table slot.
rvoid object_shutdown (rvoid)
rboolean objectutil_release (jvm_object_hash objhashthis, jvm_thread_index thridx)
 Attempt to wait() on an object's monitor lock by releasing it and requesting RELEASE state.
rboolean objectutil_synchronize (jvm_object_hash objhashthis, jvm_thread_index thridx)
 Attempt to synchronize() on an object's monitor lock by contending for it.
rvoid objectutil_unsynchronize (jvm_object_hash objhashthis, jvm_thread_index thridx)
 Release synchronize from an object monitor lock.


Define Documentation

#define OBJECT objhash   )     pjvm->object[objhash]
 

Access structures of object table at certain index.

The object table, being an array of slots, provides space for one object instance per slot. This macro references one of them using the objhash index.

Parameters:
objhash Object table index into the global rjvm.object[] array (via pjvm->object[]).
Returns:
pointer to a object slot

Definition at line 104 of file object.h.

Referenced by field_index_get_object_instance_pjvalue(), field_index_put_object_instance_pjvalue(), gc_run_stub(), jlObject_wait4ever(), object_allocate_slot(), object_instance_delete(), object_instance_finalize(), object_new_setup(), and objectutil_synchronize().

#define OBJECT_STATUS_EMPTY   0x0000
 

This slot is available for use.

Definition at line 164 of file object.h.

Referenced by opcode_run().

#define OBJECT_STATUS_INUSE   0x0001
 

This slot contains an object.

Definition at line 166 of file object.h.

Referenced by gc_run_stub(), object_allocate_slot(), object_instance_finalize(), object_new_setup(), and objectutil_synchronize().

#define OBJECT_STATUS_NULL   0x0002
 

NULL object (only 1 exists in normal use, any else besides the JVMCFG_NULL_OBJECT is an object slot now being initialized.

)

Definition at line 167 of file object.h.

Referenced by gc_run_stub(), object_allocate_slot(), object_new_setup(), and objectutil_synchronize().

#define OBJECT_STATUS_ARRAY   0x0004
 

Object is an array instead of an object instance.

Definition at line 174 of file object.h.

Referenced by opcode_run().

#define OBJECT_STATUS_GCREQ   0x0008
 

Object may be garbage collected.

Definition at line 176 of file object.h.

Referenced by gc_run_stub().

#define OBJECT_STATUS_CLASS   0x0020
 

This object is a class definition instead of an object instance.

Definition at line 181 of file object.h.

#define OBJECT_STATUS_SUBARRAY   0x0020
 

This is a subset of an array, that is, of smaller dimension.

Definition at line 184 of file object.h.

#define OBJECT_STATUS_THREAD   0x0040
 

Object is a java/Lang/Thread.

Definition at line 186 of file object.h.

Referenced by opcode_run().

#define OBJECT_STATUS_REFERENCE   0x0080
 

Object instance variable is a reference.

This is the same definition as for CLASS_STATUS_REFERENCE and for LOCAL_STATUS_REFERENCE, the local variable reference bit for variables on the stack frame, where the GC algorithm implements it.

Definition at line 188 of file object.h.

#define OBJECT_STATUS_MLOCK   0x0100
 

Object monitor locked by mlock_thridx.

Definition at line 201 of file object.h.

Referenced by jlObject_wait4ever(), and objectutil_synchronize().

#define OBJECT_STATUS_2000   0x2000
 

not used

Definition at line 210 of file object.h.

#define OBJECT_STATUS_4000   0x4000
 

not used

Definition at line 211 of file object.h.

#define OBJECT_STATUS_8000   0x8000
 

not used

Definition at line 212 of file object.h.

#define LOCAL_STATUS_REFERENCE   OBJECT_STATUS_REFERENCE
 

Reserved symbol for garbage collection of local variables, distinguishing primatives from reference types.

When garbage collecting local variables on the stack, there must be a distinction drawn between local variables that are primative data types and those that area reference types. This symbol is reserved for that purpose. If implemented, it will always be found in the gc_XXX.c and gc_XXX.h source files and will never be found anywhere else. However, it is also mentioned in the documentation outside of GC modules; therefore, it is documented here for completeness.

The actual value and implementation of this symbol is dependent on the GC system and the constraints given elsewhere in the documentation. The value given here is a dummy value. Its actual value must be declared previous to the inclusion in a source file of this header file.

Definition at line 331 of file object.h.


Function Documentation

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

rvoid object_init rvoid   ) 
 

rvoid object_shutdown rvoid   ) 
 

rvoid object_new_setup jvm_object_hash  objhash  ) 
 

Set up an empty object in a given object table slot.

The objhash of JVMCFG_NULL_OBJECT has special properties in that it can ALWAYS be allocated and is NEVER garbage collected! Part of the purpose for this is the JVMCFG_NULL_OBJECT is of value zero, which is widely used throughout the code as a special value. This this slot is not available for anything else.

Parameters:
objhash Object table hash of slot to set up.
Returns:
rvoid
< This slot contains an object

< NULL object (only 1 exists in normal use, any else besides the JVMCFG_NULL_OBJECT is an object slot now being initialized.)

< Invalid basetype due to malformed tag or other error (not in spec)

< Not stated in spec, but implied

< Not defined, empty (not in spec)

< This slot contains an object

< This slot contains an object

< This slot contains an object

Definition at line 245 of file object.c.

References jvm_class_index_null, jvm_object_hash_null, jvm_thread_index_null, LOCAL_ACC_EMPTY, LOCAL_BASETYPE_ERROR, LOCAL_CONSTANT_NO_ARRAY_DIMS, OBJECT, OBJECT_OBJECT_LINKAGE, OBJECT_STATUS_INUSE, OBJECT_STATUS_NULL, and rnull.

Referenced by object_init().

jvm_object_hash object_instance_new rushort  special_obj,
ClassFile pcfs,
jvm_class_index  clsidx,
jvm_array_dim  arraydims,
jint arraylength,
rboolean  run_init_,
jvm_thread_index  thridx
 

Create a Java new object instance of a class and optionally run its <init> method with default parameters (none).

The following four mutually exclusive variations are available using special_obj modifier:

  • OBJECT_STATUS_EMPTY: Normal object, no special treatment.

  • OBJECT_STATUS_THREAD: Treat the object instance creation as a normal object, but mark it as a java.lang.Thread .

  • OBJECT_STATUS_CLASS: Treat the object instance creation as loading a class instead of instantiating an object and use clsidx as the class table slot value that defines the class.

  • OBJECT_STATUS_ARRAY: Treat the object instance creation as a dimension of an array class instead of instantiating an object of the requested class.

    Plus a fifth for internal use in this function only:

  • OBJECT_STATUS_SUBARRAY: used internally to flag that this object is a subset of a larger array. DO NOT USE this modifier!

No verification of special_obj is performed, only these values are assumed.

All fields (or array components) are set to zeroes per JVM spec.

Notice that standard practice is to do new ArrayType[][][] and initialize one dimension at a time. This function can certainly operate in this way, simply set arraydims to 1. But it can initialize a multi-dimensional array all at once.

Use a simple circular slot allocation mechanism to report where most recent object was allocated. The search for the next slot will begin from here and go all the way around the array to this same slot. If not successful, return a jvm_object_hash_null, else the object hash value of the slot.

Even though this function makes types of two recursive calls to itself, there is very little local storage allocated on the stack, and that is mainly fragmented into the if() blocks where such storage is used. Therefore, even though this function may recurse for either (a) number of array dimensions, or (b) number of superclasses, in depth, there should never be any real machine stack overflow problems unless the stack is either, (a) unnaturally restricted to a very small size or, (b) a class file is not checked for CONSTANT_MAX_ARRAY_DIMS or, (c) test for superclass circularity is not working properly or, (d) a class has zillions of legitimate superclasses, such as could be created by an automated JVM regression tester.

Parameters:
special_obj Bit-mapped request for various special considerations for object construction. If not needed, use OBJECT_STATUS_EMPTY. If used, the values are:

Parameters:
pcfs Pointer to ClassFile area.
clsidx Class table index for class object linkage.
arraydims If this is an instance of an array object, specifies the number of array dimensions. Always use LOCAL_CONSTANT_NO_ARRAY_DIMS for non-arrays, that is, when OBJECT_STATUS_ARRAY is not set.
arraylength Array of number of elements in each array dimension. Only meaningful when OBJECT_STATUS_ARRAY is set. Okay to be zero in the first dimension, meaning no data in the object's arraydata member (rnull instead).
run_init_ When rtrue, run the object's <init> method with default parameters, otherwise rfalse.
thridx Thread table index associated with this java.lang.Thread object. Meaningful only when OBJECT_STATUS_THREAD is set or when run_init_ is rtrue.
Returns:
Object hash value of allocation. Throw error if no slots.
Exceptions:
JVMCLASS_JAVA_LANG_OUTOFMEMORYERROR if no object slots are available.
JVMCLASS_JAVA_LANG_UNSUPPORTEDCLASSVERSIONERROR if there is an unrecognized array base type.
< This object is a class definition instead of an object instance

< This object is a class definition instead of an object instance

< Object is an array instead of an object instance

< Primative for java.lang.Class < an instance of class '/class/name'

< Object is an array instead of an object instance

< This is a subset of an array, that is, of smaller dimension

Todo:
case needs testing: 0 == arraylength[0]
< Signed byte

< Unicode character

< Double-precision floating-point value

< Single-precision floating-point value

< Integer

< Long integer

< an instance of class '/class/name'

< Signed short

< Boolean, true or false

< Object is an array instead of an object instance

< This is a subset of an array, that is, of smaller dimension

< Object is a java/Lang/Thread < Object is a java/Lang/Thread < References java.lang.Object < Object is a java/Lang/Thread < This slot is available for use

< Not stated in spec, but implied

< NULL object (only 1 exists in normal use, any else besides the JVMCFG_NULL_OBJECT is an object slot now being initialized.)

< (Not in this section of spec, but very relevant)

Definition at line 545 of file object.c.

Referenced by opcode_load_run_throwable(), and opcode_run().

rvoid object_instance_finalize jvm_object_hash  objhash,
jvm_thread_index  thridx
 

Finalize an object instance before deletion.

This invokes an object's finalize() method, if declared, on the specified thread, or on the system thread if jvm_thread_index_null thread given.

Parameters:
objhash Object hash of object to finalize.
thridx Thread table index of thread to run finalize() on.
Returns:
rvoid
< This slot contains an object

< null-terminated string form of METHOD_CHAR_OPEN_PARM

< null-terminated string form of METHOD_CHAR_OPEN_PARM

< null-terminated string form of METHOD_CHAR_VOID

< null-terminated string form of METHOD_CHAR_OPEN_PARM

< null-terminated string form of METHOD_CHAR_OPEN_PARM

< null-terminated string form of METHOD_CHAR_VOID

Definition at line 871 of file object.c.

References jvm_object_hash_null, JVMCFG_MAX_OBJECTS, OBJECT, OBJECT_OBJECT_LINKAGE, OBJECT_STATUS_INUSE, rnull, and rtrue.

jvm_object_hash object_instance_delete jvm_object_hash  objhash,
rboolean  rmref
 

Un-reserve a slot from the object area.

This is the reverse of the process of object_instance_new() above. Only tear down the heap allocations and mark the slot as empty. Leave the rest of the data in place for post-mortem. When the slot gets allocated again, any zeroing out of values will just get overwritten again, so don't bother.

The object_instance_finalize() function MUST be run before calling this function!

Parameters:
objhash Object hash value of allocation.
rmref rtrue if object references should be removed, which is NOT SO during JVM shutdown. Regardless of this value, class references are always removed.
Returns:
Same as input if slot was freed, else jvm_object_hash_null.
< This slot contains an object

Todo:
Is the java.lang.Object.finalize() method (or its subclass) invoked by the actual Java code when an object reference is removed? Is this a GC function? Where should this method be called when tearing down this object?
< Object is an array instead of an object instance

< This is a subset of an array, that is, of smaller dimension

< Object is an array instead of an object instance

< This is a subset of an array, that is, of smaller dimension

< This slot contains an object

< This slot contains an object

Definition at line 1016 of file object.c.

References GC_OBJECT_RMREF_FROM_OBJECT, and OBJECT.

rboolean objectutil_synchronize jvm_object_hash  objhashthis,
jvm_thread_index  thridx
 

Attempt to synchronize() on an object's monitor lock by contending for it.

If acquired, stay in the RUNNING state. If not, go to the SYNCHRONIZED state and arbitrate for it in the LOCK state.

Parameters:
objhashthis Object table hash of this object.
thridx Thread table index of a thread requesting ownership of this object's monitor lock.
Returns:
rtrue if this thread now owns this object's monitor lock, otherwise rfalse.
Todo:
Make sure IllegalMonitorStateException logic covers all possibilities or needs to be removed.
Todo:
Make sure thread interruption logic below here is working.
Exceptions:
JVMCLASS_JAVA_LANG_NULLPOINTEREXCEPTION if the object hash is the null object, typically due to bad input parameter.
JVMCLASS_JAVA_LANG_ILLEGALMONITORSTATEEXCEPTION if current thread cannot possibly own the object's monitor lock, typically due to bad input parameter.
< This slot contains an object

< NULL object (only 1 exists in normal use, any else besides the JVMCFG_NULL_OBJECT is an object slot now being initialized.)

< Object monitor locked by mlock_thridx

< Object monitor locked by mlock_thridx

< Access structures of the thread now running in the JVM.

< Object monitor locked by mlock_thridx

< Access structures of the thread now running in the JVM.

< Access structures of the thread now running in the JVM.

< thread threw a java.lang.Exception (but NOT a java.lang.Error). The object type is found in pThrowableEvent and is not rnull.

Definition at line 102 of file objectutil.c.

References CURRENT_THREAD, jvm_object_hash_null, JVMCLASS_JAVA_LANG_ILLEGALMONITORSTATEEXCEPTION, JVMCLASS_JAVA_LANG_NULLPOINTEREXCEPTION, OBJECT, OBJECT_STATUS_INUSE, OBJECT_STATUS_MLOCK, OBJECT_STATUS_NULL, rfalse, rtrue, THREAD, THREAD_STATUS_THREW_EXCEPTION, thread_throw_exception(), and threadstate_request_synchronized().

Referenced by opcode_run().

rvoid objectutil_unsynchronize jvm_object_hash  objhashthis,
jvm_thread_index  thridx
 

Release synchronize from an object monitor lock.

Parameters:
objhashthis Object table hash of this object.
thridx Thread table index of a thread requesting to remove this object's monitor lock.
Attention:
Notice that the locktarget is NOT cleared here! This is so that the value may be retained until the thread successfully arbitrates for ownership again in threadstate_process_lock(). Once the MLOCK is reacquired there, the locktarget will have been cleared by objectutil_synchronize(). The purpose of objectutil_release() is to provide an avenue in the RUNNING state to release an MLOCK and set up locktarget for the WAIT, NOTIFY, LOCK, ACQUIRE process.
Returns:
rvoid
Todo:
Make sure thread interruption logic below here is working.
Exceptions:
JVMCLASS_JAVA_LANG_ILLEGALMONITORSTATEEXCEPTION if current thread does not own the object's monitor lock.
< This slot contains an object

< NULL object (only 1 exists in normal use, any else besides the JVMCFG_NULL_OBJECT is an object slot now being initialized.)

Todo:
Should the not INUSE condition cause INTERNALERROR?
< Access structures of the thread now running in the JVM.

< thread threw a java.lang.Exception (but NOT a java.lang.Error). The object type is found in pThrowableEvent and is not rnull.

< Object monitor locked by mlock_thridx

< Object monitor locked by mlock_thridx

< Access structures of the thread now running in the JVM.

< thread threw a java.lang.Exception (but NOT a java.lang.Error). The object type is found in pThrowableEvent and is not rnull.

Definition at line 240 of file objectutil.c.

Referenced by opcode_run().

rboolean objectutil_release jvm_object_hash  objhashthis,
jvm_thread_index  thridx
 

Attempt to wait() on an object's monitor lock by releasing it and requesting RELEASE state.

Save the MLOCK to be released for subsequent processing by threadstate_request_release().

Parameters:
objhashthis Object table hash of this object.
thridx Thread table index of a thread requesting to release this object's monitor lock.
Returns:
the result of threadstate_request_release()

Definition at line 326 of file objectutil.c.

Referenced by jlObject_wait4ever().


Generated on Fri Sep 30 18:50:14 2005 by  doxygen 1.4.4