зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 596ae187c20b (bug 1570886) for xpcshell failures at devtools/server/tests/unit/test_objectgrips-08.js on a CLOSED TREE
This commit is contained in:
Родитель
f63f1e8dd9
Коммит
37c688712e
|
@ -121,6 +121,7 @@ class JS_PUBLIC_API TransitiveCompileOptions {
|
|||
bool sourceIsLazy = false;
|
||||
bool allowHTMLComments = true;
|
||||
bool hideScriptFromDebugger = false;
|
||||
bool bigIntEnabledOption = false;
|
||||
bool fieldsEnabledOption = true;
|
||||
|
||||
/**
|
||||
|
|
|
@ -134,6 +134,12 @@ class JS_PUBLIC_API RealmCreationOptions {
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool getBigIntEnabled() const { return bigint_; }
|
||||
RealmCreationOptions& setBigIntEnabled(bool flag) {
|
||||
bigint_ = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool getFieldsEnabled() const { return fields_; }
|
||||
RealmCreationOptions& setFieldsEnabled(bool flag) {
|
||||
fields_ = flag;
|
||||
|
@ -175,6 +181,7 @@ class JS_PUBLIC_API RealmCreationOptions {
|
|||
bool cloneSingletons_ = false;
|
||||
bool sharedMemoryAndAtomics_ = false;
|
||||
bool streams_ = false;
|
||||
bool bigint_ = false;
|
||||
bool fields_ = false;
|
||||
bool awaitFix_ = false;
|
||||
bool secureContext_ = false;
|
||||
|
|
|
@ -2475,7 +2475,7 @@ MOZ_MUST_USE bool TokenStreamSpecific<Unit, AnyCharsAccess>::decimalNumber(
|
|||
this->sourceUnits.addressOfNextCodeUnit(), &dval)) {
|
||||
return false;
|
||||
}
|
||||
} else if (unit == 'n') {
|
||||
} else if (unit == 'n' && anyCharsAccess().options().bigIntEnabledOption) {
|
||||
isBigInt = true;
|
||||
unit = peekCodeUnit();
|
||||
} else {
|
||||
|
@ -2677,6 +2677,7 @@ MOZ_MUST_USE bool TokenStreamSpecific<Unit, AnyCharsAccess>::regexpLiteral(
|
|||
template <typename Unit, class AnyCharsAccess>
|
||||
MOZ_MUST_USE bool TokenStreamSpecific<Unit, AnyCharsAccess>::bigIntLiteral(
|
||||
TokenStart start, Modifier modifier, TokenKind* out) {
|
||||
MOZ_ASSERT(anyCharsAccess().options().bigIntEnabledOption);
|
||||
MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == toUnit('n'));
|
||||
MOZ_ASSERT(this->sourceUnits.offset() > start.offset());
|
||||
uint32_t length = this->sourceUnits.offset() - start.offset();
|
||||
|
@ -2961,7 +2962,7 @@ MOZ_MUST_USE bool TokenStreamSpecific<Unit, AnyCharsAccess>::getTokenInternal(
|
|||
return badToken();
|
||||
}
|
||||
|
||||
if (unit == 'n') {
|
||||
if (unit == 'n' && anyCharsAccess().options().bigIntEnabledOption) {
|
||||
error(JSMSG_BIGINT_INVALID_SYNTAX);
|
||||
return badToken();
|
||||
}
|
||||
|
@ -2983,7 +2984,7 @@ MOZ_MUST_USE bool TokenStreamSpecific<Unit, AnyCharsAccess>::getTokenInternal(
|
|||
return decimalNumber(unit, start, numStart, modifier, ttp);
|
||||
}
|
||||
|
||||
if (unit == 'n') {
|
||||
if (unit == 'n' && anyCharsAccess().options().bigIntEnabledOption) {
|
||||
isBigInt = true;
|
||||
unit = peekCodeUnit();
|
||||
} else {
|
||||
|
|
|
@ -33,6 +33,7 @@ static JSObject* jsfuzz_createGlobal(JSContext* cx, JSPrincipals* principals) {
|
|||
JS::RealmOptions options;
|
||||
options.creationOptions()
|
||||
.setStreamsEnabled(true)
|
||||
.setBigIntEnabled(true)
|
||||
.setFieldsEnabled(false)
|
||||
.setAwaitFixEnabled(true);
|
||||
return JS_NewGlobalObject(cx, getGlobalClass(), principals,
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// |jit-test| --no-bigint
|
||||
|
||||
load(libdir + "asserts.js");
|
||||
|
||||
assertEq(DataView.prototype.hasOwnProperty('getInt32'), true)
|
||||
assertEq(DataView.prototype.hasOwnProperty('getBigInt64'), false);
|
||||
assertEq(DataView.prototype.hasOwnProperty('getBigUint64'), false);
|
||||
assertEq(DataView.prototype.hasOwnProperty('setBigInt64'), false);
|
||||
assertEq(DataView.prototype.hasOwnProperty('setBigUint64'), false);
|
||||
|
||||
assertThrowsInstanceOf(() => BigInt, ReferenceError);
|
|
@ -90,6 +90,7 @@ JSObject* JSAPITest::createGlobal(JSPrincipals* principals) {
|
|||
JS::RealmOptions options;
|
||||
options.creationOptions()
|
||||
.setStreamsEnabled(true)
|
||||
.setBigIntEnabled(true)
|
||||
.setFieldsEnabled(true)
|
||||
.setAwaitFixEnabled(true);
|
||||
newGlobal = JS_NewGlobalObject(cx, getGlobalClass(), principals,
|
||||
|
|
|
@ -728,8 +728,7 @@ JS_PUBLIC_API JSObject* JS_TransplantObject(JSContext* cx, HandleObject origobj,
|
|||
JSObject::swap(cx, origobj, newIdentityWrapper);
|
||||
if (origobj->compartment()->lookupWrapper(newIdentity)) {
|
||||
MOZ_ASSERT(origobj->is<CrossCompartmentWrapperObject>());
|
||||
if (!origobj->compartment()->putWrapper(
|
||||
cx, CrossCompartmentKey(newIdentity), origv)) {
|
||||
if (!origobj->compartment()->putWrapper(cx, CrossCompartmentKey(newIdentity), origv)) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
}
|
||||
|
@ -3480,6 +3479,7 @@ void JS::TransitiveCompileOptions::copyPODTransitiveOptions(
|
|||
introductionOffset = rhs.introductionOffset;
|
||||
hasIntroductionInfo = rhs.hasIntroductionInfo;
|
||||
hideScriptFromDebugger = rhs.hideScriptFromDebugger;
|
||||
bigIntEnabledOption = rhs.bigIntEnabledOption;
|
||||
fieldsEnabledOption = rhs.fieldsEnabledOption;
|
||||
};
|
||||
|
||||
|
@ -3576,6 +3576,7 @@ JS::CompileOptions::CompileOptions(JSContext* cx)
|
|||
}
|
||||
throwOnAsmJSValidationFailureOption =
|
||||
cx->options().throwOnAsmJSValidationFailure();
|
||||
bigIntEnabledOption = cx->realm()->creationOptions().getBigIntEnabled();
|
||||
fieldsEnabledOption = cx->realm()->creationOptions().getFieldsEnabled();
|
||||
|
||||
// Certain modes of operation disallow syntax parsing in general.
|
||||
|
|
|
@ -52,6 +52,9 @@
|
|||
--spectre-mitigations=on
|
||||
--more-compartments
|
||||
|
||||
# Experimental JS language features
|
||||
--no-bigint
|
||||
|
||||
# GC-related
|
||||
# These 2 flags can cause the shell to slow down
|
||||
# --gc-zeal=2
|
||||
|
|
|
@ -479,6 +479,7 @@ static bool enableWasmVerbose = false;
|
|||
static bool enableTestWasmAwaitTier2 = false;
|
||||
static bool enableAsyncStacks = false;
|
||||
static bool enableStreams = false;
|
||||
static bool enableBigInt = false;
|
||||
static bool enableFields = false;
|
||||
static bool enableAwaitFix = false;
|
||||
#ifdef JS_GC_ZEAL
|
||||
|
@ -3783,6 +3784,7 @@ static const JSClass sandbox_class = {"sandbox", JSCLASS_GLOBAL_FLAGS,
|
|||
static void SetStandardRealmOptions(JS::RealmOptions& options) {
|
||||
options.creationOptions()
|
||||
.setSharedMemoryAndAtomicsEnabled(enableSharedMemory)
|
||||
.setBigIntEnabled(enableBigInt)
|
||||
.setStreamsEnabled(enableStreams)
|
||||
.setFieldsEnabled(enableFields)
|
||||
.setAwaitFixEnabled(enableAwaitFix);
|
||||
|
@ -6205,6 +6207,13 @@ static bool NewGlobal(JSContext* cx, unsigned argc, Value* vp) {
|
|||
: ShellGlobalKind::GlobalObject;
|
||||
}
|
||||
|
||||
if (!JS_GetProperty(cx, opts, "enableBigInt", &v)) {
|
||||
return false;
|
||||
}
|
||||
if (v.isBoolean()) {
|
||||
creationOptions.setBigIntEnabled(v.toBoolean());
|
||||
}
|
||||
|
||||
if (!JS_GetProperty(cx, opts, "systemPrincipal", &v)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -10205,6 +10214,7 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
|
|||
enableTestWasmAwaitTier2 = op.getBoolOption("test-wasm-await-tier2");
|
||||
enableAsyncStacks = !op.getBoolOption("no-async-stacks");
|
||||
enableStreams = !op.getBoolOption("no-streams");
|
||||
enableBigInt = !op.getBoolOption("no-bigint");
|
||||
enableFields = !op.getBoolOption("disable-experimental-fields");
|
||||
enableAwaitFix = op.getBoolOption("enable-experimental-await-fix");
|
||||
|
||||
|
@ -10956,6 +10966,7 @@ int main(int argc, char** argv, char** envp) {
|
|||
!op.addBoolOption('\0', "enable-streams",
|
||||
"Enable WHATWG Streams (default)") ||
|
||||
!op.addBoolOption('\0', "no-streams", "Disable WHATWG Streams") ||
|
||||
!op.addBoolOption('\0', "no-bigint", "Disable BigInt support") ||
|
||||
!op.addBoolOption('\0', "disable-experimental-fields",
|
||||
"Disable public fields in classes") ||
|
||||
!op.addBoolOption('\0', "enable-experimental-await-fix",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("BigInt"))
|
||||
// Any copyright is dedicated to the Public Domain.
|
||||
// https://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("BigInt"))
|
||||
// Any copyright is dedicated to the Public Domain.
|
||||
// https://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("BigInt"))
|
||||
// Any copyright is dedicated to the Public Domain.
|
||||
// https://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("BigInt"))
|
||||
// Any copyright is dedicated to the Public Domain.
|
||||
// https://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("BigInt"))
|
||||
|
||||
const testArray = [1n];
|
||||
for (const constructor of anyTypedArrayConstructors) {
|
||||
assertThrowsInstanceOf(() => new constructor(testArray), TypeError);
|
||||
|
|
|
@ -17,4 +17,13 @@ testBigInt(1n);
|
|||
testBigInt(0xffffFFFFffffFFFFffffFFFFffffFFFFn);
|
||||
testBigInt(-0xffffFFFFffffFFFFffffFFFFffffFFFFn);
|
||||
|
||||
var g = newGlobal({ enableBigInt: false, sameCompartmentAs: this });
|
||||
var deserializeNoBigInt = g.evaluate("deserialize");
|
||||
|
||||
assertEq(deserializeNoBigInt(serialize(1)), 1);
|
||||
assertThrows(() => deserializeNoBigInt(serialize(1n)))
|
||||
assertThrows(() => deserializeNoBigInt(serialize(0n)))
|
||||
assertThrows(() => deserializeNoBigInt(serialize(0xffffffn)))
|
||||
assertThrows(() => deserializeNoBigInt(serialize(-1n)))
|
||||
|
||||
reportCompare(0, 0, 'ok');
|
||||
|
|
|
@ -104,6 +104,11 @@ bool GlobalObject::skipDeselectedConstructor(JSContext* cx, JSProtoKey key) {
|
|||
case JSProto_CountQueuingStrategy:
|
||||
return !cx->realm()->creationOptions().getStreamsEnabled();
|
||||
|
||||
case JSProto_BigInt64Array:
|
||||
case JSProto_BigUint64Array:
|
||||
case JSProto_BigInt:
|
||||
return !cx->realm()->creationOptions().getBigIntEnabled();
|
||||
|
||||
// Return true if the given constructor has been disabled at run-time.
|
||||
case JSProto_Atomics:
|
||||
case JSProto_SharedArrayBuffer:
|
||||
|
|
|
@ -3058,6 +3058,15 @@ extern bool PropertySpecNameToId(JSContext* cx, JSPropertySpec::Name name,
|
|||
// JSPropertySpec list, but omit the definition if the preference is off.
|
||||
JS_FRIEND_API bool js::ShouldIgnorePropertyDefinition(JSContext* cx,
|
||||
JSProtoKey key, jsid id) {
|
||||
if (key == JSProto_DataView &&
|
||||
!cx->realm()->creationOptions().getBigIntEnabled() &&
|
||||
(id == NameToId(cx->names().getBigInt64) ||
|
||||
id == NameToId(cx->names().getBigUint64) ||
|
||||
id == NameToId(cx->names().setBigInt64) ||
|
||||
id == NameToId(cx->names().setBigUint64))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -2038,6 +2038,12 @@ JSString* JSStructuredCloneReader::readString(uint32_t data) {
|
|||
}
|
||||
|
||||
BigInt* JSStructuredCloneReader::readBigInt(uint32_t data) {
|
||||
if (!context()->realm()->creationOptions().getBigIntEnabled()) {
|
||||
JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr,
|
||||
JSMSG_SC_BIGINT_DISABLED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t length = data & JS_BITMASK(31);
|
||||
bool isNegative = data & (1 << 31);
|
||||
if (length == 0) {
|
||||
|
|
|
@ -764,12 +764,14 @@ bool xpc::ExtraWarningsForSystemJS() { return false; }
|
|||
|
||||
static mozilla::Atomic<bool> sSharedMemoryEnabled(false);
|
||||
static mozilla::Atomic<bool> sStreamsEnabled(false);
|
||||
static mozilla::Atomic<bool> sBigIntEnabled(false);
|
||||
static mozilla::Atomic<bool> sFieldsEnabled(false);
|
||||
static mozilla::Atomic<bool> sAwaitFixEnabled(false);
|
||||
|
||||
void xpc::SetPrefableRealmOptions(JS::RealmOptions& options) {
|
||||
options.creationOptions()
|
||||
.setSharedMemoryAndAtomicsEnabled(sSharedMemoryEnabled)
|
||||
.setBigIntEnabled(sBigIntEnabled)
|
||||
.setStreamsEnabled(sStreamsEnabled)
|
||||
.setFieldsEnabled(sFieldsEnabled)
|
||||
.setAwaitFixEnabled(sAwaitFixEnabled);
|
||||
|
@ -910,6 +912,8 @@ static void ReloadPrefsCallback(const char* pref, XPCJSContext* xpccx) {
|
|||
|
||||
bool useAsyncStack = Preferences::GetBool(JS_OPTIONS_DOT_STR "asyncstack");
|
||||
|
||||
sBigIntEnabled = Preferences::GetBool(JS_OPTIONS_DOT_STR "bigint");
|
||||
|
||||
bool throwOnDebuggeeWouldRun =
|
||||
Preferences::GetBool(JS_OPTIONS_DOT_STR "throw_on_debuggee_would_run");
|
||||
|
||||
|
|
|
@ -3336,6 +3336,12 @@
|
|||
# Prefs starting with "javascript."
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# BigInt API
|
||||
- name: javascript.options.bigint
|
||||
type: RelaxedAtomicBool
|
||||
value: true
|
||||
mirror: always
|
||||
|
||||
- name: javascript.options.compact_on_user_inactive
|
||||
type: bool
|
||||
value: true
|
||||
|
|
Загрузка…
Ссылка в новой задаче