| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 preamble_[PreparseDataConstants::kVersionOffset] = | 76 preamble_[PreparseDataConstants::kVersionOffset] = |
| 77 PreparseDataConstants::kCurrentVersion; | 77 PreparseDataConstants::kCurrentVersion; |
| 78 preamble_[PreparseDataConstants::kHasErrorOffset] = false; | 78 preamble_[PreparseDataConstants::kHasErrorOffset] = false; |
| 79 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = 0; | 79 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = 0; |
| 80 preamble_[PreparseDataConstants::kSymbolCountOffset] = 0; | 80 preamble_[PreparseDataConstants::kSymbolCountOffset] = 0; |
| 81 preamble_[PreparseDataConstants::kSizeOffset] = 0; | 81 preamble_[PreparseDataConstants::kSizeOffset] = 0; |
| 82 ASSERT_EQ(6, PreparseDataConstants::kHeaderSize); | 82 ASSERT_EQ(6, PreparseDataConstants::kHeaderSize); |
| 83 #ifdef DEBUG | 83 #ifdef DEBUG |
| 84 prev_start_ = -1; | 84 prev_start_ = -1; |
| 85 #endif | 85 #endif |
| 86 should_log_symbols_ = true; | |
| 87 } | 86 } |
| 88 | 87 |
| 89 | 88 |
| 90 void CompleteParserRecorder::LogMessage(int start_pos, | 89 void CompleteParserRecorder::LogMessage(int start_pos, |
| 91 int end_pos, | 90 int end_pos, |
| 92 const char* message, | 91 const char* message, |
| 93 const char* arg_opt, | 92 const char* arg_opt, |
| 94 bool is_reference_error) { | 93 bool is_reference_error) { |
| 95 if (has_error()) return; | 94 if (has_error()) return; |
| 96 preamble_[PreparseDataConstants::kHasErrorOffset] = true; | 95 preamble_[PreparseDataConstants::kHasErrorOffset] = true; |
| 97 function_store_.Reset(); | 96 function_store_.Reset(); |
| 98 STATIC_ASSERT(PreparseDataConstants::kMessageStartPos == 0); | 97 STATIC_ASSERT(PreparseDataConstants::kMessageStartPos == 0); |
| 99 function_store_.Add(start_pos); | 98 function_store_.Add(start_pos); |
| 100 STATIC_ASSERT(PreparseDataConstants::kMessageEndPos == 1); | 99 STATIC_ASSERT(PreparseDataConstants::kMessageEndPos == 1); |
| 101 function_store_.Add(end_pos); | 100 function_store_.Add(end_pos); |
| 102 STATIC_ASSERT(PreparseDataConstants::kMessageArgCountPos == 2); | 101 STATIC_ASSERT(PreparseDataConstants::kMessageArgCountPos == 2); |
| 103 function_store_.Add((arg_opt == NULL) ? 0 : 1); | 102 function_store_.Add((arg_opt == NULL) ? 0 : 1); |
| 104 STATIC_ASSERT(PreparseDataConstants::kIsReferenceErrorPos == 3); | 103 STATIC_ASSERT(PreparseDataConstants::kIsReferenceErrorPos == 3); |
| 105 function_store_.Add(is_reference_error ? 1 : 0); | 104 function_store_.Add(is_reference_error ? 1 : 0); |
| 106 STATIC_ASSERT(PreparseDataConstants::kMessageTextPos == 4); | 105 STATIC_ASSERT(PreparseDataConstants::kMessageTextPos == 4); |
| 107 WriteString(CStrVector(message)); | 106 WriteString(CStrVector(message)); |
| 108 if (arg_opt != NULL) WriteString(CStrVector(arg_opt)); | 107 if (arg_opt != NULL) WriteString(CStrVector(arg_opt)); |
| 109 should_log_symbols_ = false; | |
| 110 } | 108 } |
| 111 | 109 |
| 112 | 110 |
| 113 void CompleteParserRecorder::WriteString(Vector<const char> str) { | 111 void CompleteParserRecorder::WriteString(Vector<const char> str) { |
| 114 function_store_.Add(str.length()); | 112 function_store_.Add(str.length()); |
| 115 for (int i = 0; i < str.length(); i++) { | 113 for (int i = 0; i < str.length(); i++) { |
| 116 function_store_.Add(str[i]); | 114 function_store_.Add(str[i]); |
| 117 } | 115 } |
| 118 } | 116 } |
| 119 | 117 |
| 120 | 118 |
| 121 void CompleteParserRecorder::LogOneByteSymbol(int start, | 119 void CompleteParserRecorder::LogOneByteSymbol(int start, |
| 122 Vector<const uint8_t> literal) { | 120 Vector<const uint8_t> literal) { |
| 123 ASSERT(should_log_symbols_); | |
| 124 int hash = vector_hash(literal); | 121 int hash = vector_hash(literal); |
| 125 LogSymbol(start, hash, true, literal); | 122 LogSymbol(start, hash, true, literal); |
| 126 } | 123 } |
| 127 | 124 |
| 128 | 125 |
| 129 void CompleteParserRecorder::LogTwoByteSymbol(int start, | 126 void CompleteParserRecorder::LogTwoByteSymbol(int start, |
| 130 Vector<const uint16_t> literal) { | 127 Vector<const uint16_t> literal) { |
| 131 ASSERT(should_log_symbols_); | |
| 132 int hash = vector_hash(literal); | 128 int hash = vector_hash(literal); |
| 133 LogSymbol(start, hash, false, Vector<const byte>::cast(literal)); | 129 LogSymbol(start, hash, false, Vector<const byte>::cast(literal)); |
| 134 } | 130 } |
| 135 | 131 |
| 136 | 132 |
| 137 void CompleteParserRecorder::LogSymbol(int start, | 133 void CompleteParserRecorder::LogSymbol(int start, |
| 138 int hash, | 134 int hash, |
| 139 bool is_one_byte, | 135 bool is_one_byte, |
| 140 Vector<const byte> literal_bytes) { | 136 Vector<const byte> literal_bytes) { |
| 141 Key key = { is_one_byte, literal_bytes }; | 137 Key key = { is_one_byte, literal_bytes }; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 number &= mask; | 196 number &= mask; |
| 201 mask >>= 7; | 197 mask >>= 7; |
| 202 i -= 7; | 198 i -= 7; |
| 203 } | 199 } |
| 204 ASSERT(number < (1 << 7)); | 200 ASSERT(number < (1 << 7)); |
| 205 symbol_store_.Add(static_cast<byte>(number)); | 201 symbol_store_.Add(static_cast<byte>(number)); |
| 206 } | 202 } |
| 207 | 203 |
| 208 | 204 |
| 209 } } // namespace v8::internal. | 205 } } // namespace v8::internal. |
| OLD | NEW |