From af21548a056a1c36a27707bb25af659552a8dfe6 Mon Sep 17 00:00:00 2001
From: kseitz <kseitz@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 18 Jan 2006 21:52:45 +0000
Subject: [PATCH]         * include/java-interp.h (_Jv_CompileMethod): Add
 declaration.         (class _Jv_InterpMethod): Add _Jv_CompileMethod as a
 friend.         * interpret.cc (_Jv_CompileMethod): New function.        
 (run):  Massage code to allow for NULL args.         Update comments to
 explain NULL args.         Return if compiling the method and args is NULL.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109918 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libjava/ChangeLog             |  9 +++++++
 libjava/include/java-interp.h |  7 +++++-
 libjava/interpret.cc          | 44 ++++++++++++++++++++++++-----------
 3 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 047f34336887..032a98db4ceb 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,12 @@
+2006-01-18  Keith Seitz  <keiths@redhat.com>
+
+	* include/java-interp.h (_Jv_CompileMethod): Add declaration.
+	(class _Jv_InterpMethod): Add _Jv_CompileMethod as a friend.
+	* interpret.cc (_Jv_CompileMethod): New function.
+	(run): 	Massage code to allow for NULL args.
+	Update comments to explain NULL args.
+	Return if compiling the method and args is NULL.
+
 2006-01-18  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR libgcj/25840
diff --git a/libjava/include/java-interp.h b/libjava/include/java-interp.h
index 269e39c5a5ef..872fb10a32be 100644
--- a/libjava/include/java-interp.h
+++ b/libjava/include/java-interp.h
@@ -1,6 +1,6 @@
 // java-interp.h - Header file for the bytecode interpreter.  -*- c++ -*-
 
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005  Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -44,6 +44,7 @@ void * _Jv_AllocMethodInvocation (jsize size);
 int  _Jv_count_arguments (_Jv_Utf8Const *signature,
 			  jboolean staticp = true);
 void _Jv_VerifyMethod (_Jv_InterpMethod *method);
+void _Jv_CompileMethod (_Jv_InterpMethod* method);
 
 /* the interpreter is written in C++, primarily because it makes it easy for
  * the entire thing to be "friend" with class Class. */
@@ -184,6 +185,10 @@ class _Jv_InterpMethod : public _Jv_MethodBase
  public:
   static void dump_object(jobject o);
 
+#ifdef DIRECT_THREADED
+  friend void _Jv_CompileMethod (_Jv_InterpMethod*);
+#endif
+  
   friend class _Jv_ClassReader;
   friend class _Jv_BytecodeVerifier;
   friend class _Jv_StackTrace;
diff --git a/libjava/interpret.cc b/libjava/interpret.cc
index dacf19dfb12e..d6e8ccca023d 100644
--- a/libjava/interpret.cc
+++ b/libjava/interpret.cc
@@ -1,6 +1,6 @@
 // interpret.cc - Code for the interpreter
 
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation
 
    This file is part of libgcj.
 
@@ -792,6 +792,8 @@ _Jv_InterpMethod::compile (const void * const *insn_targets)
 }
 #endif /* DIRECT_THREADED */
 
+/* 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)
 {
@@ -812,19 +814,6 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args, _Jv_InterpMethod *meth)
 
   _Jv_word locals[meth->max_locals];
 
-  /* Go straight at it!  the ffi raw format matches the internal
-     stack representation exactly.  At least, that's the idea.
-  */
-  memcpy ((void*) locals, (void*) args, meth->args_raw_size);
-
-  _Jv_word *pool_data = meth->defining_class->constants.data;
-
-  /* These three are temporaries for common code used by several
-     instructions.  */
-  void (*fun)();
-  _Jv_ResolvedMethod* rmeth;
-  int tmpval;
-
 #define INSN_LABEL(op) &&insn_##op
 
   static const void *const insn_target[] = 
@@ -1070,6 +1059,11 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args, _Jv_InterpMethod *meth)
 	meth->compile (insn_target);
       _Jv_MutexUnlock (&compile_mutex);
     }
+
+  // If we're only compiling, stop here
+  if (args == NULL)
+    return;
+
   pc = (insn_slot *) meth->prepared;
 
 #else
@@ -1102,6 +1096,19 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args, _Jv_InterpMethod *meth)
 
 #define TAKE_GOTO pc = GOTO_VAL ()
 
+  /* Go straight at it!  the ffi raw format matches the internal
+     stack representation exactly.  At least, that's the idea.
+  */
+  memcpy ((void*) locals, (void*) args, meth->args_raw_size);
+
+  _Jv_word *pool_data = meth->defining_class->constants.data;
+
+  /* These three are temporaries for common code used by several
+     instructions.  */
+  void (*fun)();
+  _Jv_ResolvedMethod* rmeth;
+  int tmpval;
+
   try
     {
       // We keep nop around.  It is used if we're interpreting the
@@ -3866,4 +3873,13 @@ _Jv_InterpreterEngine::do_post_miranda_hook (jclass klass)
     }
 }
 
+#ifdef DIRECT_THREADED
+void
+_Jv_CompileMethod (_Jv_InterpMethod* method)
+{
+  if (method->prepared == NULL)
+    _Jv_InterpMethod::run (NULL, NULL, method);
+}
+#endif // DIRECT_THREADED
+
 #endif // INTERPRETER
-- 
GitLab