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/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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 | 53 |
54 void CompleteParserRecorder::WriteString(Vector<const char> str) { | 54 void CompleteParserRecorder::WriteString(Vector<const char> str) { |
55 function_store_.Add(str.length()); | 55 function_store_.Add(str.length()); |
56 for (int i = 0; i < str.length(); i++) { | 56 for (int i = 0; i < str.length(); i++) { |
57 function_store_.Add(str[i]); | 57 function_store_.Add(str[i]); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 | 61 |
62 Vector<unsigned> CompleteParserRecorder::ExtractData() { | 62 ScriptData* CompleteParserRecorder::GetScriptData() { |
63 int function_size = function_store_.size(); | 63 int function_size = function_store_.size(); |
64 int total_size = PreparseDataConstants::kHeaderSize + function_size; | 64 int total_size = PreparseDataConstants::kHeaderSize + function_size; |
65 Vector<unsigned> data = Vector<unsigned>::New(total_size); | 65 unsigned* data = NewArray<unsigned>(total_size); |
66 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = function_size; | 66 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = function_size; |
67 MemCopy(data.start(), preamble_, sizeof(preamble_)); | 67 MemCopy(data, preamble_, sizeof(preamble_)); |
68 if (function_size > 0) { | 68 if (function_size > 0) { |
69 function_store_.WriteTo(data.SubVector(PreparseDataConstants::kHeaderSize, | 69 function_store_.WriteTo(Vector<unsigned>( |
70 total_size)); | 70 data + PreparseDataConstants::kHeaderSize, function_size)); |
71 } | 71 } |
72 return data; | 72 ASSERT(IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)); |
| 73 ScriptData* result = new ScriptData(reinterpret_cast<byte*>(data), |
| 74 total_size * sizeof(unsigned)); |
| 75 result->AcquireDataOwnership(); |
| 76 return result; |
73 } | 77 } |
74 | 78 |
75 | 79 |
76 } } // namespace v8::internal. | 80 } } // namespace v8::internal. |
OLD | NEW |