#pragma once
#include "Gate.h"
#include "Opcode.h"
#include "OptionsList.h"
#include <wtf/WTFConfig.h>
namespace JSC {
class ExecutableAllocator;
class FixedVMPoolExecutableAllocator;
class VM;
#if ENABLE(SEPARATED_WX_HEAP)
using JITWriteSeparateHeapsFunction = void (*)(off_t, const void*, size_t);
#endif
struct Config {
static Config& singleton();
JS_EXPORT_PRIVATE static void disableFreezingForTesting();
JS_EXPORT_PRIVATE static void enableRestrictedOptions();
static void permanentlyFreeze() { WTF::Config::permanentlyFreeze(); }
static void configureForTesting()
{
WTF::setPermissionsOfConfigPage();
disableFreezingForTesting();
enableRestrictedOptions();
}
bool isPermanentlyFrozen() { return g_wtfConfig.isPermanentlyFrozen; }
bool disabledFreezingForTesting;
bool restrictedOptionsEnabled;
bool jitDisabled;
bool initializeHasBeenCalled;
struct {
#if ASSERT_ENABLED
bool canUseJITIsSet;
#endif
bool canUseJIT;
} vm;
ExecutableAllocator* executableAllocator;
FixedVMPoolExecutableAllocator* fixedVMPoolExecutableAllocator;
void* startExecutableMemory;
void* endExecutableMemory;
uintptr_t startOfFixedWritableMemoryPool;
#if ENABLE(SEPARATED_WX_HEAP)
JITWriteSeparateHeapsFunction jitWriteSeparateHeaps;
#endif
OptionsStorage options;
void (*shellTimeoutCheckCallback)(VM&);
struct {
uint8_t exceptionInstructions[maxOpcodeLength + 1];
uint8_t wasmExceptionInstructions[maxOpcodeLength + 1];
const void* gateMap[numberOfGates];
} llint;
#if CPU(ARM64E) && ENABLE(PTRTAG_DEBUGGING)
WTF::PtrTagLookup ptrTagLookupRecord;
#endif
};
#if ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
constexpr size_t alignmentOfJSCConfig = std::alignment_of<JSC::Config>::value;
static_assert(WTF::offsetOfWTFConfigExtension + sizeof(JSC::Config) <= WTF::ConfigSizeToProtect);
static_assert(roundUpToMultipleOf<alignmentOfJSCConfig>(WTF::offsetOfWTFConfigExtension) == WTF::offsetOfWTFConfigExtension);
#define g_jscConfig (*bitwise_cast<JSC::Config*>(&g_wtfConfig.spaceForExtensions))
#else // not ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
extern "C" JS_EXPORT_PRIVATE Config g_jscConfig;
#endif // ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
constexpr size_t offsetOfJSCConfigInitializeHasBeenCalled = offsetof(JSC::Config, initializeHasBeenCalled);
constexpr size_t offsetOfJSCConfigGateMap = offsetof(JSC::Config, llint.gateMap);
}
#if !ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
using JSC::g_jscConfig;
#endif