When locking with MutexLockerEx(SOMELOCK, Mutex::_no_safepoint_check_flag) if some other code locks without Mutex::_no_safepoint_check_flag, the JVM will deadlock. The JVM should have some check that prevents you from doing this. From email discussion:
On 6/17/14, 6:11 AM, Mikael Gerdin wrote:
> I wish there was a consistency check though. If you take a lock without
> checking for safepoint, we should give an assertion if you take the same
> lock and check for safepoint. Not sure if there's an easy way to code
> it, but I think it would be worth having.
Can't we use the type system for this?
class NoSafepointCheckMutex which always elides safepoint checks
class Mutex which does not allow elision of safepoint checks.