2019-01-24 03:56:56 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: set ts=8 sts=2 et sw=2 tw=80:
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
/* JavaScript API. */
|
|
|
|
|
|
|
|
#ifndef js_ContextOptions_h
|
|
|
|
#define js_ContextOptions_h
|
|
|
|
|
|
|
|
#include "jstypes.h" // JS_PUBLIC_API
|
|
|
|
|
2021-04-09 23:03:51 +03:00
|
|
|
#include "js/WasmFeatures.h"
|
|
|
|
|
2019-10-28 01:34:11 +03:00
|
|
|
struct JS_PUBLIC_API JSContext;
|
2019-01-24 03:56:56 +03:00
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
class JS_PUBLIC_API ContextOptions {
|
|
|
|
public:
|
2021-04-09 23:03:51 +03:00
|
|
|
// clang-format off
|
2019-01-24 03:56:56 +03:00
|
|
|
ContextOptions()
|
2019-07-10 12:43:39 +03:00
|
|
|
: asmJS_(true),
|
2019-01-24 03:56:56 +03:00
|
|
|
wasm_(true),
|
2019-10-04 20:35:46 +03:00
|
|
|
wasmForTrustedPrinciples_(true),
|
2019-01-24 03:56:56 +03:00
|
|
|
wasmVerbose_(false),
|
|
|
|
wasmBaseline_(true),
|
|
|
|
wasmIon_(true),
|
2021-04-09 23:03:51 +03:00
|
|
|
#define WASM_DEFAULT_FEATURE(NAME, ...) wasm##NAME##_(true),
|
|
|
|
#define WASM_EXPERIMENTAL_FEATURE(NAME, ...) wasm##NAME##_(false),
|
2021-11-24 22:31:55 +03:00
|
|
|
JS_FOR_WASM_FEATURES(WASM_DEFAULT_FEATURE, WASM_DEFAULT_FEATURE, WASM_EXPERIMENTAL_FEATURE)
|
2021-04-09 23:03:51 +03:00
|
|
|
#undef WASM_DEFAULT_FEATURE
|
|
|
|
#undef WASM_EXPERIMENTAL_FEATURE
|
2019-01-24 03:56:56 +03:00
|
|
|
testWasmAwaitTier2_(false),
|
|
|
|
throwOnAsmJSValidationFailure_(false),
|
2020-01-10 21:54:42 +03:00
|
|
|
disableIon_(false),
|
2020-02-24 22:37:41 +03:00
|
|
|
disableEvalSecurityChecks_(false),
|
2019-01-24 03:56:56 +03:00
|
|
|
asyncStack_(true),
|
Bug 1601179 - Enable async stacks but limit captured async stacks to debuggees. r=jorendorff,smaug
The 'asyncStack' flag on JS execution contexts is used as a general switch
to enable async stack capture across all locations in SpiderMonkey, but
this causes problems because it can at times be too much of a performance
burden to general and track all of these stacks.
Since the introduction of this option, we have only enabled it on Nightly
and DevEdition for non-mobile builds, which has left a lot of users unable
to take advantage of this data while debugging.
This patch enables async stack traces across all of Firefox, but introduces
a new pref to toggle the scope of the actual expensive part of async stacks,
which is _capturing_ them and keeping them alive in memory. The new pref
limits the capturing of async stack traces to only debuggees, unless an
explicit pref is flipped to capture async traces for all cases.
This means that while async stacks are technically enabled, and code could
manually capture a stack and pass it back to SpiderMonkey and see that stack
reflected in later captured stacks, SpiderMonkey itself and related async
DOM APIs, among others, will not capture stacks or pass them to SpiderMonkey,
so there should be no general change in performance by enabling the broader
feature itself, unless the user is actively debugging the page.
One effect of this patch is that if you have the debugger open and then close
it, objects that have async stacks associated with them will retain those
stacks and they will continue to show up in stack traces, no _new_ stacks
will be captured. jorendorff and I have decided that this is okay because
the expectation that the debugger fully revert every possible effect that it
could have on a page is a nice goal but not a strict requirement.
Differential Revision: https://phabricator.services.mozilla.com/D68503
2020-06-14 05:41:45 +03:00
|
|
|
asyncStackCaptureDebuggeeOnly_(false),
|
2020-05-08 03:37:21 +03:00
|
|
|
sourcePragmas_(true),
|
2019-01-24 03:56:56 +03:00
|
|
|
throwOnDebuggeeWouldRun_(true),
|
|
|
|
dumpStackOnDebuggeeWouldRun_(false),
|
|
|
|
strictMode_(false),
|
2020-02-28 17:17:59 +03:00
|
|
|
#ifdef JS_ENABLE_SMOOSH
|
2020-03-16 17:35:35 +03:00
|
|
|
trackNotImplemented_(false),
|
2020-02-28 17:17:59 +03:00
|
|
|
trySmoosh_(false),
|
|
|
|
#endif
|
2020-07-27 23:24:20 +03:00
|
|
|
fuzzing_(false),
|
2021-12-01 21:26:08 +03:00
|
|
|
importAssertions_(false) {
|
2019-12-14 00:35:17 +03:00
|
|
|
}
|
2021-04-09 23:03:51 +03:00
|
|
|
// clang-format on
|
2019-01-24 03:56:56 +03:00
|
|
|
|
|
|
|
bool asmJS() const { return asmJS_; }
|
|
|
|
ContextOptions& setAsmJS(bool flag) {
|
|
|
|
asmJS_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
ContextOptions& toggleAsmJS() {
|
|
|
|
asmJS_ = !asmJS_;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wasm() const { return wasm_; }
|
|
|
|
ContextOptions& setWasm(bool flag) {
|
|
|
|
wasm_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
ContextOptions& toggleWasm() {
|
|
|
|
wasm_ = !wasm_;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2019-10-04 20:35:46 +03:00
|
|
|
bool wasmForTrustedPrinciples() const { return wasmForTrustedPrinciples_; }
|
|
|
|
ContextOptions& setWasmForTrustedPrinciples(bool flag) {
|
|
|
|
wasmForTrustedPrinciples_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2019-01-24 03:56:56 +03:00
|
|
|
bool wasmVerbose() const { return wasmVerbose_; }
|
|
|
|
ContextOptions& setWasmVerbose(bool flag) {
|
|
|
|
wasmVerbose_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wasmBaseline() const { return wasmBaseline_; }
|
|
|
|
ContextOptions& setWasmBaseline(bool flag) {
|
|
|
|
wasmBaseline_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wasmIon() const { return wasmIon_; }
|
|
|
|
ContextOptions& setWasmIon(bool flag) {
|
|
|
|
wasmIon_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool testWasmAwaitTier2() const { return testWasmAwaitTier2_; }
|
|
|
|
ContextOptions& setTestWasmAwaitTier2(bool flag) {
|
|
|
|
testWasmAwaitTier2_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2021-04-09 23:03:51 +03:00
|
|
|
#define WASM_FEATURE(NAME, ...) \
|
|
|
|
bool wasm##NAME() const { return wasm##NAME##_; } \
|
|
|
|
ContextOptions& setWasm##NAME(bool flag) { \
|
|
|
|
wasm##NAME##_ = flag; \
|
|
|
|
return *this; \
|
2020-04-30 14:55:13 +03:00
|
|
|
}
|
2021-11-24 22:31:55 +03:00
|
|
|
JS_FOR_WASM_FEATURES(WASM_FEATURE, WASM_FEATURE, WASM_FEATURE)
|
2021-04-09 23:03:51 +03:00
|
|
|
#undef WASM_FEATURE
|
2020-05-05 11:17:47 +03:00
|
|
|
|
2019-01-24 03:56:56 +03:00
|
|
|
bool throwOnAsmJSValidationFailure() const {
|
|
|
|
return throwOnAsmJSValidationFailure_;
|
|
|
|
}
|
|
|
|
ContextOptions& setThrowOnAsmJSValidationFailure(bool flag) {
|
|
|
|
throwOnAsmJSValidationFailure_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
ContextOptions& toggleThrowOnAsmJSValidationFailure() {
|
|
|
|
throwOnAsmJSValidationFailure_ = !throwOnAsmJSValidationFailure_;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-01-10 21:54:42 +03:00
|
|
|
// Override to allow disabling Ion for this context irrespective of the
|
|
|
|
// process-wide Ion-enabled setting. This must be set right after creating
|
|
|
|
// the context.
|
|
|
|
bool disableIon() const { return disableIon_; }
|
|
|
|
ContextOptions& setDisableIon() {
|
|
|
|
disableIon_ = true;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2021-12-01 21:26:08 +03:00
|
|
|
bool importAssertions() const { return importAssertions_; }
|
|
|
|
ContextOptions& setImportAssertions(bool enabled) {
|
|
|
|
importAssertions_ = enabled;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-02-24 22:37:41 +03:00
|
|
|
// Override to allow disabling the eval restriction security checks for
|
|
|
|
// this context.
|
|
|
|
bool disableEvalSecurityChecks() const { return disableEvalSecurityChecks_; }
|
|
|
|
ContextOptions& setDisableEvalSecurityChecks() {
|
|
|
|
disableEvalSecurityChecks_ = true;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2019-01-24 03:56:56 +03:00
|
|
|
bool asyncStack() const { return asyncStack_; }
|
|
|
|
ContextOptions& setAsyncStack(bool flag) {
|
|
|
|
asyncStack_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
Bug 1601179 - Enable async stacks but limit captured async stacks to debuggees. r=jorendorff,smaug
The 'asyncStack' flag on JS execution contexts is used as a general switch
to enable async stack capture across all locations in SpiderMonkey, but
this causes problems because it can at times be too much of a performance
burden to general and track all of these stacks.
Since the introduction of this option, we have only enabled it on Nightly
and DevEdition for non-mobile builds, which has left a lot of users unable
to take advantage of this data while debugging.
This patch enables async stack traces across all of Firefox, but introduces
a new pref to toggle the scope of the actual expensive part of async stacks,
which is _capturing_ them and keeping them alive in memory. The new pref
limits the capturing of async stack traces to only debuggees, unless an
explicit pref is flipped to capture async traces for all cases.
This means that while async stacks are technically enabled, and code could
manually capture a stack and pass it back to SpiderMonkey and see that stack
reflected in later captured stacks, SpiderMonkey itself and related async
DOM APIs, among others, will not capture stacks or pass them to SpiderMonkey,
so there should be no general change in performance by enabling the broader
feature itself, unless the user is actively debugging the page.
One effect of this patch is that if you have the debugger open and then close
it, objects that have async stacks associated with them will retain those
stacks and they will continue to show up in stack traces, no _new_ stacks
will be captured. jorendorff and I have decided that this is okay because
the expectation that the debugger fully revert every possible effect that it
could have on a page is a nice goal but not a strict requirement.
Differential Revision: https://phabricator.services.mozilla.com/D68503
2020-06-14 05:41:45 +03:00
|
|
|
bool asyncStackCaptureDebuggeeOnly() const {
|
|
|
|
return asyncStackCaptureDebuggeeOnly_;
|
|
|
|
}
|
|
|
|
ContextOptions& setAsyncStackCaptureDebuggeeOnly(bool flag) {
|
|
|
|
asyncStackCaptureDebuggeeOnly_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-05-08 03:37:21 +03:00
|
|
|
// Enable/disable support for parsing '//(#@) source(Mapping)?URL=' pragmas.
|
|
|
|
bool sourcePragmas() const { return sourcePragmas_; }
|
|
|
|
ContextOptions& setSourcePragmas(bool flag) {
|
|
|
|
sourcePragmas_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2019-01-24 03:56:56 +03:00
|
|
|
bool throwOnDebuggeeWouldRun() const { return throwOnDebuggeeWouldRun_; }
|
|
|
|
ContextOptions& setThrowOnDebuggeeWouldRun(bool flag) {
|
|
|
|
throwOnDebuggeeWouldRun_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool dumpStackOnDebuggeeWouldRun() const {
|
|
|
|
return dumpStackOnDebuggeeWouldRun_;
|
|
|
|
}
|
|
|
|
ContextOptions& setDumpStackOnDebuggeeWouldRun(bool flag) {
|
|
|
|
dumpStackOnDebuggeeWouldRun_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool strictMode() const { return strictMode_; }
|
|
|
|
ContextOptions& setStrictMode(bool flag) {
|
|
|
|
strictMode_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
ContextOptions& toggleStrictMode() {
|
|
|
|
strictMode_ = !strictMode_;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-02-28 17:17:59 +03:00
|
|
|
#ifdef JS_ENABLE_SMOOSH
|
2020-03-16 17:35:35 +03:00
|
|
|
// Track Number of Not Implemented Calls by writing to a file
|
|
|
|
bool trackNotImplemented() const { return trackNotImplemented_; }
|
|
|
|
ContextOptions& setTrackNotImplemented(bool flag) {
|
|
|
|
trackNotImplemented_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-02-28 17:17:59 +03:00
|
|
|
// Try compiling SmooshMonkey frontend first, and fallback to C++
|
|
|
|
// implementation when it fails.
|
|
|
|
bool trySmoosh() const { return trySmoosh_; }
|
|
|
|
ContextOptions& setTrySmoosh(bool flag) {
|
|
|
|
trySmoosh_ = flag;
|
|
|
|
return *this;
|
|
|
|
}
|
2020-03-16 17:35:35 +03:00
|
|
|
|
2020-02-28 17:17:59 +03:00
|
|
|
#endif // JS_ENABLE_SMOOSH
|
|
|
|
|
2019-01-24 03:56:56 +03:00
|
|
|
bool fuzzing() const { return fuzzing_; }
|
2019-11-26 10:25:22 +03:00
|
|
|
// Defined out-of-line because it depends on a compile-time option
|
|
|
|
ContextOptions& setFuzzing(bool flag);
|
2019-01-24 03:56:56 +03:00
|
|
|
|
|
|
|
void disableOptionsForSafeMode() {
|
|
|
|
setAsmJS(false);
|
|
|
|
setWasmBaseline(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool asmJS_ : 1;
|
|
|
|
bool wasm_ : 1;
|
2019-10-04 20:35:46 +03:00
|
|
|
bool wasmForTrustedPrinciples_ : 1;
|
2019-01-24 03:56:56 +03:00
|
|
|
bool wasmVerbose_ : 1;
|
|
|
|
bool wasmBaseline_ : 1;
|
|
|
|
bool wasmIon_ : 1;
|
2021-04-09 23:03:51 +03:00
|
|
|
#define WASM_FEATURE(NAME, ...) bool wasm##NAME##_ : 1;
|
2021-11-24 22:31:55 +03:00
|
|
|
JS_FOR_WASM_FEATURES(WASM_FEATURE, WASM_FEATURE, WASM_FEATURE)
|
2021-04-09 23:03:51 +03:00
|
|
|
#undef WASM_FEATURE
|
2019-01-24 03:56:56 +03:00
|
|
|
bool testWasmAwaitTier2_ : 1;
|
|
|
|
bool throwOnAsmJSValidationFailure_ : 1;
|
2020-01-10 21:54:42 +03:00
|
|
|
bool disableIon_ : 1;
|
2020-02-24 22:37:41 +03:00
|
|
|
bool disableEvalSecurityChecks_ : 1;
|
2019-01-24 03:56:56 +03:00
|
|
|
bool asyncStack_ : 1;
|
Bug 1601179 - Enable async stacks but limit captured async stacks to debuggees. r=jorendorff,smaug
The 'asyncStack' flag on JS execution contexts is used as a general switch
to enable async stack capture across all locations in SpiderMonkey, but
this causes problems because it can at times be too much of a performance
burden to general and track all of these stacks.
Since the introduction of this option, we have only enabled it on Nightly
and DevEdition for non-mobile builds, which has left a lot of users unable
to take advantage of this data while debugging.
This patch enables async stack traces across all of Firefox, but introduces
a new pref to toggle the scope of the actual expensive part of async stacks,
which is _capturing_ them and keeping them alive in memory. The new pref
limits the capturing of async stack traces to only debuggees, unless an
explicit pref is flipped to capture async traces for all cases.
This means that while async stacks are technically enabled, and code could
manually capture a stack and pass it back to SpiderMonkey and see that stack
reflected in later captured stacks, SpiderMonkey itself and related async
DOM APIs, among others, will not capture stacks or pass them to SpiderMonkey,
so there should be no general change in performance by enabling the broader
feature itself, unless the user is actively debugging the page.
One effect of this patch is that if you have the debugger open and then close
it, objects that have async stacks associated with them will retain those
stacks and they will continue to show up in stack traces, no _new_ stacks
will be captured. jorendorff and I have decided that this is okay because
the expectation that the debugger fully revert every possible effect that it
could have on a page is a nice goal but not a strict requirement.
Differential Revision: https://phabricator.services.mozilla.com/D68503
2020-06-14 05:41:45 +03:00
|
|
|
bool asyncStackCaptureDebuggeeOnly_ : 1;
|
2020-05-08 03:37:21 +03:00
|
|
|
bool sourcePragmas_ : 1;
|
2019-01-24 03:56:56 +03:00
|
|
|
bool throwOnDebuggeeWouldRun_ : 1;
|
|
|
|
bool dumpStackOnDebuggeeWouldRun_ : 1;
|
|
|
|
bool strictMode_ : 1;
|
2020-02-28 17:17:59 +03:00
|
|
|
#ifdef JS_ENABLE_SMOOSH
|
2020-03-16 17:35:35 +03:00
|
|
|
bool trackNotImplemented_ : 1;
|
2020-02-28 17:17:59 +03:00
|
|
|
bool trySmoosh_ : 1;
|
|
|
|
#endif
|
2019-01-24 03:56:56 +03:00
|
|
|
bool fuzzing_ : 1;
|
2021-12-01 21:26:08 +03:00
|
|
|
bool importAssertions_ : 1;
|
2019-01-24 03:56:56 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
JS_PUBLIC_API ContextOptions& ContextOptionsRef(JSContext* cx);
|
|
|
|
|
|
|
|
} // namespace JS
|
|
|
|
|
|
|
|
#endif // js_ContextOptions_h
|