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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 } | 103 } |
104 return data; | 104 return data; |
105 } | 105 } |
106 | 106 |
107 | 107 |
108 // ---------------------------------------------------------------------------- | 108 // ---------------------------------------------------------------------------- |
109 // CompleteParserRecorder - Record both function entries and symbols. | 109 // CompleteParserRecorder - Record both function entries and symbols. |
110 | 110 |
111 CompleteParserRecorder::CompleteParserRecorder() | 111 CompleteParserRecorder::CompleteParserRecorder() |
112 : FunctionLoggingParserRecorder(), | 112 : FunctionLoggingParserRecorder(), |
| 113 literal_chars_(0), |
113 symbol_store_(0), | 114 symbol_store_(0), |
114 symbol_entries_(0), | 115 symbol_keys_(0), |
115 symbol_table_(vector_compare), | 116 symbol_table_(vector_compare), |
116 symbol_id_(0) { | 117 symbol_id_(0) { |
117 } | 118 } |
118 | 119 |
119 | 120 |
120 void CompleteParserRecorder::LogSymbol( | 121 void CompleteParserRecorder::LogSymbol(int start, |
121 int start, const char* literal_chars, int length) { | 122 int hash, |
122 if (!is_recording_) return; | 123 bool is_ascii, |
123 | 124 Vector<const byte> literal_bytes) { |
124 Vector<const char> literal(literal_chars, length); | 125 Key key = { is_ascii, literal_bytes }; |
125 int hash = vector_hash(literal); | 126 HashMap::Entry* entry = symbol_table_.Lookup(&key, hash, true); |
126 HashMap::Entry* entry = symbol_table_.Lookup(&literal, hash, true); | |
127 int id = static_cast<int>(reinterpret_cast<intptr_t>(entry->value)); | 127 int id = static_cast<int>(reinterpret_cast<intptr_t>(entry->value)); |
128 if (id == 0) { | 128 if (id == 0) { |
| 129 // Copy literal contents for later comparison. |
| 130 key.literal_bytes = |
| 131 Vector<const byte>::cast(literal_chars_.AddBlock(literal_bytes)); |
129 // Put (symbol_id_ + 1) into entry and increment it. | 132 // Put (symbol_id_ + 1) into entry and increment it. |
130 id = ++symbol_id_; | 133 id = ++symbol_id_; |
131 entry->value = reinterpret_cast<void*>(id); | 134 entry->value = reinterpret_cast<void*>(id); |
132 Vector<Vector<const char> > symbol = symbol_entries_.AddBlock(1, literal); | 135 Vector<Key> symbol = symbol_keys_.AddBlock(1, key); |
133 entry->key = &symbol[0]; | 136 entry->key = &symbol[0]; |
134 } | 137 } |
135 WriteNumber(id - 1); | 138 WriteNumber(id - 1); |
136 } | 139 } |
137 | 140 |
138 | 141 |
139 Vector<unsigned> CompleteParserRecorder::ExtractData() { | 142 Vector<unsigned> CompleteParserRecorder::ExtractData() { |
140 int function_size = function_store_.size(); | 143 int function_size = function_store_.size(); |
141 // Add terminator to symbols, then pad to unsigned size. | 144 // Add terminator to symbols, then pad to unsigned size. |
142 int symbol_size = symbol_store_.size(); | 145 int symbol_size = symbol_store_.size(); |
(...skipping 28 matching lines...) Expand all Loading... |
171 symbol_store_.Add(static_cast<byte>(number >> i) | 0x80u); | 174 symbol_store_.Add(static_cast<byte>(number >> i) | 0x80u); |
172 number &= mask; | 175 number &= mask; |
173 } | 176 } |
174 mask >>= 7; | 177 mask >>= 7; |
175 } | 178 } |
176 symbol_store_.Add(static_cast<byte>(number)); | 179 symbol_store_.Add(static_cast<byte>(number)); |
177 } | 180 } |
178 | 181 |
179 | 182 |
180 } } // namespace v8::internal. | 183 } } // namespace v8::internal. |
OLD | NEW |