| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index 324b10ce2066c5fc0c24fd485813f895557b089c..86b7e844ec0681068b85720cd4291a165f8d6401 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -7622,6 +7622,30 @@ bool String::SlowAsArrayIndex(uint32_t* index) {
|
| }
|
|
|
|
|
| +void SeqString::Truncate(int new_length) {
|
| + int string_size, allocated_string_size;
|
| + ASSERT(new_length < length() && new_length > 0);
|
| + if (IsSeqOneByteString()) {
|
| + allocated_string_size = SeqOneByteString::SizeFor(length());
|
| + string_size = SeqOneByteString::SizeFor(new_length);
|
| + } else {
|
| + allocated_string_size = SeqTwoByteString::SizeFor(length());
|
| + string_size = SeqTwoByteString::SizeFor(new_length);
|
| + }
|
| +
|
| + int delta = allocated_string_size - string_size;
|
| + set_length(new_length);
|
| +
|
| + // String sizes are pointer size aligned, so that we can use filler objects
|
| + // that are a multiple of pointer size.
|
| + Address end_of_string = address() + string_size;
|
| + GetHeap()->CreateFillerObjectAt(end_of_string, delta);
|
| + if (Marking::IsBlack(Marking::MarkBitFrom(this))) {
|
| + MemoryChunk::IncrementLiveBytesFromMutator(address(), -delta);
|
| + }
|
| +}
|
| +
|
| +
|
| uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) {
|
| // For array indexes mix the length into the hash as an array index could
|
| // be zero.
|
|
|