mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 508848ad378a (bug 939562) for causing bug 978450
This commit is contained in:
parent
2a78acc9bc
commit
554b2aaf5b
@ -721,8 +721,19 @@ static const char js_werror_option_str[] = JS_OPTIONS_DOT_STR "werror";
|
||||
static const char js_zeal_option_str[] = JS_OPTIONS_DOT_STR "gczeal";
|
||||
static const char js_zeal_frequency_str[] = JS_OPTIONS_DOT_STR "gczeal.frequency";
|
||||
#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_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";
|
||||
static const char js_baselinejit_content_str[] = JS_OPTIONS_DOT_STR "baselinejit.content";
|
||||
static const char js_baselinejit_chrome_str[] = JS_OPTIONS_DOT_STR "baselinejit.chrome";
|
||||
static const char js_baselinejit_eager_str[] = JS_OPTIONS_DOT_STR "baselinejit.unsafe_eager_compilation";
|
||||
static const char js_ion_content_str[] = JS_OPTIONS_DOT_STR "ion.content";
|
||||
static const char js_ion_chrome_str[] = JS_OPTIONS_DOT_STR "ion.chrome";
|
||||
static const char js_ion_eager_str[] = JS_OPTIONS_DOT_STR "ion.unsafe_eager_compilation";
|
||||
static const char js_parallel_parsing_str[] = JS_OPTIONS_DOT_STR "parallel_parsing";
|
||||
static const char js_ion_parallel_compilation_str[] = JS_OPTIONS_DOT_STR "ion.parallel_compilation";
|
||||
|
||||
void
|
||||
nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
|
||||
@ -745,6 +756,39 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
|
||||
nsCOMPtr<nsIDOMWindow> contentWindow(do_QueryInterface(global));
|
||||
nsCOMPtr<nsIDOMChromeWindow> chromeWindow(do_QueryInterface(global));
|
||||
|
||||
bool useTypeInference = Preferences::GetBool((chromeWindow || !contentWindow) ?
|
||||
js_typeinfer_chrome_str :
|
||||
js_typeinfer_content_str);
|
||||
bool useBaselineJIT = Preferences::GetBool((chromeWindow || !contentWindow) ?
|
||||
js_baselinejit_chrome_str :
|
||||
js_baselinejit_content_str);
|
||||
bool useBaselineJITEager = Preferences::GetBool(js_baselinejit_eager_str);
|
||||
bool useIon = Preferences::GetBool((chromeWindow || !contentWindow) ?
|
||||
js_ion_chrome_str :
|
||||
js_ion_content_str);
|
||||
bool useIonEager = Preferences::GetBool(js_ion_eager_str);
|
||||
bool useAsmJS = Preferences::GetBool(js_asmjs_content_str);
|
||||
bool parallelParsing = Preferences::GetBool(js_parallel_parsing_str);
|
||||
bool parallelIonCompilation = Preferences::GetBool(js_ion_parallel_compilation_str);
|
||||
nsCOMPtr<nsIXULRuntime> xr = do_GetService(XULRUNTIME_SERVICE_CONTRACTID);
|
||||
if (xr) {
|
||||
bool safeMode = false;
|
||||
xr->GetInSafeMode(&safeMode);
|
||||
if (safeMode) {
|
||||
useTypeInference = false;
|
||||
useBaselineJIT = false;
|
||||
useBaselineJITEager = false;
|
||||
useIon = false;
|
||||
useIonEager = false;
|
||||
useAsmJS = false;
|
||||
}
|
||||
}
|
||||
|
||||
JS::ContextOptionsRef(cx).setTypeInference(useTypeInference)
|
||||
.setBaseline(useBaselineJIT)
|
||||
.setIon(useIon)
|
||||
.setAsmJS(useAsmJS);
|
||||
|
||||
#ifdef DEBUG
|
||||
// In debug builds, warnings are enabled in chrome context if
|
||||
// javascript.options.strict.debug is true
|
||||
@ -756,6 +800,15 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
|
||||
|
||||
JS::ContextOptionsRef(cx).setWerror(Preferences::GetBool(js_werror_option_str));
|
||||
|
||||
::JS_SetParallelParsingEnabled(context->mContext, parallelParsing);
|
||||
::JS_SetParallelIonCompilationEnabled(context->mContext, parallelIonCompilation);
|
||||
|
||||
::JS_SetGlobalJitCompilerOption(context->mContext, JSJITCOMPILER_BASELINE_USECOUNT_TRIGGER,
|
||||
(useBaselineJITEager ? 0 : -1));
|
||||
|
||||
::JS_SetGlobalJitCompilerOption(context->mContext, JSJITCOMPILER_ION_USECOUNT_TRIGGER,
|
||||
(useIonEager ? 0 : -1));
|
||||
|
||||
#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);
|
||||
|
@ -148,7 +148,7 @@ namespace {
|
||||
|
||||
const uint32_t kNoIndex = uint32_t(-1);
|
||||
|
||||
const JS::ContextOptions kRequiredContextOptions =
|
||||
const JS::ContextOptions kRequiredJSContextOptions =
|
||||
JS::ContextOptions().setDontReportUncaught(true)
|
||||
.setNoScriptRval(true);
|
||||
|
||||
@ -300,7 +300,7 @@ GenerateSharedWorkerKey(const nsACString& aScriptSpec, const nsACString& aName,
|
||||
}
|
||||
|
||||
void
|
||||
LoadRuntimeAndContextOptions(const char* aPrefName, void* /* aClosure */)
|
||||
LoadJSContextOptions(const char* aPrefName, void* /* aClosure */)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
@ -330,47 +330,51 @@ LoadRuntimeAndContextOptions(const char* aPrefName, void* /* aClosure */)
|
||||
}
|
||||
#endif
|
||||
|
||||
// Runtime options.
|
||||
JS::RuntimeOptions runtimeOptions;
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("asmjs"))) {
|
||||
runtimeOptions.setAsmJS(true);
|
||||
}
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("typeinference"))) {
|
||||
runtimeOptions.setTypeInference(true);
|
||||
}
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("baselinejit"))) {
|
||||
runtimeOptions.setBaseline(true);
|
||||
}
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("ion"))) {
|
||||
runtimeOptions.setIon(true);
|
||||
}
|
||||
|
||||
// Common options.
|
||||
JS::ContextOptions commonContextOptions = kRequiredContextOptions;
|
||||
JS::ContextOptions commonOptions = kRequiredJSContextOptions;
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("strict"))) {
|
||||
commonContextOptions.setExtraWarnings(true);
|
||||
commonOptions.setExtraWarnings(true);
|
||||
}
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("werror"))) {
|
||||
commonContextOptions.setWerror(true);
|
||||
commonOptions.setWerror(true);
|
||||
}
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("asmjs"))) {
|
||||
commonOptions.setAsmJS(true);
|
||||
}
|
||||
|
||||
// Content options.
|
||||
JS::ContextOptions contentContextOptions = commonContextOptions;
|
||||
JS::ContextOptions contentOptions = commonOptions;
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("baselinejit.content"))) {
|
||||
contentOptions.setBaseline(true);
|
||||
}
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("ion.content"))) {
|
||||
contentOptions.setIon(true);
|
||||
}
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("typeinference.content"))) {
|
||||
contentOptions.setTypeInference(true);
|
||||
}
|
||||
|
||||
// Chrome options.
|
||||
JS::ContextOptions chromeContextOptions = commonContextOptions;
|
||||
JS::ContextOptions chromeOptions = commonOptions;
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("baselinejit.chrome"))) {
|
||||
chromeOptions.setBaseline(true);
|
||||
}
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("ion.chrome"))) {
|
||||
chromeOptions.setIon(true);
|
||||
}
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("typeinference.chrome"))) {
|
||||
chromeOptions.setTypeInference(true);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("strict.debug"))) {
|
||||
chromeContextOptions.setExtraWarnings(true);
|
||||
chromeOptions.setExtraWarnings(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
RuntimeService::SetDefaultRuntimeAndContextOptions(runtimeOptions,
|
||||
contentContextOptions,
|
||||
chromeContextOptions);
|
||||
RuntimeService::SetDefaultJSContextOptions(contentOptions, chromeOptions);
|
||||
|
||||
if (rts) {
|
||||
rts->UpdateAllWorkerRuntimeAndContextOptions();
|
||||
rts->UpdateAllWorkerJSContextOptions();
|
||||
}
|
||||
}
|
||||
|
||||
@ -767,8 +771,6 @@ CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate, JSRuntime* aRuntime)
|
||||
JSSettings settings;
|
||||
aWorkerPrivate->CopyJSSettings(settings);
|
||||
|
||||
JS::RuntimeOptionsRef(aRuntime) = settings.runtimeOptions;
|
||||
|
||||
JSSettings::JSGCSettingsArray& gcSettings = settings.gcSettings;
|
||||
|
||||
// This is the real place where we set the max memory for the runtime.
|
||||
@ -1612,11 +1614,10 @@ RuntimeService::Init()
|
||||
|
||||
// Initialize JSSettings.
|
||||
if (!sDefaultJSSettings.gcSettings[0].IsSet()) {
|
||||
sDefaultJSSettings.runtimeOptions = JS::RuntimeOptions();
|
||||
sDefaultJSSettings.chrome.contextOptions = kRequiredContextOptions;
|
||||
sDefaultJSSettings.chrome.contextOptions = kRequiredJSContextOptions;
|
||||
sDefaultJSSettings.chrome.maxScriptRuntime = -1;
|
||||
sDefaultJSSettings.chrome.compartmentOptions.setVersion(JSVERSION_LATEST);
|
||||
sDefaultJSSettings.content.contextOptions = kRequiredContextOptions;
|
||||
sDefaultJSSettings.content.contextOptions = kRequiredJSContextOptions;
|
||||
sDefaultJSSettings.content.maxScriptRuntime = MAX_SCRIPT_RUN_TIME_SEC;
|
||||
#ifdef JS_GC_ZEAL
|
||||
sDefaultJSSettings.gcZealFrequency = JS_DEFAULT_ZEAL_FREQ;
|
||||
@ -1691,13 +1692,13 @@ RuntimeService::Init()
|
||||
PREF_DOM_WINDOW_DUMP_ENABLED,
|
||||
reinterpret_cast<void *>(WORKERPREF_DUMP))) ||
|
||||
#endif
|
||||
NS_FAILED(Preferences::RegisterCallback(LoadRuntimeAndContextOptions,
|
||||
NS_FAILED(Preferences::RegisterCallback(LoadJSContextOptions,
|
||||
PREF_JS_OPTIONS_PREFIX,
|
||||
nullptr)) ||
|
||||
NS_FAILED(Preferences::RegisterCallbackAndCall(
|
||||
LoadRuntimeAndContextOptions,
|
||||
PREF_WORKERS_OPTIONS_PREFIX,
|
||||
nullptr)) ||
|
||||
LoadJSContextOptions,
|
||||
PREF_WORKERS_OPTIONS_PREFIX,
|
||||
nullptr)) ||
|
||||
NS_FAILED(Preferences::RegisterCallbackAndCall(
|
||||
JSVersionChanged,
|
||||
PREF_WORKERS_LATEST_JS_VERSION,
|
||||
@ -1844,10 +1845,10 @@ RuntimeService::Cleanup()
|
||||
if (NS_FAILED(Preferences::UnregisterCallback(JSVersionChanged,
|
||||
PREF_WORKERS_LATEST_JS_VERSION,
|
||||
nullptr)) ||
|
||||
NS_FAILED(Preferences::UnregisterCallback(LoadRuntimeAndContextOptions,
|
||||
NS_FAILED(Preferences::UnregisterCallback(LoadJSContextOptions,
|
||||
PREF_JS_OPTIONS_PREFIX,
|
||||
nullptr)) ||
|
||||
NS_FAILED(Preferences::UnregisterCallback(LoadRuntimeAndContextOptions,
|
||||
NS_FAILED(Preferences::UnregisterCallback(LoadJSContextOptions,
|
||||
PREF_WORKERS_OPTIONS_PREFIX,
|
||||
nullptr)) ||
|
||||
#if DUMP_CONTROLLED_BY_PREF
|
||||
@ -2229,10 +2230,9 @@ RuntimeService::NoteIdleThread(WorkerThread* aThread)
|
||||
}
|
||||
|
||||
void
|
||||
RuntimeService::UpdateAllWorkerRuntimeAndContextOptions()
|
||||
RuntimeService::UpdateAllWorkerJSContextOptions()
|
||||
{
|
||||
BROADCAST_ALL_WORKERS(UpdateRuntimeAndContextOptions,
|
||||
sDefaultJSSettings.runtimeOptions,
|
||||
BROADCAST_ALL_WORKERS(UpdateJSContextOptions,
|
||||
sDefaultJSSettings.content.contextOptions,
|
||||
sDefaultJSSettings.chrome.contextOptions);
|
||||
}
|
||||
|
@ -174,19 +174,16 @@ public:
|
||||
}
|
||||
|
||||
static void
|
||||
SetDefaultRuntimeAndContextOptions(
|
||||
const JS::RuntimeOptions& aRuntimeOptions,
|
||||
const JS::ContextOptions& aContentCxOptions,
|
||||
const JS::ContextOptions& aChromeCxOptions)
|
||||
SetDefaultJSContextOptions(const JS::ContextOptions& aContentOptions,
|
||||
const JS::ContextOptions& aChromeOptions)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
sDefaultJSSettings.runtimeOptions = aRuntimeOptions;
|
||||
sDefaultJSSettings.content.contextOptions = aContentCxOptions;
|
||||
sDefaultJSSettings.chrome.contextOptions = aChromeCxOptions;
|
||||
sDefaultJSSettings.content.contextOptions = aContentOptions;
|
||||
sDefaultJSSettings.chrome.contextOptions = aChromeOptions;
|
||||
}
|
||||
|
||||
void
|
||||
UpdateAllWorkerRuntimeAndContextOptions();
|
||||
UpdateAllWorkerJSContextOptions();
|
||||
|
||||
void
|
||||
UpdateAllWorkerPreference(WorkerPreference aPref, bool aValue);
|
||||
|
@ -1515,32 +1515,25 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
class UpdateRuntimeAndContextOptionsRunnable MOZ_FINAL : public WorkerControlRunnable
|
||||
class UpdateJSContextOptionsRunnable MOZ_FINAL : public WorkerControlRunnable
|
||||
{
|
||||
JS::RuntimeOptions mRuntimeOptions;
|
||||
JS::ContextOptions mContentCxOptions;
|
||||
JS::ContextOptions mChromeCxOptions;
|
||||
JS::ContextOptions mContentOptions;
|
||||
JS::ContextOptions mChromeOptions;
|
||||
|
||||
public:
|
||||
UpdateRuntimeAndContextOptionsRunnable(
|
||||
WorkerPrivate* aWorkerPrivate,
|
||||
const JS::RuntimeOptions& aRuntimeOptions,
|
||||
const JS::ContextOptions& aContentCxOptions,
|
||||
const JS::ContextOptions& aChromeCxOptions)
|
||||
UpdateJSContextOptionsRunnable(WorkerPrivate* aWorkerPrivate,
|
||||
const JS::ContextOptions& aContentOptions,
|
||||
const JS::ContextOptions& aChromeOptions)
|
||||
: WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount),
|
||||
mRuntimeOptions(aRuntimeOptions),
|
||||
mContentCxOptions(aContentCxOptions),
|
||||
mChromeCxOptions(aChromeCxOptions)
|
||||
mContentOptions(aContentOptions), mChromeOptions(aChromeOptions)
|
||||
{ }
|
||||
|
||||
private:
|
||||
virtual bool
|
||||
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) MOZ_OVERRIDE
|
||||
{
|
||||
aWorkerPrivate->UpdateRuntimeAndContextOptionsInternal(aCx,
|
||||
mRuntimeOptions,
|
||||
mContentCxOptions,
|
||||
mChromeCxOptions);
|
||||
aWorkerPrivate->UpdateJSContextOptionsInternal(aCx, mContentOptions,
|
||||
mChromeOptions);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@ -2842,26 +2835,22 @@ WorkerPrivateParent<Derived>::GetInnerWindowId()
|
||||
|
||||
template <class Derived>
|
||||
void
|
||||
WorkerPrivateParent<Derived>::UpdateRuntimeAndContextOptions(
|
||||
JSContext* aCx,
|
||||
const JS::RuntimeOptions& aRuntimeOptions,
|
||||
const JS::ContextOptions& aContentCxOptions,
|
||||
const JS::ContextOptions& aChromeCxOptions)
|
||||
WorkerPrivateParent<Derived>::UpdateJSContextOptions(
|
||||
JSContext* aCx,
|
||||
const JS::ContextOptions& aContentOptions,
|
||||
const JS::ContextOptions& aChromeOptions)
|
||||
{
|
||||
AssertIsOnParentThread();
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
mJSSettings.runtimeOptions = aRuntimeOptions;
|
||||
mJSSettings.content.contextOptions = aContentCxOptions;
|
||||
mJSSettings.chrome.contextOptions = aChromeCxOptions;
|
||||
mJSSettings.content.contextOptions = aContentOptions;
|
||||
mJSSettings.chrome.contextOptions = aChromeOptions;
|
||||
}
|
||||
|
||||
nsRefPtr<UpdateRuntimeAndContextOptionsRunnable> runnable =
|
||||
new UpdateRuntimeAndContextOptionsRunnable(ParentAsWorkerPrivate(),
|
||||
aRuntimeOptions,
|
||||
aContentCxOptions,
|
||||
aChromeCxOptions);
|
||||
nsRefPtr<UpdateJSContextOptionsRunnable> runnable =
|
||||
new UpdateJSContextOptionsRunnable(ParentAsWorkerPrivate(), aContentOptions,
|
||||
aChromeOptions);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
NS_WARNING("Failed to update worker context options!");
|
||||
JS_ClearPendingException(aCx);
|
||||
@ -5499,21 +5488,17 @@ WorkerPrivate::RescheduleTimeoutTimer(JSContext* aCx)
|
||||
}
|
||||
|
||||
void
|
||||
WorkerPrivate::UpdateRuntimeAndContextOptionsInternal(
|
||||
JSContext* aCx,
|
||||
const JS::RuntimeOptions& aRuntimeOptions,
|
||||
const JS::ContextOptions& aContentCxOptions,
|
||||
const JS::ContextOptions& aChromeCxOptions)
|
||||
WorkerPrivate::UpdateJSContextOptionsInternal(JSContext* aCx,
|
||||
const JS::ContextOptions& aContentOptions,
|
||||
const JS::ContextOptions& aChromeOptions)
|
||||
{
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
JS::RuntimeOptionsRef(aCx) = aRuntimeOptions;
|
||||
JS::ContextOptionsRef(aCx) = IsChromeWorker() ? aChromeCxOptions : aContentCxOptions;
|
||||
JS::ContextOptionsRef(aCx) = IsChromeWorker() ? aChromeOptions : aContentOptions;
|
||||
|
||||
for (uint32_t index = 0; index < mChildWorkers.Length(); index++) {
|
||||
mChildWorkers[index]->UpdateRuntimeAndContextOptions(aCx, aRuntimeOptions,
|
||||
aContentCxOptions,
|
||||
aChromeCxOptions);
|
||||
mChildWorkers[index]->UpdateJSContextOptions(aCx, aContentOptions,
|
||||
aChromeOptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,10 +389,8 @@ public:
|
||||
GetInnerWindowId();
|
||||
|
||||
void
|
||||
UpdateRuntimeAndContextOptions(JSContext* aCx,
|
||||
const JS::RuntimeOptions& aRuntimeOptions,
|
||||
const JS::ContextOptions& aContentCxOptions,
|
||||
const JS::ContextOptions& aChromeCxOptions);
|
||||
UpdateJSContextOptions(JSContext* aCx, const JS::ContextOptions& aChromeOptions,
|
||||
const JS::ContextOptions& aContentOptions);
|
||||
|
||||
void
|
||||
UpdatePreference(JSContext* aCx, WorkerPreference aPref, bool aValue);
|
||||
@ -908,11 +906,8 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
UpdateRuntimeAndContextOptionsInternal(
|
||||
JSContext* aCx,
|
||||
const JS::RuntimeOptions& aRuntimeOptions,
|
||||
const JS::ContextOptions& aContentCxOptions,
|
||||
const JS::ContextOptions& aChromeCxOptions);
|
||||
UpdateJSContextOptionsInternal(JSContext* aCx, const JS::ContextOptions& aContentOptions,
|
||||
const JS::ContextOptions& aChromeOptions);
|
||||
|
||||
void
|
||||
UpdatePreferenceInternal(JSContext* aCx, WorkerPreference aPref, bool aValue);
|
||||
|
@ -107,7 +107,6 @@ struct JSSettings
|
||||
JSContentChromeSettings chrome;
|
||||
JSContentChromeSettings content;
|
||||
JSGCSettingsArray gcSettings;
|
||||
JS::RuntimeOptions runtimeOptions;
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
uint8_t gcZeal;
|
||||
|
@ -1655,7 +1655,11 @@ jsdContext::GetJSContext(JSContext **_rval)
|
||||
#define JSOPTION_DONT_REPORT_UNCAUGHT JS_BIT(8)
|
||||
#define JSOPTION_NO_DEFAULT_COMPARTMENT_OBJECT JS_BIT(11)
|
||||
#define JSOPTION_NO_SCRIPT_RVAL JS_BIT(12)
|
||||
#define JSOPTION_BASELINE JS_BIT(14)
|
||||
#define JSOPTION_TYPE_INFERENCE JS_BIT(16)
|
||||
#define JSOPTION_STRICT_MODE JS_BIT(17)
|
||||
#define JSOPTION_ION JS_BIT(18)
|
||||
#define JSOPTION_ASMJS JS_BIT(19)
|
||||
#define JSOPTION_MASK JS_BITMASK(20)
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1669,7 +1673,11 @@ jsdContext::GetOptions(uint32_t *_rval)
|
||||
| (JS::ContextOptionsRef(mJSCx).dontReportUncaught() ? JSOPTION_DONT_REPORT_UNCAUGHT : 0)
|
||||
| (JS::ContextOptionsRef(mJSCx).noDefaultCompartmentObject() ? JSOPTION_NO_DEFAULT_COMPARTMENT_OBJECT : 0)
|
||||
| (JS::ContextOptionsRef(mJSCx).noScriptRval() ? JSOPTION_NO_SCRIPT_RVAL : 0)
|
||||
| (JS::ContextOptionsRef(mJSCx).strictMode() ? JSOPTION_STRICT_MODE : 0);
|
||||
| (JS::ContextOptionsRef(mJSCx).strictMode() ? JSOPTION_STRICT_MODE : 0)
|
||||
| (JS::ContextOptionsRef(mJSCx).baseline() ? JSOPTION_BASELINE : 0)
|
||||
| (JS::ContextOptionsRef(mJSCx).typeInference() ? JSOPTION_TYPE_INFERENCE : 0)
|
||||
| (JS::ContextOptionsRef(mJSCx).ion() ? JSOPTION_ION : 0)
|
||||
| (JS::ContextOptionsRef(mJSCx).asmJS() ? JSOPTION_ASMJS : 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1690,7 +1698,11 @@ jsdContext::SetOptions(uint32_t options)
|
||||
.setDontReportUncaught(options & JSOPTION_DONT_REPORT_UNCAUGHT)
|
||||
.setNoDefaultCompartmentObject(options & JSOPTION_NO_DEFAULT_COMPARTMENT_OBJECT)
|
||||
.setNoScriptRval(options & JSOPTION_NO_SCRIPT_RVAL)
|
||||
.setStrictMode(options & JSOPTION_STRICT_MODE);
|
||||
.setStrictMode(options & JSOPTION_STRICT_MODE)
|
||||
.setBaseline(options & JSOPTION_BASELINE)
|
||||
.setTypeInference(options & JSOPTION_TYPE_INFERENCE)
|
||||
.setIon(options & JSOPTION_ION)
|
||||
.setAsmJS(options & JSOPTION_ASMJS);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1160,7 +1160,7 @@ SetJitCompilerOption(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (number < 0)
|
||||
number = -1;
|
||||
|
||||
JS_SetGlobalJitCompilerOption(cx->runtime(), opt, uint32_t(number));
|
||||
JS_SetGlobalJitCompilerOption(cx, opt, uint32_t(number));
|
||||
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
@ -1175,10 +1175,10 @@ GetJitCompilerOptions(JSContext *cx, unsigned argc, jsval *vp)
|
||||
|
||||
RootedValue value(cx);
|
||||
|
||||
#define JIT_COMPILER_MATCH(key, string) \
|
||||
opt = JSJITCOMPILER_ ## key; \
|
||||
value.setInt32(JS_GetGlobalJitCompilerOption(cx->runtime(), opt)); \
|
||||
if (!JS_SetProperty(cx, info, string, value)) \
|
||||
#define JIT_COMPILER_MATCH(key, string) \
|
||||
opt = JSJITCOMPILER_ ## key; \
|
||||
value.setInt32(JS_GetGlobalJitCompilerOption(cx, opt)); \
|
||||
if (!JS_SetProperty(cx, info, string, value)) \
|
||||
return false;
|
||||
|
||||
JSJitCompilerOption opt = JSJITCOMPILER_NOT_AN_OPTION;
|
||||
|
@ -6952,7 +6952,7 @@ js::IsAsmJSCompilationAvailable(JSContext *cx, unsigned argc, Value *vp)
|
||||
cx->signalHandlersInstalled() &&
|
||||
cx->gcSystemPageSize() == AsmJSPageSize &&
|
||||
!cx->compartment()->debugMode() &&
|
||||
cx->runtime()->options().asmJS();
|
||||
cx->compartment()->options().asmJS(cx);
|
||||
|
||||
args.rval().set(BooleanValue(available));
|
||||
return true;
|
||||
|
@ -312,7 +312,7 @@ struct BaselineScript
|
||||
inline bool
|
||||
IsBaselineEnabled(JSContext *cx)
|
||||
{
|
||||
return cx->runtime()->options().baseline();
|
||||
return cx->compartment()->options().baseline(cx);
|
||||
}
|
||||
|
||||
MethodStatus
|
||||
|
@ -159,8 +159,8 @@ void StopAllOffThreadCompilations(JSCompartment *comp);
|
||||
static inline bool
|
||||
IsIonEnabled(JSContext *cx)
|
||||
{
|
||||
return cx->runtime()->options().ion() &&
|
||||
cx->runtime()->options().baseline() &&
|
||||
return cx->compartment()->options().ion(cx) &&
|
||||
cx->compartment()->options().baseline(cx) &&
|
||||
cx->typeInferenceEnabled();
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ JSContext *createContext()
|
||||
JSContext *cx = JSAPITest::createContext();
|
||||
if (!cx)
|
||||
return nullptr;
|
||||
JS::RuntimeOptionsRef(cx).setBaseline(true)
|
||||
JS::ContextOptionsRef(cx).setBaseline(true)
|
||||
.setIon(true);
|
||||
return cx;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ END_TEST(testProfileStrings_isCalledWithInterpreter)
|
||||
BEGIN_TEST(testProfileStrings_isCalledWithJIT)
|
||||
{
|
||||
CHECK(initialize(cx));
|
||||
JS::RuntimeOptionsRef(cx).setBaseline(true)
|
||||
JS::ContextOptionsRef(cx).setBaseline(true)
|
||||
.setIon(true);
|
||||
|
||||
EXEC("function g() { var p = new Prof(); p.test_fn(); }");
|
||||
@ -190,7 +190,7 @@ END_TEST(testProfileStrings_isCalledWithJIT)
|
||||
BEGIN_TEST(testProfileStrings_isCalledWhenError)
|
||||
{
|
||||
CHECK(initialize(cx));
|
||||
JS::RuntimeOptionsRef(cx).setBaseline(true)
|
||||
JS::ContextOptionsRef(cx).setBaseline(true)
|
||||
.setIon(true);
|
||||
|
||||
EXEC("function check2() { throw 'a'; }");
|
||||
@ -214,7 +214,7 @@ END_TEST(testProfileStrings_isCalledWhenError)
|
||||
BEGIN_TEST(testProfileStrings_worksWhenEnabledOnTheFly)
|
||||
{
|
||||
CHECK(initialize(cx));
|
||||
JS::RuntimeOptionsRef(cx).setBaseline(true)
|
||||
JS::ContextOptionsRef(cx).setBaseline(true)
|
||||
.setIon(true);
|
||||
|
||||
EXEC("function b(p) { p.test_fn(); }");
|
||||
|
@ -883,18 +883,6 @@ JS_StringToVersion(const char *string)
|
||||
return JSVERSION_UNKNOWN;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JS::RuntimeOptions &)
|
||||
JS::RuntimeOptionsRef(JSRuntime *rt)
|
||||
{
|
||||
return rt->options();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JS::RuntimeOptions &)
|
||||
JS::RuntimeOptionsRef(JSContext *cx)
|
||||
{
|
||||
return cx->runtime()->options();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JS::ContextOptions &)
|
||||
JS::ContextOptionsRef(JSContext *cx)
|
||||
{
|
||||
@ -2466,6 +2454,36 @@ class AutoHoldZone
|
||||
|
||||
} /* anonymous namespace */
|
||||
|
||||
bool
|
||||
JS::CompartmentOptions::baseline(JSContext *cx) const
|
||||
{
|
||||
return baselineOverride_.get(cx->options().baseline());
|
||||
}
|
||||
|
||||
bool
|
||||
JS::CompartmentOptions::typeInference(const ExclusiveContext *cx) const
|
||||
{
|
||||
/* Unlike the other options that can be overriden on a per compartment
|
||||
* basis, the default value for the typeInference option is stored on the
|
||||
* compartment's type zone, rather than the current JSContext. Type zones
|
||||
* copy this default value over from the current JSContext when they are
|
||||
* created.
|
||||
*/
|
||||
return typeInferenceOverride_.get(cx->compartment()->zone()->types.inferenceEnabled);
|
||||
}
|
||||
|
||||
bool
|
||||
JS::CompartmentOptions::ion(JSContext *cx) const
|
||||
{
|
||||
return ionOverride_.get(cx->options().ion());
|
||||
}
|
||||
|
||||
bool
|
||||
JS::CompartmentOptions::asmJS(JSContext *cx) const
|
||||
{
|
||||
return asmJSOverride_.get(cx->options().asmJS());
|
||||
}
|
||||
|
||||
bool
|
||||
JS::CompartmentOptions::cloneSingletons(JSContext *cx) const
|
||||
{
|
||||
@ -4437,7 +4455,7 @@ JS::CompileOptions::CompileOptions(JSContext *cx, JSVersion version)
|
||||
strictOption = cx->options().strictMode();
|
||||
extraWarningsOption = cx->options().extraWarnings();
|
||||
werrorOption = cx->options().werror();
|
||||
asmJSOption = cx->runtime()->options().asmJS();
|
||||
asmJSOption = cx->options().asmJS();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -6013,23 +6031,23 @@ JS_ScheduleGC(JSContext *cx, uint32_t count)
|
||||
#endif
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_SetParallelParsingEnabled(JSRuntime *rt, bool enabled)
|
||||
JS_SetParallelParsingEnabled(JSContext *cx, bool enabled)
|
||||
{
|
||||
#ifdef JS_ION
|
||||
rt->setParallelParsingEnabled(enabled);
|
||||
cx->runtime()->setParallelParsingEnabled(enabled);
|
||||
#endif
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_SetParallelIonCompilationEnabled(JSRuntime *rt, bool enabled)
|
||||
JS_SetParallelIonCompilationEnabled(JSContext *cx, bool enabled)
|
||||
{
|
||||
#ifdef JS_ION
|
||||
rt->setParallelIonCompilationEnabled(enabled);
|
||||
cx->runtime()->setParallelIonCompilationEnabled(enabled);
|
||||
#endif
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_SetGlobalJitCompilerOption(JSRuntime *rt, JSJitCompilerOption opt, uint32_t value)
|
||||
JS_SetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt, uint32_t value)
|
||||
{
|
||||
#ifdef JS_ION
|
||||
|
||||
@ -6052,19 +6070,19 @@ JS_SetGlobalJitCompilerOption(JSRuntime *rt, JSJitCompilerOption opt, uint32_t v
|
||||
break;
|
||||
case JSJITCOMPILER_ION_ENABLE:
|
||||
if (value == 1) {
|
||||
JS::RuntimeOptionsRef(rt).setIon(true);
|
||||
JS::ContextOptionsRef(cx).setIon(true);
|
||||
IonSpew(js::jit::IonSpew_Scripts, "Enable ion");
|
||||
} else if (value == 0) {
|
||||
JS::RuntimeOptionsRef(rt).setIon(false);
|
||||
JS::ContextOptionsRef(cx).setIon(false);
|
||||
IonSpew(js::jit::IonSpew_Scripts, "Disable ion");
|
||||
}
|
||||
break;
|
||||
case JSJITCOMPILER_BASELINE_ENABLE:
|
||||
if (value == 1) {
|
||||
JS::RuntimeOptionsRef(rt).setBaseline(true);
|
||||
JS::ContextOptionsRef(cx).setBaseline(true);
|
||||
IonSpew(js::jit::IonSpew_BaselineScripts, "Enable baseline");
|
||||
} else if (value == 0) {
|
||||
JS::RuntimeOptionsRef(rt).setBaseline(false);
|
||||
JS::ContextOptionsRef(cx).setBaseline(false);
|
||||
IonSpew(js::jit::IonSpew_BaselineScripts, "Disable baseline");
|
||||
}
|
||||
break;
|
||||
@ -6075,7 +6093,7 @@ JS_SetGlobalJitCompilerOption(JSRuntime *rt, JSJitCompilerOption opt, uint32_t v
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(int)
|
||||
JS_GetGlobalJitCompilerOption(JSRuntime *rt, JSJitCompilerOption opt)
|
||||
JS_GetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt)
|
||||
{
|
||||
#ifdef JS_ION
|
||||
switch (opt) {
|
||||
@ -6084,9 +6102,9 @@ JS_GetGlobalJitCompilerOption(JSRuntime *rt, JSJitCompilerOption opt)
|
||||
case JSJITCOMPILER_ION_USECOUNT_TRIGGER:
|
||||
return jit::js_JitOptions.forcedDefaultIonUsesBeforeCompile;
|
||||
case JSJITCOMPILER_ION_ENABLE:
|
||||
return JS::RuntimeOptionsRef(rt).ion();
|
||||
return JS::ContextOptionsRef(cx).ion();
|
||||
case JSJITCOMPILER_BASELINE_ENABLE:
|
||||
return JS::RuntimeOptionsRef(rt).baseline();
|
||||
return JS::ContextOptionsRef(cx).baseline();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
135
js/src/jsapi.h
135
js/src/jsapi.h
@ -1438,69 +1438,6 @@ JS_StringToVersion(const char *string);
|
||||
|
||||
namespace JS {
|
||||
|
||||
class JS_PUBLIC_API(RuntimeOptions) {
|
||||
public:
|
||||
RuntimeOptions()
|
||||
: baseline_(false),
|
||||
typeInference_(false),
|
||||
ion_(false),
|
||||
asmJS_(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool baseline() const { return baseline_; }
|
||||
RuntimeOptions &setBaseline(bool flag) {
|
||||
baseline_ = flag;
|
||||
return *this;
|
||||
}
|
||||
RuntimeOptions &toggleBaseline() {
|
||||
baseline_ = !baseline_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool typeInference() const { return typeInference_; }
|
||||
RuntimeOptions &setTypeInference(bool flag) {
|
||||
typeInference_ = flag;
|
||||
return *this;
|
||||
}
|
||||
RuntimeOptions &toggleTypeInference() {
|
||||
typeInference_ = !typeInference_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool ion() const { return ion_; }
|
||||
RuntimeOptions &setIon(bool flag) {
|
||||
ion_ = flag;
|
||||
return *this;
|
||||
}
|
||||
RuntimeOptions &toggleIon() {
|
||||
ion_ = !ion_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool asmJS() const { return asmJS_; }
|
||||
RuntimeOptions &setAsmJS(bool flag) {
|
||||
asmJS_ = flag;
|
||||
return *this;
|
||||
}
|
||||
RuntimeOptions &toggleAsmJS() {
|
||||
asmJS_ = !asmJS_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
bool baseline_ : 1;
|
||||
bool typeInference_ : 1;
|
||||
bool ion_ : 1;
|
||||
bool asmJS_ : 1;
|
||||
};
|
||||
|
||||
JS_PUBLIC_API(RuntimeOptions &)
|
||||
RuntimeOptionsRef(JSRuntime *rt);
|
||||
|
||||
JS_PUBLIC_API(RuntimeOptions &)
|
||||
RuntimeOptionsRef(JSContext *cx);
|
||||
|
||||
class JS_PUBLIC_API(ContextOptions) {
|
||||
public:
|
||||
ContextOptions()
|
||||
@ -1512,6 +1449,10 @@ class JS_PUBLIC_API(ContextOptions) {
|
||||
noDefaultCompartmentObject_(false),
|
||||
noScriptRval_(false),
|
||||
strictMode_(false),
|
||||
baseline_(false),
|
||||
typeInference_(false),
|
||||
ion_(false),
|
||||
asmJS_(false),
|
||||
cloneSingletons_(false)
|
||||
{
|
||||
}
|
||||
@ -1596,6 +1537,46 @@ class JS_PUBLIC_API(ContextOptions) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool baseline() const { return baseline_; }
|
||||
ContextOptions &setBaseline(bool flag) {
|
||||
baseline_ = flag;
|
||||
return *this;
|
||||
}
|
||||
ContextOptions &toggleBaseline() {
|
||||
baseline_ = !baseline_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool typeInference() const { return typeInference_; }
|
||||
ContextOptions &setTypeInference(bool flag) {
|
||||
typeInference_ = flag;
|
||||
return *this;
|
||||
}
|
||||
ContextOptions &toggleTypeInference() {
|
||||
typeInference_ = !typeInference_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool ion() const { return ion_; }
|
||||
ContextOptions &setIon(bool flag) {
|
||||
ion_ = flag;
|
||||
return *this;
|
||||
}
|
||||
ContextOptions &toggleIon() {
|
||||
ion_ = !ion_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool asmJS() const { return asmJS_; }
|
||||
ContextOptions &setAsmJS(bool flag) {
|
||||
asmJS_ = flag;
|
||||
return *this;
|
||||
}
|
||||
ContextOptions &toggleAsmJS() {
|
||||
asmJS_ = !asmJS_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool cloneSingletons() const { return cloneSingletons_; }
|
||||
ContextOptions &setCloneSingletons(bool flag) {
|
||||
cloneSingletons_ = flag;
|
||||
@ -1615,6 +1596,10 @@ class JS_PUBLIC_API(ContextOptions) {
|
||||
bool noDefaultCompartmentObject_ : 1;
|
||||
bool noScriptRval_ : 1;
|
||||
bool strictMode_ : 1;
|
||||
bool baseline_ : 1;
|
||||
bool typeInference_ : 1;
|
||||
bool ion_ : 1;
|
||||
bool asmJS_ : 1;
|
||||
bool cloneSingletons_ : 1;
|
||||
};
|
||||
|
||||
@ -2661,6 +2646,18 @@ class JS_PUBLIC_API(CompartmentOptions)
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool baseline(JSContext *cx) const;
|
||||
Override &baselineOverride() { return baselineOverride_; }
|
||||
|
||||
bool typeInference(const js::ExclusiveContext *cx) const;
|
||||
Override &typeInferenceOverride() { return typeInferenceOverride_; }
|
||||
|
||||
bool ion(JSContext *cx) const;
|
||||
Override &ionOverride() { return ionOverride_; }
|
||||
|
||||
bool asmJS(JSContext *cx) const;
|
||||
Override &asmJSOverride() { return asmJSOverride_; }
|
||||
|
||||
bool cloneSingletons(JSContext *cx) const;
|
||||
Override &cloneSingletonsOverride() { return cloneSingletonsOverride_; }
|
||||
|
||||
@ -2683,6 +2680,10 @@ class JS_PUBLIC_API(CompartmentOptions)
|
||||
JSVersion version_;
|
||||
bool invisibleToDebugger_;
|
||||
bool mergeable_;
|
||||
Override baselineOverride_;
|
||||
Override typeInferenceOverride_;
|
||||
Override ionOverride_;
|
||||
Override asmJSOverride_;
|
||||
Override cloneSingletonsOverride_;
|
||||
union {
|
||||
ZoneSpecifier spec;
|
||||
@ -4717,10 +4718,10 @@ JS_ScheduleGC(JSContext *cx, uint32_t count);
|
||||
#endif
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_SetParallelParsingEnabled(JSRuntime *rt, bool enabled);
|
||||
JS_SetParallelParsingEnabled(JSContext *cx, bool enabled);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_SetParallelIonCompilationEnabled(JSRuntime *rt, bool enabled);
|
||||
JS_SetParallelIonCompilationEnabled(JSContext *cx, bool enabled);
|
||||
|
||||
#define JIT_COMPILER_OPTIONS(Register) \
|
||||
Register(BASELINE_USECOUNT_TRIGGER, "baseline.usecount.trigger") \
|
||||
@ -4739,9 +4740,9 @@ typedef enum JSJitCompilerOption {
|
||||
} JSJitCompilerOption;
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_SetGlobalJitCompilerOption(JSRuntime *rt, JSJitCompilerOption opt, uint32_t value);
|
||||
JS_SetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt, uint32_t value);
|
||||
extern JS_PUBLIC_API(int)
|
||||
JS_GetGlobalJitCompilerOption(JSRuntime *rt, JSJitCompilerOption opt);
|
||||
JS_GetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt);
|
||||
|
||||
/*
|
||||
* Convert a uint32_t index into a jsid.
|
||||
|
@ -521,7 +521,7 @@ namespace js {
|
||||
inline bool
|
||||
ExclusiveContext::typeInferenceEnabled() const
|
||||
{
|
||||
return zone()->types.inferenceEnabled;
|
||||
return compartment_->options().typeInference(this);
|
||||
}
|
||||
|
||||
inline js::Handle<js::GlobalObject*>
|
||||
|
@ -1862,7 +1862,7 @@ void
|
||||
TypeZone::init(JSContext *cx)
|
||||
{
|
||||
if (!cx ||
|
||||
!cx->runtime()->options().typeInference() ||
|
||||
!cx->options().typeInference() ||
|
||||
!cx->runtime()->jitSupportsFloatingPoint)
|
||||
{
|
||||
return;
|
||||
|
@ -118,7 +118,11 @@ static double gTimeoutInterval = -1.0;
|
||||
static volatile bool gTimedOut = false;
|
||||
static JS::Value gTimeoutFunc;
|
||||
|
||||
static bool enableTypeInference = true;
|
||||
static bool enableDisassemblyDumps = false;
|
||||
static bool enableIon = true;
|
||||
static bool enableBaseline = true;
|
||||
static bool enableAsmJS = true;
|
||||
|
||||
static bool printTiming = false;
|
||||
static const char *jsCacheDir = nullptr;
|
||||
@ -648,8 +652,7 @@ Options(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
JS::RuntimeOptions oldRuntimeOptions = JS::RuntimeOptionsRef(cx);
|
||||
JS::ContextOptions oldContextOptions = JS::ContextOptionsRef(cx);
|
||||
JS::ContextOptions oldOptions = JS::ContextOptionsRef(cx);
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
JSString *str = JS::ToString(cx, args[i]);
|
||||
if (!str)
|
||||
@ -663,7 +666,7 @@ Options(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (strcmp(opt.ptr(), "strict") == 0)
|
||||
JS::ContextOptionsRef(cx).toggleExtraWarnings();
|
||||
else if (strcmp(opt.ptr(), "typeinfer") == 0)
|
||||
JS::RuntimeOptionsRef(cx).toggleTypeInference();
|
||||
JS::ContextOptionsRef(cx).toggleTypeInference();
|
||||
else if (strcmp(opt.ptr(), "werror") == 0)
|
||||
JS::ContextOptionsRef(cx).toggleWerror();
|
||||
else if (strcmp(opt.ptr(), "strict_mode") == 0)
|
||||
@ -687,19 +690,19 @@ Options(JSContext *cx, unsigned argc, jsval *vp)
|
||||
|
||||
char *names = strdup("");
|
||||
bool found = false;
|
||||
if (!names && oldContextOptions.extraWarnings()) {
|
||||
if (!names && oldOptions.extraWarnings()) {
|
||||
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "strict");
|
||||
found = true;
|
||||
}
|
||||
if (!names && oldRuntimeOptions.typeInference()) {
|
||||
if (!names && oldOptions.typeInference()) {
|
||||
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "typeinfer");
|
||||
found = true;
|
||||
}
|
||||
if (!names && oldContextOptions.werror()) {
|
||||
if (!names && oldOptions.werror()) {
|
||||
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "werror");
|
||||
found = true;
|
||||
}
|
||||
if (!names && oldContextOptions.strictMode()) {
|
||||
if (!names && oldOptions.strictMode()) {
|
||||
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "strict_mode");
|
||||
found = true;
|
||||
}
|
||||
@ -5482,6 +5485,14 @@ NewContext(JSRuntime *rt)
|
||||
|
||||
JS_SetContextPrivate(cx, data);
|
||||
JS_SetErrorReporter(cx, my_ErrorReporter);
|
||||
if (enableTypeInference)
|
||||
JS::ContextOptionsRef(cx).toggleTypeInference();
|
||||
if (enableIon)
|
||||
JS::ContextOptionsRef(cx).toggleIon();
|
||||
if (enableBaseline)
|
||||
JS::ContextOptionsRef(cx).toggleBaseline();
|
||||
if (enableAsmJS)
|
||||
JS::ContextOptionsRef(cx).toggleAsmJS();
|
||||
return cx;
|
||||
}
|
||||
|
||||
@ -5583,11 +5594,11 @@ BindScriptArgs(JSContext *cx, JSObject *obj_, OptionParser *op)
|
||||
// so we're guarding the function definition with an #ifdef, too, to avoid
|
||||
// build warning for unused function in non-ion-enabled builds:
|
||||
#if defined(JS_ION)
|
||||
static bool
|
||||
static int
|
||||
OptionFailure(const char *option, const char *str)
|
||||
{
|
||||
fprintf(stderr, "Unrecognized option for %s: %s\n", option, str);
|
||||
return false;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif /* JS_ION */
|
||||
|
||||
@ -5596,6 +5607,14 @@ ProcessArgs(JSContext *cx, JSObject *obj_, OptionParser *op)
|
||||
{
|
||||
RootedObject obj(cx, obj_);
|
||||
|
||||
if (op->getBoolOption('c'))
|
||||
compileOnly = true;
|
||||
|
||||
if (op->getBoolOption('w'))
|
||||
reportWarnings = true;
|
||||
else if (op->getBoolOption('W'))
|
||||
reportWarnings = false;
|
||||
|
||||
if (op->getBoolOption('s'))
|
||||
JS::ContextOptionsRef(cx).toggleExtraWarnings();
|
||||
|
||||
@ -5604,6 +5623,163 @@ ProcessArgs(JSContext *cx, JSObject *obj_, OptionParser *op)
|
||||
JS_SetDebugMode(cx, true);
|
||||
}
|
||||
|
||||
jsCacheDir = op->getStringOption("js-cache");
|
||||
if (jsCacheDir) {
|
||||
if (op->getBoolOption("js-cache-per-process"))
|
||||
jsCacheDir = JS_smprintf("%s/%u", jsCacheDir, (unsigned)getpid());
|
||||
jsCacheAsmJSPath = JS_smprintf("%s/asmjs.cache", jsCacheDir);
|
||||
}
|
||||
|
||||
if (op->getBoolOption('b'))
|
||||
printTiming = true;
|
||||
|
||||
if (op->getBoolOption('D')) {
|
||||
cx->runtime()->profilingScripts = true;
|
||||
enableDisassemblyDumps = true;
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
int32_t threadCount = op->getIntOption("thread-count");
|
||||
if (threadCount >= 0)
|
||||
SetFakeCPUCount(threadCount);
|
||||
#endif /* JS_THREADSAFE */
|
||||
|
||||
#if defined(JS_ION)
|
||||
if (op->getBoolOption("no-ion")) {
|
||||
enableIon = false;
|
||||
JS::ContextOptionsRef(cx).toggleIon();
|
||||
}
|
||||
if (op->getBoolOption("no-asmjs")) {
|
||||
enableAsmJS = false;
|
||||
JS::ContextOptionsRef(cx).toggleAsmJS();
|
||||
}
|
||||
|
||||
if (op->getBoolOption("no-baseline")) {
|
||||
enableBaseline = false;
|
||||
JS::ContextOptionsRef(cx).toggleBaseline();
|
||||
}
|
||||
|
||||
if (const char *str = op->getStringOption("ion-gvn")) {
|
||||
if (strcmp(str, "off") == 0) {
|
||||
jit::js_JitOptions.disableGvn = true;
|
||||
} else if (strcmp(str, "pessimistic") == 0) {
|
||||
jit::js_JitOptions.forceGvnKind = true;
|
||||
jit::js_JitOptions.forcedGvnKind = jit::GVN_Pessimistic;
|
||||
} else if (strcmp(str, "optimistic") == 0) {
|
||||
jit::js_JitOptions.forceGvnKind = true;
|
||||
jit::js_JitOptions.forcedGvnKind = jit::GVN_Optimistic;
|
||||
} else {
|
||||
return OptionFailure("ion-gvn", str);
|
||||
}
|
||||
}
|
||||
|
||||
if (const char *str = op->getStringOption("ion-licm")) {
|
||||
if (strcmp(str, "on") == 0)
|
||||
jit::js_JitOptions.disableLicm = false;
|
||||
else if (strcmp(str, "off") == 0)
|
||||
jit::js_JitOptions.disableLicm = true;
|
||||
else
|
||||
return OptionFailure("ion-licm", str);
|
||||
}
|
||||
|
||||
if (const char *str = op->getStringOption("ion-edgecase-analysis")) {
|
||||
if (strcmp(str, "on") == 0)
|
||||
jit::js_JitOptions.disableEdgeCaseAnalysis = false;
|
||||
else if (strcmp(str, "off") == 0)
|
||||
jit::js_JitOptions.disableEdgeCaseAnalysis = true;
|
||||
else
|
||||
return OptionFailure("ion-edgecase-analysis", str);
|
||||
}
|
||||
|
||||
if (const char *str = op->getStringOption("ion-range-analysis")) {
|
||||
if (strcmp(str, "on") == 0)
|
||||
jit::js_JitOptions.disableRangeAnalysis = false;
|
||||
else if (strcmp(str, "off") == 0)
|
||||
jit::js_JitOptions.disableRangeAnalysis = true;
|
||||
else
|
||||
return OptionFailure("ion-range-analysis", str);
|
||||
}
|
||||
|
||||
if (op->getBoolOption("ion-check-range-analysis"))
|
||||
jit::js_JitOptions.checkRangeAnalysis = true;
|
||||
|
||||
if (const char *str = op->getStringOption("ion-inlining")) {
|
||||
if (strcmp(str, "on") == 0)
|
||||
jit::js_JitOptions.disableInlining = false;
|
||||
else if (strcmp(str, "off") == 0)
|
||||
jit::js_JitOptions.disableInlining = true;
|
||||
else
|
||||
return OptionFailure("ion-inlining", str);
|
||||
}
|
||||
|
||||
if (const char *str = op->getStringOption("ion-osr")) {
|
||||
if (strcmp(str, "on") == 0)
|
||||
jit::js_JitOptions.osr = true;
|
||||
else if (strcmp(str, "off") == 0)
|
||||
jit::js_JitOptions.osr = false;
|
||||
else
|
||||
return OptionFailure("ion-osr", str);
|
||||
}
|
||||
|
||||
if (const char *str = op->getStringOption("ion-limit-script-size")) {
|
||||
if (strcmp(str, "on") == 0)
|
||||
jit::js_JitOptions.limitScriptSize = true;
|
||||
else if (strcmp(str, "off") == 0)
|
||||
jit::js_JitOptions.limitScriptSize = false;
|
||||
else
|
||||
return OptionFailure("ion-limit-script-size", str);
|
||||
}
|
||||
|
||||
int32_t useCount = op->getIntOption("ion-uses-before-compile");
|
||||
if (useCount >= 0)
|
||||
jit::js_JitOptions.setUsesBeforeCompile(useCount);
|
||||
|
||||
useCount = op->getIntOption("baseline-uses-before-compile");
|
||||
if (useCount >= 0)
|
||||
jit::js_JitOptions.baselineUsesBeforeCompile = useCount;
|
||||
|
||||
if (op->getBoolOption("baseline-eager"))
|
||||
jit::js_JitOptions.baselineUsesBeforeCompile = 0;
|
||||
|
||||
if (const char *str = op->getStringOption("ion-regalloc")) {
|
||||
if (strcmp(str, "lsra") == 0) {
|
||||
jit::js_JitOptions.forceRegisterAllocator = true;
|
||||
jit::js_JitOptions.forcedRegisterAllocator = jit::RegisterAllocator_LSRA;
|
||||
} else if (strcmp(str, "backtracking") == 0) {
|
||||
jit::js_JitOptions.forceRegisterAllocator = true;
|
||||
jit::js_JitOptions.forcedRegisterAllocator = jit::RegisterAllocator_Backtracking;
|
||||
} else if (strcmp(str, "stupid") == 0) {
|
||||
jit::js_JitOptions.forceRegisterAllocator = true;
|
||||
jit::js_JitOptions.forcedRegisterAllocator = jit::RegisterAllocator_Stupid;
|
||||
} else {
|
||||
return OptionFailure("ion-regalloc", str);
|
||||
}
|
||||
}
|
||||
|
||||
if (op->getBoolOption("ion-eager"))
|
||||
jit::js_JitOptions.setEagerCompilation();
|
||||
|
||||
if (op->getBoolOption("ion-compile-try-catch"))
|
||||
jit::js_JitOptions.compileTryCatch = true;
|
||||
|
||||
bool parallelCompilation = true;
|
||||
if (const char *str = op->getStringOption("ion-parallel-compile")) {
|
||||
if (strcmp(str, "off") == 0)
|
||||
parallelCompilation = false;
|
||||
else if (strcmp(str, "on") != 0)
|
||||
return OptionFailure("ion-parallel-compile", str);
|
||||
}
|
||||
#ifdef JS_THREADSAFE
|
||||
cx->runtime()->setParallelIonCompilationEnabled(parallelCompilation);
|
||||
#endif
|
||||
|
||||
#endif /* JS_ION */
|
||||
|
||||
#ifdef DEBUG
|
||||
if (op->getBoolOption("dump-entrained-variables"))
|
||||
dumpEntrainedVariables = true;
|
||||
#endif
|
||||
|
||||
/* |scriptArgs| gets bound on the global before any code is run. */
|
||||
if (!BindScriptArgs(cx, obj, op))
|
||||
return EXIT_FAILURE;
|
||||
@ -5647,191 +5823,20 @@ ProcessArgs(JSContext *cx, JSObject *obj_, OptionParser *op)
|
||||
return gExitCode ? gExitCode : EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static bool
|
||||
SetRuntimeOptions(JSRuntime *rt, const OptionParser &op)
|
||||
{
|
||||
#if defined(JS_ION)
|
||||
bool enableBaseline = !op.getBoolOption("no-baseline");
|
||||
bool enableIon = !op.getBoolOption("no-ion");
|
||||
bool enableTypeInference = !op.getBoolOption("no-ti");
|
||||
bool enableAsmJS = !op.getBoolOption("no-asmjs");
|
||||
|
||||
JS::RuntimeOptionsRef(rt).setBaseline(enableBaseline)
|
||||
.setIon(enableIon)
|
||||
.setTypeInference(enableTypeInference)
|
||||
.setAsmJS(enableAsmJS);
|
||||
|
||||
if (const char *str = op.getStringOption("ion-gvn")) {
|
||||
if (strcmp(str, "off") == 0) {
|
||||
jit::js_JitOptions.disableGvn = true;
|
||||
} else if (strcmp(str, "pessimistic") == 0) {
|
||||
jit::js_JitOptions.forceGvnKind = true;
|
||||
jit::js_JitOptions.forcedGvnKind = jit::GVN_Pessimistic;
|
||||
} else if (strcmp(str, "optimistic") == 0) {
|
||||
jit::js_JitOptions.forceGvnKind = true;
|
||||
jit::js_JitOptions.forcedGvnKind = jit::GVN_Optimistic;
|
||||
} else {
|
||||
return OptionFailure("ion-gvn", str);
|
||||
}
|
||||
}
|
||||
|
||||
if (const char *str = op.getStringOption("ion-licm")) {
|
||||
if (strcmp(str, "on") == 0)
|
||||
jit::js_JitOptions.disableLicm = false;
|
||||
else if (strcmp(str, "off") == 0)
|
||||
jit::js_JitOptions.disableLicm = true;
|
||||
else
|
||||
return OptionFailure("ion-licm", str);
|
||||
}
|
||||
|
||||
if (const char *str = op.getStringOption("ion-edgecase-analysis")) {
|
||||
if (strcmp(str, "on") == 0)
|
||||
jit::js_JitOptions.disableEdgeCaseAnalysis = false;
|
||||
else if (strcmp(str, "off") == 0)
|
||||
jit::js_JitOptions.disableEdgeCaseAnalysis = true;
|
||||
else
|
||||
return OptionFailure("ion-edgecase-analysis", str);
|
||||
}
|
||||
|
||||
if (const char *str = op.getStringOption("ion-range-analysis")) {
|
||||
if (strcmp(str, "on") == 0)
|
||||
jit::js_JitOptions.disableRangeAnalysis = false;
|
||||
else if (strcmp(str, "off") == 0)
|
||||
jit::js_JitOptions.disableRangeAnalysis = true;
|
||||
else
|
||||
return OptionFailure("ion-range-analysis", str);
|
||||
}
|
||||
|
||||
if (op.getBoolOption("ion-check-range-analysis"))
|
||||
jit::js_JitOptions.checkRangeAnalysis = true;
|
||||
|
||||
if (const char *str = op.getStringOption("ion-inlining")) {
|
||||
if (strcmp(str, "on") == 0)
|
||||
jit::js_JitOptions.disableInlining = false;
|
||||
else if (strcmp(str, "off") == 0)
|
||||
jit::js_JitOptions.disableInlining = true;
|
||||
else
|
||||
return OptionFailure("ion-inlining", str);
|
||||
}
|
||||
|
||||
if (const char *str = op.getStringOption("ion-osr")) {
|
||||
if (strcmp(str, "on") == 0)
|
||||
jit::js_JitOptions.osr = true;
|
||||
else if (strcmp(str, "off") == 0)
|
||||
jit::js_JitOptions.osr = false;
|
||||
else
|
||||
return OptionFailure("ion-osr", str);
|
||||
}
|
||||
|
||||
if (const char *str = op.getStringOption("ion-limit-script-size")) {
|
||||
if (strcmp(str, "on") == 0)
|
||||
jit::js_JitOptions.limitScriptSize = true;
|
||||
else if (strcmp(str, "off") == 0)
|
||||
jit::js_JitOptions.limitScriptSize = false;
|
||||
else
|
||||
return OptionFailure("ion-limit-script-size", str);
|
||||
}
|
||||
|
||||
int32_t useCount = op.getIntOption("ion-uses-before-compile");
|
||||
if (useCount >= 0)
|
||||
jit::js_JitOptions.setUsesBeforeCompile(useCount);
|
||||
|
||||
useCount = op.getIntOption("baseline-uses-before-compile");
|
||||
if (useCount >= 0)
|
||||
jit::js_JitOptions.baselineUsesBeforeCompile = useCount;
|
||||
|
||||
if (op.getBoolOption("baseline-eager"))
|
||||
jit::js_JitOptions.baselineUsesBeforeCompile = 0;
|
||||
|
||||
if (const char *str = op.getStringOption("ion-regalloc")) {
|
||||
if (strcmp(str, "lsra") == 0) {
|
||||
jit::js_JitOptions.forceRegisterAllocator = true;
|
||||
jit::js_JitOptions.forcedRegisterAllocator = jit::RegisterAllocator_LSRA;
|
||||
} else if (strcmp(str, "backtracking") == 0) {
|
||||
jit::js_JitOptions.forceRegisterAllocator = true;
|
||||
jit::js_JitOptions.forcedRegisterAllocator = jit::RegisterAllocator_Backtracking;
|
||||
} else if (strcmp(str, "stupid") == 0) {
|
||||
jit::js_JitOptions.forceRegisterAllocator = true;
|
||||
jit::js_JitOptions.forcedRegisterAllocator = jit::RegisterAllocator_Stupid;
|
||||
} else {
|
||||
return OptionFailure("ion-regalloc", str);
|
||||
}
|
||||
}
|
||||
|
||||
if (op.getBoolOption("ion-eager"))
|
||||
jit::js_JitOptions.setEagerCompilation();
|
||||
|
||||
if (op.getBoolOption("ion-compile-try-catch"))
|
||||
jit::js_JitOptions.compileTryCatch = true;
|
||||
|
||||
bool parallelCompilation = true;
|
||||
if (const char *str = op.getStringOption("ion-parallel-compile")) {
|
||||
if (strcmp(str, "off") == 0)
|
||||
parallelCompilation = false;
|
||||
else if (strcmp(str, "on") != 0)
|
||||
return OptionFailure("ion-parallel-compile", str);
|
||||
}
|
||||
#ifdef JS_THREADSAFE
|
||||
rt->setParallelIonCompilationEnabled(parallelCompilation);
|
||||
#endif
|
||||
|
||||
#if defined(JS_CODEGEN_X86) && defined(DEBUG)
|
||||
if (op.getBoolOption("no-fpu"))
|
||||
JSC::MacroAssembler::SetFloatingPointDisabled();
|
||||
#endif
|
||||
|
||||
#if (defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64)) && defined(DEBUG)
|
||||
if (op.getBoolOption("no-sse3")) {
|
||||
JSC::MacroAssembler::SetSSE3Disabled();
|
||||
PropagateFlagToNestedShells("--no-sse3");
|
||||
}
|
||||
if (op.getBoolOption("no-sse4")) {
|
||||
JSC::MacroAssembler::SetSSE4Disabled();
|
||||
PropagateFlagToNestedShells("--no-sse4");
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // JS_ION
|
||||
|
||||
#ifdef JS_ARM_SIMULATOR
|
||||
if (op.getBoolOption("arm-sim-icache-checks"))
|
||||
jit::Simulator::ICacheCheckingEnabled = true;
|
||||
|
||||
int32_t stopAt = op.getIntOption("arm-sim-stop-at");
|
||||
if (stopAt >= 0)
|
||||
jit::Simulator::StopSimAt = stopAt;
|
||||
#endif
|
||||
|
||||
reportWarnings = op.getBoolOption('w');
|
||||
compileOnly = op.getBoolOption('c');
|
||||
printTiming = op.getBoolOption('b');
|
||||
rt->profilingScripts = enableDisassemblyDumps = op.getBoolOption('D');
|
||||
|
||||
jsCacheDir = op.getStringOption("js-cache");
|
||||
if (jsCacheDir) {
|
||||
if (op.getBoolOption("js-cache-per-process"))
|
||||
jsCacheDir = JS_smprintf("%s/%u", jsCacheDir, (unsigned)getpid());
|
||||
jsCacheAsmJSPath = JS_smprintf("%s/asmjs.cache", jsCacheDir);
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
int32_t threadCount = op.getIntOption("thread-count");
|
||||
if (threadCount >= 0)
|
||||
SetFakeCPUCount(threadCount);
|
||||
#endif /* JS_THREADSAFE */
|
||||
|
||||
#ifdef DEBUG
|
||||
dumpEntrainedVariables = op.getBoolOption("dump-entrained-variables");
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int
|
||||
Shell(JSContext *cx, OptionParser *op, char **envp)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
/*
|
||||
* First check to see if type inference is enabled. These flags
|
||||
* must be set on the compartment when it is constructed.
|
||||
*/
|
||||
if (op->getBoolOption("no-ti")) {
|
||||
enableTypeInference = false;
|
||||
JS::ContextOptionsRef(cx).toggleTypeInference();
|
||||
}
|
||||
|
||||
if (op->getBoolOption("fuzzing-safe"))
|
||||
fuzzingSafe = true;
|
||||
else
|
||||
@ -6047,7 +6052,33 @@ main(int argc, char **argv, char **envp)
|
||||
* Process OOM options as early as possible so that we can observe as many
|
||||
* allocations as possible.
|
||||
*/
|
||||
OOM_printAllocationCount = op.getBoolOption('O');
|
||||
if (op.getBoolOption('O'))
|
||||
OOM_printAllocationCount = true;
|
||||
|
||||
#if defined(JS_CODEGEN_X86) && defined(JS_ION)
|
||||
if (op.getBoolOption("no-fpu"))
|
||||
JSC::MacroAssembler::SetFloatingPointDisabled();
|
||||
#endif
|
||||
|
||||
#if (defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64)) && defined(JS_ION)
|
||||
if (op.getBoolOption("no-sse3")) {
|
||||
JSC::MacroAssembler::SetSSE3Disabled();
|
||||
PropagateFlagToNestedShells("--no-sse3");
|
||||
}
|
||||
if (op.getBoolOption("no-sse4")) {
|
||||
JSC::MacroAssembler::SetSSE4Disabled();
|
||||
PropagateFlagToNestedShells("--no-sse4");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef JS_ARM_SIMULATOR
|
||||
if (op.getBoolOption("arm-sim-icache-checks"))
|
||||
jit::Simulator::ICacheCheckingEnabled = true;
|
||||
|
||||
int32_t stopAt = op.getIntOption("arm-sim-stop-at");
|
||||
if (stopAt >= 0)
|
||||
jit::Simulator::StopSimAt = stopAt;
|
||||
#endif
|
||||
|
||||
// Start the engine.
|
||||
@ -6058,10 +6089,6 @@ main(int argc, char **argv, char **envp)
|
||||
rt = JS_NewRuntime(32L * 1024L * 1024L, JS_USE_HELPER_THREADS);
|
||||
if (!rt)
|
||||
return 1;
|
||||
|
||||
if (!SetRuntimeOptions(rt, op))
|
||||
return 1;
|
||||
|
||||
gTimeoutFunc = NullValue();
|
||||
if (!JS_AddNamedValueRootRT(rt, &gTimeoutFunc, "gTimeoutFunc"))
|
||||
return 1;
|
||||
|
@ -1694,7 +1694,6 @@ struct JSRuntime : public JS::shadow::Runtime,
|
||||
void addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::RuntimeSizes *runtime);
|
||||
|
||||
private:
|
||||
JS::RuntimeOptions options_;
|
||||
|
||||
JSUseHelperThreads useHelperThreads_;
|
||||
|
||||
@ -1742,13 +1741,6 @@ struct JSRuntime : public JS::shadow::Runtime,
|
||||
return isWorkerRuntime_;
|
||||
}
|
||||
|
||||
const JS::RuntimeOptions &options() const {
|
||||
return options_;
|
||||
}
|
||||
JS::RuntimeOptions &options() {
|
||||
return options_;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
public:
|
||||
js::AutoEnterPolicy *enteredPolicy;
|
||||
|
@ -3245,41 +3245,26 @@ nsXPCComponents_Utils::Dispatch(HandleValue runnableArg, HandleValue scope,
|
||||
return NS_DispatchToMainThread(run);
|
||||
}
|
||||
|
||||
#define GENERATE_JSCONTEXTOPTION_GETTER_SETTER(_attr, _getter, _setter) \
|
||||
NS_IMETHODIMP \
|
||||
nsXPCComponents_Utils::Get## _attr(JSContext* cx, bool* aValue) \
|
||||
{ \
|
||||
*aValue = ContextOptionsRef(cx)._getter(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
nsXPCComponents_Utils::Set## _attr(JSContext* cx, bool aValue) \
|
||||
{ \
|
||||
ContextOptionsRef(cx)._setter(aValue); \
|
||||
return NS_OK; \
|
||||
#define GENERATE_JSOPTION_GETTER_SETTER(_attr, _getter, _setter) \
|
||||
NS_IMETHODIMP \
|
||||
nsXPCComponents_Utils::Get## _attr(JSContext* cx, bool* aValue) \
|
||||
{ \
|
||||
*aValue = ContextOptionsRef(cx)._getter(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
nsXPCComponents_Utils::Set## _attr(JSContext* cx, bool aValue) \
|
||||
{ \
|
||||
ContextOptionsRef(cx)._setter(aValue); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
#define GENERATE_JSRUNTIMEOPTION_GETTER_SETTER(_attr, _getter, _setter) \
|
||||
NS_IMETHODIMP \
|
||||
nsXPCComponents_Utils::Get## _attr(JSContext* cx, bool* aValue) \
|
||||
{ \
|
||||
*aValue = RuntimeOptionsRef(cx)._getter(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
nsXPCComponents_Utils::Set## _attr(JSContext* cx, bool aValue) \
|
||||
{ \
|
||||
RuntimeOptionsRef(cx)._setter(aValue); \
|
||||
return NS_OK; \
|
||||
}
|
||||
GENERATE_JSOPTION_GETTER_SETTER(Strict, extraWarnings, setExtraWarnings)
|
||||
GENERATE_JSOPTION_GETTER_SETTER(Werror, werror, setWerror)
|
||||
GENERATE_JSOPTION_GETTER_SETTER(Strict_mode, strictMode, setStrictMode)
|
||||
GENERATE_JSOPTION_GETTER_SETTER(Ion, ion, setIon)
|
||||
|
||||
GENERATE_JSCONTEXTOPTION_GETTER_SETTER(Strict, extraWarnings, setExtraWarnings)
|
||||
GENERATE_JSCONTEXTOPTION_GETTER_SETTER(Werror, werror, setWerror)
|
||||
GENERATE_JSCONTEXTOPTION_GETTER_SETTER(Strict_mode, strictMode, setStrictMode)
|
||||
GENERATE_JSRUNTIMEOPTION_GETTER_SETTER(Ion, ion, setIon)
|
||||
|
||||
#undef GENERATE_JSCONTEXTOPTION_GETTER_SETTER
|
||||
#undef GENERATE_JSRUNTIMEOPTION_GETTER_SETTER
|
||||
#undef GENERATE_JSOPTION_GETTER_SETTER
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::SetGCZeal(int32_t aValue, JSContext* cx)
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include "nsAboutProtocolUtils.h"
|
||||
|
||||
#include "GeckoProfiler.h"
|
||||
#include "nsIXULRuntime.h"
|
||||
#include "nsJSPrincipals.h"
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
@ -1499,45 +1498,6 @@ void XPCJSRuntime::SystemIsBeingShutDown()
|
||||
Enumerate(DetachedWrappedNativeProtoShutdownMarker, nullptr);
|
||||
}
|
||||
|
||||
#define JS_OPTIONS_DOT_STR "javascript.options."
|
||||
|
||||
static void
|
||||
ReloadPrefsCallback(const char *pref, void *data)
|
||||
{
|
||||
XPCJSRuntime *runtime = reinterpret_cast<XPCJSRuntime *>(data);
|
||||
JSRuntime *rt = runtime->Runtime();
|
||||
|
||||
bool safeMode = false;
|
||||
nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
|
||||
if (xr) {
|
||||
xr->GetInSafeMode(&safeMode);
|
||||
}
|
||||
|
||||
bool useBaseline = Preferences::GetBool(JS_OPTIONS_DOT_STR "baselinejit") && !safeMode;
|
||||
bool useTypeInference = Preferences::GetBool(JS_OPTIONS_DOT_STR "typeinference") && !safeMode;
|
||||
bool useIon = Preferences::GetBool(JS_OPTIONS_DOT_STR "ion") && !safeMode;
|
||||
bool useAsmJS = Preferences::GetBool(JS_OPTIONS_DOT_STR "asmjs") && !safeMode;
|
||||
|
||||
bool parallelParsing = Preferences::GetBool(JS_OPTIONS_DOT_STR "parallel_parsing");
|
||||
bool parallelIonCompilation = Preferences::GetBool(JS_OPTIONS_DOT_STR
|
||||
"ion.parallel_compilation");
|
||||
bool useBaselineEager = Preferences::GetBool(JS_OPTIONS_DOT_STR
|
||||
"baselinejit.unsafe_eager_compilation");
|
||||
bool useIonEager = Preferences::GetBool(JS_OPTIONS_DOT_STR "ion.unsafe_eager_compilation");
|
||||
|
||||
JS::RuntimeOptionsRef(rt).setBaseline(useBaseline)
|
||||
.setTypeInference(useTypeInference)
|
||||
.setIon(useIon)
|
||||
. setAsmJS(useAsmJS);
|
||||
|
||||
JS_SetParallelParsingEnabled(rt, parallelParsing);
|
||||
JS_SetParallelIonCompilationEnabled(rt, parallelIonCompilation);
|
||||
JS_SetGlobalJitCompilerOption(rt, JSJITCOMPILER_BASELINE_USECOUNT_TRIGGER,
|
||||
useBaselineEager ? 0 : -1);
|
||||
JS_SetGlobalJitCompilerOption(rt, JSJITCOMPILER_ION_USECOUNT_TRIGGER,
|
||||
useIonEager ? 0 : -1);
|
||||
}
|
||||
|
||||
XPCJSRuntime::~XPCJSRuntime()
|
||||
{
|
||||
// This destructor runs before ~CycleCollectedJSRuntime, which does the
|
||||
@ -1623,8 +1583,6 @@ XPCJSRuntime::~XPCJSRuntime()
|
||||
MOZ_ASSERT(mScratchStrings[i].empty(), "Short lived string still in use");
|
||||
}
|
||||
#endif
|
||||
|
||||
Preferences::UnregisterCallback(ReloadPrefsCallback, JS_OPTIONS_DOT_STR, this);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3178,10 +3136,6 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
||||
if (!JS_GetGlobalDebugHooks(runtime)->debuggerHandler)
|
||||
xpc_InstallJSDebuggerKeywordHandler(runtime);
|
||||
#endif
|
||||
|
||||
// Watch for the JS boolean options.
|
||||
ReloadPrefsCallback(nullptr, this);
|
||||
Preferences::RegisterCallback(ReloadPrefsCallback, JS_OPTIONS_DOT_STR, this);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -1039,11 +1039,11 @@ ProcessArgsForCompartment(JSContext *cx, char **argv, int argc)
|
||||
ContextOptionsRef(cx).toggleExtraWarnings();
|
||||
break;
|
||||
case 'I':
|
||||
RuntimeOptionsRef(cx).toggleIon()
|
||||
ContextOptionsRef(cx).toggleIon()
|
||||
.toggleAsmJS();
|
||||
break;
|
||||
case 'n':
|
||||
RuntimeOptionsRef(cx).toggleTypeInference();
|
||||
ContextOptionsRef(cx).toggleTypeInference();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1487,6 +1487,9 @@ XRE_XPCShellMain(int argc, char **argv, char **envp)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Ion not enabled yet here because of bug 931861.
|
||||
JS::ContextOptionsRef(cx).setBaseline(true);
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
ProcessArgsForCompartment(cx, argv, argc);
|
||||
|
@ -361,12 +361,56 @@ TraceXPCGlobal(JSTracer *trc, JSObject *obj)
|
||||
mozilla::dom::TraceProtoAndIfaceCache(trc, obj);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsIXULRuntime.h"
|
||||
static void
|
||||
CheckTypeInference(JSContext *cx, const JSClass *clasp, nsIPrincipal *principal)
|
||||
{
|
||||
// Check that the global class isn't whitelisted.
|
||||
if (strcmp(clasp->name, "Sandbox") ||
|
||||
strcmp(clasp->name, "nsXBLPrototypeScript compilation scope") ||
|
||||
strcmp(clasp->name, "nsXULPrototypeScript compilation scope"))
|
||||
return;
|
||||
|
||||
// Check that the pref is on.
|
||||
if (!mozilla::Preferences::GetBool("javascript.options.typeinference"))
|
||||
return;
|
||||
|
||||
// Check that we're not chrome.
|
||||
bool isSystem;
|
||||
nsIScriptSecurityManager* ssm;
|
||||
ssm = XPCWrapper::GetSecurityManager();
|
||||
if (NS_FAILED(ssm->IsSystemPrincipal(principal, &isSystem)) || !isSystem)
|
||||
return;
|
||||
|
||||
// Check that safe mode isn't on.
|
||||
bool safeMode;
|
||||
nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
|
||||
if (!xr) {
|
||||
NS_WARNING("Couldn't get XUL runtime!");
|
||||
return;
|
||||
}
|
||||
if (NS_FAILED(xr->GetInSafeMode(&safeMode)) || safeMode)
|
||||
return;
|
||||
|
||||
// Finally, do the damn assert.
|
||||
MOZ_ASSERT(ContextOptionsRef(cx).typeInference());
|
||||
}
|
||||
#else
|
||||
#define CheckTypeInference(cx, clasp, principal) {}
|
||||
#endif
|
||||
|
||||
namespace xpc {
|
||||
|
||||
JSObject*
|
||||
CreateGlobalObject(JSContext *cx, const JSClass *clasp, nsIPrincipal *principal,
|
||||
JS::CompartmentOptions& aOptions)
|
||||
{
|
||||
// Make sure that Type Inference is enabled for everything non-chrome.
|
||||
// Sandboxes and compilation scopes are exceptions. See bug 744034.
|
||||
CheckTypeInference(cx, clasp, principal);
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread(), "using a principal off the main thread?");
|
||||
MOZ_ASSERT(principal);
|
||||
|
||||
@ -376,7 +420,6 @@ CreateGlobalObject(JSContext *cx, const JSClass *clasp, nsIPrincipal *principal,
|
||||
if (!global)
|
||||
return nullptr;
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
// The constructor automatically attaches the scope to the compartment private
|
||||
// of |global|.
|
||||
(void) new XPCWrappedNativeScope(cx, global);
|
||||
|
@ -753,12 +753,15 @@ pref("javascript.options.strict", false);
|
||||
#ifdef DEBUG
|
||||
pref("javascript.options.strict.debug", true);
|
||||
#endif
|
||||
pref("javascript.options.baselinejit", true);
|
||||
pref("javascript.options.ion", true);
|
||||
pref("javascript.options.baselinejit.content", true);
|
||||
pref("javascript.options.baselinejit.chrome", true);
|
||||
pref("javascript.options.ion.content", true);
|
||||
pref("javascript.options.ion.chrome", true);
|
||||
pref("javascript.options.asmjs", true);
|
||||
pref("javascript.options.parallel_parsing", true);
|
||||
pref("javascript.options.ion.parallel_compilation", true);
|
||||
pref("javascript.options.typeinference", true);
|
||||
pref("javascript.options.typeinference.content", true);
|
||||
pref("javascript.options.typeinference.chrome", true);
|
||||
// This preference limits the memory usage of javascript.
|
||||
// If you want to change these values for your device,
|
||||
// please find Bug 417052 comment 17 and Bug 456721
|
||||
|
Loading…
Reference in New Issue
Block a user