| 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 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1424 uint32_t String::length_field() { | 1424 uint32_t String::length_field() { |
| 1425 return READ_UINT32_FIELD(this, kLengthOffset); | 1425 return READ_UINT32_FIELD(this, kLengthOffset); |
| 1426 } | 1426 } |
| 1427 | 1427 |
| 1428 | 1428 |
| 1429 void String::set_length_field(uint32_t value) { | 1429 void String::set_length_field(uint32_t value) { |
| 1430 WRITE_UINT32_FIELD(this, kLengthOffset, value); | 1430 WRITE_UINT32_FIELD(this, kLengthOffset, value); |
| 1431 } | 1431 } |
| 1432 | 1432 |
| 1433 | 1433 |
| 1434 void String::TryFlatten(StringShape shape) { | 1434 Object* String::TryFlattenIfNotFlat(StringShape shape) { |
| 1435 ASSERT(shape.type() == StringShape(this).type()); | 1435 ASSERT(shape.type() == StringShape(this).type()); |
| 1436 // We don't need to flatten strings that are already flat. Since this code | 1436 // We don't need to flatten strings that are already flat. Since this code |
| 1437 // is inlined, it can be helpful in the flat case to not call out to Flatten. | 1437 // is inlined, it can be helpful in the flat case to not call out to Flatten. |
| 1438 if (!IsFlat(shape)) { | 1438 if (!IsFlat(shape)) { |
| 1439 Flatten(shape); | 1439 return TryFlatten(shape); |
| 1440 } | 1440 } |
| 1441 return this; |
| 1441 } | 1442 } |
| 1442 | 1443 |
| 1443 | 1444 |
| 1444 uint16_t String::Get(StringShape shape, int index) { | 1445 uint16_t String::Get(StringShape shape, int index) { |
| 1445 ASSERT(shape.type() == StringShape(this).type()); | 1446 ASSERT(shape.type() == StringShape(this).type()); |
| 1446 ASSERT(index >= 0 && index < length(shape)); | 1447 ASSERT(index >= 0 && index < length(shape)); |
| 1447 switch (shape.full_representation_tag()) { | 1448 switch (shape.full_representation_tag()) { |
| 1448 case kSeqStringTag | kAsciiStringTag: | 1449 case kSeqStringTag | kAsciiStringTag: |
| 1449 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); | 1450 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); |
| 1450 case kSeqStringTag | kTwoByteStringTag: | 1451 case kSeqStringTag | kTwoByteStringTag: |
| (...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2494 #undef WRITE_INT_FIELD | 2495 #undef WRITE_INT_FIELD |
| 2495 #undef READ_SHORT_FIELD | 2496 #undef READ_SHORT_FIELD |
| 2496 #undef WRITE_SHORT_FIELD | 2497 #undef WRITE_SHORT_FIELD |
| 2497 #undef READ_BYTE_FIELD | 2498 #undef READ_BYTE_FIELD |
| 2498 #undef WRITE_BYTE_FIELD | 2499 #undef WRITE_BYTE_FIELD |
| 2499 | 2500 |
| 2500 | 2501 |
| 2501 } } // namespace v8::internal | 2502 } } // namespace v8::internal |
| 2502 | 2503 |
| 2503 #endif // V8_OBJECTS_INL_H_ | 2504 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |