On Wed, 5 May 2021 08:11:04 GMT, Robbin Ehn <r...@openjdk.org> wrote:

> Please consider this change which removes the manual transitions to blocked.
> This adds a preprocess template/functor which is executed in the destructor 
> of 'ThreadBlockInVM' if we are going to do any processing.
> This gives us a way to backout of the object/raw monitor before suspend or 
> other processing, such as a safepoint.
> 
> The object monitor code could be straight forward changed to use this instead 
> of manual transitions.
> 
> Raw monitors on the other hand are a bit more complicated due to 'implicit' 
> rules (consequences of the specs).
> Added a comment in hpp trying to explain it; we cannot simply transition with 
> a raw monitor held.
> This caused the change in the destructor ~ThreadInVMfromNative() (this 
> specific change have also been tested in unrelated exploration of 
> transition), now this RAII does the same as we do when going to native from 
> Java, just setting the state.
> Since we are going from an unsafe state, in VM, to a safe state, in native, 
> we do not need to check the poll.
> That made it possible to careful use ThreadInVMfromNative in raw monitors.
> 
> I also remove the early CAS in raw_enter.
> We lock a lock to do a CAS, in the uncontended case means CAS on lock then 
> CAS raw monitor.
> Now we instead do a transitions, in the uncontended case means fence, CAS raw 
> monitor, fence.
> (multiple fence (CAS is also a fence) very close to each other have little 
> additional performance impact on contemporary hardware)
> 
> Passes t1-t7 and manual stressing relevant test groups.

This pull request has now been integrated.

Changeset: 97ec5ad0
Author:    Robbin Ehn <r...@openjdk.org>
URL:       
https://git.openjdk.java.net/jdk/commit/97ec5ad0a6ed2cd87a9c75b0559e9bb55b72121e
Stats:     340 lines in 8 files changed: 119 ins; 150 del; 71 mod

8265753: Remove manual JavaThread transitions to blocked

Reviewed-by: dcubed, rrich, dholmes, pchilanomate

-------------

PR: https://git.openjdk.java.net/jdk/pull/3875

Reply via email to