mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 960416 - Always use JIT hardening. r=luke
--HG-- extra : rebase_source : ae9e635eac09044f05fea9ad27ab52bb888c703e
This commit is contained in:
parent
23562d286a
commit
c930b6f393
@ -721,7 +721,6 @@ static const char js_zeal_frequency_str[] = JS_OPTIONS_DOT_STR "gczeal.frequ
|
||||
#endif
|
||||
static const char js_typeinfer_content_str[] = JS_OPTIONS_DOT_STR "typeinference.content";
|
||||
static const char js_typeinfer_chrome_str[] = JS_OPTIONS_DOT_STR "typeinference.chrome";
|
||||
static const char js_jit_hardening_str[] = JS_OPTIONS_DOT_STR "jit_hardening";
|
||||
static const char js_memlog_option_str[] = JS_OPTIONS_DOT_STR "mem.log";
|
||||
static const char js_memnotify_option_str[] = JS_OPTIONS_DOT_STR "mem.notify";
|
||||
static const char js_asmjs_content_str[] = JS_OPTIONS_DOT_STR "asmjs";
|
||||
@ -758,7 +757,6 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
|
||||
bool useTypeInference = Preferences::GetBool((chromeWindow || !contentWindow) ?
|
||||
js_typeinfer_chrome_str :
|
||||
js_typeinfer_content_str);
|
||||
bool useHardening = Preferences::GetBool(js_jit_hardening_str);
|
||||
bool useBaselineJIT = Preferences::GetBool((chromeWindow || !contentWindow) ?
|
||||
js_baselinejit_chrome_str :
|
||||
js_baselinejit_content_str);
|
||||
@ -776,7 +774,6 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
|
||||
xr->GetInSafeMode(&safeMode);
|
||||
if (safeMode) {
|
||||
useTypeInference = false;
|
||||
useHardening = false;
|
||||
useBaselineJIT = false;
|
||||
useBaselineJITEager = false;
|
||||
useIon = false;
|
||||
@ -810,9 +807,6 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
|
||||
::JS_SetGlobalJitCompilerOption(context->mContext, JSJITCOMPILER_ION_USECOUNT_TRIGGER,
|
||||
(useIonEager ? 0 : -1));
|
||||
|
||||
JSRuntime *rt = JS_GetRuntime(context->mContext);
|
||||
JS_SetJitHardening(rt, useHardening);
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
int32_t zeal = Preferences::GetInt(js_zeal_option_str, -1);
|
||||
int32_t frequency = Preferences::GetInt(js_zeal_frequency_str, JS_DEFAULT_ZEAL_FREQ);
|
||||
|
@ -135,7 +135,6 @@ static_assert(MAX_WORKERS_PER_DOMAIN >= 1,
|
||||
#define PREF_JS_OPTIONS_PREFIX "javascript.options."
|
||||
#define PREF_WORKERS_OPTIONS_PREFIX PREF_WORKERS_PREFIX "options."
|
||||
#define PREF_MEM_OPTIONS_PREFIX "mem."
|
||||
#define PREF_JIT_HARDENING "jit_hardening"
|
||||
#define PREF_GCZEAL "gcZeal"
|
||||
|
||||
#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
|
||||
@ -297,9 +296,7 @@ LoadJSContextOptions(const char* aPrefName, void* /* aClosure */)
|
||||
PREF_MEM_OPTIONS_PREFIX)) ||
|
||||
StringBeginsWith(prefName,
|
||||
NS_LITERAL_CSTRING(PREF_WORKERS_OPTIONS_PREFIX
|
||||
PREF_MEM_OPTIONS_PREFIX)) ||
|
||||
prefName.EqualsLiteral(PREF_JS_OPTIONS_PREFIX PREF_JIT_HARDENING) ||
|
||||
prefName.EqualsLiteral(PREF_WORKERS_OPTIONS_PREFIX PREF_JIT_HARDENING)) {
|
||||
PREF_MEM_OPTIONS_PREFIX))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -574,27 +571,6 @@ LoadJSGCMemoryOptions(const char* aPrefName, void* /* aClosure */)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LoadJITHardeningOption(const char* /* aPrefName */, void* /* aClosure */)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
RuntimeService* rts = RuntimeService::GetService();
|
||||
|
||||
if (!rts && !gRuntimeServiceDuringInit) {
|
||||
// May be shutting down, just bail.
|
||||
return;
|
||||
}
|
||||
|
||||
bool value = GetWorkerPref(NS_LITERAL_CSTRING(PREF_JIT_HARDENING), false);
|
||||
|
||||
RuntimeService::SetDefaultJITHardening(value);
|
||||
|
||||
if (rts) {
|
||||
rts->UpdateAllWorkerJITHardening(value);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ErrorReporter(JSContext* aCx, const char* aMessage, JSErrorReport* aReport)
|
||||
{
|
||||
@ -833,8 +809,6 @@ CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate, JSRuntime* aRuntime)
|
||||
aWorkerPrivate->IsChromeWorker() ? settings.chrome.contextOptions
|
||||
: settings.content.contextOptions;
|
||||
|
||||
JS_SetJitHardening(aRuntime, settings.jitHardening);
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
JS_SetGCZeal(workerCx, settings.gcZeal, settings.gcZealFrequency);
|
||||
#endif
|
||||
@ -1675,14 +1649,6 @@ RuntimeService::Init()
|
||||
LoadJSGCMemoryOptions,
|
||||
PREF_WORKERS_OPTIONS_PREFIX PREF_MEM_OPTIONS_PREFIX,
|
||||
nullptr)) ||
|
||||
NS_FAILED(Preferences::RegisterCallback(
|
||||
LoadJITHardeningOption,
|
||||
PREF_JS_OPTIONS_PREFIX PREF_JIT_HARDENING,
|
||||
nullptr)) ||
|
||||
NS_FAILED(Preferences::RegisterCallbackAndCall(
|
||||
LoadJITHardeningOption,
|
||||
PREF_WORKERS_OPTIONS_PREFIX PREF_JIT_HARDENING,
|
||||
nullptr)) ||
|
||||
#ifdef JS_GC_ZEAL
|
||||
NS_FAILED(Preferences::RegisterCallback(
|
||||
LoadGCZealOptions,
|
||||
@ -1889,15 +1855,7 @@ RuntimeService::Cleanup()
|
||||
NS_FAILED(Preferences::UnregisterCallback(
|
||||
LoadJSGCMemoryOptions,
|
||||
PREF_WORKERS_OPTIONS_PREFIX PREF_MEM_OPTIONS_PREFIX,
|
||||
nullptr)) ||
|
||||
NS_FAILED(Preferences::UnregisterCallback(
|
||||
LoadJITHardeningOption,
|
||||
PREF_JS_OPTIONS_PREFIX PREF_JIT_HARDENING,
|
||||
nullptr)) ||
|
||||
NS_FAILED(Preferences::UnregisterCallback(
|
||||
LoadJITHardeningOption,
|
||||
PREF_WORKERS_OPTIONS_PREFIX PREF_JIT_HARDENING,
|
||||
nullptr))) {
|
||||
nullptr))) {
|
||||
NS_WARNING("Failed to unregister pref callbacks!");
|
||||
}
|
||||
|
||||
@ -2278,12 +2236,6 @@ RuntimeService::UpdateAllWorkerGCZeal()
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
RuntimeService::UpdateAllWorkerJITHardening(bool aJITHardening)
|
||||
{
|
||||
BROADCAST_ALL_WORKERS(UpdateJITHardening, aJITHardening);
|
||||
}
|
||||
|
||||
void
|
||||
RuntimeService::GarbageCollectAllWorkers(bool aShrinking)
|
||||
{
|
||||
|
@ -223,16 +223,6 @@ public:
|
||||
UpdateAllWorkerGCZeal();
|
||||
#endif
|
||||
|
||||
static void
|
||||
SetDefaultJITHardening(bool aJITHardening)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
sDefaultJSSettings.jitHardening = aJITHardening;
|
||||
}
|
||||
|
||||
void
|
||||
UpdateAllWorkerJITHardening(bool aJITHardening);
|
||||
|
||||
void
|
||||
GarbageCollectAllWorkers(bool aShrinking);
|
||||
|
||||
|
@ -1620,25 +1620,6 @@ private:
|
||||
};
|
||||
#endif
|
||||
|
||||
class UpdateJITHardeningRunnable MOZ_FINAL : public WorkerControlRunnable
|
||||
{
|
||||
bool mJITHardening;
|
||||
|
||||
public:
|
||||
UpdateJITHardeningRunnable(WorkerPrivate* aWorkerPrivate, bool aJITHardening)
|
||||
: WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount),
|
||||
mJITHardening(aJITHardening)
|
||||
{ }
|
||||
|
||||
private:
|
||||
virtual bool
|
||||
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) MOZ_OVERRIDE
|
||||
{
|
||||
aWorkerPrivate->UpdateJITHardeningInternal(aCx, mJITHardening);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class GarbageCollectRunnable MOZ_FINAL : public WorkerControlRunnable
|
||||
{
|
||||
bool mShrinking;
|
||||
@ -3006,26 +2987,6 @@ WorkerPrivateParent<Derived>::UpdateGCZeal(JSContext* aCx, uint8_t aGCZeal,
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class Derived>
|
||||
void
|
||||
WorkerPrivateParent<Derived>::UpdateJITHardening(JSContext* aCx,
|
||||
bool aJITHardening)
|
||||
{
|
||||
AssertIsOnParentThread();
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
mJSSettings.jitHardening = aJITHardening;
|
||||
}
|
||||
|
||||
nsRefPtr<UpdateJITHardeningRunnable> runnable =
|
||||
new UpdateJITHardeningRunnable(ParentAsWorkerPrivate(), aJITHardening);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
NS_WARNING("Failed to update worker jit hardening!");
|
||||
JS_ClearPendingException(aCx);
|
||||
}
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
void
|
||||
WorkerPrivateParent<Derived>::GarbageCollect(JSContext* aCx, bool aShrinking)
|
||||
@ -5621,18 +5582,6 @@ WorkerPrivate::UpdateGCZealInternal(JSContext* aCx, uint8_t aGCZeal,
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
WorkerPrivate::UpdateJITHardeningInternal(JSContext* aCx, bool aJITHardening)
|
||||
{
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
JS_SetJitHardening(JS_GetRuntime(aCx), aJITHardening);
|
||||
|
||||
for (uint32_t index = 0; index < mChildWorkers.Length(); index++) {
|
||||
mChildWorkers[index]->UpdateJITHardening(aCx, aJITHardening);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WorkerPrivate::GarbageCollectInternal(JSContext* aCx, bool aShrinking,
|
||||
bool aCollectChildren)
|
||||
|
@ -384,9 +384,6 @@ public:
|
||||
UpdateGCZeal(JSContext* aCx, uint8_t aGCZeal, uint32_t aFrequency);
|
||||
#endif
|
||||
|
||||
void
|
||||
UpdateJITHardening(JSContext* aCx, bool aJITHardening);
|
||||
|
||||
void
|
||||
GarbageCollect(JSContext* aCx, bool aShrinking);
|
||||
|
||||
@ -897,9 +894,6 @@ public:
|
||||
UpdateGCZealInternal(JSContext* aCx, uint8_t aGCZeal, uint32_t aFrequency);
|
||||
#endif
|
||||
|
||||
void
|
||||
UpdateJITHardeningInternal(JSContext* aCx, bool aJITHardening);
|
||||
|
||||
void
|
||||
GarbageCollectInternal(JSContext* aCx, bool aShrinking,
|
||||
bool aCollectChildren);
|
||||
|
@ -107,16 +107,15 @@ struct JSSettings
|
||||
JSContentChromeSettings chrome;
|
||||
JSContentChromeSettings content;
|
||||
JSGCSettingsArray gcSettings;
|
||||
bool jitHardening;
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
uint8_t gcZeal;
|
||||
uint32_t gcZealFrequency;
|
||||
#endif
|
||||
|
||||
JSSettings()
|
||||
: jitHardening(false)
|
||||
#ifdef JS_GC_ZEAL
|
||||
, gcZeal(0), gcZealFrequency(0)
|
||||
: gcZeal(0), gcZealFrequency(0)
|
||||
#endif
|
||||
{
|
||||
for (uint32_t index = 0; index < ArrayLength(gcSettings); index++) {
|
||||
|
@ -176,21 +176,14 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
enum AllocationBehavior
|
||||
{
|
||||
AllocationCanRandomize,
|
||||
AllocationDeterministic
|
||||
};
|
||||
|
||||
class ExecutableAllocator {
|
||||
typedef void (*DestroyCallback)(void* addr, size_t size);
|
||||
enum ProtectionSetting { Writable, Executable };
|
||||
DestroyCallback destroyCallback;
|
||||
|
||||
public:
|
||||
explicit ExecutableAllocator(AllocationBehavior allocBehavior)
|
||||
: destroyCallback(NULL),
|
||||
allocBehavior(allocBehavior)
|
||||
ExecutableAllocator()
|
||||
: destroyCallback(NULL)
|
||||
{
|
||||
if (!pageSize) {
|
||||
pageSize = determinePageSize();
|
||||
@ -221,7 +214,7 @@ public:
|
||||
for (size_t i = 0; i < m_smallPools.length(); i++)
|
||||
m_smallPools[i]->release();
|
||||
|
||||
m_smallPools.clear();
|
||||
m_smallPools.clear();
|
||||
}
|
||||
|
||||
// alloc() returns a pointer to some memory, and also (by reference) a
|
||||
@ -266,10 +259,6 @@ public:
|
||||
this->destroyCallback = destroyCallback;
|
||||
}
|
||||
|
||||
void setRandomize(bool enabled) {
|
||||
allocBehavior = enabled ? AllocationCanRandomize : AllocationDeterministic;
|
||||
}
|
||||
|
||||
private:
|
||||
static size_t pageSize;
|
||||
static size_t largeAllocSize;
|
||||
@ -502,7 +491,6 @@ private:
|
||||
typedef js::HashSet<ExecutablePool *, js::DefaultHasher<ExecutablePool *>, js::SystemAllocPolicy>
|
||||
ExecPoolHashSet;
|
||||
ExecPoolHashSet m_pools; // All pools, just for stats purposes.
|
||||
AllocationBehavior allocBehavior;
|
||||
|
||||
static size_t determinePageSize();
|
||||
};
|
||||
|
@ -99,7 +99,7 @@ ExecutablePool::Allocation ExecutableAllocator::systemAlloc(size_t n)
|
||||
// Randomization disabled to avoid a performance fault on x64 builds.
|
||||
// See bug 728623.
|
||||
#ifndef JS_CPU_X64
|
||||
if (allocBehavior == AllocationCanRandomize && !RandomizeIsBroken()) {
|
||||
if (!RandomizeIsBroken()) {
|
||||
void *randomAddress = computeRandomAllocationAddress();
|
||||
allocation = VirtualAlloc(randomAddress, n, MEM_COMMIT | MEM_RESERVE,
|
||||
PAGE_EXECUTE_READWRITE);
|
||||
|
@ -330,9 +330,7 @@ JitRuntime::createIonAlloc(JSContext *cx)
|
||||
{
|
||||
JS_ASSERT(cx->runtime()->currentThreadOwnsOperationCallbackLock());
|
||||
|
||||
JSC::AllocationBehavior randomize =
|
||||
cx->runtime()->jitHardening ? JSC::AllocationCanRandomize : JSC::AllocationDeterministic;
|
||||
ionAlloc_ = js_new<JSC::ExecutableAllocator>(randomize);
|
||||
ionAlloc_ = js_new<JSC::ExecutableAllocator>();
|
||||
if (!ionAlloc_)
|
||||
js_ReportOutOfMemory(cx);
|
||||
return ionAlloc_;
|
||||
|
@ -873,12 +873,6 @@ JS::ContextOptionsRef(JSContext *cx)
|
||||
return cx->options();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_SetJitHardening(JSRuntime *rt, bool enabled)
|
||||
{
|
||||
rt->setJitHardening(!!enabled);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(const char *)
|
||||
JS_GetImplementationVersion(void)
|
||||
{
|
||||
|
@ -1624,9 +1624,6 @@ class JS_PUBLIC_API(AutoSaveContextOptions) {
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_SetJitHardening(JSRuntime *rt, bool enabled);
|
||||
|
||||
extern JS_PUBLIC_API(const char *)
|
||||
JS_GetImplementationVersion(void);
|
||||
|
||||
|
@ -296,7 +296,6 @@ JSRuntime::JSRuntime(JSUseHelperThreads useHelperThreads)
|
||||
#ifdef DEBUG
|
||||
noGCOrAllocationCheck(0),
|
||||
#endif
|
||||
jitHardening(false),
|
||||
jitSupportsFloatingPoint(false),
|
||||
ionPcScriptCache(nullptr),
|
||||
threadPool(this),
|
||||
@ -660,23 +659,13 @@ JSRuntime::triggerOperationCallback(OperationCallbackTrigger trigger)
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
JSRuntime::setJitHardening(bool enabled)
|
||||
{
|
||||
jitHardening = enabled;
|
||||
if (execAlloc_)
|
||||
execAlloc_->setRandomize(enabled);
|
||||
}
|
||||
|
||||
JSC::ExecutableAllocator *
|
||||
JSRuntime::createExecutableAllocator(JSContext *cx)
|
||||
{
|
||||
JS_ASSERT(!execAlloc_);
|
||||
JS_ASSERT(cx->runtime() == this);
|
||||
|
||||
JSC::AllocationBehavior randomize =
|
||||
jitHardening ? JSC::AllocationCanRandomize : JSC::AllocationDeterministic;
|
||||
execAlloc_ = js_new<JSC::ExecutableAllocator>(randomize);
|
||||
execAlloc_ = js_new<JSC::ExecutableAllocator>();
|
||||
if (!execAlloc_)
|
||||
js_ReportOutOfMemory(cx);
|
||||
return execAlloc_;
|
||||
|
@ -1647,8 +1647,6 @@ struct JSRuntime : public JS::shadow::Runtime,
|
||||
size_t noGCOrAllocationCheck;
|
||||
#endif
|
||||
|
||||
bool jitHardening;
|
||||
|
||||
bool jitSupportsFloatingPoint;
|
||||
|
||||
// Used to reset stack limit after a signaled interrupt (i.e. ionStackLimit_ = -1)
|
||||
@ -1767,11 +1765,6 @@ struct JSRuntime : public JS::shadow::Runtime,
|
||||
|
||||
void triggerOperationCallback(OperationCallbackTrigger trigger);
|
||||
|
||||
void setJitHardening(bool enabled);
|
||||
bool getJitHardening() const {
|
||||
return jitHardening;
|
||||
}
|
||||
|
||||
void addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::RuntimeSizes *runtime);
|
||||
|
||||
private:
|
||||
|
@ -749,7 +749,6 @@ pref("javascript.options.ion.chrome", false);
|
||||
pref("javascript.options.asmjs", true);
|
||||
pref("javascript.options.parallel_parsing", true);
|
||||
pref("javascript.options.ion.parallel_compilation", true);
|
||||
pref("javascript.options.jit_hardening", true);
|
||||
pref("javascript.options.typeinference.content", true);
|
||||
pref("javascript.options.typeinference.chrome", false);
|
||||
// This preference limits the memory usage of javascript.
|
||||
|
@ -27,7 +27,6 @@ user_pref("devtools.errorconsole.enabled", true);
|
||||
user_pref("devtools.debugger.remote-port", 6023);
|
||||
user_pref("layout.debug.enable_data_xbl", true);
|
||||
user_pref("browser.EULA.override", true);
|
||||
user_pref("javascript.options.jit_hardening", true);
|
||||
user_pref("gfx.color_management.force_srgb", true);
|
||||
user_pref("network.manage-offline-status", false);
|
||||
user_pref("dom.min_background_timeout_value", 1000);
|
||||
|
Loading…
Reference in New Issue
Block a user