Title: [215318] trunk/Source
Revision
215318
Author
[email protected]
Date
2017-04-13 07:17:00 -0700 (Thu, 13 Apr 2017)

Log Message

[JSC] Use proper ifdef guard for code using MachineContext
https://bugs.webkit.org/show_bug.cgi?id=170800

Reviewed by Carlos Alberto Lopez Perez.

Source/_javascript_Core:

This patch drops MachineContext use if it is not available.
This situation can be considered like, building WebKit with musl.
In that case, we simply disable features that rely on MachineContext.
Examples are wasm fast memory, sampling profiler, and code profiling.

* runtime/Options.cpp:
(JSC::overrideDefaults):
* tools/CodeProfiling.cpp:
(JSC::CodeProfiling::begin):
(JSC::CodeProfiling::end):
Previously, PLATFORM(GTK) is excluded. But it is not obvious why it is excluded.
This patch just includes such platforms.

* wasm/WasmFaultSignalHandler.cpp:
(JSC::Wasm::enableFastMemory):

Source/WTF:

SamplingProfiler and FastMemory rely on MachineContext feature.

* wtf/Platform.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (215317 => 215318)


--- trunk/Source/_javascript_Core/ChangeLog	2017-04-13 08:31:54 UTC (rev 215317)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-04-13 14:17:00 UTC (rev 215318)
@@ -1,3 +1,26 @@
+2017-04-13  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Use proper ifdef guard for code using MachineContext
+        https://bugs.webkit.org/show_bug.cgi?id=170800
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        This patch drops MachineContext use if it is not available.
+        This situation can be considered like, building WebKit with musl.
+        In that case, we simply disable features that rely on MachineContext.
+        Examples are wasm fast memory, sampling profiler, and code profiling.
+
+        * runtime/Options.cpp:
+        (JSC::overrideDefaults):
+        * tools/CodeProfiling.cpp:
+        (JSC::CodeProfiling::begin):
+        (JSC::CodeProfiling::end):
+        Previously, PLATFORM(GTK) is excluded. But it is not obvious why it is excluded.
+        This patch just includes such platforms.
+
+        * wasm/WasmFaultSignalHandler.cpp:
+        (JSC::Wasm::enableFastMemory):
+
 2017-04-12  Dan Bernstein  <[email protected]>
 
         [Mac] Future-proof .xcconfig files

Modified: trunk/Source/_javascript_Core/runtime/Options.cpp (215317 => 215318)


--- trunk/Source/_javascript_Core/runtime/Options.cpp	2017-04-13 08:31:54 UTC (rev 215317)
+++ trunk/Source/_javascript_Core/runtime/Options.cpp	2017-04-13 14:17:00 UTC (rev 215318)
@@ -346,6 +346,10 @@
 #if !ENABLE(SIGNAL_BASED_VM_TRAPS)
     Options::usePollingTraps() = true;
 #endif
+
+#if !ENABLE(WEBASSEMBLY_FAST_MEMORY)
+    Options::useWebAssemblyFastMemory() = false;
+#endif
 }
 
 static void recomputeDependentOptions()

Modified: trunk/Source/_javascript_Core/tools/CodeProfiling.cpp (215317 => 215318)


--- trunk/Source/_javascript_Core/tools/CodeProfiling.cpp	2017-04-13 08:31:54 UTC (rev 215317)
+++ trunk/Source/_javascript_Core/tools/CodeProfiling.cpp	2017-04-13 14:17:00 UTC (rev 215318)
@@ -34,7 +34,7 @@
 #include <signal.h>
 #endif
 
-#if OS(LINUX) || OS(DARWIN)
+#if HAVE(MACHINE_CONTEXT)
 #include <sys/time.h>
 #endif
 
@@ -49,7 +49,7 @@
 #pragma clang diagnostic ignored "-Wmissing-noreturn"
 #endif
 
-#if (OS(DARWIN) && !PLATFORM(GTK) && CPU(X86_64)) || (OS(LINUX) && CPU(X86))
+#if HAVE(MACHINE_CONTEXT)
 // Helper function to start & stop the timer.
 // Presently we're using the wall-clock timer, since this seems to give the best results.
 static void setProfileTimer(unsigned usec)
@@ -67,7 +67,7 @@
 #pragma clang diagnostic pop
 #endif
 
