Title: [215269] trunk/Source
Revision
215269
Author
[email protected]
Date
2017-04-12 09:59:26 -0700 (Wed, 12 Apr 2017)

Log Message

[JSC] Clean up heap/MachineStackMarker by introducing USE(MACHINE_CONTEXT)
https://bugs.webkit.org/show_bug.cgi?id=170770

Reviewed by Mark Lam.

Source/_javascript_Core:

We use USE(MACHINE_CONTEXT) to clean up runtime/MachineContext.h. And
we clean up heap/MachineStackMarker.cpp by using MachineContext functions.

* heap/MachineStackMarker.cpp:
(JSC::MachineThreads::MachineThread::Registers::stackPointer):
(JSC::MachineThreads::MachineThread::Registers::framePointer):
(JSC::MachineThreads::MachineThread::Registers::instructionPointer):
(JSC::MachineThreads::MachineThread::Registers::llintPC):
* heap/MachineStackMarker.h:
* runtime/MachineContext.h:
(JSC::MachineContext::stackPointer):
(JSC::MachineContext::framePointer):
(JSC::MachineContext::instructionPointer):
(JSC::MachineContext::argumentPointer<1>):
(JSC::MachineContext::llintInstructionPointer):

Source/WTF:

We add a new define USE_MACHINE_CONTEXT, which becomes true if mcontext_t exists
and we know the way to retrieve values from mcontext_t.

* wtf/Platform.h:
* wtf/PlatformRegisters.h:
* wtf/ThreadingPthreads.cpp:
(WTF::Thread::getRegisters):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (215268 => 215269)


--- trunk/Source/_javascript_Core/ChangeLog	2017-04-12 15:52:39 UTC (rev 215268)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-04-12 16:59:26 UTC (rev 215269)
@@ -1,5 +1,28 @@
 2017-04-12  Yusuke Suzuki  <[email protected]>
 
+        [JSC] Clean up heap/MachineStackMarker by introducing USE(MACHINE_CONTEXT)
+        https://bugs.webkit.org/show_bug.cgi?id=170770
+
+        Reviewed by Mark Lam.
+
+        We use USE(MACHINE_CONTEXT) to clean up runtime/MachineContext.h. And
+        we clean up heap/MachineStackMarker.cpp by using MachineContext functions.
+
+        * heap/MachineStackMarker.cpp:
+        (JSC::MachineThreads::MachineThread::Registers::stackPointer):
+        (JSC::MachineThreads::MachineThread::Registers::framePointer):
+        (JSC::MachineThreads::MachineThread::Registers::instructionPointer):
+        (JSC::MachineThreads::MachineThread::Registers::llintPC):
+        * heap/MachineStackMarker.h:
+        * runtime/MachineContext.h:
+        (JSC::MachineContext::stackPointer):
+        (JSC::MachineContext::framePointer):
+        (JSC::MachineContext::instructionPointer):
+        (JSC::MachineContext::argumentPointer<1>):
+        (JSC::MachineContext::llintInstructionPointer):
+
+2017-04-12  Yusuke Suzuki  <[email protected]>
+
         [WTF] Introduce Thread class and use RefPtr<Thread> and align Windows Threading implementation semantics to Pthread one
         https://bugs.webkit.org/show_bug.cgi?id=170502
 

Modified: trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp (215268 => 215269)


--- trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp	2017-04-12 15:52:39 UTC (rev 215268)
+++ trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp	2017-04-12 16:59:26 UTC (rev 215269)
@@ -226,19 +226,13 @@
 
 void* MachineThreads::MachineThread::Registers::stackPointer() const
 {
-#if OS(DARWIN) || OS(WINDOWS) || ((OS(FREEBSD) || defined(__GLIBC__)) && ENABLE(JIT))
     return MachineContext::stackPointer(regs);
-#elif USE(PTHREADS)
-    return regs.stackPointer;
-#else
-#error Need a way to get the stack pointer for another thread on this platform
-#endif
 }
 
 #if ENABLE(SAMPLING_PROFILER)
 void* MachineThreads::MachineThread::Registers::framePointer() const
 {
-#if OS(DARWIN) || OS(WINDOWS) || (OS(FREEBSD) || defined(__GLIBC__))
+#if OS(WINDOWS) || USE(MACHINE_CONTEXT)
     return MachineContext::framePointer(regs);
 #else
 #error Need a way to get the frame pointer for another thread on this platform
@@ -247,7 +241,7 @@
 
 void* MachineThreads::MachineThread::Registers::instructionPointer() const
 {
-#if OS(DARWIN) || OS(WINDOWS) || (OS(FREEBSD) || defined(__GLIBC__))
+#if OS(WINDOWS) || USE(MACHINE_CONTEXT)
     return MachineContext::instructionPointer(regs);
 #else
 #error Need a way to get the instruction pointer for another thread on this platform
@@ -257,7 +251,7 @@
 void* MachineThreads::MachineThread::Registers::llintPC() const
 {
     // LLInt uses regT4 as PC.
-#if OS(DARWIN) || OS(WINDOWS) || (OS(FREEBSD) || defined(__GLIBC__))
+#if OS(WINDOWS) || USE(MACHINE_CONTEXT)
     return MachineContext::llintInstructionPointer(regs);
 #else
 #error Need a way to get the LLIntPC for another thread on this platform

Modified: trunk/Source/_javascript_Core/heap/MachineStackMarker.h (215268 => 215269)


--- trunk/Source/_javascript_Core/heap/MachineStackMarker.h	2017-04-12 15:52:39 UTC (rev 215268)
+++ trunk/Source/_javascript_Core/heap/MachineStackMarker.h	2017-04-12 16:59:26 UTC (rev 215269)
@@ -63,7 +63,7 @@
             void* instructionPointer() const;
             void* llintPC() const;
 #endif // ENABLE(SAMPLING_PROFILER)
-            WTF::PlatformRegisters regs;
+            PlatformRegisters regs;
         };
 
         Expected<void, Thread::PlatformSuspendError> suspend() { return m_thread->suspend(); }

Modified: trunk/Source/_javascript_Core/runtime/MachineContext.h (215268 => 215269)


--- trunk/Source/_javascript_Core/runtime/MachineContext.h	2017-04-12 15:52:39 UTC (rev 215268)
+++ trunk/Source/_javascript_Core/runtime/MachineContext.h	2017-04-12 16:59:26 UTC (rev 215269)
@@ -27,52 +27,43 @@
 
 #include "GPRInfo.h"
 #include "LLIntPCRanges.h"
+#include <wtf/PlatformRegisters.h>
 #include <wtf/StdLibExtras.h>
 
-#if OS(DARWIN) || OS(FREEBSD) || defined(__GLIBC__)
-#include <signal.h>
-// Using signal.h didn't make mcontext_t and ucontext_t available on FreeBSD.
-// This bug has been fixed in FreeBSD 11.0-CURRENT, so this workaround can be
-// removed after FreeBSD 10.x goes EOL.
-// https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=207079
-#if OS(FREEBSD)
-#include <ucontext.h>
-#endif
-#endif
-
-#if OS(DARWIN)
-#include <mach/thread_act.h>
-#endif
-
 namespace JSC {
 namespace MachineContext {
 
-#if OS(DARWIN)
 
-#if CPU(X86)
-typedef i386_thread_state_t PlatformRegisters;
-#elif CPU(X86_64)
-typedef x86_thread_state64_t PlatformRegisters;
-#elif CPU(PPC)
-typedef ppc_thread_state_t PlatformRegisters;
-#elif CPU(PPC64)
-typedef ppc_thread_state64_t PlatformRegisters;
-#elif CPU(ARM)
-typedef arm_thread_state_t PlatformRegisters;
-#elif CPU(ARM64)
-typedef arm_thread_state64_t PlatformRegisters;
-#else
-#error Unknown Architecture
-#endif
+void*& stackPointer(PlatformRegisters&);
+void* stackPointer(const PlatformRegisters&);
 
-#elif OS(WINDOWS)
+#if OS(WINDOWS) || USE(MACHINE_CONTEXT)
+void*& framePointer(PlatformRegisters&);
+void* framePointer(const PlatformRegisters&);
+void*& instructionPointer(PlatformRegisters&);
+void* instructionPointer(const PlatformRegisters&);
+template<size_t N> void*& argumentPointer(PlatformRegisters&);
+template<size_t N> void* argumentPointer(const PlatformRegisters&);
+#if ENABLE(JIT)
+void*& llintInstructionPointer(PlatformRegisters&);
+void* llintInstructionPointer(const PlatformRegisters&);
+#endif // ENABLE(JIT)
+#if USE(MACHINE_CONTEXT)
+void*& stackPointer(mcontext_t&);
+void* stackPointer(const mcontext_t&);
+void*& framePointer(mcontext_t&);
+void* framePointer(const mcontext_t&);
+void*& instructionPointer(mcontext_t&);
+void* instructionPointer(const mcontext_t&);
+template<size_t N> void*& argumentPointer(mcontext_t&);
+template<size_t N> void* argumentPointer(const mcontext_t&);
+#if ENABLE(JIT)
+void*& llintInstructionPointer(mcontext_t&);
+void* llintInstructionPointer(const mcontext_t&);
+#endif // ENABLE(JIT)
+#endif // USE(MACHINE_CONTEXT)
+#endif // OS(WINDOWS) || USE(MACHINE_CONTEXT)
 
-typedef CONTEXT PlatformRegisters;
-
-#endif
-
-
-#if OS(DARWIN) || OS(WINDOWS)
 inline void*& stackPointer(PlatformRegisters& regs)
 {
 #if OS(DARWIN)
@@ -118,7 +109,11 @@
 #error Unknown Architecture
 #endif
 
-#endif // OS(DARWIN)
+#elif USE(MACHINE_CONTEXT)
+    return stackPointer(regs.machineContext);
+#else
+    return regs.stackPointer;
+#endif
 }
 
 inline void* stackPointer(const PlatformRegisters& regs)
@@ -125,10 +120,9 @@
 {
     return stackPointer(const_cast<PlatformRegisters&>(regs));
 }
-#endif // OS(DARWIN) || OS(WINDOWS)
 
 
-#if OS(DARWIN) || ((OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
+#if USE(MACHINE_CONTEXT)
 inline void*& stackPointer(mcontext_t& machineContext)
 {
 #if OS(DARWIN)
@@ -171,10 +165,10 @@
 {
     return stackPointer(const_cast<mcontext_t&>(machineContext));
 }
-#endif // OS(DARWIN) || ((OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
+#endif // USE(MACHINE_CONTEXT)
 
 
-#if OS(DARWIN) || OS(WINDOWS)
+#if OS(WINDOWS) || USE(MACHINE_CONTEXT)
 inline void*& framePointer(PlatformRegisters& regs)
 {
 #if OS(DARWIN)
@@ -221,7 +215,9 @@
 #error Unknown Architecture
 #endif
 
-#endif // OS(DARWIN)
+#elif USE(MACHINE_CONTEXT)
+    return framePointer(regs.machineContext);
+#endif
 }
 
 inline void* framePointer(const PlatformRegisters& regs)
@@ -228,10 +224,10 @@
 {
     return framePointer(const_cast<PlatformRegisters&>(regs));
 }
-#endif // OS(DARWIN) || OS(WINDOWS)
+#endif // OS(WINDOWS) || USE(MACHINE_CONTEXT)
 
 
-#if OS(DARWIN) || ((OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
+#if USE(MACHINE_CONTEXT)
 inline void*& framePointer(mcontext_t& machineContext)
 {
 #if OS(DARWIN)
@@ -278,10 +274,10 @@
 {
     return framePointer(const_cast<mcontext_t&>(machineContext));
 }
-#endif // OS(DARWIN) || ((OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
+#endif // USE(MACHINE_CONTEXT)
 
 
-#if OS(DARWIN) || OS(WINDOWS)
+#if OS(WINDOWS) || USE(MACHINE_CONTEXT)
 inline void*& instructionPointer(PlatformRegisters& regs)
 {
 #if OS(DARWIN)
@@ -322,7 +318,9 @@
 #error Unknown Architecture
 #endif
 
-#endif // OS(DARWIN)
+#elif USE(MACHINE_CONTEXT)
+    return instructionPointer(regs.machineContext);
+#endif
 }
 
 inline void* instructionPointer(const PlatformRegisters& regs)
@@ -329,11 +327,10 @@
 {
     return instructionPointer(const_cast<PlatformRegisters&>(regs));
 }
-#endif // OS(DARWIN) || OS(WINDOWS)
+#endif // OS(WINDOWS) || USE(MACHINE_CONTEXT)
 
 
-#if OS(DARWIN) || ((OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
-
+#if USE(MACHINE_CONTEXT)
 inline void*& instructionPointer(mcontext_t& machineContext)
 {
 #if OS(DARWIN)
@@ -380,12 +377,13 @@
 {
     return instructionPointer(const_cast<mcontext_t&>(machineContext));
 }
-#endif // OS(DARWIN) || ((OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
+#endif // USE(MACHINE_CONTEXT)
 
 
-#if OS(DARWIN) || OS(WINDOWS)
-template<size_t N>
-void*& argumentPointer(PlatformRegisters&);
+#if OS(WINDOWS) || USE(MACHINE_CONTEXT)
+#if USE(MACHINE_CONTEXT)
+template<> void*& argumentPointer<1>(mcontext_t&);
+#endif
 
 template<>
 inline void*& argumentPointer<1>(PlatformRegisters& regs)
@@ -431,7 +429,9 @@
 #error Unknown Architecture
 #endif
 
-#endif // OS(DARWIN)
+#elif USE(MACHINE_CONTEXT)
+    return argumentPointer<1>(regs.machineContext);
+#endif
 }
 
 template<size_t N>
@@ -439,13 +439,9 @@
 {
     return argumentPointer<N>(const_cast<PlatformRegisters&>(regs));
 }
-#endif // OS(DARWIN) || OS(WINDOWS)
+#endif // OS(WINDOWS) || USE(MACHINE_CONTEXT)
 
-
-#if OS(DARWIN) || ((OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
-template<unsigned N>
-void*& argumentPointer(mcontext_t&);
-
+#if USE(MACHINE_CONTEXT)
 template<>
 inline void*& argumentPointer<1>(mcontext_t& machineContext)
 {
@@ -494,10 +490,10 @@
 {
     return argumentPointer<N>(const_cast<mcontext_t&>(machineContext));
 }
-#endif // OS(DARWIN) || ((OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
+#endif // USE(MACHINE_CONTEXT)
 
 #if ENABLE(JIT)
-#if OS(DARWIN) || OS(WINDOWS)
+#if OS(WINDOWS) || USE(MACHINE_CONTEXT)
 inline void*& llintInstructionPointer(PlatformRegisters& regs)
 {
     // LLInt uses regT4 as PC.
@@ -550,7 +546,9 @@
 #error Unknown Architecture
 #endif
 
-#endif // OS(DARWIN)
+#elif USE(MACHINE_CONTEXT)
+    return llintInstructionPointer(regs.machineContext);
+#endif
 }
 
 inline void* llintInstructionPointer(const PlatformRegisters& regs)
@@ -557,10 +555,10 @@
 {
     return llintInstructionPointer(const_cast<PlatformRegisters&>(regs));
 }
-#endif // OS(DARWIN) || OS(WINDOWS)
+#endif // OS(WINDOWS) || USE(MACHINE_CONTEXT)
 
 
-#if OS(DARWIN) || ((OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
+#if USE(MACHINE_CONTEXT)
 inline void*& llintInstructionPointer(mcontext_t& machineContext)
 {
     // LLInt uses regT4 as PC.
@@ -608,7 +606,7 @@
 {
     return llintInstructionPointer(const_cast<mcontext_t&>(machineContext));
 }
-#endif // OS(DARWIN) || ((OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
+#endif // USE(MACHINE_CONTEXT)
 #endif // ENABLE(JIT)
 
 }

Modified: trunk/Source/WTF/ChangeLog (215268 => 215269)


--- trunk/Source/WTF/ChangeLog	2017-04-12 15:52:39 UTC (rev 215268)
+++ trunk/Source/WTF/ChangeLog	2017-04-12 16:59:26 UTC (rev 215269)
@@ -1,5 +1,20 @@
 2017-04-12  Yusuke Suzuki  <[email protected]>
 
+        [JSC] Clean up heap/MachineStackMarker by introducing USE(MACHINE_CONTEXT)
+        https://bugs.webkit.org/show_bug.cgi?id=170770
+
+        Reviewed by Mark Lam.
+
+        We add a new define USE_MACHINE_CONTEXT, which becomes true if mcontext_t exists
+        and we know the way to retrieve values from mcontext_t.
+
+        * wtf/Platform.h:
+        * wtf/PlatformRegisters.h:
+        * wtf/ThreadingPthreads.cpp:
+        (WTF::Thread::getRegisters):
+
+2017-04-12  Yusuke Suzuki  <[email protected]>
+
         [WTF] Introduce Thread class and use RefPtr<Thread> and align Windows Threading implementation semantics to Pthread one
         https://bugs.webkit.org/show_bug.cgi?id=170502
 

Modified: trunk/Source/WTF/wtf/Platform.h (215268 => 215269)


--- trunk/Source/WTF/wtf/Platform.h	2017-04-12 15:52:39 UTC (rev 215268)
+++ trunk/Source/WTF/wtf/Platform.h	2017-04-12 16:59:26 UTC (rev 215269)
@@ -1214,4 +1214,8 @@
 #define USE_LIBWEBRTC 1
 #endif
 
+#if OS(DARWIN) || ((OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
+#define USE_MACHINE_CONTEXT 1
+#endif
+
 #endif /* WTF_Platform_h */

Modified: trunk/Source/WTF/wtf/PlatformRegisters.h (215268 => 215269)


--- trunk/Source/WTF/wtf/PlatformRegisters.h	2017-04-12 15:52:39 UTC (rev 215268)
+++ trunk/Source/WTF/wtf/PlatformRegisters.h	2017-04-12 16:59:26 UTC (rev 215269)
@@ -59,9 +59,11 @@
 
 using PlatformRegisters = CONTEXT;
 
-#elif (OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS))
+#elif USE(MACHINE_CONTEXT)
 
-using PlatformRegisters = mcontext_t;
+struct PlatformRegisters {
+    mcontext_t machineContext;
+};
 
 #else
 
@@ -72,3 +74,5 @@
 #endif
 
 } // namespace WTF
+
+using WTF::PlatformRegisters;

Modified: trunk/Source/WTF/wtf/ThreadingPthreads.cpp (215268 => 215269)


--- trunk/Source/WTF/wtf/ThreadingPthreads.cpp	2017-04-12 15:52:39 UTC (rev 215268)
+++ trunk/Source/WTF/wtf/ThreadingPthreads.cpp	2017-04-12 16:59:26 UTC (rev 215269)
@@ -387,8 +387,8 @@
         CRASH();
     }
     return userCount * sizeof(uintptr_t);
-#elif (OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS))
-    registers = m_suspendedMachineContext;
+#elif USE(MACHINE_CONTEXT)
+    registers.machineContext = m_suspendedMachineContext;
     return sizeof(PlatformRegisters);
 #elif OS(OPENBSD)
     // http://man.openbsd.org/pthread_stackseg_np.3
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to