This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA/JVMTI] SuspendThread and ResumeThread


Hi,

As requested here are the JVMTI functions SuspendThread and ResumeThread. They're very basic. They don't check for some error conditions (like checking whether the thread to be suspended is already suspended). I have them working in my sandbox breakpoint-enabled gij.

I've also taken this moment to correct two inconsistencies: removed _Jv_ThreadDebug* from posix-threads.cc since this JVMTI implementation supplants it; and moved the ifdefs governing the inclusion of _Jv_SuspendThread and _Jv_ResumeThread in boehm.cc. Now those functions are always defined, but the contents are ifdef'd. If/when my other GC cleanup patch is accepted, we can remove these ifdefs altogether.

Keith

ChangeLog
2006-07-21  Keith Seitz  <keiths@redhat.com>

* boehm.cc (_Jv_SuspendThread): Don't ifdef the function declaration,
just the contents.
(_Jv_ResumeThread): Likewise.
* posix-threads.cc (_Jv_ThreadDebugResume): Remove. Moving to JVMTI.
(_Jv_ThreadDebugSuspend): Ditto.
(_Jv_ThreadDebugSuspendCount): Ditto.
* jvmti.cc (_Jv_JVMTI_SuspentThread): New function.
(_Jv_JVMTI_ResumeThread): New function.
(_Jv_JVMTI_Interface): Define SuspendThread and ResumeThread.
Index: boehm.cc
===================================================================
--- boehm.cc	(revision 115627)
+++ boehm.cc	(working copy)
@@ -678,19 +678,20 @@
 #endif
 }
 
-#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \
-  && !defined(GC_WIN32_THREADS) && !defined(GC_DARWIN_THREADS)
-
 void
 _Jv_SuspendThread (_Jv_Thread_t *thread)
 {
+#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \
+     && !defined(GC_WIN32_THREADS) && !defined(GC_DARWIN_THREADS)
   GC_suspend_thread (_Jv_GetPlatformThreadID (thread));
+#endif
 }
 
 void
 _Jv_ResumeThread (_Jv_Thread_t *thread)
 {
+#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \
+     && !defined(GC_WIN32_THREADS) && !defined(GC_DARWIN_THREADS)
   GC_resume_thread (_Jv_GetPlatformThreadID (thread));
+#endif
 }
-
-#endif
Index: posix-threads.cc
===================================================================
--- posix-threads.cc	(revision 115627)
+++ posix-threads.cc	(working copy)
@@ -505,22 +505,6 @@
   pthread_mutex_unlock (&daemon_mutex);
 }
 
-void
-_Jv_ThreadDebugSuspend (_Jv_Thread_t *data)
-{
-}
-
-void
-_Jv_ThreadDebugResume (_Jv_Thread_t *data)
-{
-}
-
-jint
-_Jv_ThreadDebugSuspendCount (_Jv_Thread_t *data)
-{
-  return -1;
-}
-
 #if defined(SLOW_PTHREAD_SELF)
 
 #include "sysdep/locks.h"
Index: jvmti.cc
===================================================================
--- jvmti.cc	(revision 115631)
+++ jvmti.cc	(working copy)
@@ -11,8 +11,32 @@
 #include <config.h>
 
 #include <jvm.h>
+#include <java-threads.h>
+#include <java-gc.h>
 #include <jvmti.h>
 
+#include <java/lang/Thread.h>
+
+static jvmtiError
+_Jv_JVMTI_SuspendThread (MAYBE_UNUSED jvmtiEnv *env, jthread thread)
+{
+  using namespace java::lang;
+  Thread *t = reinterpret_cast<Thread *> (thread);
+  _Jv_Thread_t *data = _Jv_ThreadGetData (t);
+  _Jv_SuspendThread (data);
+  return JVMTI_ERROR_NONE;
+}
+
+static jvmtiError
+_Jv_JVMTI_ResumeThread (MAYBE_UNUSED jvmtiEnv *env, jthread thread)
+{
+  using namespace java::lang;
+  Thread *t = reinterpret_cast<Thread *> (thread);
+  _Jv_Thread_t *data = _Jv_ThreadGetData (t);
+  _Jv_ResumeThread (data);
+  return JVMTI_ERROR_NONE;
+}
+
 #define RESERVED NULL
 #define UNIMPLEMENTED NULL
 
@@ -30,8 +54,8 @@
   UNIMPLEMENTED,		// SetEventNotification
   RESERVED,			// reserved3
   UNIMPLEMENTED,		// GetAllThreads
-  UNIMPLEMENTED, 		// SuspendThread
-  UNIMPLEMENTED,		// ResumeThread
+  _Jv_JVMTI_SuspendThread,	// SuspendThread
+  _Jv_JVMTI_ResumeThread,	// ResumeThread
   UNIMPLEMENTED,		// StopThread
   UNIMPLEMENTED,		// InterruptThread
   UNIMPLEMENTED,		// GetThreadInfo

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]