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]

Re: Patch [ecj]: Central Parking


Mohan Embar writes:
 > Hi Andrew,
 > 
 > Sorry for the multiple posts. This supersedes my previous email and
 > includes Win32 support. Like I said, if you're okay with the approach
 > in principle, I'll write up a ChangeLog. If anyone else who's listerning
 > wants to look this over, I'd appreciate it.

OK.  I'm not sure why you wanted to use semaphores rather than simple
events and compare/exchange operations, but as long as you don't
change the behaviour on GNU/Linux that's OK.

 > Index: java/lang/natThread.cc
 > ===================================================================
 > --- java/lang/natThread.cc	(revision 119567)
 > +++ java/lang/natThread.cc	(working copy)
 > @@ -26,6 +26,8 @@
 >  #include <java/lang/InterruptedException.h>
 >  #include <java/lang/NullPointerException.h>
 >  
 > +#include <sun/misc/Unsafe.h>
 > +
 >  #include <jni.h>
 >  
 >  #ifdef ENABLE_JVMPI
 > @@ -54,8 +56,7 @@
 >    _Jv_MutexInit (&nt->join_mutex);
 >    _Jv_CondInit (&nt->join_cond);
 >  
 > -  pthread_mutex_init (&nt->park_mutex, NULL);
 > -  pthread_cond_init (&nt->park_cond, NULL);
 > +  nt->park_helper.init();
 >  
 >    nt->thread = _Jv_ThreadInitData (this);
 >    // FIXME: if JNI_ENV is set we will want to free it.  It is
 > @@ -75,9 +76,8 @@
 >    _Jv_MutexDestroy (&nt->join_mutex);
 >  #endif
 >    _Jv_FreeJNIEnv((JNIEnv*)nt->jni_env);
 > -
 > -  pthread_mutex_destroy (&nt->park_mutex);
 > -  pthread_cond_destroy (&nt->park_cond);
 > +  
 > +  nt->park_helper.destroy();
 >  }
 >  
 >  jint
 > @@ -131,7 +131,7 @@
 >  
 >        // Even though we've interrupted this thread, it might still be
 >        // parked.
 > -      _Jv_ThreadUnpark (this);
 > +      ::sun::misc::Unsafe::getUnsafe ()->unpark (this);

Ouch.  No!  getUnsafe () has to do a getSecurityManager check.

Andrew.


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