Revision: 20707
Author:   [email protected]
Date:     Mon Apr 14 08:49:23 2014 UTC
Log: 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).

[email protected]
BUG=

Review URL: https://codereview.chromium.org/222123003
http://code.google.com/p/v8/source/detail?r=20707

Modified:
 /branches/bleeding_edge/src/parser.cc
 /branches/bleeding_edge/src/preparse-data.cc
 /branches/bleeding_edge/src/preparse-data.h
 /branches/bleeding_edge/src/preparser.cc
 /branches/bleeding_edge/src/preparser.h

=======================================
--- /branches/bleeding_edge/src/parser.cc       Mon Apr 14 07:35:46 2014 UTC
+++ /branches/bleeding_edge/src/parser.cc       Mon Apr 14 08:49:23 2014 UTC
@@ -738,9 +738,9 @@
       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<String> result =
       parser_->scanner()->AllocateInternalizedString(parser_->isolate());
@@ -3420,8 +3420,6 @@
         // 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) {
=======================================
--- /branches/bleeding_edge/src/preparse-data.cc Tue Apr 1 14:17:43 2014 UTC +++ /branches/bleeding_edge/src/preparse-data.cc Mon Apr 14 08:49:23 2014 UTC
@@ -83,7 +83,6 @@
 #ifdef DEBUG
   prev_start_ = -1;
 #endif
-  should_log_symbols_ = true;
 }


@@ -106,7 +105,6 @@
   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::LogOneByteSymbol(int start,
Vector<const uint8_t> literal) {
-  ASSERT(should_log_symbols_);
   int hash = vector_hash(literal);
   LogSymbol(start, hash, true, literal);
 }
@@ -128,7 +125,6 @@

 void CompleteParserRecorder::LogTwoByteSymbol(int start,
Vector<const uint16_t> literal) {
-  ASSERT(should_log_symbols_);
   int hash = vector_hash(literal);
   LogSymbol(start, hash, false, Vector<const byte>::cast(literal));
 }
=======================================
--- /branches/bleeding_edge/src/preparse-data.h Tue Apr  1 14:17:43 2014 UTC
+++ /branches/bleeding_edge/src/preparse-data.h Mon Apr 14 08:49:23 2014 UTC
@@ -39,7 +39,7 @@
 // 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 @@
                           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<const uint8_t> literal) {
@@ -68,11 +66,6 @@
virtual void LogTwoByteSymbol(int start, Vector<const uint16_t> 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 @@
                           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<const uint8_t> literal);
   virtual void LogTwoByteSymbol(int start, Vector<const uint16_t> literal);
   Vector<unsigned> ExtractData();
=======================================
--- /branches/bleeding_edge/src/preparser.cc    Wed Apr  2 12:38:01 2014 UTC
+++ /branches/bleeding_edge/src/preparser.cc    Mon Apr 14 08:49:23 2014 UTC
@@ -88,7 +88,6 @@


 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 @@

 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 @@

 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 @@
 #undef CHECK_OK


-void PreParser::LogSymbol() {
-  if (log_->ShouldLogSymbols()) {
-    scanner()->LogSymbol(log_, position());
-  }
-}
-
-
 } }  // v8::internal
=======================================
--- /branches/bleeding_edge/src/preparser.h     Wed Apr  2 12:38:01 2014 UTC
+++ /branches/bleeding_edge/src/preparser.h     Mon Apr 14 08:49:23 2014 UTC
@@ -1183,11 +1183,6 @@
       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);
 };

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to