diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-09 19:58:05 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-09 19:58:05 +0000 |
commit | 65bf3316cf384588453604be6b4f0ed3751a8b0f (patch) | |
tree | 996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/include | |
parent | 8fc56618a84446beccd45b80381cdfe0e94050df (diff) | |
download | gcc-65bf3316cf384588453604be6b4f0ed3751a8b0f.tar.gz |
Merged gcj-eclipse branch to trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120621 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/include')
-rw-r--r-- | libjava/include/Makefile.in | 17 | ||||
-rw-r--r-- | libjava/include/config.h.in | 12 | ||||
-rw-r--r-- | libjava/include/java-cpool.h | 1 | ||||
-rw-r--r-- | libjava/include/java-interp.h | 27 | ||||
-rw-r--r-- | libjava/include/java-stack.h | 29 | ||||
-rw-r--r-- | libjava/include/jvm.h | 128 | ||||
-rw-r--r-- | libjava/include/posix-threads.h | 56 | ||||
-rw-r--r-- | libjava/include/posix.h | 7 | ||||
-rw-r--r-- | libjava/include/win32-threads.h | 23 | ||||
-rw-r--r-- | libjava/include/win32.h | 3 |
10 files changed, 239 insertions, 64 deletions
diff --git a/libjava/include/Makefile.in b/libjava/include/Makefile.in index 26c8ce9a582..6ebb3b4feb2 100644 --- a/libjava/include/Makefile.in +++ b/libjava/include/Makefile.in @@ -90,6 +90,8 @@ AWK = @AWK@ BACKTRACESPEC = @BACKTRACESPEC@ BASH_JAR_FALSE = @BASH_JAR_FALSE@ BASH_JAR_TRUE = @BASH_JAR_TRUE@ +BUILD_ECJ1_FALSE = @BUILD_ECJ1_FALSE@ +BUILD_ECJ1_TRUE = @BUILD_ECJ1_TRUE@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -109,7 +111,11 @@ DIVIDESPEC = @DIVIDESPEC@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ +ECJ_BUILD_JAR = @ECJ_BUILD_JAR@ +ECJ_JAR = @ECJ_JAR@ EGREP = @EGREP@ +ENABLE_SHARED_FALSE = @ENABLE_SHARED_FALSE@ +ENABLE_SHARED_TRUE = @ENABLE_SHARED_TRUE@ EXCEPTIONSPEC = @EXCEPTIONSPEC@ EXEEXT = @EXEEXT@ GCC_UNWIND_INCLUDE = @GCC_UNWIND_INCLUDE@ @@ -120,6 +126,7 @@ GCJDEPMODE = @GCJDEPMODE@ GCJFLAGS = @GCJFLAGS@ GCJH = @GCJH@ GCJVERSION = @GCJVERSION@ +GCJ_FOR_ECJX = @GCJ_FOR_ECJX@ GCLIBS = @GCLIBS@ GCSPEC = @GCSPEC@ GCTESTSPEC = @GCTESTSPEC@ @@ -131,6 +138,8 @@ HASH_SYNC_SPEC = @HASH_SYNC_SPEC@ IEEESPEC = @IEEESPEC@ INCLTDL = @INCLTDL@ INSTALL_DATA = @INSTALL_DATA@ +INSTALL_ECJ_JAR_FALSE = @INSTALL_ECJ_JAR_FALSE@ +INSTALL_ECJ_JAR_TRUE = @INSTALL_ECJ_JAR_TRUE@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ @@ -139,6 +148,8 @@ JAR = @JAR@ JAVA_HOME = @JAVA_HOME@ JAVA_HOME_SET_FALSE = @JAVA_HOME_SET_FALSE@ JAVA_HOME_SET_TRUE = @JAVA_HOME_SET_TRUE@ +JAVA_MAINTAINER_MODE_FALSE = @JAVA_MAINTAINER_MODE_FALSE@ +JAVA_MAINTAINER_MODE_TRUE = @JAVA_MAINTAINER_MODE_TRUE@ JC1GCSPEC = @JC1GCSPEC@ LD = @LD@ LDFLAGS = @LDFLAGS@ @@ -157,6 +168,7 @@ LIBGCJ_LD_SYMBOLIC = @LIBGCJ_LD_SYMBOLIC@ LIBGCJ_SPEC = @LIBGCJ_SPEC@ LIBICONV = @LIBICONV@ LIBLTDL = @LIBLTDL@ +LIBMAGIC = @LIBMAGIC@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ @@ -181,7 +193,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ -PLATFORM_INNER_NAT_HDRS = @PLATFORM_INNER_NAT_HDRS@ +PLATFORM = @PLATFORM@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ @@ -223,6 +235,8 @@ USING_WIN32_THREADS_TRUE = @USING_WIN32_THREADS_TRUE@ VERSION = @VERSION@ XLIB_AWT_FALSE = @XLIB_AWT_FALSE@ XLIB_AWT_TRUE = @XLIB_AWT_TRUE@ +X_AWT_FALSE = @X_AWT_FALSE@ +X_AWT_TRUE = @X_AWT_TRUE@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ @@ -268,6 +282,7 @@ here = @here@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ +host_exeext = @host_exeext@ host_os = @host_os@ host_subdir = @host_subdir@ host_vendor = @host_vendor@ diff --git a/libjava/include/config.h.in b/libjava/include/config.h.in index a8ebfade662..3b6e891af3d 100644 --- a/libjava/include/config.h.in +++ b/libjava/include/config.h.in @@ -1,5 +1,8 @@ /* include/config.h.in. Generated from configure.ac by autoheader. */ +/* Name of default AWT toolkit */ +#undef AWT_TOOLKIT + /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ @@ -181,6 +184,12 @@ /* Define to 1 if you have the `lstat' function. */ #undef HAVE_LSTAT +/* Define to 1 if you have the <magic.h> header file. */ +#undef HAVE_MAGIC_H + +/* Define if you have magic_open(). */ +#undef HAVE_MAGIC_OPEN + /* Define to 1 if you have the `memcpy' function. */ #undef HAVE_MEMCPY @@ -390,6 +399,9 @@ /* Define if we want to use debug calls into the garbage collector. */ #undef LIBGCJ_GC_DEBUG +/* Installation prefix */ +#undef LIBGCJ_PREFIX + /* Define if using POSIX threads on Linux. */ #undef LINUX_THREADS diff --git a/libjava/include/java-cpool.h b/libjava/include/java-cpool.h index c636e4c6bca..412250230df 100644 --- a/libjava/include/java-cpool.h +++ b/libjava/include/java-cpool.h @@ -28,6 +28,7 @@ details. */ #define JV_CONSTANT_InterfaceMethodref (11L) #define JV_CONSTANT_NameAndType (12L) #define JV_CONSTANT_ResolvedFlag (16L) +#define JV_CONSTANT_LazyFlag (32L) #define JV_CONSTANT_ResolvedString (16L | 8L) #define JV_CONSTANT_ResolvedClass (16L | 7L) diff --git a/libjava/include/java-interp.h b/libjava/include/java-interp.h index 74846c9f6b2..3b15b5cb222 100644 --- a/libjava/include/java-interp.h +++ b/libjava/include/java-interp.h @@ -45,6 +45,12 @@ int _Jv_count_arguments (_Jv_Utf8Const *signature, jboolean staticp = true); void _Jv_VerifyMethod (_Jv_InterpMethod *method); void _Jv_CompileMethod (_Jv_InterpMethod* method); +int _Jv_init_cif (_Jv_Utf8Const* signature, + int arg_count, + jboolean staticp, + ffi_cif *cif, + ffi_type **arg_types, + ffi_type **rtype_p); /* the interpreter is written in C++, primarily because it makes it easy for * the entire thing to be "friend" with class Class. */ @@ -312,18 +318,27 @@ public: // The interpreted call stack, represented by a linked list of frames. struct _Jv_InterpFrame { - _Jv_InterpMethod *self; + union + { + void *meth; + _Jv_InterpMethod *self; + _Jv_Method *proxyMethod; + }; java::lang::Thread *thread; _Jv_InterpFrame *next; - pc_t pc; - - _Jv_InterpFrame (_Jv_InterpMethod *s, java::lang::Thread *thr) + union + { + pc_t pc; + jclass proxyClass; + }; + + _Jv_InterpFrame (void *meth, java::lang::Thread *thr, jclass proxyClass = NULL) { - self = s; + this->meth = meth; thread = thr; next = (_Jv_InterpFrame *) thr->interp_frame; thr->interp_frame = (gnu::gcj::RawData *) this; - pc = NULL; + this->proxyClass = proxyClass; } ~_Jv_InterpFrame () diff --git a/libjava/include/java-stack.h b/libjava/include/java-stack.h index b9cf09a551c..d4d63d74342 100644 --- a/libjava/include/java-stack.h +++ b/libjava/include/java-stack.h @@ -30,10 +30,22 @@ details. */ using namespace gnu::gcj::runtime; using namespace java::lang; +extern "Java" +{ + namespace gnu + { + namespace classpath + { + class VMStackWalker; + } + } +} + enum _Jv_FrameType { frame_native, - frame_interpreter + frame_interpreter, + frame_proxy }; #ifdef INTERPRETER @@ -56,6 +68,10 @@ struct _Jv_StackFrame _Jv_InterpFrameInfo interp; #endif struct { + jclass proxyClass; + _Jv_Method *proxyMethod; + }; + struct { void *ip; void *start_ip; }; @@ -85,12 +101,14 @@ struct _Jv_UnwindState length = ln; pos = 0; frames = NULL; +#ifdef INTERPRETER Thread *thread = Thread::currentThread(); // Check for NULL currentThread(), in case an exception is created // very early during the runtime startup. -#ifdef INTERPRETER if (thread) interp_frame = (_Jv_InterpFrame *) thread->interp_frame; + else + interp_frame = NULL; #endif trace_function = NULL; trace_data = NULL; @@ -117,6 +135,8 @@ private: static _Unwind_Reason_Code calling_class_trace_fn (_Jv_UnwindState *state); static _Unwind_Reason_Code non_system_trace_fn (_Jv_UnwindState *state); static _Unwind_Reason_Code accesscontrol_trace_fn (_Jv_UnwindState *state); + static _Unwind_Reason_Code stackwalker_trace_fn (_Jv_UnwindState *state); + static _Unwind_Reason_Code stackwalker_nnl_trace_fn (_Jv_UnwindState *state); public: static _Jv_StackTrace *GetStackTrace (void); @@ -125,11 +145,14 @@ public: java::lang::Throwable *throwable); static jclass GetCallingClass (jclass); static void GetCallerInfo (jclass checkClass, jclass *, _Jv_Method **); - static JArray<jclass> *GetClassContext (jclass checkClass); static ClassLoader *GetFirstNonSystemClassLoader (void); static jobjectArray GetAccessControlStack (); + static JArray<jclass> *GetStackWalkerStack (); + static jclass GetStackWalkerCallingClass (); + static ClassLoader *GetStackWalkerFirstNonNullLoader (); friend jclass _Jv_GetMethodDeclaringClass (jmethodID); + friend class gnu::classpath::VMStackWalker; }; // Information about a given address. diff --git a/libjava/include/jvm.h b/libjava/include/jvm.h index 88b45be983d..203e0d95356 100644 --- a/libjava/include/jvm.h +++ b/libjava/include/jvm.h @@ -30,6 +30,10 @@ details. */ #include <gcj/cni.h> #include <gcj/field.h> +#include <java/lang/Thread.h> + +#include <sysdep/locks.h> + /* Macro for possible unused arguments. */ #define MAYBE_UNUSED __attribute__((__unused__)) @@ -137,6 +141,10 @@ extern int _Jv_strLengthUtf8(const char* str, int len); typedef struct _Jv_Utf8Const Utf8Const; _Jv_Utf8Const *_Jv_makeUtf8Const (const char *s, int len); _Jv_Utf8Const *_Jv_makeUtf8Const (jstring string); +static inline _Jv_Utf8Const *_Jv_makeUtf8Const (const char *s) +{ + return _Jv_makeUtf8Const (s, strlen (s)); +} extern jboolean _Jv_equalUtf8Consts (const _Jv_Utf8Const *, const _Jv_Utf8Const *); extern jboolean _Jv_equal (_Jv_Utf8Const *, jstring, jint); extern jboolean _Jv_equaln (_Jv_Utf8Const *, jstring, jint); @@ -233,6 +241,18 @@ namespace gcj /* Thread stack size specified by the -Xss runtime argument. */ extern size_t stack_size; + + /* The start time */ + extern jlong startTime; + + /* The VM arguments */ + extern JArray<jstring>* vmArgs; + + // Currently loaded classes + extern jint loadedClasses; + + // Unloaded classes + extern jlong unloadedClasses; } // This class handles all aspects of class preparation and linking. @@ -250,7 +270,6 @@ private: static void link_symbol_table(jclass); static void link_exception_table(jclass); static void layout_interface_methods(jclass); - static void layout_vtable_methods(jclass); static void set_vtable_entries(jclass, _Jv_VTable *); static void make_vtable(jclass); static void ensure_fields_laid_out(jclass); @@ -264,10 +283,6 @@ private: static int get_alignment_from_class(jclass); static void generate_itable(jclass, _Jv_ifaces *, jshort *); static jshort append_partial_itable(jclass, jclass, void **, jshort); - static _Jv_Method *search_method_in_class (jclass, jclass, - _Jv_Utf8Const *, - _Jv_Utf8Const *, - bool check_perms = true); static _Jv_Method *search_method_in_superclasses (jclass cls, jclass klass, _Jv_Utf8Const *method_name, _Jv_Utf8Const *method_signature, @@ -298,9 +313,17 @@ public: static void print_class_loaded (jclass); static void resolve_class_ref (jclass, jclass *); static void wait_for_state(jclass, int); + static _Jv_Method *resolve_method_entry (jclass, jclass &, + int, int, + bool, bool); static _Jv_word resolve_pool_entry (jclass, int, bool =false); static void resolve_field (_Jv_Field *, java::lang::ClassLoader *); static void verify_type_assertions (jclass); + static _Jv_Method *search_method_in_class (jclass, jclass, + _Jv_Utf8Const *, + _Jv_Utf8Const *, + bool check_perms = true); + static void layout_vtable_methods(jclass); }; /* Type of pointer used as finalizer. */ @@ -394,6 +417,8 @@ void _Jv_FreeMethodCache (); void _Jv_SetStackSize (const char *arg); extern "C" void JvRunMain (jclass klass, int argc, const char **argv); +extern "C" void JvRunMainName (const char *name, int argc, const char **argv); + void _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv, bool is_jar); @@ -633,30 +658,8 @@ extern void _Jv_RegisterBootstrapPackages (); // New style version IDs used by GCJ 4.0.1 and later. #define GCJ_40_BC_ABI_VERSION (4 * 100000 + 0 * 1000) -inline bool -_Jv_CheckABIVersion (unsigned long value) -{ - // We are compatible with GCJ 4.0.0 BC-ABI classes. This release used a - // different format for the version ID string. - if (value == OLD_GCJ_40_BC_ABI_VERSION) - return true; - - // The 20 low-end bits are used for the version number. - unsigned long version = value & 0xfffff; - - if (value & FLAG_BINARYCOMPAT_ABI) - { - int abi_rev = version % 100; - int abi_ver = version - abi_rev; - if (abi_ver == GCJ_40_BC_ABI_VERSION && abi_rev <= 0) - return true; - } - else - // C++ ABI - return version == GCJ_CXX_ABI_VERSION; - - return false; -} +void _Jv_CheckABIVersion (unsigned long value); + inline bool _Jv_ClassForBootstrapLoader (unsigned long value) @@ -695,4 +698,71 @@ _Jv_IsPhantomClass (jclass c) // A helper function defined in prims.cc. char* _Jv_PrependVersionedLibdir (char* libpath); + +// An enum for use with JvSetThreadState. We use a C++ enum rather +// than the Java enum to avoid problems with class initialization +// during VM bootstrap. +typedef enum +{ + JV_BLOCKED, + JV_NEW, + JV_RUNNABLE, + JV_TERMINATED, + JV_TIMED_WAITING, + JV_WAITING +} JvThreadState; + +// Temporarily set the thread's state. +class JvSetThreadState +{ +private: + ::java::lang::Thread *thread; + jint saved; + +public: + + // Note that 'cthread' could be NULL -- during VM startup there may + // not be a Thread available. + JvSetThreadState(::java::lang::Thread *cthread, JvThreadState nstate) + : thread (cthread), + saved (cthread ? cthread->state : (jint)JV_NEW) + { + if (thread) + thread->state = nstate; + } + + ~JvSetThreadState() + { + if (thread) + thread->state = saved; + } +}; + +// This structure is used to represent all the data the native side +// needs. An object of this type is assigned to the `data' member of +// the Thread class. +struct natThread +{ + // A thread is either alive, dead, or being sent a signal; if it is + // being sent a signal, it is also alive. Thus, if you want to know + // if a thread is alive, it is sufficient to test alive_status != + // THREAD_DEAD. + volatile obj_addr_t alive_flag; + + // These are used to interrupt sleep and join calls. We can share a + // condition variable here since it only ever gets notified when the thread + // exits. + _Jv_Mutex_t join_mutex; + _Jv_ConditionVariable_t join_cond; + + // These are used by Unsafe.park() and Unsafe.unpark(). + ParkHelper park_helper; + + // This is private data for the thread system layer. + _Jv_Thread_t *thread; + + // Each thread has its own JNI object. + void *jni_env; +}; + #endif /* __JAVA_JVM_H__ */ diff --git a/libjava/include/posix-threads.h b/libjava/include/posix-threads.h index 1f06fc3be18..d5f64957c22 100644 --- a/libjava/include/posix-threads.h +++ b/libjava/include/posix-threads.h @@ -19,6 +19,7 @@ details. */ #include <pthread.h> #include <sched.h> +#include <sysdep/locks.h> // // Typedefs. @@ -131,31 +132,7 @@ _Jv_MutexInit (_Jv_Mutex_t *mu) mu->owner = 0; } -inline int -_Jv_MutexLock (_Jv_Mutex_t *mu) -{ - pthread_t self = pthread_self (); - if (mu->owner == self) - { - mu->count++; - } - else - { -# ifdef LOCK_DEBUG - int result = pthread_mutex_lock (&mu->mutex); - if (0 != result) - { - fprintf(stderr, "Pthread_mutex_lock returned %d\n", result); - for (;;) {} - } -# else - pthread_mutex_lock (&mu->mutex); -# endif - mu->count = 1; - mu->owner = self; - } - return 0; -} +extern int _Jv_MutexLock (_Jv_Mutex_t *); inline int _Jv_MutexUnlock (_Jv_Mutex_t *mu) @@ -374,4 +351,33 @@ void _Jv_ThreadWait (void); void _Jv_ThreadInterrupt (_Jv_Thread_t *data); +// park() / unpark() support + +struct ParkHelper +{ + volatile obj_addr_t permit; + pthread_mutex_t mutex; + pthread_cond_t cond; + + void init (); + void deactivate (); + void destroy (); + void park (jboolean isAbsolute, jlong time); + void unpark (); +}; + +inline void +ParkHelper::init () +{ + pthread_mutex_init (&mutex, NULL); + pthread_cond_init (&cond, NULL); +} + +inline void +ParkHelper::destroy () +{ + pthread_mutex_destroy (&mutex); + pthread_cond_destroy (&cond); +} + #endif /* __JV_POSIX_THREADS__ */ diff --git a/libjava/include/posix.h b/libjava/include/posix.h index ea4762c6a1b..ee836e0b809 100644 --- a/libjava/include/posix.h +++ b/libjava/include/posix.h @@ -69,6 +69,13 @@ details. */ #define O_DSYNC O_SYNC #endif +// Name of the Process implementation. +#ifdef ECOS +#define _Jv_platform_process ::java::lang::EcosProcess +#else +#define _Jv_platform_process ::java::lang::PosixProcess +#endif + // Separator for file name components. #define _Jv_platform_file_separator ((jchar) '/') // Separator for path components. diff --git a/libjava/include/win32-threads.h b/libjava/include/win32-threads.h index 0b22010ac8d..442149c3cd8 100644 --- a/libjava/include/win32-threads.h +++ b/libjava/include/win32-threads.h @@ -193,6 +193,28 @@ void _Jv_ThreadInterrupt (_Jv_Thread_t *data); // See java/lang/natWin32Process.cc (waitFor) for an example. HANDLE _Jv_Win32GetInterruptEvent (void); +// park() / unpark() support + +struct ParkHelper +{ + // We use LONG instead of obj_addr_t to avoid pulling in locks.h, + // which depends on size_t, ... + volatile LONG permit; + + // The critical section is used for lazy initialization of our event + CRITICAL_SECTION cs; + HANDLE event; + + void init (); + void deactivate (); + void destroy (); + void park (jboolean isAbsolute, jlong time); + void unpark (); + +private: + void init_event(); +}; + // Remove defines from <windows.h> that conflict with various things in libgcj code #undef TRUE @@ -204,5 +226,6 @@ HANDLE _Jv_Win32GetInterruptEvent (void); #undef interface #undef STRICT #undef VOID +#undef TEXT #endif /* __JV_WIN32_THREADS__ */ diff --git a/libjava/include/win32.h b/libjava/include/win32.h index a461d88f56c..48989fe3dfa 100644 --- a/libjava/include/win32.h +++ b/libjava/include/win32.h @@ -76,6 +76,9 @@ extern jstring _Jv_Win32NewString (LPCTSTR pcsz); #define _Jv_platform_solib_prefix "" #define _Jv_platform_solib_suffix ".dll" +// Name of the Process implementation. +#define _Jv_platform_process ::java::lang::Win32Process + // Separator for file name components. #define _Jv_platform_file_separator ((jchar) '\\') // Separator for path components. |