OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 static const int kMinConversionSlack = 256; | 208 static const int kMinConversionSlack = 256; |
209 static const int kMaxGrowth = 1 * MB; | 209 static const int kMaxGrowth = 1 * MB; |
210 inline int NewCapacity(int min_capacity) { | 210 inline int NewCapacity(int min_capacity) { |
211 int capacity = Max(min_capacity, backing_store_.length()); | 211 int capacity = Max(min_capacity, backing_store_.length()); |
212 int new_capacity = Min(capacity * kGrowthFactory, capacity + kMaxGrowth); | 212 int new_capacity = Min(capacity * kGrowthFactory, capacity + kMaxGrowth); |
213 return new_capacity; | 213 return new_capacity; |
214 } | 214 } |
215 | 215 |
216 void ExpandBuffer() { | 216 void ExpandBuffer() { |
217 Vector<byte> new_store = Vector<byte>::New(NewCapacity(kInitialCapacity)); | 217 Vector<byte> new_store = Vector<byte>::New(NewCapacity(kInitialCapacity)); |
218 memcpy(new_store.start(), backing_store_.start(), position_); | 218 OS::MemCopy(new_store.start(), backing_store_.start(), position_); |
219 backing_store_.Dispose(); | 219 backing_store_.Dispose(); |
220 backing_store_ = new_store; | 220 backing_store_ = new_store; |
221 } | 221 } |
222 | 222 |
223 void ConvertToUtf16() { | 223 void ConvertToUtf16() { |
224 ASSERT(is_ascii_); | 224 ASSERT(is_ascii_); |
225 Vector<byte> new_store; | 225 Vector<byte> new_store; |
226 int new_content_size = position_ * kUC16Size; | 226 int new_content_size = position_ * kUC16Size; |
227 if (new_content_size >= backing_store_.length()) { | 227 if (new_content_size >= backing_store_.length()) { |
228 // Ensure room for all currently read code units as UC16 as well | 228 // Ensure room for all currently read code units as UC16 as well |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 bool has_multiline_comment_before_next_; | 542 bool has_multiline_comment_before_next_; |
543 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings. | 543 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings. |
544 bool harmony_scoping_; | 544 bool harmony_scoping_; |
545 // Whether we scan 'module', 'import', 'export' as keywords. | 545 // Whether we scan 'module', 'import', 'export' as keywords. |
546 bool harmony_modules_; | 546 bool harmony_modules_; |
547 }; | 547 }; |
548 | 548 |
549 } } // namespace v8::internal | 549 } } // namespace v8::internal |
550 | 550 |
551 #endif // V8_SCANNER_H_ | 551 #endif // V8_SCANNER_H_ |
OLD | NEW |