From 98cd283399207202de567d772dfd65455f36e122 Mon Sep 17 00:00:00 2001 From: "marja@chromium.org" Date: Mon, 5 May 2014 14:55:13 +0000 Subject: [PATCH] Remove symbol preparse data altogether. Removing it seems to be a clear win on mobile: producing symbol data makes cold parsing 20-30% slower, and having symbol data doesn't make warm parsing any faster. Notes: - V8 used to produce symbol data, but because of a bug, it was never used until recently. (See fix https://codereview.chromium.org/172753002 which takes the symbol data into use again.) - On desktop, warm parsing is faster if we have symbol data, and producing it during cold parsing doesn't make parsing substantially slower. However, this doesn't seem to be the case on mobile. - The preparse data (cached data) will now contain only the positions of the lazy functions. BUG= R=dcarney@chromium.org Review URL: https://codereview.chromium.org/261273003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@21146 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/parser.cc | 36 ------------ src/parser.h | 9 --- src/preparse-data-format.h | 7 +-- src/preparse-data.cc | 112 ++---------------------------------- src/preparse-data.h | 27 --------- src/scanner.cc | 9 --- src/scanner.h | 2 - test/cctest/test-parsing.cc | 136 ++++---------------------------------------- 8 files changed, 18 insertions(+), 320 deletions(-) diff --git a/src/parser.cc b/src/parser.cc index 4b4594b..0ff11f2 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -182,25 +182,6 @@ void RegExpBuilder::AddQuantifierToAtom( } -Handle Parser::LookupCachedSymbol(int symbol_id) { - // Make sure the cache is large enough to hold the symbol identifier. - if (symbol_cache_.length() <= symbol_id) { - // Increase length to index + 1. - symbol_cache_.AddBlock(Handle::null(), - symbol_id + 1 - symbol_cache_.length(), zone()); - } - Handle result = symbol_cache_.at(symbol_id); - if (result.is_null()) { - result = scanner()->AllocateInternalizedString(isolate_); - ASSERT(!result.is_null()); - symbol_cache_.at(symbol_id) = result; - return result; - } - isolate()->counters()->total_preparse_symbols_skipped()->Increment(); - return result; -} - - ScriptData* ScriptData::New(const char* data, int length) { // The length is obviously invalid. if (length % sizeof(unsigned) != 0) { @@ -280,10 +261,6 @@ bool ScriptData::SanityCheck() { static_cast(store_[PreparseDataConstants::kFunctionsSizeOffset]); if (functions_size < 0) return false; if (functions_size % FunctionEntry::kSize != 0) return false; - // Check that the count of symbols is non-negative. - int symbol_count = - static_cast(store_[PreparseDataConstants::kSymbolCountOffset]); - if (symbol_count < 0) return false; // Check that the total size has room for header and function entries. int minimum_size = PreparseDataConstants::kHeaderSize + functions_size; @@ -707,18 +684,6 @@ void ParserTraits::ReportMessageAt(Scanner::Location source_location, Handle ParserTraits::GetSymbol(Scanner* scanner) { - if (parser_->cached_data_mode() == CONSUME_CACHED_DATA) { - int symbol_id = (*parser_->cached_data())->GetSymbolIdentifier(); - // If there is no symbol data, -1 will be returned. - if (symbol_id >= 0 && - symbol_id < (*parser_->cached_data())->symbol_count()) { - return parser_->LookupCachedSymbol(symbol_id); - } - } else if (parser_->cached_data_mode() == PRODUCE_CACHED_DATA) { - // 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()); ASSERT(!result.is_null()); @@ -819,7 +784,6 @@ Parser::Parser(CompilationInfo* info) info->zone(), this), isolate_(info->isolate()), - symbol_cache_(0, info->zone()), script_(info->script()), scanner_(isolate_->unicode_cache()), reusable_preparser_(NULL), diff --git a/src/parser.h b/src/parser.h index 8bc8a48..71bbfd1 100644 --- a/src/parser.h +++ b/src/parser.h @@ -91,11 +91,6 @@ class ScriptData { const char* BuildMessage() const; Vector BuildArgs() const; - int symbol_count() { - return (store_.length() > PreparseDataConstants::kHeaderSize) - ? store_[PreparseDataConstants::kSymbolCountOffset] - : 0; - } int function_count() { int functions_size = static_cast(store_[PreparseDataConstants::kFunctionsSizeOffset]); @@ -658,7 +653,6 @@ class Parser : public ParserBase { } else { ASSERT(data != NULL); cached_data_ = data; - symbol_cache_.Initialize(*data ? (*data)->symbol_count() : 0, zone()); } } @@ -769,8 +763,6 @@ class Parser : public ParserBase { Scope* NewScope(Scope* parent, ScopeType type); - Handle LookupCachedSymbol(int symbol_id); - // Skip over a lazy function, either using cached data if we have it, or // by parsing the function with PreParser. Consumes the ending }. void SkipLazyFunctionBody(Handle function_name, @@ -790,7 +782,6 @@ class Parser : public ParserBase { bool* ok); Isolate* isolate_; - ZoneList > symbol_cache_; Handle