Re: Leaving the stack frame

Peter Veentjer <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
For more info:

http://java.sun.com/docs/books/jvms/second_edition/html/Compiling.doc.html#6530

And be careful with synchronized methods since they are compiled differently
than a synchronized block in a method.

On Tue, May 25, 2010 at 4:10 PM, Peter Veentjer <[email protected]>wrote:

> As far as I know the exit block always is called. I would expect that in
> the bytecode a synchronised block is compiled to
>
> monitor.enter
> try{
>     logic in block
> }finally{
>     monitor.exit
> }
>
> So adding logic on the monitor.exit, should be as simple as adding extra
> instructions in front of the monitor.exit.
>
> I haven't tested this btw so it could be that I'm wrong.
>
> On Tue, May 25, 2010 at 3:12 PM, Will Morton <[email protected]> wrote:
>
>> I'm teaching myself ASM by writing a little utility that catches
>> thread deadlock scenarios before they happen.  The idea is that each
>> class containing synchronized blocks/methods is annotated with
>> @SyncPriority(int priority), with a runtime instrumenter that monitors
>> syncs and throws exceptions if high-priority syncs get called inside
>> low-priority ones.
>>
>> For entering synchronized areas this looks fairly simple.   For sync
>> blocks I can scan for MONITORENTER instructions and insert some calls
>> that look up the syncpriority annotation value and do the checks, and
>> add the same checks before synchronized method calls.
>>
>> However, adding checks to threads leaving sync areas seems to be
>> tougher.  Normal execution flow is ok - I can add checks before
>> RETURNs in sync methods, and before MONITOREXIT instructions - but
>> exception handling is a problem - if an exception is thrown but not
>> caught inside a synchronized method/block, the jvm unwinds the stack
>> without calling RETURNS or MONITOREXITs (I think), meaning my checks
>> are not notified of leaving the sync.
>>
>> Is there any way of inserting some code that is called reliably when a
>> stack frame is left via a thrown exception?
>>
>> Many thanks
>>
>> Will
>>
>>
>> --
>> You receive this message as a subscriber of the [email protected] mailing list.
>> To unsubscribe: mailto:[email protected]
>> For general help: mailto:[email protected]?subject=help
>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>
>>
>
message-footer.txt (text/plain, 238 B)
-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.