Reviewers: ulan,

Message:
ulan, ptal

Description:
Parser cleanup: PreParser doesn't need to produce symbol data any more.

State of the art:
- There is no 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=u...@chromium.org
BUG=

Please review this at https://codereview.chromium.org/222123003/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+4, -44 lines):
  M src/parser.cc
  M src/preparse-data.h
  M src/preparse-data.cc
  M src/preparser.h
  M src/preparser.cc


Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 5fce1dd94a677df4ade93876e6ac78496c08d1c1..2977ef3b1c2155c4c87b83f25bd2992bfe18c773 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -714,9 +714,9 @@ Handle<String> 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<String> result =
       parser_->scanner()->AllocateInternalizedString(parser_->isolate());
@@ -3398,8 +3398,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) {
Index: src/preparse-data.cc
diff --git a/src/preparse-data.cc b/src/preparse-data.cc
index 5bc6173e90f07847e2a99c834ae24195a4fa6d3c..36590e011a5deda2e897c6f266a7e0a24fc3b288 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<const char> str) {

 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::LogOneByteSymbol(int start,

 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));
 }
Index: src/preparse-data.h
diff --git a/src/preparse-data.h b/src/preparse-data.h
index cfc33fe1319f0434133442ee7ad999d60570f398..b5007f28add67d102bf34e2cebded1acb49564f4 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<const uint8_t> literal) {
@@ -68,11 +66,6 @@ class ParserRecorder {
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 @@ 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<const uint8_t> literal);
   virtual void LogTwoByteSymbol(int start, Vector<const uint16_t> literal);
   Vector<unsigned> ExtractData();
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index 21e2b7786f3fd84e2e6eac3542e6bbdf4b1c3bdc..2f329764600427e0fc52e3bc223ec031af7097f1 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
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index 4d4e10402e0629c8e36329c135da6686a07617d8..de08eb317f9cf3d1456faca7a82865394b8618a6 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -1183,11 +1183,6 @@ class PreParser : public ParserBase<PreParserTraits> {
       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
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to