RFR(m): 8220351: Cross-modifying code
Andrew Haley
aph at redhat.com
Mon Mar 11 09:34:22 UTC 2019
On 3/8/19 3:24 PM, Robbin Ehn wrote:
> Hi all, please review.
>
> Issue:
> https://bugs.openjdk.java.net/browse/JDK-8220351
> Changeset:
> http://cr.openjdk.java.net/~rehn/8220351/webrev/
>
> After a JavaThread have been in a safepoint/(handshake) safe state it can start
> executing updated code. E.g. an oop in the instruction stream can have been
> updated.
>
> Most hardware's require a barrier or that the code cross modified is far away to
> guarantee that the thread executing the updated instruction stream sees the
> modification.
>
> What far away is and how far an update instruction stream is from a safepoint
> safe state is not clear.
>
> To be compliant with those architectures an instruction stream barrier must be
> added when leaving the safepoint safe state.
>
> There may be crashes today due to this missing barrier.
> A new CPU with deeper pipeline or changes to the VM which moves a safepoint safe
> state closer to a nmethod can increase changes of a crash.
What is this hunk for?
@@ -2558,12 +2558,9 @@
// VM thread changes sync state to synchronizing and suspends threads for GC.
// Thread A is resumed to finish this native method, but doesn't block here since it
// didn't see any synchronization is progress, and escapes.
- __ movl(Address(r15_thread, JavaThread::thread_state_offset()), _thread_in_native_trans);
-
- // Force this write out before the read below
- __ membar(Assembler::Membar_mask_bits(
- Assembler::LoadLoad | Assembler::LoadStore |
- Assembler::StoreLoad | Assembler::StoreStore));
+
+ __ lock();
+ __ addl(Address(r15_thread, JavaThread::thread_state_offset()), 1 /* _thread_in_native_trans */);
Label after_transition;
--
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the hotspot-dev
mailing list