-#if (OS(DARWIN) && !PLATFORM(GTK) && CPU(X86_64)) || (OS(LINUX) && CPU(X86))
+#if HAVE(MACHINE_CONTEXT)
 static void profilingTimer(int, siginfo_t*, void* uap)
 {
     mcontext_t context = static_cast<ucontext_t*>(uap)->uc_mcontext;
@@ -136,7 +136,7 @@
     if (alreadyProfiling)
         return;
 
-#if (OS(DARWIN) && !PLATFORM(GTK) && CPU(X86_64)) || (OS(LINUX) && CPU(X86))
+#if HAVE(MACHINE_CONTEXT)
     // Regsiter a signal handler & itimer.
     struct sigaction action;
     action.sa_sigaction = reinterpret_cast<void (*)(int, siginfo_t *, void *)>(profilingTimer);
@@ -160,7 +160,7 @@
     if (s_profileStack)
         return;
 
-#if (OS(DARWIN) && !PLATFORM(GTK) && CPU(X86_64)) || (OS(LINUX) && CPU(X86))
+#if HAVE(MACHINE_CONTEXT)
     // Stop profiling
     setProfileTimer(0);
 #endif

Modified: trunk/Source/_javascript_Core/wasm/WasmFaultSignalHandler.cpp (215317 => 215318)


--- trunk/Source/_javascript_Core/wasm/WasmFaultSignalHandler.cpp	2017-04-13 08:31:54 UTC (rev 215317)
+++ trunk/Source/_javascript_Core/wasm/WasmFaultSignalHandler.cpp	2017-04-13 14:17:00 UTC (rev 215318)
@@ -41,16 +41,18 @@
 
 namespace JSC { namespace Wasm {
 
-
 namespace {
 static const bool verbose = false;
 }
 
+static StaticLock codeLocationsLock;
+static LazyNeverDestroyed<HashSet<std::tuple<void*, void*>>> codeLocations; // (start, end)
+
+#if ENABLE(WEBASSEMBLY_FAST_MEMORY)
+
 static struct sigaction oldSigBusHandler;
 static struct sigaction oldSigSegvHandler;
 static bool fastHandlerInstalled { false };
-static StaticLock codeLocationsLock;
-static LazyNeverDestroyed<HashSet<std::tuple<void*, void*>>> codeLocations; // (start, end)
 
 static void trapHandler(int signal, siginfo_t* sigInfo, void* ucontext)
 {
@@ -108,6 +110,8 @@
         sigaction(signal, &oldSigSegvHandler, nullptr);
 }
 
+#endif // ENABLE(WEBASSEMBLY_FAST_MEMORY)
+
 void registerCode(void* start, void* end)
 {
     if (!fastMemoryEnabled())
@@ -136,6 +140,7 @@
         if (!Options::useWebAssemblyFastMemory())
             return;
 
+#if ENABLE(WEBASSEMBLY_FAST_MEMORY)
         struct sigaction action;
 
         action.sa_sigaction = trapHandler;
@@ -155,6 +160,7 @@
 
         codeLocations.construct();
         fastHandlerInstalled = true;
+#endif // ENABLE(WEBASSEMBLY_FAST_MEMORY)
     });
 }
     

Modified: trunk/Source/WTF/ChangeLog (215317 => 215318)


--- trunk/Source/WTF/ChangeLog	2017-04-13 08:31:54 UTC (rev 215317)
+++ trunk/Source/WTF/ChangeLog	2017-04-13 14:17:00 UTC (rev 215318)
@@ -1,3 +1,14 @@
+2017-04-13  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Use proper ifdef guard for code using MachineContext
+        https://bugs.webkit.org/show_bug.cgi?id=170800
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        SamplingProfiler and FastMemory rely on MachineContext feature.
+
+        * wtf/Platform.h:
+
 2017-04-12  Dan Bernstein  <[email protected]>
 
         [Mac] Future-proof .xcconfig files

Modified: trunk/Source/WTF/wtf/Platform.h (215317 => 215318)


--- trunk/Source/WTF/wtf/Platform.h	2017-04-13 08:31:54 UTC (rev 215317)
+++ trunk/Source/WTF/wtf/Platform.h	2017-04-13 14:17:00 UTC (rev 215318)
@@ -657,6 +657,10 @@
 #define HAVE_CFNETWORK_STORAGE_PARTITIONING 1
 #endif
 
+#if OS(DARWIN) || ((OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
+#define HAVE_MACHINE_CONTEXT 1
+#endif
+
 /* ENABLE macro defaults */
 
 /* FIXME: move out all ENABLE() defines from here to FeatureDefines.h */
@@ -789,7 +793,7 @@
  * In configurations other than Windows and Darwin, because layout of mcontext_t depends on standard libraries (like glibc),
  * sampling profiler is enabled if WebKit uses pthreads and glibc. */
 #if !defined(ENABLE_SAMPLING_PROFILER)
-#if (OS(DARWIN) || OS(WINDOWS) || PLATFORM(GTK)) && ENABLE(JIT)
+#if ENABLE(JIT) && (OS(WINDOWS) || HAVE(MACHINE_CONTEXT))
 #define ENABLE_SAMPLING_PROFILER 1
 #else
 #define ENABLE_SAMPLING_PROFILER 0
@@ -796,6 +800,10 @@
 #endif
 #endif
 
+#if ENABLE(WEBASSEMBLY) && HAVE(MACHINE_CONTEXT)
+#define ENABLE_WEBASSEMBLY_FAST_MEMORY 1
+#endif
+
 /* Counts uses of write barriers using sampling counters. Be sure to also
    set ENABLE_SAMPLING_COUNTERS to 1. */
 #if !defined(ENABLE_WRITE_BARRIER_PROFILING)
@@ -921,7 +929,7 @@
 #endif
 #endif
 
-#if (OS(DARWIN) || OS(LINUX) || OS(FREEBSD)) && ENABLE(JIT)
+#if ENABLE(JIT) && HAVE(MACHINE_CONTEXT)
 #define ENABLE_SIGNAL_BASED_VM_TRAPS 1
 #endif
 
@@ -1214,8 +1222,4 @@
 #define USE_LIBWEBRTC 1
 #endif
 
-#if OS(DARWIN) || ((OS(FREEBSD) || defined(__GLIBC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
-#define HAVE_MACHINE_CONTEXT 1
-#endif
-
 #endif /* WTF_Platform_h */
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to