- Revision
- 262356
- Author
- mark....@apple.com
- Date
- 2020-05-31 00:05:35 -0700 (Sun, 31 May 2020)
Log Message
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:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (262355 => 262356)
--- trunk/Source/_javascript_Core/ChangeLog 2020-05-31 05:54:43 UTC (rev 262355)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-05-31 07:05:35 UTC (rev 262356)
@@ -1,3 +1,29 @@
+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-30 Mark Lam <mark....@apple.com>
Rename Signal::BadAccess to Signal::AccessFault.
Modified: trunk/Source/_javascript_Core/runtime/JSCConfig.cpp (262355 => 262356)
--- trunk/Source/_javascript_Core/runtime/JSCConfig.cpp 2020-05-31 05:54:43 UTC (rev 262355)
+++ trunk/Source/_javascript_Core/runtime/JSCConfig.cpp 2020-05-31 07:05:35 UTC (rev 262356)
@@ -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: trunk/Source/_javascript_Core/runtime/JSCConfig.h (262355 => 262356)
--- trunk/Source/_javascript_Core/runtime/JSCConfig.h 2020-05-31 05:54:43 UTC (rev 262355)
+++ trunk/Source/_javascript_Core/runtime/JSCConfig.h 2020-05-31 07:05:35 UTC (rev 262356)
@@ -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: trunk/Source/_javascript_Core/runtime/Options.cpp (262355 => 262356)
--- trunk/Source/_javascript_Core/runtime/Options.cpp 2020-05-31 05:54:43 UTC (rev 262355)
+++ trunk/Source/_javascript_Core/runtime/Options.cpp 2020-05-31 07:05:35 UTC (rev 262356)
@@ -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: trunk/Source/_javascript_Core/tools/JSDollarVM.cpp (262355 => 262356)
--- trunk/Source/_javascript_Core/tools/JSDollarVM.cpp 2020-05-31 05:54:43 UTC (rev 262355)
+++ trunk/Source/_javascript_Core/tools/JSDollarVM.cpp 2020-05-31 07:05:35 UTC (rev 262356)
@@ -2176,7 +2176,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: trunk/Source/WTF/ChangeLog (262355 => 262356)
--- trunk/Source/WTF/ChangeLog 2020-05-31 05:54:43 UTC (rev 262355)
+++ trunk/Source/WTF/ChangeLog 2020-05-31 07:05:35 UTC (rev 262356)
@@ -1,3 +1,13 @@
+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-30 Mark Lam <mark....@apple.com>
Rename Signal::BadAccess to Signal::AccessFault.
Modified: trunk/Source/WTF/wtf/WTFConfig.h (262355 => 262356)
--- trunk/Source/WTF/wtf/WTFConfig.h 2020-05-31 05:54:43 UTC (rev 262355)
+++ trunk/Source/WTF/wtf/WTFConfig.h 2020-05-31 07:05:35 UTC (rev 262356)
@@ -57,6 +57,8 @@
SignalHandlers signalHandlers;
#endif
PtrTagLookup* ptrTagLookupHead;
+
+ uint64_t spaceForExtensions[1];
};
char ensureSize[ConfigSizeToProtect];
};