diff --git a/include/v8.h b/include/v8.h index f6cac313087..52b6192b876 100644 --- a/include/v8.h +++ b/include/v8.h @@ -5625,10 +5625,9 @@ class V8_EXPORT Isolate { kLegacyFunctionDeclaration = 29, kRegExpPrototypeSourceGetter = 30, kRegExpPrototypeOldFlagGetter = 31, - kDecimalWithLeadingZeroInStrictMode = 32, - // If you add new values here, you'll also need to update Chromium's: - // UseCounter.h, V8PerIsolateData.cpp, histograms.xml + // If you add new values here, you'll also need to update V8Initializer.cpp + // in Chromium. kUseCounterFeatureCount // This enum value must be last. }; diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h index 9c64c5350d8..1036ac94296 100644 --- a/src/parsing/parser-base.h +++ b/src/parsing/parser-base.h @@ -633,18 +633,6 @@ class ParserBase : public Traits { *ok = false; } } - // for now, this check just collects statistics. - void CheckDecimalLiteralWithLeadingZero(int* use_counts, int beg_pos, - int end_pos) { - Scanner::Location token_location = - scanner()->decimal_with_leading_zero_position(); - if (token_location.IsValid() && beg_pos <= token_location.beg_pos && - token_location.end_pos <= end_pos) { - scanner()->clear_decimal_with_leading_zero_position(); - if (use_counts != nullptr) - ++use_counts[v8::Isolate::kDecimalWithLeadingZeroInStrictMode]; - } - } inline void CheckStrictOctalLiteral(int beg_pos, int end_pos, bool* ok) { CheckOctalLiteral(beg_pos, end_pos, MessageTemplate::kStrictOctalLiteral, diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc index 3d17c5b3880..29d47b478f5 100644 --- a/src/parsing/parser.cc +++ b/src/parsing/parser.cc @@ -943,8 +943,6 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { if (ok && is_strict(language_mode())) { CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); - CheckDecimalLiteralWithLeadingZero(use_counts_, beg_pos, - scanner()->location().end_pos); } if (ok && is_sloppy(language_mode())) { // TODO(littledan): Function bindings on the global object that modify @@ -4177,8 +4175,6 @@ FunctionLiteral* Parser::ParseFunctionLiteral( if (is_strict(language_mode)) { CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), CHECK_OK); - CheckDecimalLiteralWithLeadingZero(use_counts_, scope->start_position(), - scope->end_position()); } if (is_sloppy(language_mode)) { InsertSloppyBlockFunctionVarBindings(scope, CHECK_OK); diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc index e6aa54ed166..5bf5eb42320 100644 --- a/src/parsing/preparser.cc +++ b/src/parsing/preparser.cc @@ -134,7 +134,6 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction( if (is_strict(scope_->language_mode())) { int end_pos = scanner()->location().end_pos; CheckStrictOctalLiteral(start_position, end_pos, &ok); - CheckDecimalLiteralWithLeadingZero(use_counts, start_position, end_pos); if (!ok) return kPreParseSuccess; } } @@ -1107,8 +1106,6 @@ PreParser::Expression PreParser::ParseFunctionLiteral( if (is_strict(language_mode)) { int end_position = scanner()->location().end_pos; CheckStrictOctalLiteral(start_position, end_position, CHECK_OK); - CheckDecimalLiteralWithLeadingZero(use_counts_, start_position, - end_position); } return Expression::Default(); diff --git a/src/parsing/preparser.h b/src/parsing/preparser.h index fbfe6eb0e5b..92b02071add 100644 --- a/src/parsing/preparser.h +++ b/src/parsing/preparser.h @@ -1031,8 +1031,6 @@ class PreParser : public ParserBase { } else if (is_strict(scope_->language_mode())) { CheckStrictOctalLiteral(start_position, scanner()->location().end_pos, &ok); - CheckDecimalLiteralWithLeadingZero(use_counts_, start_position, - scanner()->location().end_pos); } if (materialized_literals) { *materialized_literals = function_state_->materialized_literal_count(); diff --git a/src/parsing/scanner.cc b/src/parsing/scanner.cc index 718dbab73c8..faec88b8a4b 100644 --- a/src/parsing/scanner.cc +++ b/src/parsing/scanner.cc @@ -40,7 +40,6 @@ Scanner::Scanner(UnicodeCache* unicode_cache) : unicode_cache_(unicode_cache), bookmark_c0_(kNoBookmark), octal_pos_(Location::invalid()), - decimal_with_leading_zero_pos_(Location::invalid()), found_html_comment_(false), allow_harmony_exponentiation_operator_(false) { bookmark_current_.literal_chars = &bookmark_current_literal_; @@ -976,18 +975,10 @@ void Scanner::ScanDecimalDigits() { Token::Value Scanner::ScanNumber(bool seen_period) { DCHECK(IsDecimalDigit(c0_)); // the first digit of the number or the fraction - enum { - DECIMAL, - DECIMAL_WITH_LEADING_ZERO, - HEX, - OCTAL, - IMPLICIT_OCTAL, - BINARY - } kind = DECIMAL; + enum { DECIMAL, HEX, OCTAL, IMPLICIT_OCTAL, BINARY } kind = DECIMAL; LiteralScope literal(this); bool at_start = !seen_period; - int start_pos; // For reporting octal positions. if (seen_period) { // we have already seen a decimal point of the float AddLiteralChar('.'); @@ -996,7 +987,7 @@ Token::Value Scanner::ScanNumber(bool seen_period) { } else { // if the first character is '0' we must check for octals and hex if (c0_ == '0') { - start_pos = source_pos(); + int start_pos = source_pos(); // For reporting octal positions. AddLiteralCharAdvance(); // either 0, 0exxx, 0Exxx, 0.xxx, a hex number, a binary number or @@ -1038,7 +1029,7 @@ Token::Value Scanner::ScanNumber(bool seen_period) { while (true) { if (c0_ == '8' || c0_ == '9') { at_start = false; - kind = DECIMAL_WITH_LEADING_ZERO; + kind = DECIMAL; break; } if (c0_ < '0' || '7' < c0_) { @@ -1048,13 +1039,11 @@ Token::Value Scanner::ScanNumber(bool seen_period) { } AddLiteralCharAdvance(); } - } else if (c0_ == '8' || c0_ == '9') { - kind = DECIMAL_WITH_LEADING_ZERO; } } // Parse decimal digits and allow trailing fractional part. - if (kind == DECIMAL || kind == DECIMAL_WITH_LEADING_ZERO) { + if (kind == DECIMAL) { if (at_start) { uint64_t value = 0; while (IsDecimalDigit(c0_)) { @@ -1071,8 +1060,6 @@ Token::Value Scanner::ScanNumber(bool seen_period) { literal.Complete(); HandleLeadSurrogate(); - if (kind == DECIMAL_WITH_LEADING_ZERO) - decimal_with_leading_zero_pos_ = Location(start_pos, source_pos()); return Token::SMI; } HandleLeadSurrogate(); @@ -1089,8 +1076,7 @@ Token::Value Scanner::ScanNumber(bool seen_period) { // scan exponent, if any if (c0_ == 'e' || c0_ == 'E') { DCHECK(kind != HEX); // 'e'/'E' must be scanned as part of the hex number - if (!(kind == DECIMAL || kind == DECIMAL_WITH_LEADING_ZERO)) - return Token::ILLEGAL; + if (kind != DECIMAL) return Token::ILLEGAL; // scan exponent AddLiteralCharAdvance(); if (c0_ == '+' || c0_ == '-') @@ -1112,8 +1098,6 @@ Token::Value Scanner::ScanNumber(bool seen_period) { literal.Complete(); - if (kind == DECIMAL_WITH_LEADING_ZERO) - decimal_with_leading_zero_pos_ = Location(start_pos, source_pos()); return Token::NUMBER; } diff --git a/src/parsing/scanner.h b/src/parsing/scanner.h index 5ef2a94e834..b4c6b62d148 100644 --- a/src/parsing/scanner.h +++ b/src/parsing/scanner.h @@ -425,13 +425,6 @@ class Scanner { // Returns the location of the last seen octal literal. Location octal_position() const { return octal_pos_; } void clear_octal_position() { octal_pos_ = Location::invalid(); } - // Returns the location of the last seen decimal literal with a leading zero. - Location decimal_with_leading_zero_position() const { - return decimal_with_leading_zero_pos_; - } - void clear_decimal_with_leading_zero_position() { - decimal_with_leading_zero_pos_ = Location::invalid(); - } // Returns the value of the last smi that was scanned. int smi_value() const { return current_.smi_value_; } @@ -779,9 +772,9 @@ class Scanner { // Input stream. Must be initialized to an Utf16CharacterStream. Utf16CharacterStream* source_; - // Last-seen positions of potentially problematic tokens. + + // Start position of the octal literal last scanned. Location octal_pos_; - Location decimal_with_leading_zero_pos_; // One Unicode character look-ahead; c0_ < 0 at the end of the input. uc32 c0_;