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

class.h

Go to the documentation of this file.
00001 #ifndef _class_h_included_
00002 #define _class_h_included_
00003 
00004 /*!
00005  * @file class.h
00006  *
00007  * @brief Definition of the @c @b java.lang.Class structure in
00008  * this real machine implementation.
00009  *
00010  * The definition of a class index is found here, as is the
00011  * definition of a class.  When initializing an class,
00012  * the following activities happen in the class array:
00013  *
00014  * <b>(1)</b> Its class index is used to address an empty slot in
00015  *            the class storage area.
00016  *
00017  * <b>(2)</b> Since it is not a
00018               @link #jvm_class_index_null jvm_class_index_null@endlink
00019  *            value, its
00020  *            @link rclass#status status@endlink is set to
00021  *            @link #CLASS_STATUS_INUSE CLASS_STATUS_INUSE@endlink,
00022  *            with an @c @b |
00023               @link #OBJECT_STATUS_ARRAY OBJECT_STATUS_ARRAY@endlink
00024  *            if it is an array type.  All other bits are clear.
00025  *
00026  * <b>(3)</b> Allocate an object table slot that references this class
00027  *            table slot.  This a class definition can be references
00028  *            using an object hash.
00029  *
00030  * <b>(4)</b> Recursively define array class types.
00031  *
00032  *
00033  * @section Control
00034  *
00035  * \$URL: https://svn.apache.org/path/name/class.h $ \$Id: class.h 0 09/28/2005 dlydick $
00036  *
00037  * Copyright 2005 The Apache Software Foundation
00038  * or its licensors, as applicable.
00039  *
00040  * Licensed under the Apache License, Version 2.0 ("the License");
00041  * you may not use this file except in compliance with the License.
00042  * You may obtain a copy of the License at
00043  *
00044  *     http://www.apache.org/licenses/LICENSE-2.0
00045  *
00046  * Unless required by applicable law or agreed to in writing,
00047  * software distributed under the License is distributed on an
00048  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
00049  * either express or implied.
00050  *
00051  * See the License for the specific language governing permissions
00052  * and limitations under the License.
00053  *
00054  * @version \$LastChangedRevision: 0 $
00055  *
00056  * @date \$LastChangedDate: 09/28/2005 $
00057  *
00058  * @author \$LastChangedBy: dlydick $
00059  *         Original code contributed by Daniel Lydick on 09/28/2005.
00060  *
00061  * @section Reference
00062  *
00063  */
00064 
00065 ARCH_COPYRIGHT_APACHE(class, h, "$URL: https://svn.apache.org/path/name/class.h $ $Id: class.h 0 09/28/2005 dlydick $");
00066 
00067 
00068 #include "object.h"
00069 
00070 /*!
00071  * @def CLASS
00072  * @brief Access structures of class table at certain index.
00073  *
00074  * The class table, being an array of slots, provides space for
00075  * one class definition per slot.  This macro references one of
00076  * them using the @p @b clsidx index.
00077  *
00078  * @param clsidx  Class table index into the global
00079  * @link #rjvm.class rjvm.class[]@endlink array (via
00080  * @link #pjvm pjvm->class[]@endlink).
00081  * 
00082  * @returns pointer to a class slot
00083  */
00084 #define CLASS(clsidx) pjvm->class[clsidx]
00085 
00086 /*!
00087  * @brief General class slot definition.
00088  */
00089 typedef struct
00090 {
00091     rushort status;      /*!< Runtime status of class, bitwise */
00092 
00093 
00094 /*!
00095  * @name Class status bits
00096  *
00097  * @brief Bitwise status bits for the status of a class slot.
00098  *
00099  * These class status bits have direct
00100  * @link #OBJECT_STATUS_EMPTY OBJECT_STATUS_xxx@endlink equivalents and
00101  * a few @link #THREAD_STATUS_EMPTY THREAD_STATUS_xxx@endlink
00102  * equivalents also. There are no overloaded bit positions between them
00103  * (for ease of diagnostics).
00104  */
00105 
00106 /*@{ */ /* Begin grouped definitions */
00107 
00108 /****** First 3 bits same for class, object, and thread ***********/
00109 #define CLASS_STATUS_EMPTY    0x0000 /**< This slot is available for
00110                                           use*/
00111 #define CLASS_STATUS_INUSE    0x0001 /**< This slot contains a class */
00112 #define CLASS_STATUS_NULL     0x0002 /**< NULL class slot.
00113                                       * <em>Exactly on</em> exists
00114                                       * in normal use, any else besides
00115                                       * the @link #JVMCFG_NULL_CLASS
00116                                         JVMCFG_NULL_CLASS@endlink
00117                                       * is a class slot now
00118                                       * being initialized. */
00119 /******************************************************************/
00120 
00121 /****** Next 2 bits same for class and object *********************/
00122 #define CLASS_STATUS_GCREQ    0x0004 /**< Class may be garbage
00123                                           collected. */
00124 #define CLASS_STATUS_ARRAY    0x0008 /**< Class is an array type where
00125                                           @p @b arraydims contains
00126                                           number of dimensions */
00127 /******************************************************************/
00128 
00129 /****** Next 5 bits unique between class and object except: *******/
00130 
00131 #define CLASS_STATUS_REFERENCE 0x0080 /**< Class variable is a
00132                                        * reference.  This is the
00133                                        * @e same definition as for
00134                                        * @link #OBJECT_STATUS_REFERENCE
00135                                          OBJECT_STATUS_REFERENCE@endlink
00136                                        *  and for
00137                                        * @link #LOCAL_STATUS_REFERENCE
00138                                          LOCAL_STATUS_REFERENCE@endlink,
00139                                        * the local variable reference
00140                                        * bit for variables on the stack
00141                                        * frame, where the GC algorithm
00142                                        * implements it.
00143                                        */
00144 
00145 /******************************************************************/
00146 
00147 /****** Next 4 bits unique between class and object ***************/
00148 #define CLASS_STATUS_PRIMATIVE 0x0200 /**< Primative for
00149                                       @c @b java.lang.Class */
00150 #define CLASS_STATUS_LINKED   0x0400 /**< Class linkages completed */
00151 #define CLASS_STATUS_DOCLINIT 0x0800 /**< Class loaded,
00152                                       * needs @c @b <clinit> */
00153 #define CLASS_STATUS_CLINIT   0x1000 /**< Class loaded, initialized, 
00154                                       * and ready to allocate
00155                                       * instances */
00156 /******************************************************************/
00157 
00158 /****** Last 3 bits not used by class or object *******************/
00159 #define CLASS_STATUS_2000     0x2000 /**< not used */
00160 #define CLASS_STATUS_4000     0x4000 /**< not used */
00161 #define CLASS_STATUS_8000     0x8000 /**< not used */
00162 /******************************************************************/
00163 
00164 /*@} */ /* End of grouped definitions */
00165 
00166     u1 unused1;          /**< Not used, keep 2-byte alignment */
00167 
00168     jvm_array_dim arraydims; /**< Number of array dimensions,
00169                           * meaningful only when @link
00170                           #CLASS_STATUS_ARRAY CLASS_STATUS_ARRAY@endlink
00171                           * is set */
00172 
00173 
00174     jint *arraylength;   /**<  Array of length @p @b arraydims
00175                           * containing the length of array in each of
00176                           * those dimensions.  E.g., @b arraydims is
00177                           * 4 for new X[7][3][9][2] so this parameter
00178                           * will be a 4-element array containing the
00179                           * numbers {7, 3, 9, 2} */
00180 
00181     jvm_class_index  lower_dim_array; /**< Class table index of
00182                           * version of this class with one fewer array
00183                           * dimensions, meaningful only when @link
00184                           #CLASS_STATUS_ARRAY CLASS_STATUS_ARRAY@endlink
00185                           * is set. */
00186 
00187     jvm_object_hash  class_objhash; /**< Object table hash used to
00188                                          find this slot */
00189 
00190     u2 num_class_static_field_lookups; /**< size of
00191                           * @p @b class_static_field_lookup
00192                           * field lookup array[] for class static fields
00193                           */
00194 
00195     jvm_field_index *class_static_field_lookup; /**< field lookup
00196                           * array[] for class static fields.
00197                           * Indexed by @link #jvm_field_lookup_index
00198                             jvm_field_lookup_index@endlink
00199                           */
00200 
00201     jvalue *class_static_field_data; /**< field lookup array[] for
00202                           * class static fields.
00203                           * Indexed by @link #jvm_field_lookup_index
00204                             jvm_field_lookup_index@endlink
00205                           */
00206 
00207 
00208 
00209     u2 num_object_instance_field_lookups; /**< size of
00210                           * @p @b object_instance_field_lookup
00211                           * field lookup array[] for object instance
00212                           * fields */
00213 
00214     jvm_field_index *object_instance_field_lookup; /**< field lookup
00215                           * array[] for object instance fields.
00216                           * The jvalue array[] for each object may
00217                           * be found in @link
00218                             #robject.object_instance_field_data
00219                              robject.object_instance_field_data@endlink
00220                           * instead of here in order to have unique
00221                           * values for each and every object.  (This is
00222                           * over and against the class static field
00223                           * array[] here in this structure.)
00224                           * Indexed by @link #jvm_field_lookup_index
00225                             jvm_field_lookup_index@endlink
00226                           */
00227 
00228 
00229     jvm_class_index initiating_ClassLoader; /**<Object table hash
00230                           * of initiating @c @b ClassLoader */
00231 
00232     jvm_class_index defining_ClassLoader; /**< Object table hash
00233                           * of defining @c @b ClassLoader */
00234 
00235     rvoid          *pgarbage; /**< Garbage collection profile of
00236                           * this class.  An @link #rvoid rvoid@endlink
00237                           * pointer is used here to avoid linking this
00238                           * structure to any particular GC
00239                           * implementation.
00240                           */
00241 
00242 } rclass;
00243 
00244 /* Prototypes for functions in 'class.c' */
00245 extern rvoid           class_init(rvoid);
00246 extern rvoid           class_shutdown_1(rvoid);
00247 extern rvoid           class_shutdown_2(rvoid);
00248 extern jvm_class_index class_static_new(rushort          status_req,
00249                                         ClassFile       *pcfs,
00250                                         jvm_array_dim    arraydims,
00251                                         jint            *arraylength,
00252                                        jvm_class_index lower_dim_array);
00253 extern jvm_class_index class_reload(jvm_class_index clsidxOLD);
00254 extern jvm_class_index class_static_delete(jvm_class_index clsidx,
00255                                            rboolean        rmref);
00256 extern jvm_class_index class_find_by_cp_entry(cp_info_dup *clsname);
00257 extern jvm_class_index class_find_by_prchar(rchar *clsname);
00258 extern jvm_class_index class_load_primative(u1 basetype);
00259 extern jvm_class_index class_load_from_prchar(rchar    *clsname,
00260                                               rboolean
00261                                                    find_registerNatives,
00262                                               jint     *arraylength);
00263 extern jvm_class_index class_load_from_cp_entry_utf(
00264                                              cp_info_dup *clsname,
00265                                              rboolean
00266                                                    find_registerNatives,
00267                                              jint        *arraylength);
00268 
00269 extern jvm_class_index class_load_resolve_clinit(
00270                                           rchar        *clsname,
00271                                        jvm_thread_index thridx,
00272                                           rboolean      usesystemthread,
00273                                          rboolean find_registerNatives);
00274 
00275 extern u2               class_get_num_static_fields(ClassFile *pcfs);
00276 extern jvm_class_index *class_get_static_field_lookups(
00277                                               ClassFile *pcfs);
00278 extern jvalue          *class_get_static_field_data(
00279                                         jvm_class_index  clsidx,
00280                                               ClassFile *pcfs);
00281 
00282 extern u2               class_get_num_object_instance_fields(
00283                                                        ClassFile *pcfs);
00284 extern jvm_class_index *class_get_object_instance_field_lookups(
00285                                                        ClassFile *pcfs);
00286 extern jvalue          *class_get_object_instance_field_data(
00287                                         jvm_class_index  clsidx,
00288                                         jvm_object_hash  objhash,
00289                                               ClassFile *pcfs);
00290 
00291 /* Prototypes for functions in 'classutil.c' */
00292 extern jvm_class_index classutil_jobject2clsidx(jvm_object_hash
00293                                                                objhash);
00294 #endif /* _class_h_included_ */
00295 
00296 
00297 /* EOF */
00298 

Generated on Fri Sep 30 18:49:00 2005 by  doxygen 1.4.4