From fe66435bfb1638cabea3f2d83a053ad97e025a5c Mon Sep 17 00:00:00 2001 From: roytam1 Date: Mon, 1 May 2023 15:13:40 +0800 Subject: [PATCH] js/frontend: Parser: sync with UXP --- js/src/frontend/Parser.cpp | 40 ++++++++++++++------------------------ js/src/frontend/Parser.h | 2 -- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index 239c08130..5d1524b32 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -1,5 +1,4 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: * 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/. */ @@ -3372,8 +3371,8 @@ Parser::templateLiteral(YieldHandling yieldHandling) template typename ParseHandler::FunctionNodeType Parser::functionDefinition(uint32_t toStringStart, FunctionNodeType funNode, InHandling inHandling, - YieldHandling yieldHandling, HandleAtom funName, - FunctionSyntaxKind kind, + YieldHandling yieldHandling, + HandleAtom funName, FunctionSyntaxKind kind, GeneratorKind generatorKind, FunctionAsyncKind asyncKind, bool tryAnnexB /* = false */) { @@ -3752,7 +3751,6 @@ Parser::functionFormalParametersAndBody(InHandling inHandling, if (kind != FunctionSyntaxKind::Arrow) { #if JS_HAS_EXPR_CLOSURES - addTelemetry(JSCompartment::DeprecatedExpressionClosure); if (!warnOnceAboutExprClosure()) return false; #else @@ -3863,8 +3861,8 @@ Parser::functionStmt(uint32_t toStringStart, YieldHandling yieldHa MOZ_ASSERT(!pc->sc()->strict(), "labeled functions shouldn't be parsed in strict mode"); - // Find the innermost non-label statement. Report an error if it's - // unbraced: functions can't appear in it. Otherwise the statement + // Find the innermost non-label statement. Report an error if it's + // unbraced: functions can't appear in it. Otherwise the statement // (or its absence) determines the scope the function's bound in. while (declaredInStmt && declaredInStmt->kind() == StatementKind::Label) declaredInStmt = declaredInStmt->enclosing(); @@ -6064,7 +6062,7 @@ Parser::consequentOrAlternative(YieldHandling yieldHandling) // Peek only on the same line: ExpressionStatement's lookahead // restriction is phrased as // - // [lookahead ??{ {, function, async [no LineTerminator here] function, class, let [ }] + // [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] // // meaning that code like this is valid: // @@ -6358,7 +6356,7 @@ Parser::forHeadStart(YieldHandling yieldHandling, MOZ_ASSERT(isForIn != isForOf); // In a for-of loop, 'let' that starts the loop head is a |let| keyword, - // per the [lookahead ??let] restriction on the LeftHandSideExpression + // per the [lookahead ≠ let] restriction on the LeftHandSideExpression // variant of such loops. Expressions that start with |let| can't be used // here. // @@ -6426,7 +6424,6 @@ Parser::forStatement(YieldHandling yieldHandling) if (matched) { iflags = JSITER_FOREACH; isForEach = true; - addTelemetry(JSCompartment::DeprecatedForEach); if (!warnOnceAboutForEach()) return null(); } @@ -6949,12 +6946,11 @@ Parser::yieldExpression(InHandling inHandling) ) { /* As in Python (see PEP-255), disallow return v; in generators. */ - errorAt(begin, JSMSG_BAD_FUNCTION_YIELD); + errorAt(begin, JSMSG_BAD_GENERATOR_RETURN); return null(); } pc->functionBox()->setGeneratorKind(LegacyGenerator); - addTelemetry(JSCompartment::DeprecatedLegacyGenerator); MOZ_FALLTHROUGH; @@ -8433,7 +8429,7 @@ Parser::statement(YieldHandling yieldHandling) } // NOTE: It's unfortunately allowed to have a label named 'let' in - // non-strict code. ?’¯ + // non-strict code. 💯 if (next == TOK_COLON) return labeledStatement(yieldHandling); @@ -11250,7 +11246,7 @@ Parser::methodDefinition(uint32_t toStringStart, PropertyType prop break; default: - MOZ_CRASH("unexpected property type"); + MOZ_CRASH("Parser: methodDefinition: unexpected property type"); } GeneratorKind generatorKind = (propType == PropertyType::GeneratorMethod || @@ -11557,19 +11553,12 @@ Parser::exprInParens(InHandling inHandling, YieldHandling yieldHan return expr(inHandling, yieldHandling, tripledotHandling, possibleError, PredictInvoked); } -void -ParserBase::addTelemetry(JSCompartment::DeprecatedLanguageExtension e) -{ - JSContext* cx = context->maybeJSContext(); - if (!cx) - return; - cx->compartment()->addTelemetry(getFilename(), e); -} - bool ParserBase::warnOnceAboutExprClosure() { -#ifndef RELEASE_OR_BETA + // We extensively use expression closures. + // Disabling spew; see Issue #3061 +#if 0 JSContext* cx = context->maybeJSContext(); if (!cx) return true; @@ -11591,8 +11580,9 @@ ParserBase::warnOnceAboutForEach() return true; if (!cx->compartment()->warnedAboutForEach) { - if (!warning(JSMSG_DEPRECATED_FOR_EACH)) - return false; + // Disabled warning spew. + // if (!warning(JSMSG_DEPRECATED_FOR_EACH)) + // return false; cx->compartment()->warnedAboutForEach = true; } return true; diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index 964941df9..bdfab5170 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -915,8 +915,6 @@ class ParserBase : public StrictModeGetter bool isValidStrictBinding(PropertyName* name); - void addTelemetry(JSCompartment::DeprecatedLanguageExtension e); - bool warnOnceAboutExprClosure(); bool warnOnceAboutForEach();