| 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 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 } | 1314 } |
| 1315 | 1315 |
| 1316 | 1316 |
| 1317 StringRepresentationTag String::map_representation_tag(Map* map) { | 1317 StringRepresentationTag String::map_representation_tag(Map* map) { |
| 1318 uint32_t tag = map->instance_type() & kStringRepresentationMask; | 1318 uint32_t tag = map->instance_type() & kStringRepresentationMask; |
| 1319 return static_cast<StringRepresentationTag>(tag); | 1319 return static_cast<StringRepresentationTag>(tag); |
| 1320 } | 1320 } |
| 1321 | 1321 |
| 1322 | 1322 |
| 1323 bool String::IsFlat() { | 1323 bool String::IsFlat() { |
| 1324 String* current = this; | 1324 switch (this->representation_tag()) { |
| 1325 while (true) { | 1325 case kConsStringTag: |
| 1326 switch (current->representation_tag()) { | 1326 // Only flattened strings have second part empty. |
| 1327 case kConsStringTag: | 1327 return String::cast(ConsString::cast(this)->second())->length() == 0; |
| 1328 return String::cast(ConsString::cast(current)->second())->length() == 0; | 1328 case kSlicedStringTag: { |
| 1329 case kSlicedStringTag: | 1329 String* slice = String::cast(SlicedString::cast(this)->buffer()); |
| 1330 current = String::cast(SlicedString::cast(this)->buffer()); | 1330 StringRepresentationTag tag = slice->representation_tag(); |
| 1331 break; | 1331 return tag == kSeqStringTag || tag == kExternalStringTag; |
| 1332 default: | |
| 1333 return true; | |
| 1334 } | 1332 } |
| 1333 default: |
| 1334 return true; |
| 1335 } | 1335 } |
| 1336 } | 1336 } |
| 1337 | 1337 |
| 1338 | 1338 |
| 1339 uint16_t AsciiString::AsciiStringGet(int index) { | 1339 uint16_t AsciiString::AsciiStringGet(int index) { |
| 1340 ASSERT(index >= 0 && index < length()); | 1340 ASSERT(index >= 0 && index < length()); |
| 1341 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); | 1341 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); |
| 1342 } | 1342 } |
| 1343 | 1343 |
| 1344 | 1344 |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 #undef WRITE_INT_FIELD | 2179 #undef WRITE_INT_FIELD |
| 2180 #undef READ_SHORT_FIELD | 2180 #undef READ_SHORT_FIELD |
| 2181 #undef WRITE_SHORT_FIELD | 2181 #undef WRITE_SHORT_FIELD |
| 2182 #undef READ_BYTE_FIELD | 2182 #undef READ_BYTE_FIELD |
| 2183 #undef WRITE_BYTE_FIELD | 2183 #undef WRITE_BYTE_FIELD |
| 2184 | 2184 |
| 2185 | 2185 |
| 2186 } } // namespace v8::internal | 2186 } } // namespace v8::internal |
| 2187 | 2187 |
| 2188 #endif // V8_OBJECTS_INL_H_ | 2188 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |