| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 // ---------------------------------------------------------------------------- | 89 // ---------------------------------------------------------------------------- |
| 90 // PartialParserRecorder - Record both function entries and symbols. | 90 // PartialParserRecorder - Record both function entries and symbols. |
| 91 | 91 |
| 92 Vector<unsigned> PartialParserRecorder::ExtractData() { | 92 Vector<unsigned> PartialParserRecorder::ExtractData() { |
| 93 int function_size = function_store_.size(); | 93 int function_size = function_store_.size(); |
| 94 int total_size = PreparseDataConstants::kHeaderSize + function_size; | 94 int total_size = PreparseDataConstants::kHeaderSize + function_size; |
| 95 Vector<unsigned> data = Vector<unsigned>::New(total_size); | 95 Vector<unsigned> data = Vector<unsigned>::New(total_size); |
| 96 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = function_size; | 96 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = function_size; |
| 97 preamble_[PreparseDataConstants::kSymbolCountOffset] = 0; | 97 preamble_[PreparseDataConstants::kSymbolCountOffset] = 0; |
| 98 memcpy(data.start(), preamble_, sizeof(preamble_)); | 98 OS::MemCopy(data.start(), preamble_, sizeof(preamble_)); |
| 99 int symbol_start = PreparseDataConstants::kHeaderSize + function_size; | 99 int symbol_start = PreparseDataConstants::kHeaderSize + function_size; |
| 100 if (function_size > 0) { | 100 if (function_size > 0) { |
| 101 function_store_.WriteTo(data.SubVector(PreparseDataConstants::kHeaderSize, | 101 function_store_.WriteTo(data.SubVector(PreparseDataConstants::kHeaderSize, |
| 102 symbol_start)); | 102 symbol_start)); |
| 103 } | 103 } |
| 104 return data; | 104 return data; |
| 105 } | 105 } |
| 106 | 106 |
| 107 | 107 |
| 108 // ---------------------------------------------------------------------------- | 108 // ---------------------------------------------------------------------------- |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Add terminator to symbols, then pad to unsigned size. | 144 // Add terminator to symbols, then pad to unsigned size. |
| 145 int symbol_size = symbol_store_.size(); | 145 int symbol_size = symbol_store_.size(); |
| 146 int padding = sizeof(unsigned) - (symbol_size % sizeof(unsigned)); | 146 int padding = sizeof(unsigned) - (symbol_size % sizeof(unsigned)); |
| 147 symbol_store_.AddBlock(padding, PreparseDataConstants::kNumberTerminator); | 147 symbol_store_.AddBlock(padding, PreparseDataConstants::kNumberTerminator); |
| 148 symbol_size += padding; | 148 symbol_size += padding; |
| 149 int total_size = PreparseDataConstants::kHeaderSize + function_size | 149 int total_size = PreparseDataConstants::kHeaderSize + function_size |
| 150 + (symbol_size / sizeof(unsigned)); | 150 + (symbol_size / sizeof(unsigned)); |
| 151 Vector<unsigned> data = Vector<unsigned>::New(total_size); | 151 Vector<unsigned> data = Vector<unsigned>::New(total_size); |
| 152 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = function_size; | 152 preamble_[PreparseDataConstants::kFunctionsSizeOffset] = function_size; |
| 153 preamble_[PreparseDataConstants::kSymbolCountOffset] = symbol_id_; | 153 preamble_[PreparseDataConstants::kSymbolCountOffset] = symbol_id_; |
| 154 memcpy(data.start(), preamble_, sizeof(preamble_)); | 154 OS::MemCopy(data.start(), preamble_, sizeof(preamble_)); |
| 155 int symbol_start = PreparseDataConstants::kHeaderSize + function_size; | 155 int symbol_start = PreparseDataConstants::kHeaderSize + function_size; |
| 156 if (function_size > 0) { | 156 if (function_size > 0) { |
| 157 function_store_.WriteTo(data.SubVector(PreparseDataConstants::kHeaderSize, | 157 function_store_.WriteTo(data.SubVector(PreparseDataConstants::kHeaderSize, |
| 158 symbol_start)); | 158 symbol_start)); |
| 159 } | 159 } |
| 160 if (!has_error()) { | 160 if (!has_error()) { |
| 161 symbol_store_.WriteTo( | 161 symbol_store_.WriteTo( |
| 162 Vector<byte>::cast(data.SubVector(symbol_start, total_size))); | 162 Vector<byte>::cast(data.SubVector(symbol_start, total_size))); |
| 163 } | 163 } |
| 164 return data; | 164 return data; |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 void CompleteParserRecorder::WriteNumber(int number) { | 168 void CompleteParserRecorder::WriteNumber(int number) { |
| 169 ASSERT(number >= 0); | 169 ASSERT(number >= 0); |
| 170 | 170 |
| 171 int mask = (1 << 28) - 1; | 171 int mask = (1 << 28) - 1; |
| 172 for (int i = 28; i > 0; i -= 7) { | 172 for (int i = 28; i > 0; i -= 7) { |
| 173 if (number > mask) { | 173 if (number > mask) { |
| 174 symbol_store_.Add(static_cast<byte>(number >> i) | 0x80u); | 174 symbol_store_.Add(static_cast<byte>(number >> i) | 0x80u); |
| 175 number &= mask; | 175 number &= mask; |
| 176 } | 176 } |
| 177 mask >>= 7; | 177 mask >>= 7; |
| 178 } | 178 } |
| 179 symbol_store_.Add(static_cast<byte>(number)); | 179 symbol_store_.Add(static_cast<byte>(number)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 | 182 |
| 183 } } // namespace v8::internal. | 183 } } // namespace v8::internal. |
| OLD | NEW |