RFR: 8295214: Generational ZGC: Guard nmethods from cross modifying code

David Holmes dholmes at openjdk.org
Wed Nov 9 01:58:21 UTC 2022


On Tue, 8 Nov 2022 16:19:47 GMT, Erik Österlund <eosterlund at openjdk.org> wrote:

> Generational ZGC will need to patch nmethod instructions outside of safepoints, and guard entries into the nmethods with cross modifying code fences. This is mostly taken care of by nmethod entry barrier code. But there are a few entries that don't go through nmethod entry barriers that need fixing. In particular when entering an nmethod by returning through the stack watermark barrier. This patch ensures that whenever the stack watermark barrier exposes a new nmethod, we also ensure that a cross modify fence is executed, so that any concurrently updated instructions can be safely executed.

What are the performance implications here, if any? I don't like that everyone pays for this when it is only needed for genZGC.

Thanks.

src/hotspot/share/runtime/safepointMechanism.cpp line 108:

> 106:     if (prev_poll_word != poll_word ||
> 107:         prev_poll_word == _poll_word_armed_value) {
> 108:       // After updating the poll value, we allow entering new nmethods

I'm a little confused about the positioning here. The comment says "after updating the poll value", but we haven't updated yet (happens below) so don't we need the fence after that point?

src/hotspot/share/runtime/safepointMechanism.cpp line 144:

> 142: 
> 143:   update_poll_values(thread);
> 144:   OrderAccess::cross_modify_fence();

Has this simply been moved to cover more paths?

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

PR: https://git.openjdk.org/jdk/pull/11042


More information about the hotspot-dev mailing list