Skip to content
Browse files

v8: don't use thread-local storage

  • Loading branch information...
1 parent 7247fac commit 5264c4b7d6d3af1a9452b3d88f592282414301ef @bnoordhuis committed
Showing with 20 additions and 30 deletions.
  1. +0 −29 deps/v8/src/platform-linux.cc
  2. +20 −1 deps/v8/src/platform.h
View
29 deps/v8/src/platform-linux.cc
@@ -778,35 +778,6 @@ void Thread::Join() {
}
-Thread::LocalStorageKey Thread::CreateThreadLocalKey() {
- pthread_key_t key;
- int result = pthread_key_create(&key, NULL);
- USE(result);
- ASSERT(result == 0);
- return static_cast<LocalStorageKey>(key);
-}
-
-
-void Thread::DeleteThreadLocalKey(LocalStorageKey key) {
- pthread_key_t pthread_key = static_cast<pthread_key_t>(key);
- int result = pthread_key_delete(pthread_key);
- USE(result);
- ASSERT(result == 0);
-}
-
-
-void* Thread::GetThreadLocal(LocalStorageKey key) {
- pthread_key_t pthread_key = static_cast<pthread_key_t>(key);
- return pthread_getspecific(pthread_key);
-}
-
-
-void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
- pthread_key_t pthread_key = static_cast<pthread_key_t>(key);
- pthread_setspecific(pthread_key, value);
-}
-
-
void Thread::YieldCPU() {
sched_yield();
}
View
21 deps/v8/src/platform.h
@@ -410,10 +410,14 @@ class Thread {
// LOCAL_STORAGE_KEY_MIN_VALUE and LOCAL_STORAGE_KEY_MAX_VALUE are specified
// to ensure that enumeration type has correct value range (see Issue 830 for
// more details).
+#if __linux__
+ typedef void **LocalStorageKey;
+#else
enum LocalStorageKey {
LOCAL_STORAGE_KEY_MIN_VALUE = kMinInt,
LOCAL_STORAGE_KEY_MAX_VALUE = kMaxInt
};
+#endif
class Options {
public:
@@ -447,13 +451,28 @@ class Thread {
virtual void Run() = 0;
// Thread-local storage.
+#if __linux__
+ static LocalStorageKey CreateThreadLocalKey() {
+ return new void*(0);
+ }
+ static void DeleteThreadLocalKey(LocalStorageKey key) {
+ delete key;
+ }
+ static void* GetThreadLocal(LocalStorageKey key) {
+ return *key;
+ }
+ static void SetThreadLocal(LocalStorageKey key, void* value) {
+ *key = value;
+ }
+#else
static LocalStorageKey CreateThreadLocalKey();
static void DeleteThreadLocalKey(LocalStorageKey key);
static void* GetThreadLocal(LocalStorageKey key);
+ static void SetThreadLocal(LocalStorageKey key, void* value);
+#endif
static int GetThreadLocalInt(LocalStorageKey key) {
return static_cast<int>(reinterpret_cast<intptr_t>(GetThreadLocal(key)));
}
- static void SetThreadLocal(LocalStorageKey key, void* value);
static void SetThreadLocalInt(LocalStorageKey key, int value) {
SetThreadLocal(key, reinterpret_cast<void*>(static_cast<intptr_t>(value)));
}

0 comments on commit 5264c4b

Please sign in to comment.
Something went wrong with that request. Please try again.