X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=libjava%2Finterpret.cc;h=78686fd55b7a605034ef067d6eed5de291fbff09;hb=f95918fdf84e1c13446a31f30c4969cd15aa3802;hp=01a9c383fcd35b6be4d7130852ae77a33386a71e;hpb=0d2ab943d54d7dc16653dbb644f693d6a60c57df;p=pf3gnuchains%2Fgcc-fork.git diff --git a/libjava/interpret.cc b/libjava/interpret.cc index 01a9c383fcd..78686fd55b7 100644 --- a/libjava/interpret.cc +++ b/libjava/interpret.cc @@ -43,8 +43,6 @@ details. */ #include #include -#ifdef INTERPRETER - // Execution engine for interpreted code. _Jv_InterpreterEngine _Jv_soleInterpreterEngine; @@ -80,10 +78,15 @@ static void find_catch_location (jthrowable, jthread, jmethodID *, jlong *); // the Class monitor as user code in another thread could hold it. static _Jv_Mutex_t compile_mutex; +// See class ThreadCountAdjuster and REWRITE_INSN for how this is +// used. +_Jv_Mutex_t _Jv_InterpMethod::rewrite_insn_mutex; + void _Jv_InitInterpreter() { _Jv_MutexInit (&compile_mutex); + _Jv_MutexInit (&_Jv_InterpMethod::rewrite_insn_mutex); } #else void _Jv_InitInterpreter() {} @@ -348,7 +351,7 @@ get4 (unsigned char* loc) void _Jv_InterpMethod::run_normal (ffi_cif *, void *ret, - ffi_raw *args, + INTERP_FFI_RAW_TYPE *args, void *__this) { _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this; @@ -358,7 +361,7 @@ _Jv_InterpMethod::run_normal (ffi_cif *, void _Jv_InterpMethod::run_normal_debug (ffi_cif *, void *ret, - ffi_raw *args, + INTERP_FFI_RAW_TYPE *args, void *__this) { _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this; @@ -368,7 +371,7 @@ _Jv_InterpMethod::run_normal_debug (ffi_cif *, void _Jv_InterpMethod::run_synch_object (ffi_cif *, void *ret, - ffi_raw *args, + INTERP_FFI_RAW_TYPE *args, void *__this) { _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this; @@ -382,7 +385,7 @@ _Jv_InterpMethod::run_synch_object (ffi_cif *, void _Jv_InterpMethod::run_synch_object_debug (ffi_cif *, void *ret, - ffi_raw *args, + INTERP_FFI_RAW_TYPE *args, void *__this) { _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this; @@ -396,7 +399,7 @@ _Jv_InterpMethod::run_synch_object_debug (ffi_cif *, void _Jv_InterpMethod::run_class (ffi_cif *, void *ret, - ffi_raw *args, + INTERP_FFI_RAW_TYPE *args, void *__this) { _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this; @@ -407,7 +410,7 @@ _Jv_InterpMethod::run_class (ffi_cif *, void _Jv_InterpMethod::run_class_debug (ffi_cif *, void *ret, - ffi_raw *args, + INTERP_FFI_RAW_TYPE *args, void *__this) { _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this; @@ -418,7 +421,7 @@ _Jv_InterpMethod::run_class_debug (ffi_cif *, void _Jv_InterpMethod::run_synch_class (ffi_cif *, void *ret, - ffi_raw *args, + INTERP_FFI_RAW_TYPE *args, void *__this) { _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this; @@ -433,7 +436,7 @@ _Jv_InterpMethod::run_synch_class (ffi_cif *, void _Jv_InterpMethod::run_synch_class_debug (ffi_cif *, void *ret, - ffi_raw *args, + INTERP_FFI_RAW_TYPE *args, void *__this) { _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this; @@ -977,9 +980,10 @@ _Jv_InterpMethod::compile (const void * const *insn_targets) /* Run the given method. When args is NULL, don't run anything -- just compile it. */ void -_Jv_InterpMethod::run (void *retp, ffi_raw *args, _Jv_InterpMethod *meth) +_Jv_InterpMethod::run (void *retp, INTERP_FFI_RAW_TYPE *args, + _Jv_InterpMethod *meth) { -#undef DEBUG +#undef __GCJ_DEBUG #undef DEBUG_LOCALS_INSN #define DEBUG_LOCALS_INSN(s, t) do {} while (0) @@ -987,9 +991,10 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args, _Jv_InterpMethod *meth) } void -_Jv_InterpMethod::run_debug (void *retp, ffi_raw *args, _Jv_InterpMethod *meth) +_Jv_InterpMethod::run_debug (void *retp, INTERP_FFI_RAW_TYPE *args, + _Jv_InterpMethod *meth) { -#define DEBUG +#define __GCJ_DEBUG #undef DEBUG_LOCALS_INSN #define DEBUG_LOCALS_INSN(s, t) \ do \ @@ -1298,7 +1303,12 @@ _Jv_init_cif (_Jv_Utf8Const* signature, if (ptr != (unsigned char*)signature->chars() + signature->len()) throw_internal_error ("did not find end of signature"); - if (ffi_prep_cif (cif, FFI_DEFAULT_ABI, + ffi_abi cabi = FFI_DEFAULT_ABI; +#if defined (X86_WIN32) && !defined (__CYGWIN__) + if (!staticp) + cabi = FFI_THISCALL; +#endif + if (ffi_prep_cif (cif, cabi, arg_count, rtype, arg_types) != FFI_OK) throw_internal_error ("ffi_prep_cif failed"); @@ -1308,27 +1318,32 @@ _Jv_init_cif (_Jv_Utf8Const* signature, return item_count; } -#if FFI_NATIVE_RAW_API -# define FFI_PREP_RAW_CLOSURE ffi_prep_raw_closure_loc -# define FFI_RAW_SIZE ffi_raw_size -#else -# define FFI_PREP_RAW_CLOSURE ffi_prep_java_raw_closure_loc -# define FFI_RAW_SIZE ffi_java_raw_size -#endif - /* we put this one here, and not in interpret.cc because it * calls the utility routines _Jv_count_arguments * which are static to this module. The following struct defines the * layout we use for the stubs, it's only used in the ncode method. */ +#if FFI_NATIVE_RAW_API +# define FFI_PREP_RAW_CLOSURE ffi_prep_raw_closure_loc +# define FFI_RAW_SIZE ffi_raw_size typedef struct { ffi_raw_closure closure; _Jv_ClosureList list; ffi_cif cif; ffi_type *arg_types[0]; } ncode_closure; - -typedef void (*ffi_closure_fun) (ffi_cif*,void*,ffi_raw*,void*); +typedef void (*ffi_closure_fun) (ffi_cif*,void*,INTERP_FFI_RAW_TYPE*,void*); +#else +# define FFI_PREP_RAW_CLOSURE ffi_prep_java_raw_closure_loc +# define FFI_RAW_SIZE ffi_java_raw_size +typedef struct { + ffi_java_raw_closure closure; + _Jv_ClosureList list; + ffi_cif cif; + ffi_type *arg_types[0]; +} ncode_closure; +typedef void (*ffi_closure_fun) (ffi_cif*,void*,ffi_java_raw*,void*); +#endif void * _Jv_InterpMethod::ncode (jclass klass) @@ -1464,7 +1479,7 @@ _Jv_InterpMethod::check_handler (pc_t *pc, _Jv_InterpMethod *meth, if (exc[i].handler_type.i != 0) handler = (_Jv_Linker::resolve_pool_entry (meth->defining_class, - ex$ + exc[i].handler_type.i)).clazz; #endif /* DIRECT_THREADED */ if (handler == NULL || handler->isAssignableFrom (exc_class)) { @@ -1534,7 +1549,11 @@ _Jv_InterpMethod::get_local_var_table (char **name, char **sig, char **generic_sig, jlong *startloc, jint *length, jint *slot, int table_slot) -{ +{ +#ifdef DIRECT_THREADED + _Jv_CompileMethod (this); +#endif + if (local_var_table == NULL) return -2; if (table_slot >= local_var_table_len) @@ -1612,7 +1631,7 @@ _Jv_InterpMethod::breakpoint_at (jlong index) return (insn->insn == breakpoint_insn->insn); #else pc_t code = reinterpret_cast (bytecode ()); - return (code[index] == breakpoint_insn); + return (code[index] == bp_insn_opcode); #endif } @@ -1705,7 +1724,7 @@ throw_class_format_error (const char *msg) CATCH_LOCATION with the method and location where the catch will occur. If the exception is not caught, these are set to 0. - This function should only be used with the DEBUG interpreter. */ + This function should only be used with the __GCJ_DEBUG interpreter. */ static void find_catch_location (::java::lang::Throwable *exc, jthread thread, jmethodID *catch_method, jlong *catch_loc) @@ -1737,7 +1756,7 @@ find_catch_location (::java::lang::Throwable *exc, jthread thread, caught (if it is caught). Like find_catch_location, this should only be called with the - DEBUG interpreter. Since a few exceptions occur outside the + __GCJ_DEBUG interpreter. Since a few exceptions occur outside the interpreter proper, it is important to not call this function without checking JVMTI_REQUESTED_EVENT(Exception) first. */ void @@ -1928,5 +1947,3 @@ _Jv_CompileMethod (_Jv_InterpMethod* method) } } #endif // DIRECT_THREADED - -#endif // INTERPRETER