Title: [262445] branches/safari-610.1.15-branch/Source
Revision
262445
Author
alanc...@apple.com
Date
2020-06-02 14:58:10 -0700 (Tue, 02 Jun 2020)

Log Message

Cherry-pick r262356. rdar://problem/63891520

    Change JSC::Config to use storage in WTF::Config instead of its own.
    https://bugs.webkit.org/show_bug.cgi?id=212575
    <rdar://problem/63796584>

    Reviewed by Yusuke Suzuki.

    Source/_javascript_Core:

    Since Configs must be rounded up to CeilingOnPageSize, this will save us some
    memory since the contents of both Configs do not add up to CeilingOnPageSize.

    g_jscConfig is now located at g_wtfConfig.spaceForExtensions.

    * runtime/JSCConfig.cpp:
    (JSC::Config::disableFreezingForTesting):
    (JSC::Config::enableRestrictedOptions):
    (JSC::Config::permanentlyFreeze): Deleted.
    * runtime/JSCConfig.h:
    (JSC::Config::permanentlyFreeze):
    (JSC::Config::isPermanentlyFrozen):
    (): Deleted.
    * runtime/Options.cpp:
    (JSC::Options::setOptions):
    * tools/JSDollarVM.cpp:
    (JSC::functionCallWithStackSize):

    Source/WTF:

    * wtf/WTFConfig.h:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262356 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-610.1.15-branch/Source/_javascript_Core/ChangeLog (262444 => 262445)


--- branches/safari-610.1.15-branch/Source/_javascript_Core/ChangeLog	2020-06-02 21:58:07 UTC (rev 262444)
+++ branches/safari-610.1.15-branch/Source/_javascript_Core/ChangeLog	2020-06-02 21:58:10 UTC (rev 262445)
@@ -1,3 +1,66 @@
+2020-06-02  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r262356. rdar://problem/63891520
+
+    Change JSC::Config to use storage in WTF::Config instead of its own.
+    https://bugs.webkit.org/show_bug.cgi?id=212575
+    <rdar://problem/63796584>
+    
+    Reviewed by Yusuke Suzuki.
+    
+    Source/_javascript_Core:
+    
+    Since Configs must be rounded up to CeilingOnPageSize, this will save us some
+    memory since the contents of both Configs do not add up to CeilingOnPageSize.
+    
+    g_jscConfig is now located at g_wtfConfig.spaceForExtensions.
+    
+    * runtime/JSCConfig.cpp:
+    (JSC::Config::disableFreezingForTesting):
+    (JSC::Config::enableRestrictedOptions):
+    (JSC::Config::permanentlyFreeze): Deleted.
+    * runtime/JSCConfig.h:
+    (JSC::Config::permanentlyFreeze):
+    (JSC::Config::isPermanentlyFrozen):
+    (): Deleted.
+    * runtime/Options.cpp:
+    (JSC::Options::setOptions):
+    * tools/JSDollarVM.cpp:
+    (JSC::functionCallWithStackSize):
+    
+    Source/WTF:
+    
+    * wtf/WTFConfig.h:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262356 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-05-31  Mark Lam  <mark....@apple.com>
+
+            Change JSC::Config to use storage in WTF::Config instead of its own.
+            https://bugs.webkit.org/show_bug.cgi?id=212575
+            <rdar://problem/63796584>
+
+            Reviewed by Yusuke Suzuki.
+
+            Since Configs must be rounded up to CeilingOnPageSize, this will save us some
+            memory since the contents of both Configs do not add up to CeilingOnPageSize.
+
+            g_jscConfig is now located at g_wtfConfig.spaceForExtensions.
+
+            * runtime/JSCConfig.cpp:
+            (JSC::Config::disableFreezingForTesting):
+            (JSC::Config::enableRestrictedOptions):
+            (JSC::Config::permanentlyFreeze): Deleted.
+            * runtime/JSCConfig.h:
+            (JSC::Config::permanentlyFreeze):
+            (JSC::Config::isPermanentlyFrozen):
+            (): Deleted.
+            * runtime/Options.cpp:
+            (JSC::Options::setOptions):
+            * tools/JSDollarVM.cpp:
+            (JSC::functionCallWithStackSize):
+
 2020-05-23  Paulo Matos  <pma...@igalia.com>
 
         Fix non-unified builds for x86_64

Modified: branches/safari-610.1.15-branch/Source/_javascript_Core/runtime/JSCConfig.cpp (262444 => 262445)


--- branches/safari-610.1.15-branch/Source/_javascript_Core/runtime/JSCConfig.cpp	2020-06-02 21:58:07 UTC (rev 262444)
+++ branches/safari-610.1.15-branch/Source/_javascript_Core/runtime/JSCConfig.cpp	2020-06-02 21:58:10 UTC (rev 262445)
@@ -26,61 +26,18 @@
 #include "config.h"
 #include "JSCConfig.h"
 
-#include <wtf/Lock.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/WTFConfig.h>
-
-#if OS(DARWIN)
-#include <mach/mach.h>
-#elif OS(LINUX)
-#include <sys/mman.h>
-#endif
-
 namespace JSC {
 
-alignas(ConfigSizeToProtect) JS_EXPORT_PRIVATE Config g_jscConfig;
-
 void Config::disableFreezingForTesting()
 {
-    RELEASE_ASSERT(!g_jscConfig.isPermanentlyFrozen);
+    RELEASE_ASSERT(!g_jscConfig.isPermanentlyFrozen());
     g_jscConfig.disabledFreezingForTesting = true;
 }
 
 void Config::enableRestrictedOptions()
 {
-    RELEASE_ASSERT(!g_jscConfig.isPermanentlyFrozen);
+    RELEASE_ASSERT(!g_jscConfig.isPermanentlyFrozen());
     g_jscConfig.restrictedOptionsEnabled = true;
 }
-    
-void Config::permanentlyFreeze()
-{
-    WTF::Config::permanentlyFreeze();
 
-    static Lock configLock;
-    auto locker = holdLock(configLock);
-
-    RELEASE_ASSERT(roundUpToMultipleOf(pageSize(), ConfigSizeToProtect) == ConfigSizeToProtect);
-
-    if (!g_jscConfig.isPermanentlyFrozen)
-        g_jscConfig.isPermanentlyFrozen = true;
-
-    int result = 0;
-#if OS(DARWIN)
-    enum {
-        AllowPermissionChangesAfterThis = false,
-        DisallowPermissionChangesAfterThis = true
-    };
-
-    // There's no going back now!
-    result = vm_protect(mach_task_self(), reinterpret_cast<vm_address_t>(&g_jscConfig), ConfigSizeToProtect, DisallowPermissionChangesAfterThis, VM_PROT_READ);
-#elif OS(LINUX)
-    result = mprotect(&g_jscConfig, ConfigSizeToProtect, PROT_READ);
-#elif OS(WINDOWS)
-    // FIXME: Implement equivalent, maybe with VirtualProtect.
-    // Also need to fix WebKitTestRunner.
-#endif
-    RELEASE_ASSERT(!result);
-    RELEASE_ASSERT(g_jscConfig.isPermanentlyFrozen);
-}
-
 } // namespace JSC

Modified: branches/safari-610.1.15-branch/Source/_javascript_Core/runtime/JSCConfig.h (262444 => 262445)


--- branches/safari-610.1.15-branch/Source/_javascript_Core/runtime/JSCConfig.h	2020-06-02 21:58:07 UTC (rev 262444)
+++ branches/safari-610.1.15-branch/Source/_javascript_Core/runtime/JSCConfig.h	2020-06-02 21:58:10 UTC (rev 262445)
@@ -26,9 +26,7 @@
 #pragma once
 
 #include "OptionsList.h"
