diff --git a/runtime/vm/os_thread.cc b/runtime/vm/os_thread.cc index 74e782f0413..09630da419b 100644 --- a/runtime/vm/os_thread.cc +++ b/runtime/vm/os_thread.cc @@ -115,13 +115,6 @@ OSThread::~OSThread() { #endif timeline_block_ = nullptr; free(name_); -#if !defined(PRODUCT) - if (prepared_for_interrupts_) { - ThreadInterrupter::CleanupCurrentThreadState(thread_interrupter_state_); - thread_interrupter_state_ = nullptr; - prepared_for_interrupts_ = false; - } -#endif // !defined(PRODUCT) } void OSThread::SetName(const char* name) { @@ -161,12 +154,6 @@ void OSThread::EnableThreadInterrupts() { ASSERT(OSThread::Current() == this); uintptr_t old = thread_interrupt_disabled_.fetch_sub(1u); if (FLAG_profiler && (old == 1)) { - // We just decremented from 1 to 0. - // Make sure the thread interrupter is awake. - if (!prepared_for_interrupts_) { - thread_interrupter_state_ = ThreadInterrupter::PrepareCurrentThread(); - prepared_for_interrupts_ = true; - } ThreadInterrupter::WakeUp(); } if (old == 0) { diff --git a/runtime/vm/os_thread.h b/runtime/vm/os_thread.h index a6e03ace1e0..37012f4a523 100644 --- a/runtime/vm/os_thread.h +++ b/runtime/vm/os_thread.h @@ -297,8 +297,6 @@ class OSThread : public BaseThread { #if defined(DART_INCLUDE_PROFILER) // Thread interrupts disabled by default. RelaxedAtomic thread_interrupt_disabled_ = {1}; - bool prepared_for_interrupts_ = false; - void* thread_interrupter_state_ = nullptr; #endif // defined(DART_INCLUDE_PROFILER) Log* log_; diff --git a/runtime/vm/signal_handler.h b/runtime/vm/signal_handler.h index bfcd982e915..cabe1498f93 100644 --- a/runtime/vm/signal_handler.h +++ b/runtime/vm/signal_handler.h @@ -51,15 +51,6 @@ class SignalHandler : public AllStatic { static uintptr_t GetCStackPointer(const mcontext_t& mcontext); static uintptr_t GetDartStackPointer(const mcontext_t& mcontext); static uintptr_t GetLinkRegister(const mcontext_t& mcontext); - -#if defined(DART_HOST_OS_ANDROID) - // Prepare current thread for handling interrupts. Returns - // opaque pointer to the allocated state (if any). - static void* PrepareCurrentThread(); - - // Cleanup any state which was created by |PrepareCurrentThread|. - static void CleanupCurrentThreadState(void* state); -#endif }; #undef USE_SIGNAL_HANDLER_TRAMPOLINE diff --git a/runtime/vm/signal_handler_android.cc b/runtime/vm/signal_handler_android.cc index 02949bc8541..569b6262314 100644 --- a/runtime/vm/signal_handler_android.cc +++ b/runtime/vm/signal_handler_android.cc @@ -136,55 +136,6 @@ void SignalHandler::Remove() { RELEASE_ASSERT(r == 0); } -void* SignalHandler::PrepareCurrentThread() { - // These constants are selected to prevent allocating alternative signal - // stack if Bionic has already allocated large enough one for us. They - // match current values used in Bionic[1]. - // - // [1]: https://cs.android.com/android/platform/superproject/main/+/main:bionic/libc/bionic/pthread_internal.h;drc=3649db34a154cedb8ef53a5adbaa349970159b58;l=243 - const intptr_t kGuardPageSize = 4 * KB; -#if defined(TARGET_ARCH_IS_64_BIT) - const intptr_t kSigAltStackSize = 32 * KB; -#else - const intptr_t kSigAltStackSize = 16 * KB; -#endif - - // First check if the alternative signal stack is already installed and - // large enough. - int r; - stack_t ss; - memset(&ss, 0, sizeof(ss)); - r = sigaltstack(nullptr, &ss); - ASSERT(r == 0); - if (ss.ss_flags == 0 && ss.ss_size >= (kSigAltStackSize - kGuardPageSize)) { - // Bionic has created a large enough stack already. - return nullptr; - } - - // We are running on an older version of Android, where Bionic creates - // stacks which are too small. - ss.ss_sp = malloc(kSigAltStackSize); - ss.ss_size = kSigAltStackSize; - ss.ss_flags = 0; - r = sigaltstack(&ss, nullptr); - ASSERT(r == 0); - - return ss.ss_sp; -} - -void SignalHandler::CleanupCurrentThreadState(void* stack) { - if (stack != nullptr) { - // Disable alternative stack then free allocated memory. - stack_t ss, old_ss; - memset(&ss, 0, sizeof(ss)); - ss.ss_flags = SS_DISABLE; - int r = sigaltstack(&ss, &old_ss); - ASSERT(r == 0); - ASSERT(old_ss.ss_sp == stack); - free(stack); - } -} - } // namespace dart #endif // defined(DART_HOST_OS_ANDROID) diff --git a/runtime/vm/thread_interrupter.cc b/runtime/vm/thread_interrupter.cc index b5bf493c3cd..d89cf506371 100644 --- a/runtime/vm/thread_interrupter.cc +++ b/runtime/vm/thread_interrupter.cc @@ -231,14 +231,6 @@ void ThreadInterrupter::ThreadMain(uword parameters) { } } -#if !defined(DART_HOST_OS_ANDROID) -void* ThreadInterrupter::PrepareCurrentThread() { - return nullptr; -} - -void ThreadInterrupter::CleanupCurrentThreadState(void* state) {} -#endif - #endif // defined(DART_INCLUDE_PROFILER) } // namespace dart diff --git a/runtime/vm/thread_interrupter.h b/runtime/vm/thread_interrupter.h index 13c858dd9cf..abf98a084ee 100644 --- a/runtime/vm/thread_interrupter.h +++ b/runtime/vm/thread_interrupter.h @@ -39,13 +39,6 @@ class ThreadInterrupter : public AllStatic { // Interrupt a thread. static void InterruptThread(OSThread* thread); - // Prepare current thread for handling interrupts. Returns - // opaque pointer to the allocated state (if any). - static void* PrepareCurrentThread(); - - // Cleanup any state which was created by |PrepareCurrentThread|. - static void CleanupCurrentThreadState(void* state); - private: static constexpr intptr_t kMaxThreads = 4096; static bool initialized_; diff --git a/runtime/vm/thread_interrupter_android.cc b/runtime/vm/thread_interrupter_android.cc index edbcce60b05..191f21cbac1 100644 --- a/runtime/vm/thread_interrupter_android.cc +++ b/runtime/vm/thread_interrupter_android.cc @@ -147,14 +147,6 @@ void ThreadInterrupter::RemoveSignalHandler() { SignalHandler::Remove(); } -void* ThreadInterrupter::PrepareCurrentThread() { - return SignalHandler::PrepareCurrentThread(); -} - -void ThreadInterrupter::CleanupCurrentThreadState(void* state) { - SignalHandler::CleanupCurrentThreadState(state); -} - #endif // defined(DART_INCLUDE_PROFILER) } // namespace dart