| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3039 bool Name::Equals(Name* other) { | 3039 bool Name::Equals(Name* other) { |
| 3040 if (other == this) return true; | 3040 if (other == this) return true; |
| 3041 if ((this->IsInternalizedString() && other->IsInternalizedString()) || | 3041 if ((this->IsInternalizedString() && other->IsInternalizedString()) || |
| 3042 this->IsSymbol() || other->IsSymbol()) { | 3042 this->IsSymbol() || other->IsSymbol()) { |
| 3043 return false; | 3043 return false; |
| 3044 } | 3044 } |
| 3045 return String::cast(this)->SlowEquals(String::cast(other)); | 3045 return String::cast(this)->SlowEquals(String::cast(other)); |
| 3046 } | 3046 } |
| 3047 | 3047 |
| 3048 | 3048 |
| 3049 bool Name::Equals(Handle<Name> one, Handle<Name> two) { |
| 3050 if (one.is_identical_to(two)) return true; |
| 3051 if ((one->IsInternalizedString() && two->IsInternalizedString()) || |
| 3052 one->IsSymbol() || two->IsSymbol()) { |
| 3053 return false; |
| 3054 } |
| 3055 return String::SlowEquals(Handle<String>::cast(one), |
| 3056 Handle<String>::cast(two)); |
| 3057 } |
| 3058 |
| 3059 |
| 3049 ACCESSORS(Symbol, name, Object, kNameOffset) | 3060 ACCESSORS(Symbol, name, Object, kNameOffset) |
| 3050 ACCESSORS(Symbol, flags, Smi, kFlagsOffset) | 3061 ACCESSORS(Symbol, flags, Smi, kFlagsOffset) |
| 3051 BOOL_ACCESSORS(Symbol, flags, is_private, kPrivateBit) | 3062 BOOL_ACCESSORS(Symbol, flags, is_private, kPrivateBit) |
| 3052 | 3063 |
| 3053 | 3064 |
| 3054 bool String::Equals(String* other) { | 3065 bool String::Equals(String* other) { |
| 3055 if (other == this) return true; | 3066 if (other == this) return true; |
| 3056 if (this->IsInternalizedString() && other->IsInternalizedString()) { | 3067 if (this->IsInternalizedString() && other->IsInternalizedString()) { |
| 3057 return false; | 3068 return false; |
| 3058 } | 3069 } |
| 3059 return SlowEquals(other); | 3070 return SlowEquals(other); |
| 3060 } | 3071 } |
| 3061 | 3072 |
| 3062 | 3073 |
| 3074 bool String::Equals(Handle<String> one, Handle<String> two) { |
| 3075 if (one.is_identical_to(two)) return true; |
| 3076 if (one->IsInternalizedString() && two->IsInternalizedString()) { |
| 3077 return false; |
| 3078 } |
| 3079 return SlowEquals(one, two); |
| 3080 } |
| 3081 |
| 3082 |
| 3063 Handle<String> String::Flatten(Handle<String> string, PretenureFlag pretenure) { | 3083 Handle<String> String::Flatten(Handle<String> string, PretenureFlag pretenure) { |
| 3064 if (!string->IsConsString()) return string; | 3084 if (!string->IsConsString()) return string; |
| 3065 Handle<ConsString> cons = Handle<ConsString>::cast(string); | 3085 Handle<ConsString> cons = Handle<ConsString>::cast(string); |
| 3066 if (cons->IsFlat()) return handle(cons->first()); | 3086 if (cons->IsFlat()) return handle(cons->first()); |
| 3067 return SlowFlatten(cons, pretenure); | 3087 return SlowFlatten(cons, pretenure); |
| 3068 } | 3088 } |
| 3069 | 3089 |
| 3070 | 3090 |
| 3071 MaybeObject* String::TryFlatten(PretenureFlag pretenure) { | |
| 3072 if (!StringShape(this).IsCons()) return this; | |
| 3073 ConsString* cons = ConsString::cast(this); | |
| 3074 if (cons->IsFlat()) return cons->first(); | |
| 3075 return SlowTryFlatten(pretenure); | |
| 3076 } | |
| 3077 | |
| 3078 | |
| 3079 String* String::TryFlattenGetString(PretenureFlag pretenure) { | |
| 3080 MaybeObject* flat = TryFlatten(pretenure); | |
| 3081 Object* successfully_flattened; | |
| 3082 if (!flat->ToObject(&successfully_flattened)) return this; | |
| 3083 return String::cast(successfully_flattened); | |
| 3084 } | |
| 3085 | |
| 3086 | |
| 3087 uint16_t String::Get(int index) { | 3091 uint16_t String::Get(int index) { |
| 3088 ASSERT(index >= 0 && index < length()); | 3092 ASSERT(index >= 0 && index < length()); |
| 3089 switch (StringShape(this).full_representation_tag()) { | 3093 switch (StringShape(this).full_representation_tag()) { |
| 3090 case kSeqStringTag | kOneByteStringTag: | 3094 case kSeqStringTag | kOneByteStringTag: |
| 3091 return SeqOneByteString::cast(this)->SeqOneByteStringGet(index); | 3095 return SeqOneByteString::cast(this)->SeqOneByteStringGet(index); |
| 3092 case kSeqStringTag | kTwoByteStringTag: | 3096 case kSeqStringTag | kTwoByteStringTag: |
| 3093 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); | 3097 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); |
| 3094 case kConsStringTag | kOneByteStringTag: | 3098 case kConsStringTag | kOneByteStringTag: |
| 3095 case kConsStringTag | kTwoByteStringTag: | 3099 case kConsStringTag | kTwoByteStringTag: |
| 3096 return ConsString::cast(this)->ConsStringGet(index); | 3100 return ConsString::cast(this)->ConsStringGet(index); |
| (...skipping 3863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6960 #undef READ_UINT32_FIELD | 6964 #undef READ_UINT32_FIELD |
| 6961 #undef WRITE_UINT32_FIELD | 6965 #undef WRITE_UINT32_FIELD |
| 6962 #undef READ_SHORT_FIELD | 6966 #undef READ_SHORT_FIELD |
| 6963 #undef WRITE_SHORT_FIELD | 6967 #undef WRITE_SHORT_FIELD |
| 6964 #undef READ_BYTE_FIELD | 6968 #undef READ_BYTE_FIELD |
| 6965 #undef WRITE_BYTE_FIELD | 6969 #undef WRITE_BYTE_FIELD |
| 6966 | 6970 |
| 6967 } } // namespace v8::internal | 6971 } } // namespace v8::internal |
| 6968 | 6972 |
| 6969 #endif // V8_OBJECTS_INL_H_ | 6973 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |