Re: [Sablevm-developer] acquiring monitor
Brought to you by:
egagnon
From: Etienne M. G. <eti...@uq...> - 2003-02-10 06:36:35
|
Hi David, Archie is right; synchronization is needed to avoid creating more than one Method instance. In fact, all class-loader related code that either reads or writes class-loader data structures has to be synchronized using the monitor of the VirtualMachine class instance. In particular, calling _svmf_resolve_incomplete_method() without synchronization would yield undefined results. Furthermore, as Archie pointer, we definitely do not want another thread to create an instance between the: if (method_info->reflection_instance != NULL) ... and the ... *(method_info->reflection_instance) = *method; Doing otherwise would (among other things) leak memory. Have fun! Etienne On Sun, Feb 09, 2003 at 09:05:22PM -0800, Archie Cobbs wrote: > David Paul BELANGER wrote: > > > In the case of Class.getMethod() (and therefore Class.nativeGetMethod()) > > > the spec says that accessing the Method object associated with a > > > class is an "active use" and so the class must be linked if it hasn't > > > already been linked. And linking the class's type of course requires > > > acquiring the monitor. > > > > Yes, I do understand that part but the link functions do acquire it. > > I am wondering why we have this structure: > > > > acquire monitor > > . > > . > > . > > link_class() > > (inside link_class) > > acquire monitor > > . > > . > > . > > release monitor > > . > > initialize_class > > acquire monitor > > . > > . > > release monitor > > . > > . > > release monitor > > > > What functions are we protecting with the external acquire monitor? > > Maybe it's for the creation of the new Method reflection instance? > The JVM must ensure that it only gets created once. > > -Archie > > __________________________________________________________________________ > Archie Cobbs * Packet Design * http://www.packetdesign.com > > > ------------------------------------------------------- > This SF.NET email is sponsored by: > SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! > http://www.vasoftware.com > _______________________________________________ > Sablevm-developer mailing list > Sab...@li... > https://lists.sourceforge.net/lists/listinfo/sablevm-developer -- Etienne M. Gagnon, Ph.D. http://www.info.uqam.ca/~egagnon/ SableVM: http://www.sablevm.org/ SableCC: http://www.sablecc.org/ |