Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: src/objects.cc

Issue 11348349: Improve array to string conversion. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 7604 matching lines...) Expand 10 before | Expand all | Expand 10 after
7615 // Isolate the array index form the full hash field. 7615 // Isolate the array index form the full hash field.
7616 *index = (kArrayIndexHashMask & field) >> kHashShift; 7616 *index = (kArrayIndexHashMask & field) >> kHashShift;
7617 return true; 7617 return true;
7618 } else { 7618 } else {
7619 StringInputBuffer buffer(this); 7619 StringInputBuffer buffer(this);
7620 return ComputeArrayIndex(&buffer, index, length()); 7620 return ComputeArrayIndex(&buffer, index, length());
7621 } 7621 }
7622 } 7622 }
7623 7623
7624 7624
7625 void SeqString::Truncate(int new_length) {
7626 int string_size, allocated_string_size;
7627 ASSERT(new_length < length() && new_length > 0);
7628 if (IsSeqOneByteString()) {
7629 allocated_string_size = SeqOneByteString::SizeFor(length());
7630 string_size = SeqOneByteString::SizeFor(new_length);
7631 } else {
7632 allocated_string_size = SeqTwoByteString::SizeFor(length());
7633 string_size = SeqTwoByteString::SizeFor(new_length);
7634 }
7635
7636 int delta = allocated_string_size - string_size;
7637 set_length(new_length);
7638
7639 // String sizes are pointer size aligned, so that we can use filler objects
7640 // that are a multiple of pointer size.
7641 Address end_of_string = address() + string_size;
7642 GetHeap()->CreateFillerObjectAt(end_of_string, delta);
7643 if (Marking::IsBlack(Marking::MarkBitFrom(this))) {
7644 MemoryChunk::IncrementLiveBytesFromMutator(address(), -delta);
7645 }
7646 }
7647
7648
7625 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { 7649 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) {
7626 // For array indexes mix the length into the hash as an array index could 7650 // For array indexes mix the length into the hash as an array index could
7627 // be zero. 7651 // be zero.
7628 ASSERT(length > 0); 7652 ASSERT(length > 0);
7629 ASSERT(length <= String::kMaxArrayIndexSize); 7653 ASSERT(length <= String::kMaxArrayIndexSize);
7630 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < 7654 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
7631 (1 << String::kArrayIndexValueBits)); 7655 (1 << String::kArrayIndexValueBits));
7632 7656
7633 value <<= String::kHashShift; 7657 value <<= String::kHashShift;
7634 value |= length << String::kArrayIndexHashLengthShift; 7658 value |= length << String::kArrayIndexHashLengthShift;
(...skipping 6244 matching lines...) Expand 10 before | Expand all | Expand 10 after
13879 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13903 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13880 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13904 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13881 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13905 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13882 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13906 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13883 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13907 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13884 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13908 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13885 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13909 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13886 } 13910 }
13887 13911
13888 } } // namespace v8::internal 13912 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698