Commit ed1d232d authored by marja@chromium.org's avatar marja@chromium.org

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
parent a3d743b4
......@@ -738,9 +738,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());
......@@ -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) {
......
......@@ -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));
}
......
......@@ -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();
......
......@@ -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
......@@ -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);
};
......
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