| 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 "include/v8stdint.h" | 5 #include "include/v8stdint.h" |
| 6 #include "src/base/logging.h" | 6 #include "src/base/logging.h" |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/globals.h" | 8 #include "src/globals.h" |
| 9 #include "src/hashmap.h" | 9 #include "src/hashmap.h" |
| 10 #include "src/preparse-data.h" | 10 #include "src/preparse-data.h" |
| 11 #include "src/preparse-data-format.h" | 11 #include "src/preparse-data-format.h" |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 | 15 |
| 16 | 16 |
| 17 CompleteParserRecorder::CompleteParserRecorder() | 17 CompleteParserRecorder::CompleteParserRecorder() |
| 18 : function_store_(0) { | 18 : function_store_(0) { |
| 19 preamble_[PreparseDataConstants::kMagicOffset] = | 19 preamble_[PreparseDataConstants::kMagicOffset] = |
| 20 PreparseDataConstants::kMagicNumber; | 20 PreparseDataConstants::kMagicNumber; |
| 21 preamble_[PreparseDataConstants::kVersionOffset] = | 21 preamble_[PreparseDataConstants::kVersionOffset] = |
| 22 PreparseDataConstants::kCurrentVersion; | 22 PreparseDataConstants::kCurrentVersion; |
| 23 preamble_[PreparseDataConstants::kHasErrorOffset] = false; | 23 preamble_[PreparseDataConstants::kHasErrorOffset] = false; |
| 24 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = 0; | 24 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = 0; |
| 25 preamble_[PreparseDataConstants::kSizeOffset] = 0; | 25 preamble_[PreparseDataConstants::kSizeOffset] = 0; |
| 26 ASSERT_EQ(5, PreparseDataConstants::kHeaderSize); | 26 DCHECK_EQ(5, PreparseDataConstants::kHeaderSize); |
| 27 #ifdef DEBUG | 27 #ifdef DEBUG |
| 28 prev_start_ = -1; | 28 prev_start_ = -1; |
| 29 #endif | 29 #endif |
| 30 } | 30 } |
| 31 | 31 |
| 32 | 32 |
| 33 void CompleteParserRecorder::LogMessage(int start_pos, | 33 void CompleteParserRecorder::LogMessage(int start_pos, |
| 34 int end_pos, | 34 int end_pos, |
| 35 const char* message, | 35 const char* message, |
| 36 const char* arg_opt, | 36 const char* arg_opt, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 63 ScriptData* CompleteParserRecorder::GetScriptData() { | 63 ScriptData* CompleteParserRecorder::GetScriptData() { |
| 64 int function_size = function_store_.size(); | 64 int function_size = function_store_.size(); |
| 65 int total_size = PreparseDataConstants::kHeaderSize + function_size; | 65 int total_size = PreparseDataConstants::kHeaderSize + function_size; |
| 66 unsigned* data = NewArray<unsigned>(total_size); | 66 unsigned* data = NewArray<unsigned>(total_size); |
| 67 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = function_size; | 67 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = function_size; |
| 68 MemCopy(data, preamble_, sizeof(preamble_)); | 68 MemCopy(data, preamble_, sizeof(preamble_)); |
| 69 if (function_size > 0) { | 69 if (function_size > 0) { |
| 70 function_store_.WriteTo(Vector<unsigned>( | 70 function_store_.WriteTo(Vector<unsigned>( |
| 71 data + PreparseDataConstants::kHeaderSize, function_size)); | 71 data + PreparseDataConstants::kHeaderSize, function_size)); |
| 72 } | 72 } |
| 73 ASSERT(IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)); | 73 DCHECK(IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)); |
| 74 ScriptData* result = new ScriptData(reinterpret_cast<byte*>(data), | 74 ScriptData* result = new ScriptData(reinterpret_cast<byte*>(data), |
| 75 total_size * sizeof(unsigned)); | 75 total_size * sizeof(unsigned)); |
| 76 result->AcquireDataOwnership(); | 76 result->AcquireDataOwnership(); |
| 77 return result; | 77 return result; |
| 78 } | 78 } |
| 79 | 79 |
| 80 | 80 |
| 81 } } // namespace v8::internal. | 81 } } // namespace v8::internal. |
| OLD | NEW |