Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: third_party/WebKit/Source/wtf/ThreadingPthreads.cpp

Issue 2623273007: Fast path for ThreadSpecific for main thread on TLS-slow platforms (Closed)
Patch Set: haraken revieqw Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 void lockAtomicallyInitializedStaticMutex() { 96 void lockAtomicallyInitializedStaticMutex() {
97 DCHECK(atomicallyInitializedStaticMutex); 97 DCHECK(atomicallyInitializedStaticMutex);
98 atomicallyInitializedStaticMutex->lock(); 98 atomicallyInitializedStaticMutex->lock();
99 } 99 }
100 100
101 void unlockAtomicallyInitializedStaticMutex() { 101 void unlockAtomicallyInitializedStaticMutex() {
102 atomicallyInitializedStaticMutex->unlock(); 102 atomicallyInitializedStaticMutex->unlock();
103 } 103 }
104 104
105 ThreadIdentifier currentThread() { 105 ThreadIdentifier currentThread() {
106 // TLS lookup is fast on these platforms.
107 #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD)
108 return wtfThreadData().threadId(); 106 return wtfThreadData().threadId();
109 #else
110 // TODO(csharrison): For platforms where TLS lookup is slow, use the hack that
111 // oilpan uses in ThreadState::current() to check if this is the main thread
112 // via stack address.
113 return internal::currentThreadSyscall();
114 #endif
115 } 107 }
116 108
117 MutexBase::MutexBase(bool recursive) { 109 MutexBase::MutexBase(bool recursive) {
118 pthread_mutexattr_t attr; 110 pthread_mutexattr_t attr;
119 pthread_mutexattr_init(&attr); 111 pthread_mutexattr_init(&attr);
120 pthread_mutexattr_settype( 112 pthread_mutexattr_settype(
121 &attr, recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL); 113 &attr, recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL);
122 114
123 int result = pthread_mutex_init(&m_mutex.m_internalMutex, &attr); 115 int result = pthread_mutex_init(&m_mutex.m_internalMutex, &attr);
124 DCHECK_EQ(result, 0); 116 DCHECK_EQ(result, 0);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 246 }
255 247
256 void willCreateThread() { 248 void willCreateThread() {
257 s_threadCreated = true; 249 s_threadCreated = true;
258 } 250 }
259 #endif 251 #endif
260 252
261 } // namespace WTF 253 } // namespace WTF
262 254
263 #endif // OS(POSIX) 255 #endif // OS(POSIX)
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/ThreadSpecific.h ('k') | third_party/WebKit/Source/wtf/ThreadingWin.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698