Bug 1083458 - Remove basic expression closure code. r=jandem
authorTom Schuster <evilpies@gmail.com>
Mon, 12 Mar 2018 20:14:54 +0100
changeset 409472 dce3a6c9866b5f0dadd707db49c634b758e4cc7a
parent 409471 0d43e100b20028a416b5c29e32627da6d074db26
child 409473 0cac0a8b22db8e4c3e9d6486058dffe17000c0bb
push id101206
push userevilpies@gmail.com
push dateThu, 22 Mar 2018 14:23:25 +0000
treeherdermozilla-inbound@0cac0a8b22db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1083458
milestone61.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 1083458 - Remove basic expression closure code. r=jandem
js/src/builtin/TestingFunctions.cpp
js/src/frontend/Parser.cpp
js/src/frontend/Parser.h
js/src/jsapi.cpp
js/src/jsapi.h
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -4985,34 +4985,16 @@ SetTimeResolution(JSContext* cx, unsigne
    bool jitter = args[1].toBoolean();
 
    JS::SetTimeResolutionUsec(resolution, jitter);
 
    args.rval().setUndefined();
    return true;
 }
 
-static bool
-EnableExpressionClosures(JSContext* cx, unsigned argc, Value* vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-    JS::ContextOptionsRef(cx).setExpressionClosures(true);
-    args.rval().setUndefined();
-    return true;
-}
-
-static bool
-DisableExpressionClosures(JSContext* cx, unsigned argc, Value* vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-    JS::ContextOptionsRef(cx).setExpressionClosures(false);
-    args.rval().setUndefined();
-    return true;
-}
-
 JSScript*
 js::TestingFunctionArgumentToScript(JSContext* cx,
                                     HandleValue v,
                                     JSFunction** funp /* = nullptr */)
 {
     if (v.isString()) {
         // To convert a string to a script, compile it. Parse it as an ES6 Program.
         RootedLinearString linearStr(cx, StringToLinearString(cx, v.toString()));
@@ -5776,24 +5758,16 @@ gc::ZealModeHelpText),
 "getTimeZone()",
 "  Get the current time zone.\n"),
 
     JS_FN_HELP("setTimeResolution", SetTimeResolution, 2, 0,
 "setTimeResolution(resolution, jitter)",
 "  Enables time clamping and jittering. Specify a time resolution in\n"
 "  microseconds and whether or not to jitter\n"),
 
-    JS_FN_HELP("enableExpressionClosures", EnableExpressionClosures, 0, 0,
-"enableExpressionClosures()",
-"  Enables the deprecated, non-standard expression closures.\n"),
-
-    JS_FN_HELP("disableExpressionClosures", DisableExpressionClosures, 0, 0,
-"disableExpressionClosures()",
-"  Disables the deprecated, non-standard expression closures.\n"),
-
     JS_FN_HELP("baselineCompile", BaselineCompile, 2, 0,
 "baselineCompile([fun/code], forceDebugInstrumentation=false)",
 "  Baseline-compiles the given JS function or script.\n"
 "  Without arguments, baseline-compiles the caller's script; but note\n"
 "  that extra boilerplate is needed afterwards to cause the VM to start\n"
 "  running the jitcode rather than staying in the interpreter:\n"
 "    baselineCompile();  for (var i=0; i<1; i++) {} ...\n"
 "  The interpreter will enter the new jitcode at the loop header.\n"),
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -3257,26 +3257,16 @@ Parser<FullParseHandler, CharT>::skipLaz
     if (lazy->isExprBody())
         funbox->setIsExprBody();
 
     PropagateTransitiveParseFlags(lazy, pc->sc());
 
     if (!tokenStream.advance(fun->lazyScript()->end()))
         return false;
 
-    if (allowExpressionClosures()) {
-        // Only expression closure can be Statement kind.
-        // If we remove expression closure, we can remove isExprBody flag from
-        // LazyScript and JSScript.
-        if (kind == Statement && funbox->isExprBody()) {
-            if (!matchOrInsertSemicolon())
-                return false;
-        }
-    }
-
     // Append possible Annex B function box only upon successfully parsing.
     if (tryAnnexB && !pc->innermostScope()->addPossibleAnnexBFunctionBox(pc, funbox))
         return false;
 
     return true;
 }
 
 template <typename CharT>
@@ -3780,33 +3770,18 @@ GeneralParser<ParseHandler, CharT>::func
     // Parse the function body.
     FunctionBodyType bodyType = StatementListBody;
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return false;
     uint32_t openedPos = 0;
     if (tt != TokenKind::Lc) {
         if (kind != Arrow) {
-            if (funbox->isGenerator() || funbox->isAsync() || kind == Method ||
-                kind == GetterNoExpressionClosure || kind == SetterNoExpressionClosure ||
-                IsConstructorKind(kind) || kind == PrimaryExpression)
-            {
-                error(JSMSG_CURLY_BEFORE_BODY);
-                return false;
-            }
-
-            if (allowExpressionClosures()) {
-                this->addTelemetry(DeprecatedLanguageExtension::ExpressionClosure);
-                if (!warnOnceAboutExprClosure())
-                    return false;
-                handler.noteExpressionClosure(pn);
-            } else {
-                error(JSMSG_CURLY_BEFORE_BODY);
-                return false;
-            }
+            error(JSMSG_CURLY_BEFORE_BODY);
+            return false;
         }
 
         anyChars.ungetToken();
         bodyType = ExpressionBody;
         funbox->setIsExprBody();
     } else {
         openedPos = pos().begin;
     }
@@ -3858,17 +3833,17 @@ GeneralParser<ParseHandler, CharT>::func
     }
 
     if (bodyType == StatementListBody) {
         MUST_MATCH_TOKEN_MOD_WITH_REPORT(TokenKind::Rc, TokenStream::Operand,
                                          reportMissingClosing(JSMSG_CURLY_AFTER_BODY,
                                                               JSMSG_CURLY_OPENED, openedPos));
         funbox->setEnd(anyChars);
     } else {
-        MOZ_ASSERT_IF(!allowExpressionClosures(), kind == Arrow);
+        MOZ_ASSERT(kind == Arrow);
 
         if (anyChars.hadError())
             return false;
         funbox->setEnd(anyChars);
         if (kind == Statement && !matchOrInsertSemicolon())
             return false;
     }
 
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -335,19 +335,16 @@ class ParserBase
     void errorNoOffset(unsigned errorNumber, ...);
 
     bool isValidStrictBinding(PropertyName* name);
 
     void addTelemetry(DeprecatedLanguageExtension e);
 
     bool hasValidSimpleStrictParameterNames();
 
-    bool allowExpressionClosures() const {
-        return options().expressionClosuresOption;
-    }
     /*
      * Create a new function object given a name (which is optional if this is
      * a function expression).
      */
     JSFunction* newFunction(HandleAtom atom, FunctionSyntaxKind kind,
                             GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
                             HandleObject proto);
 
@@ -700,17 +697,16 @@ class GeneralParser
 
   public:
     using Base::anyChars;
     using Base::context;
     using Base::handler;
     using Base::isValidSimpleAssignmentTarget;
     using Base::pc;
     using Base::usedNames;
-    using Base::allowExpressionClosures;
 
   private:
     using Base::checkAndMarkSuperScope;
     using Base::declareDotGeneratorName;
     using Base::declareFunctionArgumentsObject;
     using Base::declareFunctionThis;
     using Base::finishFunction;
     using Base::hasUsedName;
@@ -1403,17 +1399,16 @@ class Parser<FullParseHandler, CharT> fi
     using Base::hadAbortedSyntaxParse;
     using Base::handler;
     using Base::newFunctionBox;
     using Base::options;
     using Base::pc;
     using Base::pos;
     using Base::ss;
     using Base::tokenStream;
