| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 return data; | 113 return data; |
| 114 } | 114 } |
| 115 | 115 |
| 116 | 116 |
| 117 // ---------------------------------------------------------------------------- | 117 // ---------------------------------------------------------------------------- |
| 118 // CompleteParserRecorder - Record both function entries and symbols. | 118 // CompleteParserRecorder - Record both function entries and symbols. |
| 119 | 119 |
| 120 CompleteParserRecorder::CompleteParserRecorder() | 120 CompleteParserRecorder::CompleteParserRecorder() |
| 121 : FunctionLoggingParserRecorder(), | 121 : FunctionLoggingParserRecorder(), |
| 122 literal_chars_(0), |
| 122 symbol_store_(0), | 123 symbol_store_(0), |
| 123 symbol_entries_(0), | 124 symbol_keys_(0), |
| 124 symbol_table_(vector_compare), | 125 symbol_table_(vector_compare), |
| 125 symbol_id_(0) { | 126 symbol_id_(0) { |
| 126 } | 127 } |
| 127 | 128 |
| 128 | 129 |
| 129 void CompleteParserRecorder::LogSymbol( | 130 void CompleteParserRecorder::LogSymbol(int start, |
| 130 int start, const char* literal_chars, int length) { | 131 int hash, |
| 131 if (!is_recording_) return; | 132 bool is_ascii, |
| 132 | 133 Vector<const byte> literal_bytes) { |
| 133 Vector<const char> literal(literal_chars, length); | 134 Key key = { is_ascii, literal_bytes }; |
| 134 int hash = vector_hash(literal); | 135 HashMap::Entry* entry = symbol_table_.Lookup(&key, hash, true); |
| 135 HashMap::Entry* entry = symbol_table_.Lookup(&literal, hash, true); | |
| 136 int id = static_cast<int>(reinterpret_cast<intptr_t>(entry->value)); | 136 int id = static_cast<int>(reinterpret_cast<intptr_t>(entry->value)); |
| 137 if (id == 0) { | 137 if (id == 0) { |
| 138 // Copy literal contents for later comparison. |
| 139 key.literal_bytes = |
| 140 Vector<const byte>::cast(literal_chars_.AddBlock(literal_bytes)); |
| 138 // Put (symbol_id_ + 1) into entry and increment it. | 141 // Put (symbol_id_ + 1) into entry and increment it. |
| 139 id = ++symbol_id_; | 142 id = ++symbol_id_; |
| 140 entry->value = reinterpret_cast<void*>(id); | 143 entry->value = reinterpret_cast<void*>(id); |
| 141 Vector<Vector<const char> > symbol = symbol_entries_.AddBlock(1, literal); | 144 Vector<Key> symbol = symbol_keys_.AddBlock(1, key); |
| 142 entry->key = &symbol[0]; | 145 entry->key = &symbol[0]; |
| 143 } | 146 } |
| 144 WriteNumber(id - 1); | 147 WriteNumber(id - 1); |
| 145 } | 148 } |
| 146 | 149 |
| 147 | 150 |
| 148 Vector<unsigned> CompleteParserRecorder::ExtractData() { | 151 Vector<unsigned> CompleteParserRecorder::ExtractData() { |
| 149 int function_size = function_store_.size(); | 152 int function_size = function_store_.size(); |
| 150 // Add terminator to symbols, then pad to unsigned size. | 153 // Add terminator to symbols, then pad to unsigned size. |
| 151 int symbol_size = symbol_store_.size(); | 154 int symbol_size = symbol_store_.size(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 180 symbol_store_.Add(static_cast<byte>(number >> i) | 0x80u); | 183 symbol_store_.Add(static_cast<byte>(number >> i) | 0x80u); |
| 181 number &= mask; | 184 number &= mask; |
| 182 } | 185 } |
| 183 mask >>= 7; | 186 mask >>= 7; |
| 184 } | 187 } |
| 185 symbol_store_.Add(static_cast<byte>(number)); | 188 symbol_store_.Add(static_cast<byte>(number)); |
| 186 } | 189 } |
| 187 | 190 |
| 188 | 191 |
| 189 } } // namespace v8::internal. | 192 } } // namespace v8::internal. |
| OLD | NEW |