diff options
| author | Steve Block <steveblock@google.com> | 2011-05-12 15:51:54 +0100 |
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2011-05-12 16:12:25 +0100 |
| commit | 9fac840a46e8b7e26894f4792ba26dde14c56b04 (patch) | |
| tree | 0b8b71befb5175abac552daa0d084fc51c1090b8 /src/preparse-data.h | |
| parent | b0fe1620dcb4135ac3ab2d66ff93072373911299 (diff) | |
| download | android_external_v8-9fac840a46e8b7e26894f4792ba26dde14c56b04.tar.gz android_external_v8-9fac840a46e8b7e26894f4792ba26dde14c56b04.tar.bz2 android_external_v8-9fac840a46e8b7e26894f4792ba26dde14c56b04.zip | |
Update V8 to r6190 as required by WebKit r75315
Change-Id: I0b2f598e4d8748df417ad350fc47a1c465ad1fef
Diffstat (limited to 'src/preparse-data.h')
| -rw-r--r-- | src/preparse-data.h | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/src/preparse-data.h b/src/preparse-data.h index a96e50fa..cc82bcc6 100644 --- a/src/preparse-data.h +++ b/src/preparse-data.h @@ -75,7 +75,8 @@ class ParserRecorder { int properties) = 0; // Logs a symbol creation of a literal or identifier. - virtual void LogSymbol(int start, const char* symbol, int length) = 0; + virtual void LogAsciiSymbol(int start, Vector<const char> literal) { } + virtual void LogUC16Symbol(int start, Vector<const uc16> literal) { } // Logs an error message and marks the log as containing an error. // Further logging will be ignored, and ExtractData will return a vector @@ -165,7 +166,8 @@ class FunctionLoggingParserRecorder : public ParserRecorder { class PartialParserRecorder : public FunctionLoggingParserRecorder { public: PartialParserRecorder() : FunctionLoggingParserRecorder() { } - virtual void LogSymbol(int start, const char* symbol, int length) { } + virtual void LogAsciiSymbol(int start, Vector<const char> literal) { } + virtual void LogUC16Symbol(int start, Vector<const uc16> literal) { } virtual ~PartialParserRecorder() { } virtual Vector<unsigned> ExtractData(); virtual int symbol_position() { return 0; } @@ -181,7 +183,17 @@ class CompleteParserRecorder: public FunctionLoggingParserRecorder { CompleteParserRecorder(); virtual ~CompleteParserRecorder() { } - virtual void LogSymbol(int start, const char* symbol, int length); + virtual void LogAsciiSymbol(int start, Vector<const char> literal) { + if (!is_recording_) return; + int hash = vector_hash(literal); + LogSymbol(start, hash, true, Vector<const byte>::cast(literal)); + } + + virtual void LogUC16Symbol(int start, Vector<const uc16> literal) { + if (!is_recording_) return; + int hash = vector_hash(literal); + LogSymbol(start, hash, false, Vector<const byte>::cast(literal)); + } virtual Vector<unsigned> ExtractData(); @@ -189,10 +201,21 @@ class CompleteParserRecorder: public FunctionLoggingParserRecorder { virtual int symbol_ids() { return symbol_id_; } private: - static int vector_hash(Vector<const char> string) { + struct Key { + bool is_ascii; + Vector<const byte> literal_bytes; + }; + + virtual void LogSymbol(int start, + int hash, + bool is_ascii, + Vector<const byte> literal); + + template <typename Char> + static int vector_hash(Vector<const Char> string) { int hash = 0; for (int i = 0; i < string.length(); i++) { - int c = string[i]; + int c = static_cast<int>(string[i]); hash += c; hash += (hash << 10); hash ^= (hash >> 6); @@ -201,18 +224,21 @@ class CompleteParserRecorder: public FunctionLoggingParserRecorder { } static bool vector_compare(void* a, void* b) { - Vector<const char>* string1 = reinterpret_cast<Vector<const char>* >(a); - Vector<const char>* string2 = reinterpret_cast<Vector<const char>* >(b); - int length = string1->length(); - if (string2->length() != length) return false; - return memcmp(string1->start(), string2->start(), length) == 0; + Key* string1 = reinterpret_cast<Key*>(a); + Key* string2 = reinterpret_cast<Key*>(b); + if (string1->is_ascii != string2->is_ascii) 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; } // Write a non-negative number to the symbol store. void WriteNumber(int number); + Collector<byte> literal_chars_; Collector<byte> symbol_store_; - Collector<Vector<const char> > symbol_entries_; + Collector<Key> symbol_keys_; HashMap symbol_table_; int symbol_id_; }; |
