webkit-gtk: Add initial support for NetBSD JIT
authorLeonardo Taccari <leot@NetBSD.org>
Tue, 25 Sep 2018 20:45:12 +0000 (22:45 +0200)
committerLeonardo Taccari <leot@NetBSD.org>
Tue, 25 Sep 2018 20:45:12 +0000 (22:45 +0200)
Only CPU(X86_64) was actually tested and a testing/review is
welcomed!  Please note that `webkit-jit' option need to be added
to PKG_OPTIONS.webkit-gtk in order to build support for the JIT.

webkit-gtk/distinfo
webkit-gtk/patches/patch-Source_JavaScriptCore_runtime_MachineContext.h [new file with mode: 0644]
webkit-gtk/patches/patch-Source_WTF_wtf_Platform.h [new file with mode: 0644]
webkit-gtk/patches/patch-Source_WebCore_inspector_InspectorFrontendHost.cpp [new file with mode: 0644]

index cc4471f663184a8f571315b3f47462833450996d..5ee4f76580b696e4e406ced3ff7f7cdb4f478cd6 100644 (file)
@@ -9,9 +9,12 @@ SHA1 (patch-Source_JavaScriptCore_assembler_ARMAssembler.h) = 99e46f9d9b26a8d9ba
 SHA1 (patch-Source_JavaScriptCore_assembler_MacroAssemblerARM.cpp) = f78e6150ed8901b3fe046b2ef182f50f1c7500a4
 SHA1 (patch-Source_JavaScriptCore_heap_MarkedSpace.cpp) = e6a23d5ef22bddd0a9606fb0e472960e4cf5673e
 SHA1 (patch-Source_JavaScriptCore_jit_ExecutableAllocator.cpp) = 2f20d6aa8f1ec4122bee9f2f95b736ee4496812f
+SHA1 (patch-Source_JavaScriptCore_runtime_MachineContext.h) = 928050c743dc889cb42fa4e74bec5664b8e1318c
 SHA1 (patch-Source_ThirdParty_gtest_include_gtest_internal_gtest-port.h) = f1eee7f9d3012edee1915234c837cff820f97092
+SHA1 (patch-Source_WTF_wtf_Platform.h) = 6ab636e109494d555d3ee63d49b1a11482309ab0
 SHA1 (patch-Source_WTF_wtf_StackBounds.cpp) = 0b35ab065e4cccbb63199cd8a9add0d5106c6150
 SHA1 (patch-Source_WTF_wtf_ThreadSpecific.h) = 38a85e10a72fe38d286a2ce747e090a2955b8791
+SHA1 (patch-Source_WebCore_inspector_InspectorFrontendHost.cpp) = daf6351a1a0b5a49592a2bb6db0d54620c7b09e3
 SHA1 (patch-Source_WebCore_platform_FileSystem.cpp) = adef1a42c4e210f0a3dcb82807e2d2039684a0ec
 SHA1 (patch-Source_WebCore_platform_graphics_filters_FEMorphology.cpp) = 16b36d2d91fd7f43156b9ee09bcafd19602ebbd9
 SHA1 (patch-Source_WebCore_rendering_shapes_RasterShape.cpp) = 551e47698dee50d097b11e3218f13bb3447edfea
diff --git a/webkit-gtk/patches/patch-Source_JavaScriptCore_runtime_MachineContext.h b/webkit-gtk/patches/patch-Source_JavaScriptCore_runtime_MachineContext.h
new file mode 100644 (file)
index 0000000..9ee585f
--- /dev/null
@@ -0,0 +1,118 @@
+$NetBSD$
+
+Add support for NetBSD
+
+XXX:
+XXX: Only CPU(X86_64) was tested and all other CPU should be reviewed and maybe
+XXX: adjusted (especially ARM, ARM64 and MIPS!).
+XXX:
+XXX: Probably using `OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)'
+XXX: can be a good way to adapt it and then check
+XXX: src/sys/arch/*/include/mcontext.h for the corresponding registers.
+XXX:
+
+--- Source/JavaScriptCore/runtime/MachineContext.h.orig        2018-08-21 16:06:10.000000000 +0000
++++ Source/JavaScriptCore/runtime/MachineContext.h
+@@ -188,6 +188,18 @@ static inline void*& stackPointerImpl(mc
+ #error Unknown Architecture
+ #endif
++#elif OS(NETBSD)
++
++#if CPU(X86)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_UESP]);
++#elif CPU(X86_64)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_RSP]);
++#elif CPU(ARM) || CPU(ARM64) || CPU(MIPS)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_SP]);
++#else
++#error Unknown Architecture
++#endif
++
+ #elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
+ #if CPU(X86)
+@@ -335,6 +347,20 @@ static inline void*& framePointerImpl(mc
+ #error Unknown Architecture
+ #endif
++#elif OS(NETBSD)
++
++#if CPU(X86)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_EBP]);
++#elif CPU(X86_64)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_RBP]);
++#elif CPU(ARM) || CPU(ARM64)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_FP]);
++#elif CPU(MIPS)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_S8]);
++#else
++#error Unknown Architecture
++#endif
++
+ #elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
+ // The following sequence depends on glibc's sys/ucontext.h.
+@@ -482,6 +508,20 @@ static inline void*& instructionPointerI
+ #error Unknown Architecture
+ #endif
++#elif OS(NETBSD)
++
++#if CPU(X86)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_EIP]);
++#elif CPU(X86_64)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_RIP]);
++#elif CPU(ARM) || CPU(ARM64)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_PC]);
++#elif CPU(MIPS)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_EPC]);
++#else
++#error Unknown Architecture
++#endif
++
+ #elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
+ // The following sequence depends on glibc's sys/ucontext.h.
+@@ -639,6 +679,20 @@ inline void*& argumentPointer<1>(mcontex
+ #error Unknown Architecture
+ #endif
++#elif OS(NETBSD)
++
++#if CPU(X86)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_EDX]);
++#elif CPU(X86_64)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_RSI]);
++#elif CPU(ARM) || CPU(ARM64)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_R1]);
++#elif CPU(MIPS)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_A1]);
++#else
++#error Unknown Architecture
++#endif
++
+ #elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
+ // The following sequence depends on glibc's sys/ucontext.h.
+@@ -756,6 +810,20 @@ inline void*& llintInstructionPointer(mc
+ #error Unknown Architecture
+ #endif
++#elif OS(NETBSD)
++
++#if CPU(X86)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_ESI]);
++#elif CPU(X86_64)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_R8]);
++#elif CPU(ARM) || CPU(ARM64)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_R8]);
++#elif CPU(MIPS)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.__gregs[_REG_T4]);
++#else
++#error Unknown Architecture
++#endif
++
+ #elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
+ // The following sequence depends on glibc's sys/ucontext.h.
diff --git a/webkit-gtk/patches/patch-Source_WTF_wtf_Platform.h b/webkit-gtk/patches/patch-Source_WTF_wtf_Platform.h
new file mode 100644 (file)
index 0000000..f1f8343
--- /dev/null
@@ -0,0 +1,29 @@
+$NetBSD$
+
+Add support for NetBSD.
+
+--- Source/WTF/wtf/Platform.h.orig     2018-09-21 19:59:47.000000000 +0000
++++ Source/WTF/wtf/Platform.h
+@@ -697,7 +697,7 @@
+ #define HAVE_CFNETWORK_STORAGE_PARTITIONING 1
+ #endif
+-#if OS(DARWIN) || OS(FUCHSIA) || ((OS(FREEBSD) || defined(__GLIBC__) || defined(__BIONIC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
++#if OS(DARWIN) || OS(FUCHSIA) || ((OS(FREEBSD) || OS(NETBSD) || defined(__GLIBC__) || defined(__BIONIC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
+ #define HAVE_MACHINE_CONTEXT 1
+ #endif
+@@ -786,11 +786,11 @@
+ #if !defined(ENABLE_DFG_JIT) && ENABLE(JIT)
+ /* Enable the DFG JIT on X86 and X86_64. */
+-#if (CPU(X86) || CPU(X86_64)) && (OS(DARWIN) || OS(LINUX) || OS(FREEBSD) || OS(HURD) || OS(WINDOWS))
++#if (CPU(X86) || CPU(X86_64)) && (OS(DARWIN) || OS(LINUX) || OS(FREEBSD) || OS(NETBSD) || OS(HURD) || OS(WINDOWS))
+ #define ENABLE_DFG_JIT 1
+ #endif
+ /* Enable the DFG JIT on ARMv7.  Only tested on iOS, Linux, and FreeBSD. */
+-#if (CPU(ARM_THUMB2) || CPU(ARM64)) && (PLATFORM(IOS) || OS(LINUX) || OS(FREEBSD))
++#if (CPU(ARM_THUMB2) || CPU(ARM64)) && (PLATFORM(IOS) || OS(LINUX) || OS(FREEBSD) || OS(NETBSD))
+ #define ENABLE_DFG_JIT 1
+ #endif
+ /* Enable the DFG JIT on ARM. */
diff --git a/webkit-gtk/patches/patch-Source_WebCore_inspector_InspectorFrontendHost.cpp b/webkit-gtk/patches/patch-Source_WebCore_inspector_InspectorFrontendHost.cpp
new file mode 100644 (file)
index 0000000..79e3a45
--- /dev/null
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Add support for NetBSD.
+
+--- Source/WebCore/inspector/InspectorFrontendHost.cpp.orig    2018-08-06 14:07:41.000000000 +0000
++++ Source/WebCore/inspector/InspectorFrontendHost.cpp
+@@ -279,6 +279,8 @@ String InspectorFrontendHost::platform()
+     return "freebsd"_s;
+ #elif OS(OPENBSD)
+     return "openbsd"_s;
++#elif OS(NETBSD)
++    return "netbsd"_s;
+ #else
+     return "unknown"_s;
+ #endif