Commit 4a2f3ee8 authored by jochen's avatar jochen Committed by Commit bot

Add use counters for how often we encounter html comments in scripts

R=yangguo@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1641673002

Cr-Commit-Position: refs/heads/master@{#33561}
parent aa354d3f
......@@ -5457,6 +5457,8 @@ class V8_EXPORT Isolate {
kPromiseChain = 17,
kPromiseAccept = 18,
kPromiseDefer = 19,
kHtmlCommentInExternalScript = 20,
kHtmlComment = 21,
kUseCounterFeatureCount // This enum value must be last.
};
......
......@@ -5148,6 +5148,12 @@ void Parser::Internalize(Isolate* isolate, Handle<Script> script, bool error) {
isolate->CountUsage(v8::Isolate::UseCounterFeature(feature));
}
}
if (scanner_.FoundHtmlComment()) {
isolate->CountUsage(v8::Isolate::kHtmlComment);
if (script->line_offset() == 0 && script->column_offset() == 0) {
isolate->CountUsage(v8::Isolate::kHtmlCommentInExternalScript);
}
}
isolate->counters()->total_preparse_skipped()->Increment(
total_preparse_skipped_);
}
......
......@@ -39,7 +39,8 @@ void Utf16CharacterStream::ResetToBookmark() { UNREACHABLE(); }
Scanner::Scanner(UnicodeCache* unicode_cache)
: unicode_cache_(unicode_cache),
bookmark_c0_(kNoBookmark),
octal_pos_(Location::invalid()) {
octal_pos_(Location::invalid()),
found_html_comment_(false) {
bookmark_current_.literal_chars = &bookmark_current_literal_;
bookmark_current_.raw_literal_chars = &bookmark_current_raw_literal_;
bookmark_next_.literal_chars = &bookmark_next_literal_;
......@@ -438,7 +439,10 @@ Token::Value Scanner::ScanHtmlComment() {
Advance();
if (c0_ == '-') {
Advance();
if (c0_ == '-') return SkipSingleLineComment();
if (c0_ == '-') {
found_html_comment_ = true;
return SkipSingleLineComment();
}
PushBack('-'); // undo Advance()
}
PushBack('!'); // undo Advance()
......
......@@ -448,6 +448,8 @@ class Scanner {
bool IdentifierIsFutureStrictReserved(const AstRawString* string) const;
bool FoundHtmlComment() const { return found_html_comment_; }
private:
// The current and look-ahead token.
struct TokenDesc {
......@@ -473,6 +475,7 @@ class Scanner {
current_.literal_chars = NULL;
current_.raw_literal_chars = NULL;
next_next_.token = Token::UNINITIALIZED;
found_html_comment_ = false;
}
// Support BookmarkScope functionality.
......@@ -752,6 +755,9 @@ class Scanner {
// Whether there is a multi-line comment that contains a
// line-terminator after the current token, and before the next.
bool has_multiline_comment_before_next_;
// Whether this scanner encountered an HTML comment.
bool found_html_comment_;
};
} // namespace internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment