When I started to work on monitorenter and monitorexit, I thought it would be quite easy. Get the reference, call the lock/unlock function, done. But, soon after beginning, I was chanting "nothing-is-what-it-seems" mantra.
For monitorenter and monitorexit, it is necessary to provide support for goto and athrow bytecode instructions. Here is why.
Providing support for athrow instruction was easy. As Jato still does not support exception handling, actually nothing but function for bytecode consuming and dummy instruction selection rule was necessary.
But, for goto, I ran into a bug in control flow analyzer. So, after few hours of debugging, did fix that bug. And every thing was easy there after.
Then sent flood of patches! YAY !
( I made some nasty formatting horrors, which were fixed by Pekka. Thanks Pekka. )