From 89a816f077bb7314e829288c1f867920d9c6bfb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Kliger=20=28=CE=BBgeek=29?= Date: Tue, 4 May 2021 14:32:27 -0400 Subject: [PATCH] [mono] Revert Mac Catalyst arm64 JITing hack (#52249) JITing in Catalyst apps is not allowed on Apple Silicon. Partly reverts a9f1207d9f14d6bdf6e4be0f206d11df8e032382 --- src/mono/mono/utils/CMakeLists.txt | 2 -- src/mono/mono/utils/mono-codeman.c | 15 ++++----------- src/mono/mono/utils/write-protect.c | 27 --------------------------- src/mono/mono/utils/write-protect.h | 18 ------------------ 4 files changed, 4 insertions(+), 58 deletions(-) delete mode 100644 src/mono/mono/utils/write-protect.c delete mode 100644 src/mono/mono/utils/write-protect.h diff --git a/src/mono/mono/utils/CMakeLists.txt b/src/mono/mono/utils/CMakeLists.txt index 6b3b3b02d3f2a..115570cf39df4 100644 --- a/src/mono/mono/utils/CMakeLists.txt +++ b/src/mono/mono/utils/CMakeLists.txt @@ -33,8 +33,6 @@ set(utils_common_sources mono-logger.c mono-logger-internals.h mono-codeman.c - write-protect.c - write-protect.h mono-counters.c mono-compiler.h mono-dl.c diff --git a/src/mono/mono/utils/mono-codeman.c b/src/mono/mono/utils/mono-codeman.c index ec84e08f0de86..087be6d2f7ede 100644 --- a/src/mono/mono/utils/mono-codeman.c +++ b/src/mono/mono/utils/mono-codeman.c @@ -28,7 +28,6 @@ static void* mono_code_manager_heap; #include #include -#include static uintptr_t code_memory_used = 0; static size_t dynamic_code_alloc_count; @@ -670,10 +669,8 @@ mono_codeman_enable_write (void) pthread_jit_write_protect_np (0); } #elif defined(HOST_MACCAT) && defined(__aarch64__) - int level = GPOINTER_TO_INT (mono_native_tls_get_value (write_level_tls_id)); - level ++; - mono_native_tls_set_value (write_level_tls_id, GINT_TO_POINTER (level)); - mono_jit_write_protect (0); + /* JITing in Catalyst apps is not allowed on Apple Silicon. */ + g_assert_not_reached (); #endif } @@ -696,11 +693,7 @@ mono_codeman_disable_write (void) pthread_jit_write_protect_np (1); } #elif defined(HOST_MACCAT) && defined(__aarch64__) - int level = GPOINTER_TO_INT (mono_native_tls_get_value (write_level_tls_id)); - g_assert (level); - level --; - mono_native_tls_set_value (write_level_tls_id, GINT_TO_POINTER (level)); - if (level == 0) - mono_jit_write_protect (1); + /* JITing in Catalyst apps is not allowed on Apple Silicon. */ + g_assert_not_reached (); #endif } diff --git a/src/mono/mono/utils/write-protect.c b/src/mono/mono/utils/write-protect.c deleted file mode 100644 index a7aeebee63052..0000000000000 --- a/src/mono/mono/utils/write-protect.c +++ /dev/null @@ -1,27 +0,0 @@ -/** - * \file - */ - -#include "config.h" - -#include "mono-compiler.h" -#include "write-protect.h" - -#if defined (HOST_MACCAT) && defined (__aarch64__) - -/* our own declaration of pthread_jit_write_protect_np so that we don't see the __API_UNAVAILABLE__ header */ -void -pthread_jit_write_protect_np (int enabled); - - -void -mono_jit_write_protect (int enabled) -{ - pthread_jit_write_protect_np (enabled); -} - -#else - -MONO_EMPTY_SOURCE_FILE (write_protect); - -#endif diff --git a/src/mono/mono/utils/write-protect.h b/src/mono/mono/utils/write-protect.h deleted file mode 100644 index f218bb6a93f30..0000000000000 --- a/src/mono/mono/utils/write-protect.h +++ /dev/null @@ -1,18 +0,0 @@ -/** - * \file - */ - -#ifndef __MONO_WRITE_PROTECT_H__ -#define __MONO_WRITE_PROTECT_H__ - -#include - -#if defined (HOST_MACCAT) && defined (__aarch64__) - -void -mono_jit_write_protect (int enabled); - -#endif /* defined (HOST_MACCAT) && defined (__aarch64__) */ - -#endif /* __MONO_WRITE_PROTECT_H__ */ -