OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 // Features shared by parsing and pre-parsing scanners. | 5 // Features shared by parsing and pre-parsing scanners. |
6 | 6 |
7 #ifndef V8_SCANNER_H_ | 7 #ifndef V8_SCANNER_H_ |
8 #define V8_SCANNER_H_ | 8 #define V8_SCANNER_H_ |
9 | 9 |
10 #include "allocation.h" | 10 #include "allocation.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 static const int kMinConversionSlack = 256; | 251 static const int kMinConversionSlack = 256; |
252 static const int kMaxGrowth = 1 * MB; | 252 static const int kMaxGrowth = 1 * MB; |
253 inline int NewCapacity(int min_capacity) { | 253 inline int NewCapacity(int min_capacity) { |
254 int capacity = Max(min_capacity, backing_store_.length()); | 254 int capacity = Max(min_capacity, backing_store_.length()); |
255 int new_capacity = Min(capacity * kGrowthFactory, capacity + kMaxGrowth); | 255 int new_capacity = Min(capacity * kGrowthFactory, capacity + kMaxGrowth); |
256 return new_capacity; | 256 return new_capacity; |
257 } | 257 } |
258 | 258 |
259 void ExpandBuffer() { | 259 void ExpandBuffer() { |
260 Vector<byte> new_store = Vector<byte>::New(NewCapacity(kInitialCapacity)); | 260 Vector<byte> new_store = Vector<byte>::New(NewCapacity(kInitialCapacity)); |
261 OS::MemCopy(new_store.start(), backing_store_.start(), position_); | 261 MemCopy(new_store.start(), backing_store_.start(), position_); |
262 backing_store_.Dispose(); | 262 backing_store_.Dispose(); |
263 backing_store_ = new_store; | 263 backing_store_ = new_store; |
264 } | 264 } |
265 | 265 |
266 void ConvertToTwoByte() { | 266 void ConvertToTwoByte() { |
267 ASSERT(is_one_byte_); | 267 ASSERT(is_one_byte_); |
268 Vector<byte> new_store; | 268 Vector<byte> new_store; |
269 int new_content_size = position_ * kUC16Size; | 269 int new_content_size = position_ * kUC16Size; |
270 if (new_content_size >= backing_store_.length()) { | 270 if (new_content_size >= backing_store_.length()) { |
271 // Ensure room for all currently read code units as UC16 as well | 271 // Ensure room for all currently read code units as UC16 as well |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 bool harmony_scoping_; | 629 bool harmony_scoping_; |
630 // Whether we scan 'module', 'import', 'export' as keywords. | 630 // Whether we scan 'module', 'import', 'export' as keywords. |
631 bool harmony_modules_; | 631 bool harmony_modules_; |
632 // Whether we scan 0o777 and 0b111 as numbers. | 632 // Whether we scan 0o777 and 0b111 as numbers. |
633 bool harmony_numeric_literals_; | 633 bool harmony_numeric_literals_; |
634 }; | 634 }; |
635 | 635 |
636 } } // namespace v8::internal | 636 } } // namespace v8::internal |
637 | 637 |
638 #endif // V8_SCANNER_H_ | 638 #endif // V8_SCANNER_H_ |
OLD | NEW |