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

linkage.h

Go to the documentation of this file.
00001 #ifndef _linkage_h_included_
00002 #define _linkage_h_included_
00003 
00004 /*!
00005  * @file linkage.h
00006  *
00007  * @brief Runtime linkages between major data structures.
00008  *
00009  * Of particular interest are the linkages between thread, class,
00010  * and object areas.
00011  *
00012  * Several useful macros are defined here.  They are used to associate
00013  * an object instance with its ClassFile structure, its class
00014  * definition, and its thread definition, where applicable.
00015  *
00016  * The macro CLASS_OBJECT_LINKAGE() associates a class definition with
00017  * its object instance.  The macro OBJECT_CLASS_LINKAGE() associates
00018  * an object instance with its class definition.
00019  *
00020  * The macro THREAD_OBJECT_LINKAGE() associates a thread definition with
00021  * its object instance.  The macro OBJECT_THREAD_LINKAGE() associates
00022  * an object instance with its thread definition.  This functionality
00023  * is @e only meaningful when the object is a
00024  * <b><code>java.lang.Thread</code></b>.
00025  *
00026  * The information stored in that object table entry points to both
00027  * the ClassFile storage for that class and to the class table entry
00028  * for that class.
00029  *
00030  * @section Control
00031  *
00032  * \$URL: https://svn.apache.org/path/name/linkage.h $ \$Id: linkage.h 0 09/28/2005 dlydick $
00033  *
00034  * Copyright 2005 The Apache Software Foundation
00035  * or its licensors, as applicable.
00036  *
00037  * Licensed under the Apache License, Version 2.0 ("the License");
00038  * you may not use this file except in compliance with the License.
00039  * You may obtain a copy of the License at
00040  *
00041  *     http://www.apache.org/licenses/LICENSE-2.0
00042  *
00043  * Unless required by applicable law or agreed to in writing,
00044  * software distributed under the License is distributed on an
00045  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
00046  * either express or implied.
00047  *
00048  * See the License for the specific language governing permissions
00049  * and limitations under the License.
00050  *
00051  * @version \$LastChangedRevision: 0 $
00052  *
00053  * @date \$LastChangedDate: 09/28/2005 $
00054  *
00055  * @author \$LastChangedBy: dlydick $
00056  *         Original code contributed by Daniel Lydick on 09/28/2005.
00057  *
00058  * @section Reference
00059  *
00060  */
00061 
00062 ARCH_COPYRIGHT_APACHE(linkage, h, "$URL: https://svn.apache.org/path/name/linkage.h $ $Id: linkage.h 0 09/28/2005 dlydick $");
00063 
00064 
00065 /*!
00066  * @def CLASS_OBJECT_LINKAGE()
00067  *
00068  * @brief Retrieve class information about a class from its
00069  * class object.
00070  *
00071  * @param  clsidx     Class table index of class definition for which
00072  *                    to locate its class definition
00073  *                   @link #jvm_table_linkage jvm_table_linkage@endlink.
00074  *
00075  *
00076  * @returns (jvm_table_linkage *) to object table class linkage entry
00077  *
00078  */
00079 #define CLASS_OBJECT_LINKAGE(clsidx) \
00080                 (&OBJECT(CLASS(clsidx).class_objhash).table_linkage)
00081 
00082 /*!
00083  * @def OBJECT_CLASS_LINKAGE()
00084  *
00085  * @brief Retrieve class information about an object from its
00086  * class.
00087  *
00088  * @param  objhash    Object hash of object for which to locate its
00089  *                    class table entry.
00090  *
00091  * @returns (jvm_table_linkage *) to object table class linkage entry
00092  *
00093  */
00094 
00095 #define OBJECT_CLASS_LINKAGE(objhash) (&OBJECT(objhash).table_linkage)
00096 
00097 
00098 /* Now the thread definitions: */
00099 
00100 /*!
00101  * @def VERIFY_THREAD_LINKAGE()
00102  *
00103  * @brief Verify that a thread slot is in use, is not a null thread,
00104  * and contains a valid, non-null, thread object hash that is
00105  * definitely marked as a thread object
00106  *
00107  * @param  thridx     Thread table index of thread to verify its
00108  *                    thread table entry.
00109  *
00110  *
00111  * @returns @link #rtrue rtrue@endlink if this thread index indicates
00112  * a valid thread table slot, otherwise @link #rfalse rfalse@endlink.
00113  *
00114  */
00115 #define VERIFY_THREAD_LINKAGE(thridx)                            \
00116    (((thridx != jvm_thread_index_null) &&                        \
00117      (THREAD(thridx).status & THREAD_STATUS_INUSE) &&            \
00118      (!(THREAD(thridx).status & THREAD_STATUS_NULL)) &&          \
00119      (THREAD(thridx).thread_objhash != jvm_object_hash_null)&&   \
00120      (OBJECT(THREAD(thridx).thread_objhash).status &             \
00121                                         OBJECT_STATUS_INUSE) &&  \
00122      (!(OBJECT(THREAD(thridx).thread_objhash).status &           \
00123                                         OBJECT_STATUS_NULL)) &&  \
00124      (OBJECT(THREAD(thridx).thread_objhash).status &             \
00125                                         OBJECT_STATUS_THREAD))   \
00126     ? rtrue                                                      \
00127     : rfalse)
00128 
00129 
00130 /*!
00131  * @def THREAD_OBJECT_LINKAGE()
00132  *
00133  * @brief Retrieve object information about a thread from its
00134  * thread object instance.
00135  *
00136  * @param  thridx     Thread table index of thread definition for which
00137  *                    to locate its class definition
00138  *                   @link #jvm_table_linkage jvm_table_linkage@endlink.
00139  *
00140  *
00141  * @returns (jvm_table_linkage *) to object table class linkage entry
00142  *
00143  *
00144  * @note  This macro will return @link #rnull rnull@endlink if
00145  *        the object hash in this slot is a
00146  *        @link #jvm_thread_index_null jvm_thread_index_null@endlink
00147  *        reference.
00148  *        
00149  */
00150 #define THREAD_OBJECT_LINKAGE(thridx)                         \
00151     ((THREAD(thridx).thread_objhash != jvm_object_hash_null)  \
00152      ? (&OBJECT(THREAD(thridx).thread_objhash).table_linkage) \
00153      : (jvm_table_linkage *) rnull)
00154 
00155 
00156 /*!
00157  * @def OBJECT_THREAD_LINKAGE()
00158  *
00159  * @brief Retrieve thread information about an object from its
00160  * thread entry.
00161  *
00162  *
00163  * @param  objhash    Object hash of object for which to locate its
00164  *                    thread table entry.
00165  *
00166  *
00167  * @returns (jvm_table_linkage *) to object table class linkage entry of
00168  *                               <b><code>java.lang.Thread</code></b>
00169  *                               class object.
00170  *
00171  * @note  This macro will return @link #rnull rnull@endlink if the
00172  * object in this slot is not a <b><code>java.lang.Thread</code></b>
00173  * object and one which indexes a valid thread.
00174  *
00175  */
00176 #define OBJECT_THREAD_LINKAGE(objhash)                                 \
00177     (((OBJECT(objhash).status & OBJECT_STATUS_INUSE) &&                \
00178       (OBJECT(objhash).status & OBJECT_STATUS_THREAD) &&               \
00179       (jvm_thread_index_null != OBJECT(objhash).table_linkage.thridx)) \
00180      ? (&OBJECT(objhash).table_linkage)                                \
00181      : ((jvm_table_linkage *) rnull))
00182 
00183 
00184 /*!
00185  * @def VERIFY_OBJECT_THREAD_LINKAGE()
00186  *
00187  * @brief Verify that a thread slot is in use, is not a null thread,
00188  * and contains a valid thread object hash.
00189  *
00190  * @param  objhash    Object hash of object for which to verify its
00191  *                    thread linkage and its thread table entry.
00192  *
00193  *
00194  * @returns @link #rtrue rtrue@endlink if this object hash indicates
00195  * a valid thread linkage and a thread table slot, otherwise
00196  * @link #rfalse rfalse@endlink.
00197  *
00198  */
00199 #define VERIFY_OBJECT_THREAD_LINKAGE(objhash)   \
00200    ((rnull != (OBJECT_THREAD_LINKAGE(objhash))) \
00201     ? rtrue                                     \
00202     : rfalse)
00203 
00204 
00205 /* Finally the object self-referential definitions: */
00206 
00207 /*!
00208  * @def OBJECT_OBJECT_LINKAGE()
00209  *
00210  * @brief Retrieve object information about an object from itself.
00211  *
00212  * @param  objhash    Object hash of object for which
00213  *                    to locate its class definition
00214  *                   @link #jvm_table_linkage jvm_table_linkage@endlink.
00215  *
00216  *
00217  * @returns (jvm_table_linkage *) to object table class linkage entry
00218  *
00219  *
00220  * @note  This macro will return @link #rnull rnull@endlink if the
00221  *        object hash in this slot is a
00222  *        @link #jvm_object_hash_null jvm_object_hash_null@endlink
00223  *        reference.
00224  *
00225  */
00226 
00227 #define OBJECT_OBJECT_LINKAGE(objhash)             \
00228     ((OBJECT(objhash).status & OBJECT_STATUS_INUSE) \
00229      ? (&OBJECT(objhash).table_linkage)             \
00230      : (jvm_table_linkage *) rnull)
00231 
00232 
00233 /* Prototypes for functions in 'linkage.c' */
00234 extern rboolean linkage_resolve_class(jvm_class_index clsidx,
00235                                       rboolean    find_registerNatives);
00236 
00237 extern rboolean linkage_unresolve_class(jvm_class_index clsidx);
00238 
00239 #endif /* _linkage_h_included_ */
00240 
00241 
00242 /* EOF */
00243 

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