| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/base/logging.h" | 5 #include "src/base/logging.h" |
| 6 #include "src/globals.h" | 6 #include "src/globals.h" |
| 7 #include "src/hashmap.h" | 7 #include "src/hashmap.h" |
| 8 #include "src/parser.h" | 8 #include "src/parser.h" |
| 9 #include "src/preparse-data.h" | 9 #include "src/preparse-data.h" |
| 10 #include "src/preparse-data-format.h" | 10 #include "src/preparse-data-format.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = 0; | 22 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = 0; |
| 23 preamble_[PreparseDataConstants::kSizeOffset] = 0; | 23 preamble_[PreparseDataConstants::kSizeOffset] = 0; |
| 24 DCHECK_EQ(5, PreparseDataConstants::kHeaderSize); | 24 DCHECK_EQ(5, PreparseDataConstants::kHeaderSize); |
| 25 #ifdef DEBUG | 25 #ifdef DEBUG |
| 26 prev_start_ = -1; | 26 prev_start_ = -1; |
| 27 #endif | 27 #endif |
| 28 } | 28 } |
| 29 | 29 |
| 30 | 30 |
| 31 void CompleteParserRecorder::LogMessage(int start_pos, int end_pos, | 31 void CompleteParserRecorder::LogMessage(int start_pos, int end_pos, |
| 32 const char* message, | 32 MessageTemplate::Template message, |
| 33 const char* arg_opt, | 33 const char* arg_opt, |
| 34 ParseErrorType error_type) { | 34 ParseErrorType error_type) { |
| 35 if (HasError()) return; | 35 if (HasError()) return; |
| 36 preamble_[PreparseDataConstants::kHasErrorOffset] = true; | 36 preamble_[PreparseDataConstants::kHasErrorOffset] = true; |
| 37 function_store_.Reset(); | 37 function_store_.Reset(); |
| 38 STATIC_ASSERT(PreparseDataConstants::kMessageStartPos == 0); | 38 STATIC_ASSERT(PreparseDataConstants::kMessageStartPos == 0); |
| 39 function_store_.Add(start_pos); | 39 function_store_.Add(start_pos); |
| 40 STATIC_ASSERT(PreparseDataConstants::kMessageEndPos == 1); | 40 STATIC_ASSERT(PreparseDataConstants::kMessageEndPos == 1); |
| 41 function_store_.Add(end_pos); | 41 function_store_.Add(end_pos); |
| 42 STATIC_ASSERT(PreparseDataConstants::kMessageArgCountPos == 2); | 42 STATIC_ASSERT(PreparseDataConstants::kMessageArgCountPos == 2); |
| 43 function_store_.Add((arg_opt == NULL) ? 0 : 1); | 43 function_store_.Add((arg_opt == NULL) ? 0 : 1); |
| 44 STATIC_ASSERT(PreparseDataConstants::kParseErrorTypePos == 3); | 44 STATIC_ASSERT(PreparseDataConstants::kParseErrorTypePos == 3); |
| 45 function_store_.Add(error_type); | 45 function_store_.Add(error_type); |
| 46 STATIC_ASSERT(PreparseDataConstants::kMessageTextPos == 4); | 46 STATIC_ASSERT(PreparseDataConstants::kMessageTemplatePos == 4); |
| 47 WriteString(CStrVector(message)); | 47 function_store_.Add(static_cast<unsigned>(message)); |
| 48 STATIC_ASSERT(PreparseDataConstants::kMessageArgPos == 5); |
| 48 if (arg_opt != NULL) WriteString(CStrVector(arg_opt)); | 49 if (arg_opt != NULL) WriteString(CStrVector(arg_opt)); |
| 49 } | 50 } |
| 50 | 51 |
| 51 | 52 |
| 52 void CompleteParserRecorder::WriteString(Vector<const char> str) { | 53 void CompleteParserRecorder::WriteString(Vector<const char> str) { |
| 53 function_store_.Add(str.length()); | 54 function_store_.Add(str.length()); |
| 54 for (int i = 0; i < str.length(); i++) { | 55 for (int i = 0; i < str.length(); i++) { |
| 55 function_store_.Add(str[i]); | 56 function_store_.Add(str[i]); |
| 56 } | 57 } |
| 57 } | 58 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 69 } | 70 } |
| 70 DCHECK(IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)); | 71 DCHECK(IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)); |
| 71 ScriptData* result = new ScriptData(reinterpret_cast<byte*>(data), | 72 ScriptData* result = new ScriptData(reinterpret_cast<byte*>(data), |
| 72 total_size * sizeof(unsigned)); | 73 total_size * sizeof(unsigned)); |
| 73 result->AcquireDataOwnership(); | 74 result->AcquireDataOwnership(); |
| 74 return result; | 75 return result; |
| 75 } | 76 } |
| 76 | 77 |
| 77 | 78 |
| 78 } } // namespace v8::internal. | 79 } } // namespace v8::internal. |
| OLD | NEW |