From c7ce63313d06454966a777bf84bf3f4b4a48ab61 Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Thu, 13 Jun 2013 13:49:20 +0200 Subject: QNX: Changing the way JSC retrieves the current stack base pointer What Qt is calling the stackbase is the top of the stack. The thread local storage [__tls()] area is at the top of the stack and the stack pointer is initialized below this on thread creation. With this patch, the stack base pointer can be retrieved faster then in the current implementation. This patch is from Sean Boudreau. Change-Id: I3d1ac58d5c43997cbf462424c66be0c7caafcf1b Reviewed-by: Thomas McGuire Reviewed-by: Alan Alpert Reviewed-by: Simon Hausmann --- .../JavaScriptCore/runtime/Collector.cpp | 36 ++-------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp index 711949b..2c859a2 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp @@ -83,10 +83,7 @@ #endif #if OS(QNX) -#include -#include -#include -#include +#include #endif #endif @@ -548,33 +545,6 @@ static void *hpux_get_stack_base() } #endif -#if OS(QNX) -static inline void *currentThreadStackBaseQNX() -{ - static void* stackBase = 0; - static size_t stackSize = 0; - static pthread_t stackThread; - pthread_t thread = pthread_self(); - if (stackBase == 0 || thread != stackThread) { - struct _debug_thread_info threadInfo; - memset(&threadInfo, 0, sizeof(threadInfo)); - threadInfo.tid = pthread_self(); - int fd = open("/proc/self", O_RDONLY); - if (fd == -1) { - LOG_ERROR("Unable to open /proc/self (errno: %d)", errno); - return 0; - } - devctl(fd, DCMD_PROC_TIDSTATUS, &threadInfo, sizeof(threadInfo), 0); - close(fd); - stackBase = reinterpret_cast(threadInfo.stkbase); - stackSize = threadInfo.stksize; - ASSERT(stackBase); - stackThread = thread; - } - return static_cast(stackBase) + stackSize; -} -#endif - static inline void* currentThreadStackBase() { #if OS(DARWIN) @@ -613,9 +583,7 @@ static inline void* currentThreadStackBase() #elif OS(HPUX) return hpux_get_stack_base(); #elif OS(QNX) - AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); - MutexLocker locker(mutex); - return currentThreadStackBaseQNX(); + return (void *) (((uintptr_t)__tls() + __PAGESIZE - 1) & ~(__PAGESIZE - 1)); #elif OS(SOLARIS) stack_t s; thr_stksegment(&s); -- cgit v0.12