-#include <wtf/PageBlock.h>
-#include <wtf/PtrTag.h>
-#include <wtf/StdLibExtras.h>
+#include <wtf/WTFConfig.h>
 
 namespace JSC {
 
@@ -45,7 +43,7 @@
 struct Config {
     JS_EXPORT_PRIVATE static void disableFreezingForTesting();
     JS_EXPORT_PRIVATE static void enableRestrictedOptions();
-    JS_EXPORT_PRIVATE static void permanentlyFreeze();
+    static void permanentlyFreeze() { WTF::Config::permanentlyFreeze(); }
 
     static void configureForTesting()
     {
@@ -53,43 +51,43 @@
         enableRestrictedOptions();
     }
 
-    union {
-        struct {
-            // All the fields in this struct should be chosen such that their
-            // initial value is 0 / null / falsy because Config is instantiated
-            // as a global singleton.
+    bool isPermanentlyFrozen() { return WTF::g_wtfConfig.isPermanentlyFrozen; }
 
-            bool isPermanentlyFrozen;
-            bool disabledFreezingForTesting;
-            bool restrictedOptionsEnabled;
-            bool jitDisabled;
+    // All the fields in this struct should be chosen such that their
+    // initial value is 0 / null / falsy because Config is instantiated
+    // as a global singleton.
 
-            // The following HasBeenCalled flags are for auditing call_once initialization functions.
-            bool initializeThreadingHasBeenCalled;
+    bool disabledFreezingForTesting;
+    bool restrictedOptionsEnabled;
+    bool jitDisabled;
 
-            ExecutableAllocator* executableAllocator;
-            FixedVMPoolExecutableAllocator* fixedVMPoolExecutableAllocator;
-            void* startExecutableMemory;
-            void* endExecutableMemory;
-            uintptr_t startOfFixedWritableMemoryPool;
+    // The following HasBeenCalled flags are for auditing call_once initialization functions.
+    bool initializeThreadingHasBeenCalled;
 
+    ExecutableAllocator* executableAllocator;
+    FixedVMPoolExecutableAllocator* fixedVMPoolExecutableAllocator;
+    void* startExecutableMemory;
+    void* endExecutableMemory;
+    uintptr_t startOfFixedWritableMemoryPool;
+
 #if ENABLE(SEPARATED_WX_HEAP)
-            JITWriteSeparateHeapsFunction jitWriteSeparateHeaps;
-            bool useFastPermisionsJITCopy;
+    JITWriteSeparateHeapsFunction jitWriteSeparateHeaps;
+    bool useFastPermisionsJITCopy;
 #endif
 
-            OptionsStorage options;
+    OptionsStorage options;
 
-            void (*shellTimeoutCheckCallback)(VM&);
+    void (*shellTimeoutCheckCallback)(VM&);
 
-            WTF::PtrTagLookup ptrTagLookupRecord;
-        };
-        char ensureSize[ConfigSizeToProtect];
-    };
+    WTF::PtrTagLookup ptrTagLookupRecord;
 };
 
-extern "C" alignas(ConfigSizeToProtect) JS_EXPORT_PRIVATE Config g_jscConfig;
+constexpr size_t offsetOfWTFConfigExtension = offsetof(WTF::Config, spaceForExtensions);
+constexpr size_t alignmentOfJSCConfig = std::alignment_of<JSC::Config>::value;
 
-static_assert(sizeof(Config) == ConfigSizeToProtect, "");
+static_assert(sizeof(JSC::Config) <= (sizeof(WTF::Config) - offsetOfWTFConfigExtension));
+static_assert(roundUpToMultipleOf<alignmentOfJSCConfig>(offsetOfWTFConfigExtension) == offsetOfWTFConfigExtension);
 
+#define g_jscConfig (*bitwise_cast<Config*>(&WTF::g_wtfConfig.spaceForExtensions))
+
 } // namespace JSC

Modified: branches/safari-610.1.15-branch/Source/_javascript_Core/runtime/Options.cpp (262444 => 262445)


