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 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1684 bool String::Equals(String* other) { | 1684 bool String::Equals(String* other) { |
1685 if (other == this) return true; | 1685 if (other == this) return true; |
1686 if (StringShape(this).IsSymbol() && StringShape(other).IsSymbol()) { | 1686 if (StringShape(this).IsSymbol() && StringShape(other).IsSymbol()) { |
1687 return false; | 1687 return false; |
1688 } | 1688 } |
1689 return SlowEquals(other); | 1689 return SlowEquals(other); |
1690 } | 1690 } |
1691 | 1691 |
1692 | 1692 |
1693 Object* String::TryFlatten(PretenureFlag pretenure) { | 1693 Object* String::TryFlatten(PretenureFlag pretenure) { |
1694 // We don't need to flatten strings that are already flat. Since this code | 1694 if (!StringShape(this).IsCons()) return this; |
Mads Ager (chromium)
2010/05/19 12:27:43
StringShapes should be deprecated, they were a fai
| |
1695 // is inlined, it can be helpful in the flat case to not call out to Flatten. | 1695 ConsString* cons = ConsString::cast(this); |
1696 if (IsFlat()) return this; | 1696 if (cons->second()->length() == 0) return cons->first(); |
1697 return SlowTryFlatten(pretenure); | 1697 return SlowTryFlatten(pretenure); |
1698 } | 1698 } |
1699 | 1699 |
1700 | 1700 |
1701 String* String::TryFlattenGetString(PretenureFlag pretenure) { | |
1702 Object* flat = TryFlatten(pretenure); | |
1703 return flat->IsFailure() ? this : String::cast(flat); | |
1704 } | |
1705 | |
1706 | |
1701 uint16_t String::Get(int index) { | 1707 uint16_t String::Get(int index) { |
1702 ASSERT(index >= 0 && index < length()); | 1708 ASSERT(index >= 0 && index < length()); |
1703 switch (StringShape(this).full_representation_tag()) { | 1709 switch (StringShape(this).full_representation_tag()) { |
1704 case kSeqStringTag | kAsciiStringTag: | 1710 case kSeqStringTag | kAsciiStringTag: |
1705 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); | 1711 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); |
1706 case kSeqStringTag | kTwoByteStringTag: | 1712 case kSeqStringTag | kTwoByteStringTag: |
1707 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); | 1713 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); |
1708 case kConsStringTag | kAsciiStringTag: | 1714 case kConsStringTag | kAsciiStringTag: |
1709 case kConsStringTag | kTwoByteStringTag: | 1715 case kConsStringTag | kTwoByteStringTag: |
1710 return ConsString::cast(this)->ConsStringGet(index); | 1716 return ConsString::cast(this)->ConsStringGet(index); |
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3157 #undef WRITE_INT_FIELD | 3163 #undef WRITE_INT_FIELD |
3158 #undef READ_SHORT_FIELD | 3164 #undef READ_SHORT_FIELD |
3159 #undef WRITE_SHORT_FIELD | 3165 #undef WRITE_SHORT_FIELD |
3160 #undef READ_BYTE_FIELD | 3166 #undef READ_BYTE_FIELD |
3161 #undef WRITE_BYTE_FIELD | 3167 #undef WRITE_BYTE_FIELD |
3162 | 3168 |
3163 | 3169 |
3164 } } // namespace v8::internal | 3170 } } // namespace v8::internal |
3165 | 3171 |
3166 #endif // V8_OBJECTS_INL_H_ | 3172 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |