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/compiler.h" | 6 #include "src/compiler.h" |
7 #include "src/globals.h" | 7 #include "src/globals.h" |
8 #include "src/hashmap.h" | 8 #include "src/hashmap.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 10 matching lines...) Expand all Loading... |
21 preamble_[PreparseDataConstants::kHasErrorOffset] = false; | 21 preamble_[PreparseDataConstants::kHasErrorOffset] = false; |
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, | 31 void CompleteParserRecorder::LogMessage(int start_pos, int end_pos, |
32 int end_pos, | |
33 const char* message, | 32 const char* message, |
34 const char* arg_opt, | 33 const char* arg_opt, |
35 bool is_reference_error) { | 34 ParseErrorType error_type) { |
36 if (HasError()) return; | 35 if (HasError()) return; |
37 preamble_[PreparseDataConstants::kHasErrorOffset] = true; | 36 preamble_[PreparseDataConstants::kHasErrorOffset] = true; |
38 function_store_.Reset(); | 37 function_store_.Reset(); |
39 STATIC_ASSERT(PreparseDataConstants::kMessageStartPos == 0); | 38 STATIC_ASSERT(PreparseDataConstants::kMessageStartPos == 0); |
40 function_store_.Add(start_pos); | 39 function_store_.Add(start_pos); |
41 STATIC_ASSERT(PreparseDataConstants::kMessageEndPos == 1); | 40 STATIC_ASSERT(PreparseDataConstants::kMessageEndPos == 1); |
42 function_store_.Add(end_pos); | 41 function_store_.Add(end_pos); |
43 STATIC_ASSERT(PreparseDataConstants::kMessageArgCountPos == 2); | 42 STATIC_ASSERT(PreparseDataConstants::kMessageArgCountPos == 2); |
44 function_store_.Add((arg_opt == NULL) ? 0 : 1); | 43 function_store_.Add((arg_opt == NULL) ? 0 : 1); |
45 STATIC_ASSERT(PreparseDataConstants::kIsReferenceErrorPos == 3); | 44 STATIC_ASSERT(PreparseDataConstants::kParseErrorTypePos == 3); |
46 function_store_.Add(is_reference_error ? 1 : 0); | 45 function_store_.Add(error_type); |
47 STATIC_ASSERT(PreparseDataConstants::kMessageTextPos == 4); | 46 STATIC_ASSERT(PreparseDataConstants::kMessageTextPos == 4); |
48 WriteString(CStrVector(message)); | 47 WriteString(CStrVector(message)); |
49 if (arg_opt != NULL) WriteString(CStrVector(arg_opt)); | 48 if (arg_opt != NULL) WriteString(CStrVector(arg_opt)); |
50 } | 49 } |
51 | 50 |
52 | 51 |
53 void CompleteParserRecorder::WriteString(Vector<const char> str) { | 52 void CompleteParserRecorder::WriteString(Vector<const char> str) { |
54 function_store_.Add(str.length()); | 53 function_store_.Add(str.length()); |
55 for (int i = 0; i < str.length(); i++) { | 54 for (int i = 0; i < str.length(); i++) { |
56 function_store_.Add(str[i]); | 55 function_store_.Add(str[i]); |
(...skipping 13 matching lines...) Expand all Loading... |
70 } | 69 } |
71 DCHECK(IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)); | 70 DCHECK(IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)); |
72 ScriptData* result = new ScriptData(reinterpret_cast<byte*>(data), | 71 ScriptData* result = new ScriptData(reinterpret_cast<byte*>(data), |
73 total_size * sizeof(unsigned)); | 72 total_size * sizeof(unsigned)); |
74 result->AcquireDataOwnership(); | 73 result->AcquireDataOwnership(); |
75 return result; | 74 return result; |
76 } | 75 } |
77 | 76 |
78 | 77 |
79 } } // namespace v8::internal. | 78 } } // namespace v8::internal. |
OLD | NEW |