From ed1d232d5d0a0b61075416047f117129dfef0dd5 Mon Sep 17 00:00:00 2001 From: "marja@chromium.org" Date: Mon, 14 Apr 2014 08:49:23 +0000 Subject: [PATCH] Parser cleanup: PreParser doesn't need to produce symbol data any more. State of the art: - Chromium doesn't do a separate preparsing phase any more. - We start parsing with Parser, and when it sees a lazy function, it falls back to PreParser for that function. - The symbol data should contain symbols which are *outside* lazy functions. - So Parser should always produce symbol data, and PreParser should never. - Because it's this simple now, we don't need to keep track of "should produce symbol data" (i.e., whether we're inside a lazy func or not). R=ulan@chromium.org BUG= Review URL: https://codereview.chromium.org/222123003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20707 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/parser.cc | 8 +++----- src/preparse-data.cc | 4 ---- src/preparse-data.h | 19 +------------------ src/preparser.cc | 12 ------------ src/preparser.h | 5 ----- 5 files changed, 4 insertions(+), 44 deletions(-) diff --git a/src/parser.cc b/src/parser.cc index 90171ef..18d0ebb 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -738,9 +738,9 @@ Handle ParserTraits::GetSymbol(Scanner* scanner) { return parser_->LookupCachedSymbol(symbol_id); } } else if (parser_->cached_data_mode() == PRODUCE_CACHED_DATA) { - if (parser_->log_->ShouldLogSymbols()) { - parser_->scanner()->LogSymbol(parser_->log_, parser_->position()); - } + // Parser is never used inside lazy functions (it falls back to PreParser + // instead), so we can produce the symbol data unconditionally. + parser_->scanner()->LogSymbol(parser_->log_, parser_->position()); } Handle result = parser_->scanner()->AllocateInternalizedString(parser_->isolate()); @@ -3420,8 +3420,6 @@ FunctionLiteral* Parser::ParseFunctionLiteral( // With no cached data, we partially parse the function, without // building an AST. This gathers the data needed to build a lazy // function. - // FIXME(marja): Now the PreParser doesn't need to log functions / - // symbols; only errors -> clean that up. SingletonLogger logger; PreParser::PreParseResult result = LazyParseFunctionLiteral(&logger); if (result == PreParser::kPreParseStackOverflow) { diff --git a/src/preparse-data.cc b/src/preparse-data.cc index 5bc6173..36590e0 100644 --- a/src/preparse-data.cc +++ b/src/preparse-data.cc @@ -83,7 +83,6 @@ CompleteParserRecorder::CompleteParserRecorder() #ifdef DEBUG prev_start_ = -1; #endif - should_log_symbols_ = true; } @@ -106,7 +105,6 @@ void CompleteParserRecorder::LogMessage(int start_pos, STATIC_ASSERT(PreparseDataConstants::kMessageTextPos == 4); WriteString(CStrVector(message)); if (arg_opt != NULL) WriteString(CStrVector(arg_opt)); - should_log_symbols_ = false; } @@ -120,7 +118,6 @@ void CompleteParserRecorder::WriteString(Vector str) { void CompleteParserRecorder::LogOneByteSymbol(int start, Vector literal) { - ASSERT(should_log_symbols_); int hash = vector_hash(literal); LogSymbol(start, hash, true, literal); } @@ -128,7 +125,6 @@ void CompleteParserRecorder::LogOneByteSymbol(int start, void CompleteParserRecorder::LogTwoByteSymbol(int start, Vector literal) { - ASSERT(should_log_symbols_); int hash = vector_hash(literal); LogSymbol(start, hash, false, Vector::cast(literal)); } diff --git a/src/preparse-data.h b/src/preparse-data.h index cfc33fe..b5007f2 100644 --- a/src/preparse-data.h +++ b/src/preparse-data.h @@ -39,7 +39,7 @@ namespace internal { // Abstract interface for preparse data recorder. class ParserRecorder { public: - ParserRecorder() : should_log_symbols_(false) { } + ParserRecorder() { } virtual ~ParserRecorder() { } // Logs the scope and some details of a function literal in the source. @@ -58,8 +58,6 @@ class ParserRecorder { const char* argument_opt, bool is_reference_error) = 0; - // Logs a symbol creation of a literal or identifier. - bool ShouldLogSymbols() { return should_log_symbols_; } // The following functions are only callable on CompleteParserRecorder // and are guarded by calls to ShouldLogSymbols. virtual void LogOneByteSymbol(int start, Vector literal) { @@ -68,11 +66,6 @@ class ParserRecorder { virtual void LogTwoByteSymbol(int start, Vector literal) { UNREACHABLE(); } - virtual void PauseRecording() { UNREACHABLE(); } - virtual void ResumeRecording() { UNREACHABLE(); } - - protected: - bool should_log_symbols_; private: DISALLOW_COPY_AND_ASSIGN(ParserRecorder); @@ -189,16 +182,6 @@ class CompleteParserRecorder : public ParserRecorder { const char* argument_opt, bool is_reference_error_); - virtual void PauseRecording() { - ASSERT(should_log_symbols_); - should_log_symbols_ = false; - } - - virtual void ResumeRecording() { - ASSERT(!should_log_symbols_); - should_log_symbols_ = !has_error(); - } - virtual void LogOneByteSymbol(int start, Vector literal); virtual void LogTwoByteSymbol(int start, Vector literal); Vector ExtractData(); diff --git a/src/preparser.cc b/src/preparser.cc index 21e2b77..2f32976 100644 --- a/src/preparser.cc +++ b/src/preparser.cc @@ -88,7 +88,6 @@ void PreParserTraits::ReportMessageAt(int start_pos, PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) { - pre_parser_->LogSymbol(); if (scanner->current_token() == Token::FUTURE_RESERVED_WORD) { return PreParserIdentifier::FutureReserved(); } else if (scanner->current_token() == @@ -109,7 +108,6 @@ PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) { PreParserExpression PreParserTraits::ExpressionFromString( int pos, Scanner* scanner, PreParserFactory* factory) { - pre_parser_->LogSymbol(); if (scanner->UnescapedLiteralMatches("use strict", 10)) { return PreParserExpression::UseStrictStringLiteral(); } @@ -932,10 +930,7 @@ PreParser::Expression PreParser::ParseFunctionLiteral( void PreParser::ParseLazyFunctionLiteralBody(bool* ok) { int body_start = position(); - bool is_logging = log_->ShouldLogSymbols(); - if (is_logging) log_->PauseRecording(); ParseSourceElements(Token::RBRACE, ok); - if (is_logging) log_->ResumeRecording(); if (!*ok) return; // Position right after terminal '}'. @@ -966,11 +961,4 @@ PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) { #undef CHECK_OK -void PreParser::LogSymbol() { - if (log_->ShouldLogSymbols()) { - scanner()->LogSymbol(log_, position()); - } -} - - } } // v8::internal diff --git a/src/preparser.h b/src/preparser.h index 4d4e104..de08eb3 100644 --- a/src/preparser.h +++ b/src/preparser.h @@ -1183,11 +1183,6 @@ class PreParser : public ParserBase { bool* ok); void ParseLazyFunctionLiteralBody(bool* ok); - // Logs the currently parsed literal as a symbol in the preparser data. - void LogSymbol(); - // Log the currently parsed string literal. - Expression GetStringSymbol(); - bool CheckInOrOf(bool accept_OF); }; -- 2.7.4