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
This commit is contained in:
parent
78f550c6fd
commit
81b0236d76
@ -1001,7 +1001,7 @@ class CompleteParserRecorder: public PartialParserRecorder {
|
|||||||
Vector<Vector<const char> > symbol = symbol_entries_.AddBlock(1, literal);
|
Vector<Vector<const char> > symbol = symbol_entries_.AddBlock(1, literal);
|
||||||
entry->key = &symbol[0];
|
entry->key = &symbol[0];
|
||||||
}
|
}
|
||||||
symbol_store_.Add(id - 1);
|
WriteNumber(id - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Vector<unsigned> ExtractData() {
|
virtual Vector<unsigned> ExtractData() {
|
||||||
@ -1503,6 +1503,7 @@ FunctionLiteral* Parser::ParseProgram(Handle<String> source,
|
|||||||
source->TryFlatten();
|
source->TryFlatten();
|
||||||
scanner_.Initialize(source, JAVASCRIPT);
|
scanner_.Initialize(source, JAVASCRIPT);
|
||||||
ASSERT(target_stack_ == NULL);
|
ASSERT(target_stack_ == NULL);
|
||||||
|
if (pre_data_ != NULL) pre_data_->Initialize();
|
||||||
|
|
||||||
// Compute the parsing mode.
|
// Compute the parsing mode.
|
||||||
mode_ = FLAG_lazy ? PARSE_LAZILY : PARSE_EAGERLY;
|
mode_ = FLAG_lazy ? PARSE_LAZILY : PARSE_EAGERLY;
|
||||||
@ -5492,7 +5493,9 @@ ScriptDataImpl* PartialPreParse(Handle<String> source,
|
|||||||
|
|
||||||
|
|
||||||
void ScriptDataImpl::Initialize() {
|
void ScriptDataImpl::Initialize() {
|
||||||
|
// Prepares state for use.
|
||||||
if (store_.length() >= kHeaderSize) {
|
if (store_.length() >= kHeaderSize) {
|
||||||
|
function_index_ = kHeaderSize;
|
||||||
int symbol_data_offset = kHeaderSize + store_[kFunctionsSizeOffset];
|
int symbol_data_offset = kHeaderSize + store_[kFunctionsSizeOffset];
|
||||||
if (store_.length() > symbol_data_offset) {
|
if (store_.length() > symbol_data_offset) {
|
||||||
symbol_data_ = reinterpret_cast<byte*>(&store_[symbol_data_offset]);
|
symbol_data_ = reinterpret_cast<byte*>(&store_[symbol_data_offset]);
|
||||||
|
@ -101,10 +101,7 @@ class ScriptDataImpl : public ScriptData {
|
|||||||
public:
|
public:
|
||||||
explicit ScriptDataImpl(Vector<unsigned> store)
|
explicit ScriptDataImpl(Vector<unsigned> store)
|
||||||
: store_(store),
|
: store_(store),
|
||||||
function_index_(kHeaderSize),
|
owns_store_(true) { }
|
||||||
owns_store_(true) {
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create an empty ScriptDataImpl that is guaranteed to not satisfy
|
// Create an empty ScriptDataImpl that is guaranteed to not satisfy
|
||||||
// a SanityCheck.
|
// a SanityCheck.
|
||||||
@ -190,10 +187,8 @@ class ScriptDataImpl : public ScriptData {
|
|||||||
ScriptDataImpl(const char* backing_store, int length)
|
ScriptDataImpl(const char* backing_store, int length)
|
||||||
: store_(reinterpret_cast<unsigned*>(const_cast<char*>(backing_store)),
|
: store_(reinterpret_cast<unsigned*>(const_cast<char*>(backing_store)),
|
||||||
length / sizeof(unsigned)),
|
length / sizeof(unsigned)),
|
||||||
function_index_(kHeaderSize),
|
|
||||||
owns_store_(false) {
|
owns_store_(false) {
|
||||||
ASSERT_EQ(0, reinterpret_cast<intptr_t>(backing_store) % sizeof(unsigned));
|
ASSERT_EQ(0, reinterpret_cast<intptr_t>(backing_store) % sizeof(unsigned));
|
||||||
Initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read strings written by ParserRecorder::WriteString.
|
// Read strings written by ParserRecorder::WriteString.
|
||||||
|
Loading…
Reference in New Issue
Block a user