Skip to content

Commit 68ce9ff

Browse files
battleblowbsdkurt
authored andcommitted
Fix crashes on Apple Silicon (openjdk#5)
See explanation in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265284#c10 From: NetBSD port (but with additional portability tweaks) Authored by: pho@netbsd.org
1 parent c037092 commit 68ce9ff

31 files changed

+102
-44
lines changed

src/hotspot/cpu/aarch64/jniFastGetField_aarch64.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static const Register result = r7;
5858
// (8262896). So each FastGetXXXField is wrapped into a C++ statically
5959
// compiled template function that optionally switches to WXExec if necessary.
6060

61-
#ifdef __APPLE__
61+
#ifdef _ALLBSD_SOURCE
6262

6363
static address generated_fast_get_field[T_LONG + 1 - T_BOOLEAN];
6464

@@ -86,14 +86,14 @@ address JNI_FastGetField::generate_fast_get_int_field1() {
8686
return (address)static_fast_get_field_wrapper<BType>;
8787
}
8888

89-
#else // __APPLE__
89+
#else // _ALLBSD_SOURCE
9090

9191
template<int BType>
9292
address JNI_FastGetField::generate_fast_get_int_field1() {
9393
return generate_fast_get_int_field0((BasicType)BType);
9494
}
9595

96-
#endif // __APPLE__
96+
#endif // _ALLBSD_SOURCE
9797

9898
address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
9999
const char *name;

src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
253253
ucontext_t* uc, JavaThread* thread) {
254254
// Enable WXWrite: this function is called by the signal handler at arbitrary
255255
// point of execution.
256-
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, thread));
256+
ThreadWXEnable wx(WXWrite, thread);
257257

258258
// decide if this trap can be handled by a stub
259259
address stub = nullptr;

src/hotspot/share/c1/c1_Runtime1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ void Runtime1::patch_code(JavaThread* current, C1StubId stub_id) {
13391339

13401340
// Enable WXWrite: the function is called by c1 stub as a runtime function
13411341
// (see another implementation above).
1342-
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, current));
1342+
BSD_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, current));
13431343

13441344
if (TracePatching) {
13451345
tty->print_cr("Deoptimizing because patch is needed");

src/hotspot/share/gc/shared/barrierSetNMethod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void BarrierSetNMethod::arm_all_nmethods() {
167167
int BarrierSetNMethod::nmethod_stub_entry_barrier(address* return_address_ptr) {
168168
// Enable WXWrite: the function is called directly from nmethod_entry_barrier
169169
// stub.
170-
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, Thread::current()));
170+
BSD_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, Thread::current()));
171171

172172
address return_address = *return_address_ptr;
173173
AARCH64_PORT_ONLY(return_address = pauth_strip_pointer(return_address));

src/hotspot/share/gc/shenandoah/shenandoahBarrierSetNMethod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ bool ShenandoahBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {
5151
return true;
5252
}
5353

54-
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, Thread::current());)
54+
BSD_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, Thread::current());)
5555

5656
if (nm->is_unloading()) {
5757
// We don't need to take the lock when unlinking nmethods from

src/hotspot/share/gc/z/zBarrierSetNMethod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool ZBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {
5555
return true;
5656
}
5757

58-
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, Thread::current()));
58+
BSD_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, Thread::current()));
5959

6060
if (nm->is_unloading()) {
6161
log_develop_trace(gc, nmethod)("nmethod: " PTR_FORMAT " visited by entry (unloading)", p2i(nm));

src/hotspot/share/interpreter/interpreterRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ JRT_END
10191019

10201020
nmethod* InterpreterRuntime::frequency_counter_overflow(JavaThread* current, address branch_bcp) {
10211021
// Enable WXWrite: the function is called directly by interpreter.
1022-
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, current));
1022+
BSD_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, current));
10231023

10241024
// frequency_counter_overflow_inner can throw async exception.
10251025
nmethod* nm = frequency_counter_overflow_inner(current, branch_bcp);

src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void JfrJvmtiAgent::retransform_classes(JNIEnv* env, jobjectArray classes_array,
143143
}
144144
ResourceMark rm(THREAD);
145145
// WXWrite is needed before entering the vm below and in callee methods.
146-
MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, THREAD));
146+
BSD_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, THREAD));
147147
jclass* const classes = create_classes_array(classes_count, CHECK);
148148
assert(classes != nullptr, "invariant");
149149
for (jint i = 0; i < classes_count; i++) {

src/hotspot/share/jfr/jni/jfrJniMethod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ NO_TRANSITION(void, jfr_set_enabled(JNIEnv* env, jclass jvm, jlong event_type_id
107107
JfrEventSetting::set_enabled(event_type_id, JNI_TRUE == enabled);
108108
if (EventOldObjectSample::eventId == event_type_id) {
109109
JavaThread* thread = JavaThread::thread_from_jni_environment(env);
110-
MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread));
110+
BSD_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread));
111111
ThreadInVMfromNative transition(thread);
112112
if (JNI_TRUE == enabled) {
113113
LeakProfiler::start(JfrOptionSet::old_object_queue_size());

src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ void JfrRecorderService::emit_leakprofiler_events(int64_t cutoff_ticks, bool emi
700700
JfrRotationLock lock;
701701
// Take the rotation lock before the transition.
702702
JavaThread* current_thread = JavaThread::current();
703-
MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, current_thread));
703+
BSD_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, current_thread));
704704
ThreadInVMfromNative transition(current_thread);
705705
LeakProfiler::emit_events(cutoff_ticks, emit_all, skip_bfs);
706706
}

0 commit comments

Comments
 (0)