Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 3572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3583 // Support for StringInputBuffer. | 3583 // Support for StringInputBuffer. |
| 3584 void ExternalTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 3584 void ExternalTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
| 3585 unsigned* offset_ptr, | 3585 unsigned* offset_ptr, |
| 3586 unsigned chars); | 3586 unsigned chars); |
| 3587 | 3587 |
| 3588 private: | 3588 private: |
| 3589 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString); | 3589 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString); |
| 3590 }; | 3590 }; |
| 3591 | 3591 |
| 3592 | 3592 |
| 3593 class FlatStringReader { | |
| 3594 public: | |
| 3595 explicit FlatStringReader(Handle<String> str); | |
|
Erik Corry
2008/11/19 09:45:38
FlatStringReaders can only be stack allocated, rig
| |
| 3596 explicit FlatStringReader(Vector<const char> input); | |
| 3597 ~FlatStringReader(); | |
| 3598 void RefreshState(); | |
| 3599 inline uc32 Get(int index); | |
| 3600 int length() { return length_; } | |
| 3601 static void PostGarbageCollectionProcessing(); | |
| 3602 private: | |
| 3603 String** str_; | |
| 3604 bool is_ascii_; | |
| 3605 int length_; | |
| 3606 const void* start_; | |
| 3607 FlatStringReader* prev_; | |
| 3608 static FlatStringReader* top_; | |
| 3609 }; | |
| 3610 | |
| 3611 | |
| 3593 // Note that StringInputBuffers are not valid across a GC! To fix this | 3612 // Note that StringInputBuffers are not valid across a GC! To fix this |
| 3594 // it would have to store a String Handle instead of a String* and | 3613 // it would have to store a String Handle instead of a String* and |
| 3595 // AsciiStringReadBlock would have to be modified to use memcpy. | 3614 // AsciiStringReadBlock would have to be modified to use memcpy. |
| 3596 // | 3615 // |
| 3597 // StringInputBuffer is able to traverse any string regardless of how | 3616 // StringInputBuffer is able to traverse any string regardless of how |
| 3598 // deeply nested a sequence of ConsStrings it is made of. However, | 3617 // deeply nested a sequence of ConsStrings it is made of. However, |
| 3599 // performance will be better if deep strings are flattened before they | 3618 // performance will be better if deep strings are flattened before they |
| 3600 // are traversed. Since flattening requires memory allocation this is | 3619 // are traversed. Since flattening requires memory allocation this is |
| 3601 // not always desirable, however (esp. in debugging situations). | 3620 // not always desirable, however (esp. in debugging situations). |
| 3602 class StringInputBuffer: public unibrow::InputBuffer<String, String*, 1024> { | 3621 class StringInputBuffer: public unibrow::InputBuffer<String, String*, 1024> { |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4177 } else { | 4196 } else { |
| 4178 value &= ~(1 << bit_position); | 4197 value &= ~(1 << bit_position); |
| 4179 } | 4198 } |
| 4180 return value; | 4199 return value; |
| 4181 } | 4200 } |
| 4182 }; | 4201 }; |
| 4183 | 4202 |
| 4184 } } // namespace v8::internal | 4203 } } // namespace v8::internal |
| 4185 | 4204 |
| 4186 #endif // V8_OBJECTS_H_ | 4205 #endif // V8_OBJECTS_H_ |
| OLD | NEW |