harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pavel Ozhdikhin" <pavel.ozhdik...@gmail.com>
Subject Re: [drlvm][jitrino]-how to release the lock when an exeption is thrown in a synchronized block?
Date Mon, 15 Oct 2007 02:33:34 GMT
On 10/13/07, 史成荣 <icyrong@gmail.com> wrote:
>
> Do you means monitorenter/monitorexit in all control flow of HIR are
> balanced?


 Yes, they should be.

The bytecode which contains unbalanced monitorenter/monitorexit and would
pass the verifier might be created [1], but I have not seen such examples
produced by a Java compiler. It would be interesting to look into your
example.

Thanks,
Pavel

[1] http://citeseer.ist.psu.edu/agesen99efficient.html


Thanks,
> Chengrong
>
>
> 2007/10/12, Pavel Ozhdikhin <pavel.ozhdikhin@gmail.com>:
> >
> > On 10/12/07, 史成荣 <icyrong@gmail.com> wrote:
> >
> > > We know that according to the specification, when an exeption is
> thrown,
> > > the
> > > control flow goes to the handler of the exeption. If the  exeption is
> > > thrown
> > > in a synchronized block, the VM must do a "monitorexit" operation to
> > > release
> > > the lock. But I took a look at some control flow graphs(HIR) created
> by
> > > JIT,
> > > and didn't find any "monitorexit" instructions when an exeption is
> > thrown
> > > in
> > > a synchronized block. Could any one tell me when and how the
> > "monitorexit"
> > > operation is done when an exeption is thrown in a synchronized block?
> >
> >
> > A java compiler should use Java exception mechanics to make sure monexit
> > is
> > called when the exception is thrown in a synchronized block (see section
> > 7.14 "Synchronization" of JVMS2). JIT also emulates this technique when
> it
> > inlines a sychronized method.
> >
> > When an exception is thrown from a synchronized method (not inlined), VM
> > releases the lock.
> >
> > If you have an example of unbalanced monitorenter/monitorexit in HIR,
> > please
> > share the test here so I could take a deeper look.
> >
> > Thanks,
> > Pavel
> >
>
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message