00001 #ifndef _jvm_h_included_ 00002 #define _jvm_h_included_ 00003 00004 /*! 00005 * @file jvm.h 00006 * 00007 * @brief Definition of the Java Virtual Machine structures running on 00008 * this real machine implementation. 00009 * 00010 * Everything about the state of the machine is stored here unless it 00011 * is stored out in the Java code, which is in the heap. 00012 * 00013 * The JVM specification is available from Sun Microsystems' web site 00014 * at http://java.sun.com/docs/books/vmspec/index.html and 00015 * may be read online at 00016 http://java.sun.com/docs/books/vmspec/2nd-edition/html/VMSpecTOC.doc.html 00017 * 00018 * The Java 5 class file format is available as a PDF file separately at 00019 http://java.sun.com/docs/books/vmspec/2nd-edition/ClassFileFormat-final-draft.pdf 00020 * and was the basis for the ClassFile structure of this implementation. 00021 * 00022 * 00023 * @todo Need to verify which web document for the 00024 * Java 5 class file definition is either "official", 00025 * actually correct, or is the <em>de facto</em> standard. 00026 * 00027 * 00028 * @section Control 00029 * 00030 * \$URL: https://svn.apache.org/path/name/jvm.h $ \$Id: jvm.h 0 09/28/2005 dlydick $ 00031 * 00032 * Copyright 2005 The Apache Software Foundation 00033 * or its licensors, as applicable. 00034 * 00035 * Licensed under the Apache License, Version 2.0 ("the License"); 00036 * you may not use this file except in compliance with the License. 00037 * You may obtain a copy of the License at 00038 * 00039 * http://www.apache.org/licenses/LICENSE-2.0 00040 * 00041 * Unless required by applicable law or agreed to in writing, 00042 * software distributed under the License is distributed on an 00043 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 00044 * either express or implied. 00045 * 00046 * See the License for the specific language governing permissions 00047 * and limitations under the License. 00048 * 00049 * @version \$LastChangedRevision: 0 $ 00050 * 00051 * @date \$LastChangedDate: 09/28/2005 $ 00052 * 00053 * @author \$LastChangedBy: dlydick $ 00054 * Original code contributed by Daniel Lydick on 09/28/2005. 00055 * 00056 * @section Reference 00057 * 00058 */ 00059 00060 ARCH_COPYRIGHT_APACHE(jvm, h, "$URL: https://svn.apache.org/path/name/jvm.h $ $Id: jvm.h 0 09/28/2005 dlydick $"); 00061 00062 00063 #include <pthread.h> /* For mutex(3THR) functions */ 00064 #include <setjmp.h> /* For jmp_buf structure for setjmp(3)/longjmp(3)*/ 00065 00066 #include "jvalue.h" 00067 #include "class.h" 00068 #include "object.h" 00069 #include "thread.h" 00070 00071 00072 /*! 00073 * @brief Define a JVM model 00074 * 00075 * This model has all the usual components, a program counter, 00076 * a stack pointer and stack area, and thread defintions. 00077 */ 00078 typedef struct 00079 { 00080 /* 00081 * External structures from command line into main(argc, argv, envp) 00082 */ 00083 00084 /* Command line parms */ 00085 int argc; /**< Direct copy of main(argc,,) */ 00086 char **argv; /**< Direct copy of main(,argv,) */ 00087 char **envp; /**< Direct copy of main(,,envp) */ 00088 00089 /* Slices of command line parms */ 00090 char *argv0; /**< Program name, @p @b argv[0] in 'C', 00091 $0 in @b sh */ 00092 00093 char *argv0name; /**< Program name argv0,but without path 00094 component*/ 00095 00096 int argcj; /**< Index of argv[] passed to JVM main(). */ 00097 00098 char **argvj; /**< Portion of argv[] passed to JVM main(). 00099 * Should @b never be @link #rnull rnull@endlink, 00100 * but zero args will have argvj[0] as 00101 * @link #rnull rnull@endlink, which always 00102 * follows last parm (eg, if 3 args, then 00103 * argvj[3] == @link #rnull rnull@endlink) */ 00104 00105 /* Debug message level (verbosity) */ 00106 jvm_debug_level_enum debug_message_level; /**< Verbosity of 00107 debug messages in code */ 00108 00109 /* Environment */ 00110 rchar *java_home; /**< @b JAVA_HOME environment variable */ 00111 00112 rchar *classpath; /**< @b CLASSPATH environment variable */ 00113 00114 rchar *bootclasspath; /**< @b BOOTCLASSPATH environment variable */ 00115 00116 00117 00118 /* Will use only @e one of these two startup modes: */ 00119 rchar *startclass;/**< Internal name of JVM start class, 00120 as @c @b Lstart/class/name; */ 00121 00122 rchar *startjar; /**< Name of JAR file containing start class, 00123 if any, else @link #rnull rnull@endlink. */ 00124 00125 volatile rboolean timeslice_expired; /**< JVM time slice 00126 * processing-- use only ONE mutex for 00127 * inter-thread control of @e all thread sleep 00128 * timers. @p @b timeslice_expired is not mutexed 00129 * as a producer-consumer item of a single 00130 * @c @b volatile byte. 00131 * 00132 * @todo Verify this is okay. The @link 00133 rthread#sleeptime rthread.sleeptime@endlink 00134 * item is a multi-byte integer, and so could be 00135 * unsafe if not mutexed. (It is still made 00136 * @c @b volatile just to raise the 00137 * awareness of users to this issue.) 00138 */ 00139 00140 rbyte unused2[3]; /**< 4-byte alignment */ 00141 00142 pthread_mutex_t sleeplock; /**< Thread-safe read/update mechanism 00143 * for @link rthread#sleeptime 00144 rthread.sleeptime@endlink. See 00145 * @link jvm/src/timeslice.c 00146 timeslice.c@endlink for details. 00147 */ 00148 00149 00150 /* 00151 * Thread area structures, including program counter 00152 * and stack pointer 00153 */ 00154 00155 00156 /* 00157 * Thread being examined by JVM at the current time 00158 * Typically accessed as CURRENT_THREAD 00159 */ 00160 jvm_thread_index current_thread; /**< Thread being manipulated by 00161 * JVM at the current time. 00162 * Typically accessed as 00163 * @link #CURRENT_THREAD 00164 CURRENT_THREAD@endlink 00165 */ 00166 00167 rulong jvm_instruction_count; /**< Total number of virtual 00168 * instructions run by the JVM. 00169 * See also (rthread) 00170 * @p @b thread_instruction_count 00171 * and 00172 * @p @b pass_instruction_count 00173 */ 00174 00175 jvm_thread_index thread_new_last; /**< Last thread slot to be 00176 allocated by thread_new() */ 00177 00178 rthread thread[JVMCFG_MAX_THREADS]; /**< Table of java.lang.Thread 00179 * structures. Indexed by 00180 * @link #jvm_thread_index 00181 jvm_thread_index @endlink 00182 * integers. Typically accessed 00183 * as @link #THREAD() 00184 THREAD(index) @endlink */ 00185 00186 00187 /* 00188 * Class area structures 00189 */ 00190 00191 jvm_class_index class_allocate_last; /**< Last class slot to be 00192 * allocated by 00193 * class_static_new() */ 00194 00195 00196 rclass class[JVMCFG_MAX_CLASSES]; /**< Table of java.lang.Class 00197 * structures. Indexed by 00198 * @link #jvm_class_index 00199 jvm_class_index @endlink 00200 * integers. Typically accessed 00201 * as @link #CLASS() 00202 CLASS(index)@endlink */ 00203 00204 00205 /* 00206 * Object area structures 00207 */ 00208 00209 jvm_object_hash object_allocate_last; /**< Last object slot to be 00210 * allocated by 00211 * object_instance_new() */ 00212 00213 robject object[JVMCFG_MAX_OBJECTS]; /**< Table of java.lang.Object 00214 * structures. Indexed by 00215 * @link #jvm_object_hash 00216 jvm_object_hash @endlink 00217 * integers. Typically accessed 00218 * as @link #OBJECT() 00219 OBJECT(index) @endlink. 00220 * 00221 * The @link #jvm_object_hash 00222 jvm_object_hash @endlink 00223 * index is @e also absolutely 00224 * identical to a Java object 00225 * reference and a Java array 00226 * dimension reference. */ 00227 00228 } rjvm; 00229 00230 extern rjvm *pjvm; /**< Declared in @link #pjvm jvm.c @endlink */ 00231 00232 00233 00234 /* Prototypes for functions in 'jvm.c' */ 00235 00236 extern rvoid jvm_manual_thread_run(jvm_thread_index thridx, 00237 rboolean shutdown, 00238 rchar *clsname, 00239 rchar *mthname, 00240 rchar *mthdesc); 00241 00242 extern rint jvm(int argc, char **argv, char **envp); 00243 00244 #endif /* _jvm_h_included_ */ 00245 00246 /* EOF */ 00247