Bug 1507520 - Make BigInt parsing dependent on run-time feature flag r=jandem,terpri
☠☠ backed out by 0e0f77578ad5 ☠ ☠
authorAndy Wingo <wingo@igalia.com>
Wed, 23 Jan 2019 16:55:32 +0000
changeset 515139 647e4cfc0eb44fb8abe57a2a4fa36c91edf3030a
parent 515138 0e5aa503740c61f3d8ac2660428f01760bae199c
child 515140 6aefbed9ce430f1da6b59a4ff98fb69375fa4f8f
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem, terpri
bugs1507520
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1507520 - Make BigInt parsing dependent on run-time feature flag r=jandem,terpri Differential Revision: https://phabricator.services.mozilla.com/D17349
js/public/CompileOptions.h
js/src/frontend/TokenStream.cpp
js/src/jsapi.cpp
--- a/js/public/CompileOptions.h
+++ b/js/public/CompileOptions.h
@@ -111,16 +111,17 @@ class JS_PUBLIC_API TransitiveCompileOpt
   bool werrorOption = false;
   AsmJSOption asmJSOption = AsmJSOption::Disabled;
   bool throwOnAsmJSValidationFailureOption = false;
   bool forceAsync = false;
   bool sourceIsLazy = false;
   bool allowHTMLComments = true;
   bool isProbablySystemCode = false;
   bool hideScriptFromDebugger = false;
+  bool bigIntEnabledOption = false;
 
   /**
    * |introductionType| is a statically allocated C string: one of "eval",
    * "Function", or "GeneratorFunction".
    */
   const char* introductionType = nullptr;
 
   unsigned introductionLineno = 0;
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -2154,17 +2154,17 @@ MOZ_MUST_USE bool TokenStreamSpecific<Un
     // Most numbers are pure decimal integers without fractional component
     // or exponential notation.  Handle that with optimized code.
     if (!GetDecimalInteger(anyCharsAccess().cx, numStart,
                            this->sourceUnits.addressOfNextCodeUnit(), &dval)) {
       return false;
     }
   }
 #ifdef ENABLE_BIGINT
-  else if (unit == 'n') {
+  else if (unit == 'n' && anyCharsAccess().options().bigIntEnabledOption) {
     isBigInt = true;
     unit = peekCodeUnit();
   }
 #endif
   else {
     // Consume any decimal dot and fractional component.
     if (unit == '.') {
       decimalPoint = HasDecimal;
@@ -2360,16 +2360,17 @@ MOZ_MUST_USE bool TokenStreamSpecific<Un
   newRegExpToken(reflags, start, out);
   return true;
 }
 
 #ifdef ENABLE_BIGINT
 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();
   MOZ_ASSERT(length >= 2);
   this->charBuffer.clear();
   mozilla::Range<const Unit> chars(
       this->sourceUnits.codeUnitPtrAt(start.offset()), length);
   for (uint32_t idx = 0; idx < length - 1; idx++) {
@@ -2640,17 +2641,17 @@ MOZ_MUST_USE bool TokenStreamSpecific<Un
         numStart = this->sourceUnits.addressOfNextCodeUnit() - 1;
 
         // NOTE: |unit| may be EOF here.  (This is permitted by case #3
         //       in TokenStream.h docs for this function.)
         return decimalNumber(unit, start, numStart, modifier, ttp);
       }
 
 #ifdef ENABLE_BIGINT
-      if (unit == 'n') {
+      if (unit == 'n' && anyCharsAccess().options().bigIntEnabledOption) {
         if (isLegacyOctalOrNoctal) {
           error(JSMSG_BIGINT_INVALID_SYNTAX);
           return badToken();
         }
         isBigInt = true;
         unit = peekCodeUnit();
       } else {
         ungetCodeUnit(unit);
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3417,16 +3417,17 @@ void JS::TransitiveCompileOptions::copyP
   forceAsync = rhs.forceAsync;
   sourceIsLazy = rhs.sourceIsLazy;
   introductionType = rhs.introductionType;
   introductionLineno = rhs.introductionLineno;
   introductionOffset = rhs.introductionOffset;
   hasIntroductionInfo = rhs.hasIntroductionInfo;
   isProbablySystemCode = rhs.isProbablySystemCode;
   hideScriptFromDebugger = rhs.hideScriptFromDebugger;
+  bigIntEnabledOption = rhs.bigIntEnabledOption;
 };
 
 void JS::ReadOnlyCompileOptions::copyPODOptions(
     const ReadOnlyCompileOptions& rhs) {
   copyPODTransitiveOptions(rhs);
   lineno = rhs.lineno;
   column = rhs.column;
   scriptSourceOffset = rhs.scriptSourceOffset;
@@ -3543,16 +3544,17 @@ JS::CompileOptions::CompileOptions(JSCon
     asmJSOption = AsmJSOption::Disabled;
   } else if (cx->realm()->debuggerObservesAsmJS()) {
     asmJSOption = AsmJSOption::DisabledByDebugger;
   } else {
     asmJSOption = AsmJSOption::Enabled;
   }
   throwOnAsmJSValidationFailureOption =
       cx->options().throwOnAsmJSValidationFailure();
+  bigIntEnabledOption = cx->realm()->creationOptions().getBigIntEnabled();
 }
 
 CompileOptions& CompileOptions::setIntroductionInfoToCaller(
     JSContext* cx, const char* introductionType) {
   RootedScript maybeScript(cx);
   const char* filename;
   unsigned lineno;
   uint32_t pcOffset;