-    using Base::allowExpressionClosures;
 
   private:
     using Base::alloc;
     using Base::checkLabelOrIdentifierReference;
 #if DEBUG
     using Base::checkOptionsCalled;
 #endif
     using Base::context;
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3960,17 +3960,16 @@ void
 JS::TransitiveCompileOptions::copyPODTransitiveOptions(const TransitiveCompileOptions& rhs)
 {
     mutedErrors_ = rhs.mutedErrors_;
     utf8 = rhs.utf8;
     selfHostingMode = rhs.selfHostingMode;
     canLazilyParse = rhs.canLazilyParse;
     strictOption = rhs.strictOption;
     extraWarningsOption = rhs.extraWarningsOption;
-    expressionClosuresOption = rhs.expressionClosuresOption;
     werrorOption = rhs.werrorOption;
     asmJSOption = rhs.asmJSOption;
     throwOnAsmJSValidationFailureOption = rhs.throwOnAsmJSValidationFailureOption;
     forceAsync = rhs.forceAsync;
     sourceIsLazy = rhs.sourceIsLazy;
     introductionType = rhs.introductionType;
     introductionLineno = rhs.introductionLineno;
     introductionOffset = rhs.introductionOffset;
@@ -4083,17 +4082,16 @@ JS::OwningCompileOptions::setIntroducerF
 }
 
 JS::CompileOptions::CompileOptions(JSContext* cx)
     : ReadOnlyCompileOptions(), elementRoot(cx), elementAttributeNameRoot(cx),
       introductionScriptRoot(cx)
 {
     strictOption = cx->options().strictMode();
     extraWarningsOption = cx->compartment()->behaviors().extraWarnings(cx);
-    expressionClosuresOption = cx->options().expressionClosures();
     isProbablySystemCode = cx->compartment()->isProbablySystemCode();
     werrorOption = cx->options().werror();
     if (!cx->options().asmJS())
         asmJSOption = AsmJSOption::Disabled;
     else if (cx->compartment()->debuggerObservesAsmJS())
         asmJSOption = AsmJSOption::DisabledByDebugger;
     else
         asmJSOption = AsmJSOption::Enabled;
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -985,17 +985,16 @@ class JS_PUBLIC_API(ContextOptions) {
         dumpStackOnDebuggeeWouldRun_(false),
         werror_(false),
         strictMode_(false),
         extraWarnings_(false),
         streams_(false)
 #ifdef FUZZING
         , fuzzing_(false)
 #endif
-        , expressionClosures_(false)
         , arrayProtoValues_(true)
     {
     }
 
     bool baseline() const { return baseline_; }
     ContextOptions& setBaseline(bool flag) {
         baseline_ = flag;
         return *this;
@@ -1142,22 +1141,16 @@ class JS_PUBLIC_API(ContextOptions) {
 #ifdef FUZZING
     bool fuzzing() const { return fuzzing_; }
     ContextOptions& setFuzzing(bool flag) {
         fuzzing_ = flag;
         return *this;
     }
 #endif
 
-    bool expressionClosures() const { return expressionClosures_; }
-    ContextOptions& setExpressionClosures(bool flag) {
-        expressionClosures_ = flag;
-        return *this;
-    }
-
     bool arrayProtoValues() const { return arrayProtoValues_; }
     ContextOptions& setArrayProtoValues(bool flag) {
         arrayProtoValues_ = flag;
         return *this;
     }
 
     void disableOptionsForSafeMode() {
         setBaseline(false);
@@ -1184,17 +1177,16 @@ class JS_PUBLIC_API(ContextOptions) {
     bool dumpStackOnDebuggeeWouldRun_ : 1;
     bool werror_ : 1;
     bool strictMode_ : 1;
     bool extraWarnings_ : 1;
     bool streams_: 1;
 #ifdef FUZZING
     bool fuzzing_ : 1;
 #endif
-    bool expressionClosures_ : 1;
     bool arrayProtoValues_ : 1;
 
 };
 
 JS_PUBLIC_API(ContextOptions&)
 ContextOptionsRef(JSContext* cx);
 
 /**
@@ -3586,17 +3578,16 @@ class JS_FRIEND_API(TransitiveCompileOpt
         filename_(nullptr),
         introducerFilename_(nullptr),
         sourceMapURL_(nullptr),
         utf8(false),
         selfHostingMode(false),
         canLazilyParse(true),
         strictOption(false),
         extraWarningsOption(false),
-        expressionClosuresOption(false),
         werrorOption(false),
         asmJSOption(AsmJSOption::Disabled),
         throwOnAsmJSValidationFailureOption(false),
         forceAsync(false),
         sourceIsLazy(false),
         allowHTMLComments(true),
         isProbablySystemCode(false),
         hideScriptFromDebugger(false),
@@ -3622,17 +3613,16 @@ class JS_FRIEND_API(TransitiveCompileOpt
     virtual JSScript* introductionScript() const = 0;
 
     // POD options.
     bool utf8;
     bool selfHostingMode;
     bool canLazilyParse;
     bool strictOption;
     bool extraWarningsOption;
-    bool expressionClosuresOption;
     bool werrorOption;
     AsmJSOption asmJSOption;
     bool throwOnAsmJSValidationFailureOption;
     bool forceAsync;
     bool sourceIsLazy;
     bool allowHTMLComments;
     bool isProbablySystemCode;
     bool hideScriptFromDebugger;