Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Revert of add UseCounters for NonOctalDecimalIntegerLiteral in strict…
Browse files Browse the repository at this point in the history
… mode (patchset #6 id:100001 of https://codereview.chromium.org/1948403002/ )

Reason for revert:
[Sheriff] Breaks
https://build.chromium.org/p/client.v8.ports/builders/V8%20Arm%20-%20debug%20builder/builds/602

Original issue's description:
> In parallel to the strict octal check that would reject `012` in strict mode, this patch collects UseCounters for `089` in strict mode. The spec says this should be an error, but this patch does not report it as such.
>
> BUG=v8:4973
> LOG=y
>
> Committed: https://crrev.com/d0b6686c14339bd5d0aeaf610705c7ed85393e1f
> Cr-Commit-Position: refs/heads/master@{#36221}

TBR=littledan@chromium.org,caitpotter88@gmail.com,jwolfe@igalia.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:4973

Review-Url: https://codereview.chromium.org/1970333004
Cr-Commit-Position: refs/heads/master@{#36224}
  • Loading branch information
mi-ac authored and Commit bot committed May 13, 2016
1 parent 6924245 commit a05ecb0
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 54 deletions.
5 changes: 2 additions & 3 deletions include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
};

Expand Down
12 changes: 0 additions & 12 deletions src/parsing/parser-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions src/parsing/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions src/parsing/preparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions src/parsing/preparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -1031,8 +1031,6 @@ class PreParser : public ParserBase<PreParserTraits> {
} 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();
Expand Down
26 changes: 5 additions & 21 deletions src/parsing/scanner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down Expand Up @@ -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('.');
Expand All @@ -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
Expand Down Expand Up @@ -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_) {
Expand All @@ -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_)) {
Expand All @@ -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();
Expand All @@ -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_ == '-')
Expand All @@ -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;
}

Expand Down
11 changes: 2 additions & 9 deletions src/parsing/scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_; }
Expand Down Expand Up @@ -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_;
Expand Down

0 comments on commit a05ecb0

Please sign in to comment.