Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1043)

Unified Diff: src/preparse-data.cc

Issue 261273003: Remove symbol preparse data altogether. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/preparse-data.h ('k') | src/preparse-data-format.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparse-data.cc
diff --git a/src/preparse-data.cc b/src/preparse-data.cc
index a54eb82b2e458311969370e79bebdf8b29e24194..5ddf72137f34471a98a9da044f4e8c9a6cf480a7 100644
--- a/src/preparse-data.cc
+++ b/src/preparse-data.cc
@@ -15,48 +15,16 @@ namespace v8 {
namespace internal {
-template <typename Char>
-static int vector_hash(Vector<const Char> string) {
- int hash = 0;
- for (int i = 0; i < string.length(); i++) {
- int c = static_cast<int>(string[i]);
- hash += c;
- hash += (hash << 10);
- hash ^= (hash >> 6);
- }
- return hash;
-}
-
-
-static bool vector_compare(void* a, void* b) {
- CompleteParserRecorder::Key* string1 =
- reinterpret_cast<CompleteParserRecorder::Key*>(a);
- CompleteParserRecorder::Key* string2 =
- reinterpret_cast<CompleteParserRecorder::Key*>(b);
- if (string1->is_one_byte != string2->is_one_byte) return false;
- int length = string1->literal_bytes.length();
- if (string2->literal_bytes.length() != length) return false;
- return memcmp(string1->literal_bytes.start(),
- string2->literal_bytes.start(), length) == 0;
-}
-
-
CompleteParserRecorder::CompleteParserRecorder()
- : function_store_(0),
- literal_chars_(0),
- symbol_store_(0),
- symbol_keys_(0),
- string_table_(vector_compare),
- symbol_id_(0) {
+ : function_store_(0) {
preamble_[PreparseDataConstants::kMagicOffset] =
PreparseDataConstants::kMagicNumber;
preamble_[PreparseDataConstants::kVersionOffset] =
PreparseDataConstants::kCurrentVersion;
preamble_[PreparseDataConstants::kHasErrorOffset] = false;
preamble_[PreparseDataConstants::kFunctionsSizeOffset] = 0;
- preamble_[PreparseDataConstants::kSymbolCountOffset] = 0;
preamble_[PreparseDataConstants::kSizeOffset] = 0;
- ASSERT_EQ(6, PreparseDataConstants::kHeaderSize);
+ ASSERT_EQ(5, PreparseDataConstants::kHeaderSize);
#ifdef DEBUG
prev_start_ = -1;
#endif
@@ -93,90 +61,18 @@ void CompleteParserRecorder::WriteString(Vector<const char> str) {
}
-void CompleteParserRecorder::LogOneByteSymbol(int start,
- Vector<const uint8_t> literal) {
- int hash = vector_hash(literal);
- LogSymbol(start, hash, true, literal);
-}
-
-
-void CompleteParserRecorder::LogTwoByteSymbol(int start,
- Vector<const uint16_t> literal) {
- int hash = vector_hash(literal);
- LogSymbol(start, hash, false, Vector<const byte>::cast(literal));
-}
-
-
-void CompleteParserRecorder::LogSymbol(int start,
- int hash,
- bool is_one_byte,
- Vector<const byte> literal_bytes) {
- Key key = { is_one_byte, literal_bytes };
- HashMap::Entry* entry = string_table_.Lookup(&key, hash, true);
- int id = static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
- if (id == 0) {
- // Copy literal contents for later comparison.
- key.literal_bytes =
- Vector<const byte>::cast(literal_chars_.AddBlock(literal_bytes));
- // Put (symbol_id_ + 1) into entry and increment it.
- id = ++symbol_id_;
- entry->value = reinterpret_cast<void*>(id);
- Vector<Key> symbol = symbol_keys_.AddBlock(1, key);
- entry->key = &symbol[0];
- }
- WriteNumber(id - 1);
-}
-
-
Vector<unsigned> CompleteParserRecorder::ExtractData() {
int function_size = function_store_.size();
- // Add terminator to symbols, then pad to unsigned size.
- int symbol_size = symbol_store_.size();
- int padding = sizeof(unsigned) - (symbol_size % sizeof(unsigned));
- symbol_store_.AddBlock(padding, PreparseDataConstants::kNumberTerminator);
- symbol_size += padding;
- int total_size = PreparseDataConstants::kHeaderSize + function_size
- + (symbol_size / sizeof(unsigned));
+ int total_size = PreparseDataConstants::kHeaderSize + function_size;
Vector<unsigned> data = Vector<unsigned>::New(total_size);
preamble_[PreparseDataConstants::kFunctionsSizeOffset] = function_size;
- preamble_[PreparseDataConstants::kSymbolCountOffset] = symbol_id_;
OS::MemCopy(data.start(), preamble_, sizeof(preamble_));
- int symbol_start = PreparseDataConstants::kHeaderSize + function_size;
if (function_size > 0) {
function_store_.WriteTo(data.SubVector(PreparseDataConstants::kHeaderSize,
- symbol_start));
- }
- if (!has_error()) {
- symbol_store_.WriteTo(
- Vector<byte>::cast(data.SubVector(symbol_start, total_size)));
+ total_size));
}
return data;
}
-void CompleteParserRecorder::WriteNumber(int number) {
- // Split the number into chunks of 7 bits. Write them one after another (the
- // most significant first). Use the MSB of each byte for signalling that the
- // number continues. See ScriptDataImpl::ReadNumber for the reading side.
- ASSERT(number >= 0);
-
- int mask = (1 << 28) - 1;
- int i = 28;
- // 26 million symbols ought to be enough for anybody.
- ASSERT(number <= mask);
- while (number < mask) {
- mask >>= 7;
- i -= 7;
- }
- while (i > 0) {
- symbol_store_.Add(static_cast<byte>(number >> i) | 0x80u);
- number &= mask;
- mask >>= 7;
- i -= 7;
- }
- ASSERT(number < (1 << 7));
- symbol_store_.Add(static_cast<byte>(number));
-}
-
-
} } // namespace v8::internal.
« no previous file with comments | « src/preparse-data.h ('k') | src/preparse-data-format.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698