mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[vm] Require C11 thread_local support.
Thus requiring iOS 9+. TEST=build Change-Id: I40062753ae030231d4e4ae428c9145f4370cb9a0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213283 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Chinmay Garde <chinmaygarde@google.com>
This commit is contained in:
parent
ebb1a53a44
commit
700969604a
|
@ -20,9 +20,7 @@ OSThread* OSThread::thread_list_head_ = NULL;
|
|||
Mutex* OSThread::thread_list_lock_ = NULL;
|
||||
bool OSThread::creation_enabled_ = false;
|
||||
|
||||
#if defined(HAS_C11_THREAD_LOCAL)
|
||||
thread_local ThreadState* OSThread::current_vm_thread_ = NULL;
|
||||
#endif
|
||||
|
||||
OSThread::OSThread()
|
||||
: BaseThread(true),
|
||||
|
@ -282,14 +280,12 @@ void OSThread::SetCurrentTLS(BaseThread* value) {
|
|||
// Provides thread-local destructors.
|
||||
SetThreadLocal(thread_key_, reinterpret_cast<uword>(value));
|
||||
|
||||
#if defined(HAS_C11_THREAD_LOCAL)
|
||||
// Allows the C compiler more freedom to optimize.
|
||||
if ((value != NULL) && !value->is_os_thread()) {
|
||||
current_vm_thread_ = static_cast<Thread*>(value);
|
||||
} else {
|
||||
current_vm_thread_ = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
OSThreadIterator::OSThreadIterator() {
|
||||
|
|
|
@ -12,11 +12,6 @@
|
|||
#include "vm/allocation.h"
|
||||
#include "vm/globals.h"
|
||||
|
||||
// On iOS, thread_local requires iOS 9+.
|
||||
#if !DART_HOST_OS_IOS
|
||||
#define HAS_C11_THREAD_LOCAL 1
|
||||
#endif
|
||||
|
||||
// Declare the OS-specific types ahead of defining the generic classes.
|
||||
#if defined(DART_HOST_OS_ANDROID)
|
||||
#include "vm/os_thread_android.h"
|
||||
|
@ -182,9 +177,7 @@ class OSThread : public BaseThread {
|
|||
}
|
||||
static void SetCurrent(OSThread* current) { SetCurrentTLS(current); }
|
||||
|
||||
#if defined(HAS_C11_THREAD_LOCAL)
|
||||
static ThreadState* CurrentVMThread() { return current_vm_thread_; }
|
||||
#endif
|
||||
|
||||
// TODO(5411455): Use flag to override default value and Validate the
|
||||
// stack size by querying OS.
|
||||
|
@ -308,9 +301,7 @@ class OSThread : public BaseThread {
|
|||
static OSThread* thread_list_head_;
|
||||
static bool creation_enabled_;
|
||||
|
||||
#if defined(HAS_C11_THREAD_LOCAL)
|
||||
static thread_local ThreadState* current_vm_thread_;
|
||||
#endif
|
||||
|
||||
friend class IsolateGroup; // to access set_thread(Thread*).
|
||||
friend class OSThreadIterator;
|
||||
|
|
|
@ -282,15 +282,7 @@ class Thread : public ThreadState {
|
|||
|
||||
// The currently executing thread, or NULL if not yet initialized.
|
||||
static Thread* Current() {
|
||||
#if defined(HAS_C11_THREAD_LOCAL)
|
||||
return static_cast<Thread*>(OSThread::CurrentVMThread());
|
||||
#else
|
||||
BaseThread* thread = OSThread::GetCurrentTLS();
|
||||
if (thread == NULL || thread->is_os_thread()) {
|
||||
return NULL;
|
||||
}
|
||||
return static_cast<Thread*>(thread);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Makes the current thread enter 'isolate'.
|
||||
|
|
|
@ -25,15 +25,7 @@ class ThreadState : public BaseThread {
|
|||
public:
|
||||
// The currently executing thread, or NULL if not yet initialized.
|
||||
static ThreadState* Current() {
|
||||
#if defined(HAS_C11_THREAD_LOCAL)
|
||||
return OSThread::CurrentVMThread();
|
||||
#else
|
||||
BaseThread* thread = OSThread::GetCurrentTLS();
|
||||
if (thread == NULL || thread->is_os_thread()) {
|
||||
return NULL;
|
||||
}
|
||||
return static_cast<ThreadState*>(thread);
|
||||
#endif
|
||||
}
|
||||
|
||||
explicit ThreadState(bool is_os_thread);
|
||||
|
|
Loading…
Reference in a new issue