Fix memory leak in ipa-pure-const
[gcc.git] / libjava / interpret.cc
index 6153c5420367818f240170e7a94914812c3472a3..78686fd55b7a605034ef067d6eed5de291fbff09 100644 (file)
@@ -78,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() {}
@@ -978,7 +983,7 @@ void
 _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)
 
@@ -989,7 +994,7 @@ void
 _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");
 
@@ -1469,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))
                 {
@@ -1621,7 +1631,7 @@ _Jv_InterpMethod::breakpoint_at (jlong index)
       return (insn->insn == breakpoint_insn->insn);
 #else
       pc_t code = reinterpret_cast<pc_t> (bytecode ());
-      return (code[index] == breakpoint_insn);
+      return (code[index] == bp_insn_opcode);
 #endif
     }
 
@@ -1714,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)
@@ -1746,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