Title: [237059] trunk/Source
Revision
237059
Author
[email protected]
Date
2018-10-11 18:32:19 -0700 (Thu, 11 Oct 2018)

Log Message

Use currentStackPointer more
https://bugs.webkit.org/show_bug.cgi?id=190503

Reviewed by Saam Barati.

Source/_javascript_Core:

* runtime/VM.cpp:
(JSC::VM::committedStackByteCount):

Source/WTF:

Use WTF::currentStackPointer more in WebKit to adopt ASAN detect_stack_use_after_return option.

* wtf/StackBounds.cpp:
(WTF::testStackDirection2):
(WTF::testStackDirection):
* wtf/ThreadingPthreads.cpp:
(WTF::Thread::signalHandlerSuspendResume):
(WTF::getApproximateStackPointer): Deleted.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (237058 => 237059)


--- trunk/Source/_javascript_Core/ChangeLog	2018-10-12 00:23:08 UTC (rev 237058)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-10-12 01:32:19 UTC (rev 237059)
@@ -1,3 +1,13 @@
+2018-10-11  Yusuke Suzuki  <[email protected]>
+
+        Use currentStackPointer more
+        https://bugs.webkit.org/show_bug.cgi?id=190503
+
+        Reviewed by Saam Barati.
+
+        * runtime/VM.cpp:
+        (JSC::VM::committedStackByteCount):
+
 2018-10-08  Yusuke Suzuki  <[email protected]>
 
         [JSC] JSC should have "parseFunction" to optimize Function constructor

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (237058 => 237059)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2018-10-12 00:23:08 UTC (rev 237058)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2018-10-12 01:32:19 UTC (rev 237059)
@@ -1157,8 +1157,8 @@
     // When using the C stack, we don't know how many stack pages are actually
     // committed. So, we use the current stack usage as an estimate.
     ASSERT(Thread::current().stack().isGrowingDownward());
-    int8_t* current = reinterpret_cast<int8_t*>(&current);
-    int8_t* high = reinterpret_cast<int8_t*>(Thread::current().stack().origin());
+    uint8_t* current = bitwise_cast<uint8_t*>(currentStackPointer());
+    uint8_t* high = bitwise_cast<uint8_t*>(Thread::current().stack().origin());
     return high - current;
 #else
     return CLoopStack::committedByteCount();

Modified: trunk/Source/WTF/ChangeLog (237058 => 237059)


--- trunk/Source/WTF/ChangeLog	2018-10-12 00:23:08 UTC (rev 237058)
+++ trunk/Source/WTF/ChangeLog	2018-10-12 01:32:19 UTC (rev 237059)
@@ -1,3 +1,19 @@
+2018-10-11  Yusuke Suzuki  <[email protected]>
+
+        Use currentStackPointer more
+        https://bugs.webkit.org/show_bug.cgi?id=190503
+
+        Reviewed by Saam Barati.
+
+        Use WTF::currentStackPointer more in WebKit to adopt ASAN detect_stack_use_after_return option.
+
+        * wtf/StackBounds.cpp:
+        (WTF::testStackDirection2):
+        (WTF::testStackDirection):
+        * wtf/ThreadingPthreads.cpp:
+        (WTF::Thread::signalHandlerSuspendResume):
+        (WTF::getApproximateStackPointer): Deleted.
+
 2018-10-11  Ross Kirsling  <[email protected]>
 
         [WTF] Semaphore.h conflicts with POSIX header

Modified: trunk/Source/WTF/wtf/StackBounds.cpp (237058 => 237059)


--- trunk/Source/WTF/wtf/StackBounds.cpp	2018-10-12 00:23:08 UTC (rev 237058)
+++ trunk/Source/WTF/wtf/StackBounds.cpp	2018-10-12 01:32:19 UTC (rev 237059)
@@ -50,17 +50,17 @@
     return StackDirection::Downward;
 }
 #else
-static NEVER_INLINE NOT_TAIL_CALLED StackBounds::StackDirection testStackDirection2(volatile const int* pointer)
+static NEVER_INLINE NOT_TAIL_CALLED StackBounds::StackDirection testStackDirection2(volatile const uint8_t* pointer)
 {
-    volatile int stackValue = 42;
-    return (pointer < &stackValue) ? StackBounds::StackDirection::Upward : StackBounds::StackDirection::Downward;
+    volatile uint8_t* stackValue = bitwise_cast<uint8_t*>(currentStackPointer());
+    return (pointer < stackValue) ? StackBounds::StackDirection::Upward : StackBounds::StackDirection::Downward;
 }
 
 static NEVER_INLINE NOT_TAIL_CALLED StackBounds::StackDirection testStackDirection()
 {
     NO_TAIL_CALLS();
-    volatile int stackValue = 42;
-    return testStackDirection2(&stackValue);
+    volatile uint8_t* stackValue = bitwise_cast<uint8_t*>(currentStackPointer());
+    return testStackDirection2(stackValue);
 }
 
 NEVER_INLINE StackBounds::StackDirection StackBounds::stackDirection()

Modified: trunk/Source/WTF/wtf/ThreadingPthreads.cpp (237058 => 237059)


--- trunk/Source/WTF/wtf/ThreadingPthreads.cpp	2018-10-12 00:23:08 UTC (rev 237058)
+++ trunk/Source/WTF/wtf/ThreadingPthreads.cpp	2018-10-12 01:32:19 UTC (rev 237059)
@@ -109,19 +109,6 @@
 static constexpr const int SigThreadSuspendResume = SIGUSR1;
 static std::atomic<Thread*> targetThread { nullptr };
 
-IGNORE_GCC_WARNINGS_BEGIN("return-local-addr")
-IGNORE_CLANG_WARNINGS_BEGIN("return-stack-address")
-
-static NEVER_INLINE void* getApproximateStackPointer()
-{
-    volatile uintptr_t stackLocation;
-    stackLocation = bitwise_cast<uintptr_t>(&stackLocation);
-    return bitwise_cast<void*>(stackLocation);
-}
-
-IGNORE_CLANG_WARNINGS_END
-IGNORE_GCC_WARNINGS_END
-
 void Thread::signalHandlerSuspendResume(int, siginfo_t*, void* ucontext)
 {
     // Touching a global variable atomic types from signal handlers is allowed.
@@ -137,7 +124,7 @@
         return;
     }
 
-    void* approximateStackPointer = getApproximateStackPointer();
+    void* approximateStackPointer = currentStackPointer();
     if (!thread->m_stack.contains(approximateStackPointer)) {
         // This happens if we use an alternative signal stack.
         // 1. A user-defined signal handler is invoked with an alternative signal stack.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to