Bug 1507520 - Make BigInt parsing dependent on run-time feature flag r=jandem,terpri

Differential Revision: https://phabricator.services.mozilla.com/D17349

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andy Wingo 2019-01-24 09:06:41 +00:00
parent cc6d429241
commit eff6f7d841
3 changed files with 12 additions and 2 deletions

View File

@ -116,6 +116,9 @@ class JS_PUBLIC_API TransitiveCompileOptions {
bool allowHTMLComments = true;
bool isProbablySystemCode = false;
bool hideScriptFromDebugger = false;
#ifdef ENABLE_BIGINT
bool bigIntEnabledOption = false;
#endif
/**
* |introductionType| is a statically allocated C string: one of "eval",

View File

@ -2159,7 +2159,7 @@ MOZ_MUST_USE bool TokenStreamSpecific<Unit, AnyCharsAccess>::decimalNumber(
}
}
#ifdef ENABLE_BIGINT
else if (unit == 'n') {
else if (unit == 'n' && anyCharsAccess().options().bigIntEnabledOption) {
isBigInt = true;
unit = peekCodeUnit();
}
@ -2365,6 +2365,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();
@ -2645,7 +2646,7 @@ MOZ_MUST_USE bool TokenStreamSpecific<Unit, AnyCharsAccess>::getTokenInternal(
}
#ifdef ENABLE_BIGINT
if (unit == 'n') {
if (unit == 'n' && anyCharsAccess().options().bigIntEnabledOption) {
if (isLegacyOctalOrNoctal) {
error(JSMSG_BIGINT_INVALID_SYNTAX);
return badToken();

View File

@ -3422,6 +3422,9 @@ void JS::TransitiveCompileOptions::copyPODTransitiveOptions(
hasIntroductionInfo = rhs.hasIntroductionInfo;
isProbablySystemCode = rhs.isProbablySystemCode;
hideScriptFromDebugger = rhs.hideScriptFromDebugger;
#ifdef ENABLE_BIGINT
bigIntEnabledOption = rhs.bigIntEnabledOption;
#endif
};
void JS::ReadOnlyCompileOptions::copyPODOptions(
@ -3548,6 +3551,9 @@ JS::CompileOptions::CompileOptions(JSContext* cx)
}
throwOnAsmJSValidationFailureOption =
cx->options().throwOnAsmJSValidationFailure();
#ifdef ENABLE_BIGINT
bigIntEnabledOption = cx->realm()->creationOptions().getBigIntEnabled();
#endif
}
CompileOptions& CompileOptions::setIntroductionInfoToCaller(