jvmti.cc (_envListLock): Change type to ReentrantReadWriteLock.
* jvmti.cc (_envListLock): Change type to ReentrantReadWriteLock. (_Jv_JVMTI_DisposeEnvironment): Switch to read/write lock. (check_enabled_event): Likewise. (_Jv_GetJVMTIEnv): Likewise. (_Jv_JVMTI_Init): Likewise. (_Jv_JVMTI_PostEvent): Likewise. From-SVN: r121616
This commit is contained in:
parent
cefde4f5c7
commit
d6df67efcd
2 changed files with 55 additions and 33 deletions
|
@ -1,3 +1,14 @@
|
||||||
|
2007-02-05 Keith Seitz <keiths@redhat.com>
|
||||||
|
|
||||||
|
* jvmti.cc (_envListLock): Change type to
|
||||||
|
ReentrantReadWriteLock.
|
||||||
|
(_Jv_JVMTI_DisposeEnvironment): Switch to read/write
|
||||||
|
lock.
|
||||||
|
(check_enabled_event): Likewise.
|
||||||
|
(_Jv_GetJVMTIEnv): Likewise.
|
||||||
|
(_Jv_JVMTI_Init): Likewise.
|
||||||
|
(_Jv_JVMTI_PostEvent): Likewise.
|
||||||
|
|
||||||
2007-02-05 Keith Seitz <keiths@redhat.com>
|
2007-02-05 Keith Seitz <keiths@redhat.com>
|
||||||
|
|
||||||
* gnu/classpath/jdwp/natVMVirtualMachine.cc
|
* gnu/classpath/jdwp/natVMVirtualMachine.cc
|
||||||
|
|
|
@ -27,7 +27,6 @@ details. */
|
||||||
|
|
||||||
#include <java/lang/Class.h>
|
#include <java/lang/Class.h>
|
||||||
#include <java/lang/ClassLoader.h>
|
#include <java/lang/ClassLoader.h>
|
||||||
#include <java/lang/Object.h>
|
|
||||||
#include <java/lang/OutOfMemoryError.h>
|
#include <java/lang/OutOfMemoryError.h>
|
||||||
#include <java/lang/Thread.h>
|
#include <java/lang/Thread.h>
|
||||||
#include <java/lang/ThreadGroup.h>
|
#include <java/lang/ThreadGroup.h>
|
||||||
|
@ -37,6 +36,8 @@ details. */
|
||||||
#include <java/lang/reflect/Modifier.h>
|
#include <java/lang/reflect/Modifier.h>
|
||||||
#include <java/util/Collection.h>
|
#include <java/util/Collection.h>
|
||||||
#include <java/util/HashMap.h>
|
#include <java/util/HashMap.h>
|
||||||
|
#include <java/util/concurrent/locks/Lock.h>
|
||||||
|
#include <java/util/concurrent/locks/ReentrantReadWriteLock.h>
|
||||||
#include <java/net/URL.h>
|
#include <java/net/URL.h>
|
||||||
|
|
||||||
static void check_enabled_events (void);
|
static void check_enabled_events (void);
|
||||||
|
@ -103,7 +104,8 @@ struct jvmti_env_list
|
||||||
struct jvmti_env_list *next;
|
struct jvmti_env_list *next;
|
||||||
};
|
};
|
||||||
static struct jvmti_env_list *_jvmtiEnvironments = NULL;
|
static struct jvmti_env_list *_jvmtiEnvironments = NULL;
|
||||||
static java::lang::Object *_envListLock = NULL;
|
static java::util::concurrent::locks::
|
||||||
|
ReentrantReadWriteLock *_envListLock = NULL;
|
||||||
#define FOREACH_ENVIRONMENT(Ele) \
|
#define FOREACH_ENVIRONMENT(Ele) \
|
||||||
for (Ele = _jvmtiEnvironments; Ele != NULL; Ele = Ele->next)
|
for (Ele = _jvmtiEnvironments; Ele != NULL; Ele = Ele->next)
|
||||||
|
|
||||||
|
@ -896,7 +898,7 @@ _Jv_JVMTI_DisposeEnvironment (jvmtiEnv *env)
|
||||||
return JVMTI_ERROR_INVALID_ENVIRONMENT;
|
return JVMTI_ERROR_INVALID_ENVIRONMENT;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
JvSynchronize dummy (_envListLock);
|
_envListLock->writeLock ()->lock ();
|
||||||
if (_jvmtiEnvironments->env == env)
|
if (_jvmtiEnvironments->env == env)
|
||||||
{
|
{
|
||||||
struct jvmti_env_list *next = _jvmtiEnvironments->next;
|
struct jvmti_env_list *next = _jvmtiEnvironments->next;
|
||||||
|
@ -909,12 +911,16 @@ _Jv_JVMTI_DisposeEnvironment (jvmtiEnv *env)
|
||||||
while (e->next != NULL && e->next->env != env)
|
while (e->next != NULL && e->next->env != env)
|
||||||
e = e->next;
|
e = e->next;
|
||||||
if (e->next == NULL)
|
if (e->next == NULL)
|
||||||
|
{
|
||||||
|
_envListLock->writeLock ()->unlock ();
|
||||||
return JVMTI_ERROR_INVALID_ENVIRONMENT;
|
return JVMTI_ERROR_INVALID_ENVIRONMENT;
|
||||||
|
}
|
||||||
|
|
||||||
struct jvmti_env_list *next = e->next->next;
|
struct jvmti_env_list *next = e->next->next;
|
||||||
_Jv_Free (e->next);
|
_Jv_Free (e->next);
|
||||||
e->next = next;
|
e->next = next;
|
||||||
}
|
}
|
||||||
|
_envListLock->writeLock ()->unlock ();
|
||||||
}
|
}
|
||||||
|
|
||||||
_Jv_Free (env);
|
_Jv_Free (env);
|
||||||
|
@ -1215,7 +1221,9 @@ check_enabled_event (jvmtiEvent type)
|
||||||
|
|
||||||
int index = EVENT_INDEX (type); // safe since caller checks this
|
int index = EVENT_INDEX (type); // safe since caller checks this
|
||||||
|
|
||||||
JvSynchronize dummy (_envListLock);
|
if (_jvmtiEnvironments != NULL)
|
||||||
|
{
|
||||||
|
_envListLock->readLock ()->lock ();
|
||||||
struct jvmti_env_list *e;
|
struct jvmti_env_list *e;
|
||||||
FOREACH_ENVIRONMENT (e)
|
FOREACH_ENVIRONMENT (e)
|
||||||
{
|
{
|
||||||
|
@ -1225,10 +1233,14 @@ check_enabled_event (jvmtiEvent type)
|
||||||
if (e->env->enabled[index] && *callback != NULL)
|
if (e->env->enabled[index] && *callback != NULL)
|
||||||
{
|
{
|
||||||
*enabled = true;
|
*enabled = true;
|
||||||
|
_envListLock->readLock ()->unlock ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_envListLock->readLock ()->unlock ();
|
||||||
|
}
|
||||||
|
|
||||||
*enabled = false;
|
*enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1739,14 +1751,12 @@ _Jv_GetJVMTIEnv (void)
|
||||||
_Jv_JVMTIEnv *env
|
_Jv_JVMTIEnv *env
|
||||||
= (_Jv_JVMTIEnv *) _Jv_MallocUnchecked (sizeof (_Jv_JVMTIEnv));
|
= (_Jv_JVMTIEnv *) _Jv_MallocUnchecked (sizeof (_Jv_JVMTIEnv));
|
||||||
env->p = &_Jv_JVMTI_Interface;
|
env->p = &_Jv_JVMTI_Interface;
|
||||||
|
|
||||||
{
|
|
||||||
JvSynchronize dummy (_envListLock);
|
|
||||||
struct jvmti_env_list *element
|
struct jvmti_env_list *element
|
||||||
= (struct jvmti_env_list *) _Jv_MallocUnchecked (sizeof (struct jvmti_env_list));
|
= (struct jvmti_env_list *) _Jv_MallocUnchecked (sizeof (struct jvmti_env_list));
|
||||||
element->env = env;
|
element->env = env;
|
||||||
element->next = NULL;
|
element->next = NULL;
|
||||||
|
|
||||||
|
_envListLock->writeLock ()->lock ();
|
||||||
if (_jvmtiEnvironments == NULL)
|
if (_jvmtiEnvironments == NULL)
|
||||||
_jvmtiEnvironments = element;
|
_jvmtiEnvironments = element;
|
||||||
else
|
else
|
||||||
|
@ -1756,7 +1766,7 @@ _Jv_GetJVMTIEnv (void)
|
||||||
;
|
;
|
||||||
e->next = element;
|
e->next = element;
|
||||||
}
|
}
|
||||||
}
|
_envListLock->writeLock ()->unlock ();
|
||||||
|
|
||||||
/* Mark JVMTI active. This is used to force the interpreter
|
/* Mark JVMTI active. This is used to force the interpreter
|
||||||
to use either debugging or non-debugging code. Once JVMTI
|
to use either debugging or non-debugging code. Once JVMTI
|
||||||
|
@ -1769,7 +1779,8 @@ void
|
||||||
_Jv_JVMTI_Init ()
|
_Jv_JVMTI_Init ()
|
||||||
{
|
{
|
||||||
_jvmtiEnvironments = NULL;
|
_jvmtiEnvironments = NULL;
|
||||||
_envListLock = new java::lang::Object ();
|
_envListLock
|
||||||
|
= new java::util::concurrent::locks::ReentrantReadWriteLock ();
|
||||||
|
|
||||||
// No environments, so this should set all JVMTI:: members to false
|
// No environments, so this should set all JVMTI:: members to false
|
||||||
check_enabled_events ();
|
check_enabled_events ();
|
||||||
|
@ -2133,7 +2144,7 @@ _Jv_JVMTI_PostEvent (jvmtiEvent type, jthread event_thread, ...)
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start (args, event_thread);
|
va_start (args, event_thread);
|
||||||
|
|
||||||
JvSynchronize dummy (_envListLock);
|
_envListLock->readLock ()->lock ();
|
||||||
struct jvmti_env_list *e;
|
struct jvmti_env_list *e;
|
||||||
FOREACH_ENVIRONMENT (e)
|
FOREACH_ENVIRONMENT (e)
|
||||||
{
|
{
|
||||||
|
@ -2149,6 +2160,6 @@ _Jv_JVMTI_PostEvent (jvmtiEvent type, jthread event_thread, ...)
|
||||||
post_event (e->env, type, event_thread, args);
|
post_event (e->env, type, event_thread, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_envListLock->readLock ()->unlock ();
|
||||||
va_end (args);
|
va_end (args);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue