OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 3983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3994 // Such strings may appear when the embedder prefers two-byte | 3994 // Such strings may appear when the embedder prefers two-byte |
3995 // representations even for ascii data. | 3995 // representations even for ascii data. |
3996 inline bool IsExternalTwoByteStringWithAsciiChars(); | 3996 inline bool IsExternalTwoByteStringWithAsciiChars(); |
3997 | 3997 |
3998 // Get and set individual two byte chars in the string. | 3998 // Get and set individual two byte chars in the string. |
3999 inline void Set(int index, uint16_t value); | 3999 inline void Set(int index, uint16_t value); |
4000 // Get individual two byte char in the string. Repeated calls | 4000 // Get individual two byte char in the string. Repeated calls |
4001 // to this method are not efficient unless the string is flat. | 4001 // to this method are not efficient unless the string is flat. |
4002 inline uint16_t Get(int index); | 4002 inline uint16_t Get(int index); |
4003 | 4003 |
4004 // Try to flatten the top level ConsString that is hiding behind this | 4004 // Try to flatten the string. Checks first inline to see if it is |
4005 // string. This is a no-op unless the string is a ConsString. Flatten | 4005 // necessary. Does nothing if the string is not a cons string. |
4006 // mutates the ConsString and might return a failure. | 4006 // Flattening allocates a sequential string with the same data as |
4007 Object* SlowTryFlatten(PretenureFlag pretenure); | 4007 // the given string and mutates the cons string to a degenerate |
| 4008 // form, where the first component is the new sequential string and |
| 4009 // the second component is the empty string. If allocation fails, |
| 4010 // this function returns a failure. If flattening succeeds, this |
| 4011 // function returns the sequential string that is now the first |
| 4012 // component of the cons string. |
| 4013 // |
| 4014 // Degenerate cons strings are handled specially by the garbage |
| 4015 // collector (see IsShortcutCandidate). |
| 4016 // |
| 4017 // Use FlattenString from Handles.cc to flatten even in case an |
| 4018 // allocation failure happens. |
| 4019 inline Object* TryFlatten(PretenureFlag pretenure = NOT_TENURED); |
4008 | 4020 |
4009 // Try to flatten the string. Checks first inline to see if it is necessary. | 4021 // Convenience function. Has exactly the same behavior as |
4010 // Do not handle allocation failures. After calling TryFlatten, the | 4022 // TryFlatten(), except in the case of failure returns the original |
4011 // string could still be a ConsString, in which case a failure is returned. | 4023 // string. |
4012 // Use FlattenString from Handles.cc to be sure to flatten. | 4024 inline String* TryFlattenGetString(PretenureFlag pretenure = NOT_TENURED); |
4013 inline Object* TryFlatten(PretenureFlag pretenure = NOT_TENURED); | |
4014 | 4025 |
4015 Vector<const char> ToAsciiVector(); | 4026 Vector<const char> ToAsciiVector(); |
4016 Vector<const uc16> ToUC16Vector(); | 4027 Vector<const uc16> ToUC16Vector(); |
4017 | 4028 |
4018 // Mark the string as an undetectable object. It only applies to | 4029 // Mark the string as an undetectable object. It only applies to |
4019 // ascii and two byte string types. | 4030 // ascii and two byte string types. |
4020 bool MarkAsUndetectable(); | 4031 bool MarkAsUndetectable(); |
4021 | 4032 |
4022 // Return a substring. | 4033 // Return a substring. |
4023 Object* SubString(int from, int to, PretenureFlag pretenure = NOT_TENURED); | 4034 Object* SubString(int from, int to, PretenureFlag pretenure = NOT_TENURED); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4190 static inline const unibrow::byte* ReadBlock(String* input, | 4201 static inline const unibrow::byte* ReadBlock(String* input, |
4191 ReadBlockBuffer* buffer, | 4202 ReadBlockBuffer* buffer, |
4192 unsigned* offset, | 4203 unsigned* offset, |
4193 unsigned max_chars); | 4204 unsigned max_chars); |
4194 static void ReadBlockIntoBuffer(String* input, | 4205 static void ReadBlockIntoBuffer(String* input, |
4195 ReadBlockBuffer* buffer, | 4206 ReadBlockBuffer* buffer, |
4196 unsigned* offset_ptr, | 4207 unsigned* offset_ptr, |
4197 unsigned max_chars); | 4208 unsigned max_chars); |
4198 | 4209 |
4199 private: | 4210 private: |
| 4211 // Try to flatten the top level ConsString that is hiding behind this |
| 4212 // string. This is a no-op unless the string is a ConsString. Flatten |
| 4213 // mutates the ConsString and might return a failure. |
| 4214 Object* SlowTryFlatten(PretenureFlag pretenure); |
| 4215 |
4200 // Slow case of String::Equals. This implementation works on any strings | 4216 // Slow case of String::Equals. This implementation works on any strings |
4201 // but it is most efficient on strings that are almost flat. | 4217 // but it is most efficient on strings that are almost flat. |
4202 bool SlowEquals(String* other); | 4218 bool SlowEquals(String* other); |
4203 | 4219 |
4204 // Slow case of AsArrayIndex. | 4220 // Slow case of AsArrayIndex. |
4205 bool SlowAsArrayIndex(uint32_t* index); | 4221 bool SlowAsArrayIndex(uint32_t* index); |
4206 | 4222 |
4207 // Compute and set the hash code. | 4223 // Compute and set the hash code. |
4208 uint32_t ComputeAndSetHash(); | 4224 uint32_t ComputeAndSetHash(); |
4209 | 4225 |
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5163 } else { | 5179 } else { |
5164 value &= ~(1 << bit_position); | 5180 value &= ~(1 << bit_position); |
5165 } | 5181 } |
5166 return value; | 5182 return value; |
5167 } | 5183 } |
5168 }; | 5184 }; |
5169 | 5185 |
5170 } } // namespace v8::internal | 5186 } } // namespace v8::internal |
5171 | 5187 |
5172 #endif // V8_OBJECTS_H_ | 5188 #endif // V8_OBJECTS_H_ |
OLD | NEW |