From 6884d1313c76c26469b52eab390eac393f9445d4 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Thu, 8 Apr 2021 19:05:31 +0000 Subject: [PATCH] [WPE] Build fixes for musl C library on Linux https://bugs.webkit.org/show_bug.cgi?id=210068 Patch by Khem Raj on 2021-04-08 Reviewed by Carlos Alberto Lopez Perez. Source/JavaScriptCore: Use OS(LINUX) to include musl in platform test for linux and consolidate all linux platfrom under same test. Use smaller limits for JSC stack size per thread and reserved zone size. * runtime/MachineContext.h: (JSC::MachineContext::stackPointerImpl): (JSC::MachineContext::framePointerImpl): (JSC::MachineContext::instructionPointerImpl): (JSC::MachineContext::argumentPointer<1>): (JSC::MachineContext::llintInstructionPointer): * runtime/OptionsList.h: Source/WTF: Define 128KB DEFAULT_THREAD_STACK_SIZE_IN_KB for musl Use OS(LINUX) check to include musl when building for Linux based platforms. * wtf/PlatformHave.h: * wtf/Threading.cpp: Canonical link: https://commits.webkit.org/236306@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275670 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/JavaScriptCore/ChangeLog | 20 +++++++++++++++++++ .../JavaScriptCore/runtime/MachineContext.h | 10 +++++----- Source/JavaScriptCore/runtime/OptionsList.h | 20 +++++++++++++++---- Source/WTF/ChangeLog | 14 +++++++++++++ Source/WTF/wtf/PlatformHave.h | 2 +- Source/WTF/wtf/Threading.cpp | 2 ++ 6 files changed, 58 insertions(+), 10 deletions(-) diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index dc36489bac94..78bea89fc3b6 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,23 @@ +2021-04-08 Khem Raj + + [WPE] Build fixes for musl C library on Linux + https://bugs.webkit.org/show_bug.cgi?id=210068 + + Reviewed by Carlos Alberto Lopez Perez. + + Use OS(LINUX) to include musl in platform test + for linux and consolidate all linux platfrom + under same test. Use smaller limits for JSC + stack size per thread and reserved zone size. + + * runtime/MachineContext.h: + (JSC::MachineContext::stackPointerImpl): + (JSC::MachineContext::framePointerImpl): + (JSC::MachineContext::instructionPointerImpl): + (JSC::MachineContext::argumentPointer<1>): + (JSC::MachineContext::llintInstructionPointer): + * runtime/OptionsList.h: + 2021-04-07 Yusuke Suzuki [JSC] DUCET level-1 weighs are equal if characters are alphabets diff --git a/Source/JavaScriptCore/runtime/MachineContext.h b/Source/JavaScriptCore/runtime/MachineContext.h index ead9cdfd7b63..86b36ca22f70 100644 --- a/Source/JavaScriptCore/runtime/MachineContext.h +++ b/Source/JavaScriptCore/runtime/MachineContext.h @@ -196,7 +196,7 @@ static inline void*& stackPointerImpl(mcontext_t& machineContext) #error Unknown Architecture #endif -#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__) +#elif OS(FUCHSIA) || OS(LINUX) #if CPU(X86) return reinterpret_cast((uintptr_t&) machineContext.gregs[REG_ESP]); @@ -347,7 +347,7 @@ static inline void*& framePointerImpl(mcontext_t& machineContext) #error Unknown Architecture #endif -#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__) +#elif OS(FUCHSIA) || OS(LINUX) // The following sequence depends on glibc's sys/ucontext.h. #if CPU(X86) @@ -498,7 +498,7 @@ static inline void*& instructionPointerImpl(mcontext_t& machineContext) #error Unknown Architecture #endif -#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__) +#elif OS(FUCHSIA) || OS(LINUX) // The following sequence depends on glibc's sys/ucontext.h. #if CPU(X86) @@ -656,7 +656,7 @@ inline void*& argumentPointer<1>(mcontext_t& machineContext) #error Unknown Architecture #endif -#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__) +#elif OS(FUCHSIA) || OS(LINUX) // The following sequence depends on glibc's sys/ucontext.h. #if CPU(X86) @@ -773,7 +773,7 @@ inline void*& llintInstructionPointer(mcontext_t& machineContext) #error Unknown Architecture #endif -#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__) +#elif OS(FUCHSIA) || OS(LINUX) // The following sequence depends on glibc's sys/ucontext.h. #if CPU(X86) diff --git a/Source/JavaScriptCore/runtime/OptionsList.h b/Source/JavaScriptCore/runtime/OptionsList.h index 6ef7016faae9..15a06eb671c8 100644 --- a/Source/JavaScriptCore/runtime/OptionsList.h +++ b/Source/JavaScriptCore/runtime/OptionsList.h @@ -71,6 +71,18 @@ JS_EXPORT_PRIVATE bool canUseJITCage(); // On instantiation of the first VM instance, the Options will be write protected // and cannot be modified thereafter. +#if OS(LINUX) && !defined(__BIONIC__) && !defined(__GLIBC__) +// non-glibc/non-android options on linux ( musl ) +constexpr unsigned jscMaxPerThreadStack = 128 * KB; +constexpr unsigned jscSoftReservedZoneSize = 32 * KB; +constexpr unsigned jscReservedZoneSize = 16 * KB; +#else +// default +constexpr unsigned jscMaxPerThreadStack = 5 * MB; +constexpr unsigned jscSoftReservedZoneSize = 128 * KB; +constexpr unsigned jscReservedZoneSize = 64 * KB; +#endif + #define FOR_EACH_JSC_OPTION(v) \ v(Bool, useKernTCSM, defaultTCSMValue(), Normal, "Note: this needs to go before other options since they depend on this value.") \ v(Bool, validateOptions, false, Normal, "crashes if mis-typed JSC options were passed to the VM") \ @@ -86,9 +98,9 @@ JS_EXPORT_PRIVATE bool canUseJITCage(); \ v(Bool, reportMustSucceedExecutableAllocations, false, Normal, nullptr) \ \ - v(Unsigned, maxPerThreadStackUsage, 5 * MB, Normal, "Max allowed stack usage by the VM") \ - v(Unsigned, softReservedZoneSize, 128 * KB, Normal, "A buffer greater than reservedZoneSize that reserves space for stringifying exceptions.") \ - v(Unsigned, reservedZoneSize, 64 * KB, Normal, "The amount of stack space we guarantee to our clients (and to interal VM code that does not call out to clients).") \ + v(Unsigned, maxPerThreadStackUsage, jscMaxPerThreadStack, Normal, "Max allowed stack usage by the VM") \ + v(Unsigned, softReservedZoneSize, jscSoftReservedZoneSize, Normal, "A buffer greater than reservedZoneSize that reserves space for stringifying exceptions.") \ + v(Unsigned, reservedZoneSize, jscReservedZoneSize, Normal, "The amount of stack space we guarantee to our clients (and to interal VM code that does not call out to clients).") \ \ v(Bool, crashOnDisallowedVMEntry, ASSERT_ENABLED, Normal, "Forces a crash if we attempt to enter the VM when disallowed") \ v(Bool, crashIfCantAllocateJITMemory, false, Normal, nullptr) \ @@ -611,7 +623,7 @@ class OptionRange { bool init(const char*); bool isInRange(unsigned); const char* rangeString() const { return (m_state > InitError) ? m_rangeString : s_nullRangeStr; } - + void dump(PrintStream& out) const; private: diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog index 791e0fd0f85d..90422f5c70a2 100644 --- a/Source/WTF/ChangeLog +++ b/Source/WTF/ChangeLog @@ -1,3 +1,17 @@ +2021-04-08 Khem Raj + + [WPE] Build fixes for musl C library on Linux + https://bugs.webkit.org/show_bug.cgi?id=210068 + + Reviewed by Carlos Alberto Lopez Perez. + + Define 128KB DEFAULT_THREAD_STACK_SIZE_IN_KB for musl + Use OS(LINUX) check to include musl when building for + Linux based platforms. + + * wtf/PlatformHave.h: + * wtf/Threading.cpp: + 2021-04-08 Chris Dumez OfflineAudioContext objects are leaking diff --git a/Source/WTF/wtf/PlatformHave.h b/Source/WTF/wtf/PlatformHave.h index 87c3c935705b..38339017a5dd 100644 --- a/Source/WTF/wtf/PlatformHave.h +++ b/Source/WTF/wtf/PlatformHave.h @@ -206,7 +206,7 @@ #define HAVE_HOSTED_CORE_ANIMATION 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(LINUX)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS))) #define HAVE_MACHINE_CONTEXT 1 #endif diff --git a/Source/WTF/wtf/Threading.cpp b/Source/WTF/wtf/Threading.cpp index e16b3c0f85d2..b4032a74580d 100644 --- a/Source/WTF/wtf/Threading.cpp +++ b/Source/WTF/wtf/Threading.cpp @@ -52,6 +52,8 @@ static Optional stackSize(ThreadType threadType) #elif OS(DARWIN) && ASAN_ENABLED if (threadType == ThreadType::Compiler) return 1 * MB; // ASan needs more stack space (especially on Debug builds). +#elif OS(LINUX) && !defined(__BIONIC__) && !defined(__GLIBC__) // MUSL default thread stack size. + return 128 * KB; #else UNUSED_PARAM(threadType); #endif