From 81b0236d76dd4fbaffc8542d582829a365833f60 Mon Sep 17 00:00:00 2001 From: "lrn@chromium.org" Date: Fri, 17 Sep 2010 12:55:27 +0000 Subject: [PATCH] Make preparsing data reusable. Fix bug in writing symbol ids over 128. Review URL: http://codereview.chromium.org/3416010 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5485 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/parser.cc | 5 ++++- src/parser.h | 7 +------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/parser.cc b/src/parser.cc index 856c474066..1edcb1df41 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -1001,7 +1001,7 @@ class CompleteParserRecorder: public PartialParserRecorder { Vector > symbol = symbol_entries_.AddBlock(1, literal); entry->key = &symbol[0]; } - symbol_store_.Add(id - 1); + WriteNumber(id - 1); } virtual Vector ExtractData() { @@ -1503,6 +1503,7 @@ FunctionLiteral* Parser::ParseProgram(Handle source, source->TryFlatten(); scanner_.Initialize(source, JAVASCRIPT); ASSERT(target_stack_ == NULL); + if (pre_data_ != NULL) pre_data_->Initialize(); // Compute the parsing mode. mode_ = FLAG_lazy ? PARSE_LAZILY : PARSE_EAGERLY; @@ -5492,7 +5493,9 @@ ScriptDataImpl* PartialPreParse(Handle source, void ScriptDataImpl::Initialize() { + // Prepares state for use. if (store_.length() >= kHeaderSize) { + function_index_ = kHeaderSize; int symbol_data_offset = kHeaderSize + store_[kFunctionsSizeOffset]; if (store_.length() > symbol_data_offset) { symbol_data_ = reinterpret_cast(&store_[symbol_data_offset]); diff --git a/src/parser.h b/src/parser.h index 8bab92d5a9..8c00857276 100644 --- a/src/parser.h +++ b/src/parser.h @@ -101,10 +101,7 @@ class ScriptDataImpl : public ScriptData { public: explicit ScriptDataImpl(Vector store) : store_(store), - function_index_(kHeaderSize), - owns_store_(true) { - Initialize(); - } + owns_store_(true) { } // Create an empty ScriptDataImpl that is guaranteed to not satisfy // a SanityCheck. @@ -190,10 +187,8 @@ class ScriptDataImpl : public ScriptData { ScriptDataImpl(const char* backing_store, int length) : store_(reinterpret_cast(const_cast(backing_store)), length / sizeof(unsigned)), - function_index_(kHeaderSize), owns_store_(false) { ASSERT_EQ(0, reinterpret_cast(backing_store) % sizeof(unsigned)); - Initialize(); } // Read strings written by ParserRecorder::WriteString.