--- branches/safari-610.1.15-branch/Source/_javascript_Core/runtime/Options.cpp	2020-06-02 21:58:07 UTC (rev 262444)
+++ branches/safari-610.1.15-branch/Source/_javascript_Core/runtime/Options.cpp	2020-06-02 21:58:10 UTC (rev 262445)
@@ -677,7 +677,7 @@
 
 bool Options::setOptions(const char* optionsStr)
 {
-    RELEASE_ASSERT(!g_jscConfig.isPermanentlyFrozen);
+    RELEASE_ASSERT(!g_jscConfig.isPermanentlyFrozen());
     Vector<char*> options;
 
     size_t length = strlen(optionsStr);

Modified: branches/safari-610.1.15-branch/Source/_javascript_Core/tools/JSDollarVM.cpp (262444 => 262445)


--- branches/safari-610.1.15-branch/Source/_javascript_Core/tools/JSDollarVM.cpp	2020-06-02 21:58:07 UTC (rev 262444)
+++ branches/safari-610.1.15-branch/Source/_javascript_Core/tools/JSDollarVM.cpp	2020-06-02 21:58:10 UTC (rev 262445)
@@ -2168,7 +2168,7 @@
         return throwVMError(globalObject, throwScope, "Not supported for this platform");
 
 #if ENABLE(MASM_PROBE)
-    if (g_jscConfig.isPermanentlyFrozen || !g_jscConfig.disabledFreezingForTesting)
+    if (g_jscConfig.isPermanentlyFrozen() || !g_jscConfig.disabledFreezingForTesting)
         return throwVMError(globalObject, throwScope, "Options are frozen");
 
     if (callFrame->argumentCount() < 2)

Modified: branches/safari-610.1.15-branch/Source/WTF/ChangeLog (262444 => 262445)


--- branches/safari-610.1.15-branch/Source/WTF/ChangeLog	2020-06-02 21:58:07 UTC (rev 262444)
+++ branches/safari-610.1.15-branch/Source/WTF/ChangeLog	2020-06-02 21:58:10 UTC (rev 262445)
@@ -1,3 +1,50 @@
+2020-06-02  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r262356. rdar://problem/63891520
+
+    Change JSC::Config to use storage in WTF::Config instead of its own.
+    https://bugs.webkit.org/show_bug.cgi?id=212575
+    <rdar://problem/63796584>
+    
+    Reviewed by Yusuke Suzuki.
+    
+    Source/_javascript_Core:
+    
+    Since Configs must be rounded up to CeilingOnPageSize, this will save us some
+    memory since the contents of both Configs do not add up to CeilingOnPageSize.
+    
+    g_jscConfig is now located at g_wtfConfig.spaceForExtensions.
+    
+    * runtime/JSCConfig.cpp:
+    (JSC::Config::disableFreezingForTesting):
+    (JSC::Config::enableRestrictedOptions):
+    (JSC::Config::permanentlyFreeze): Deleted.
+    * runtime/JSCConfig.h:
+    (JSC::Config::permanentlyFreeze):
+    (JSC::Config::isPermanentlyFrozen):
+    (): Deleted.
+    * runtime/Options.cpp:
+    (JSC::Options::setOptions):
+    * tools/JSDollarVM.cpp:
+    (JSC::functionCallWithStackSize):
+    
+    Source/WTF:
+    
+    * wtf/WTFConfig.h:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262356 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-05-31  Mark Lam  <mark....@apple.com>
+
+            Change JSC::Config to use storage in WTF::Config instead of its own.
+            https://bugs.webkit.org/show_bug.cgi?id=212575
+            <rdar://problem/63796584>
+
+            Reviewed by Yusuke Suzuki.
+
+            * wtf/WTFConfig.h:
+
 2020-05-22  David Kilzer  <ddkil...@apple.com>
 
         WTF::isValidEnum() has a typo in static_assert making it a tautological comparison

Modified: branches/safari-610.1.15-branch/Source/WTF/wtf/WTFConfig.h (262444 => 262445)


--- branches/safari-610.1.15-branch/Source/WTF/wtf/WTFConfig.h	2020-06-02 21:58:07 UTC (rev 262444)
+++ branches/safari-610.1.15-branch/Source/WTF/wtf/WTFConfig.h	2020-06-02 21:58:10 UTC (rev 262445)
@@ -57,6 +57,8 @@
             SignalHandlers signalHandlers;
 #endif
             PtrTagLookup* ptrTagLookupHead;
+
+            uint64_t spaceForExtensions[1];
         };
         char ensureSize[ConfigSizeToProtect];
     };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to