On macOS/aarch64 a thread must switch to WXWrite mode before entering the VM [1]
Entering the VM without WXWrite can cause sporadic crashes as described in JDK-8327036.
Below are locations that violate the invariant. For each location a test is given that fails if executed with with -XX:+AssertWXAtThreadSync.
JfrJvmtiAgent::retransform_classes()
https://github.com/openjdk/jdk/blob/cfd9209e03176bd8e02acd74b51a16f3113fbd21/src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.cpp#L149
jfr_set_enabled()
https://github.com/openjdk/jdk/blob/0776fff0e321c3f541354404b3ec0aa1992923a0/src/hotspot/share/jfr/jni/jfrJniMethod.cpp#L104
Tests:
jdk/jfr/event/runtime/TestClassLoadEvent.java
compiler/intrinsics/klass/CastNullCheckDroppingsTest.java
JvmtiExport::get_jvmti_interface
https://github.com/openjdk/jdk/blob/c342188fd978dd94e7788fb0fb0345fd8c0eaa9a/src/hotspot/share/prims/jvmtiExport.cpp#L385
Test:serviceability/jvmti/vthread/GetThreadState/GetThreadStateTest.java
GetCarrierThread
https://github.com/openjdk/jdk/blob/c342188fd978dd94e7788fb0fb0345fd8c0eaa9a/src/hotspot/share/prims/jvmtiExtensions.cpp#L133
Test:serviceability/jvmti/vthread/GetThreadStateMountedTest/GetThreadStateMountedTest.java
JfrRecorderService::emit_leakprofiler_events
https://github.com/openjdk/jdk/blob/c342188fd978dd94e7788fb0fb0345fd8c0eaa9a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp#L702
Test:jdk/jfr/event/oldobject/TestObjectAge.java
JfrJavaEventWriter::flush
https://github.com/openjdk/jdk/blob/c342188fd978dd94e7788fb0fb0345fd8c0eaa9a/src/hotspot/share/jfr/writers/jfrJavaEventWriter.cpp#L126
JfrStorage::register_full
https://github.com/openjdk/jdk/blob/c342188fd978dd94e7788fb0fb0345fd8c0eaa9a/src/hotspot/share/jfr/recorder/storage/jfrStorage.cpp#L294
Test:jdk/jfr/api/consumer/TestRecordingFileWrite.java
JfrIntrinsicSupport::write_checkpoint
https://github.com/openjdk/jdk/blob/d3f3011d56267360d65841da3550eca79cf1575b/src/hotspot/share/jfr/support/jfrIntrinsics.cpp#L54
Test:jdk/jfr/threading/TestManyVirtualThreads.java
[1] https://github.com/openjdk/jdk/blob/0583f7357480c0500daa82f490b2fcc05f2fb65a/src/hotspot/share/runtime/interfaceSupport.inline.hpp#L253-L259