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

Side by Side Diff: src/objects.cc

Issue 347002: Derive string size constants... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 1 month 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
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 832
833 // Fill the remainder of the string with dead wood. 833 // Fill the remainder of the string with dead wood.
834 int new_size = this->Size(); // Byte size of the external String object. 834 int new_size = this->Size(); // Byte size of the external String object.
835 Heap::CreateFillerObjectAt(this->address() + new_size, size - new_size); 835 Heap::CreateFillerObjectAt(this->address() + new_size, size - new_size);
836 return true; 836 return true;
837 } 837 }
838 838
839 839
840 void String::StringShortPrint(StringStream* accumulator) { 840 void String::StringShortPrint(StringStream* accumulator) {
841 int len = length(); 841 int len = length();
842 if (len > kMaxMediumStringSize) { 842 if (len > kMaxMediumSize) {
843 accumulator->Add("<Very long string[%u]>", len); 843 accumulator->Add("<Very long string[%u]>", len);
844 return; 844 return;
845 } 845 }
846 846
847 if (!LooksValid()) { 847 if (!LooksValid()) {
848 accumulator->Add("<Invalid String>"); 848 accumulator->Add("<Invalid String>");
849 return; 849 return;
850 } 850 }
851 851
852 StringInputBuffer buf(this); 852 StringInputBuffer buf(this);
(...skipping 3800 matching lines...) Expand 10 before | Expand all | Expand 10 after
4653 static inline uint32_t HashField(uint32_t hash, bool is_array_index) { 4653 static inline uint32_t HashField(uint32_t hash, bool is_array_index) {
4654 uint32_t result = 4654 uint32_t result =
4655 (hash << String::kLongLengthShift) | String::kHashComputedMask; 4655 (hash << String::kLongLengthShift) | String::kHashComputedMask;
4656 if (is_array_index) result |= String::kIsArrayIndexMask; 4656 if (is_array_index) result |= String::kIsArrayIndexMask;
4657 return result; 4657 return result;
4658 } 4658 }
4659 4659
4660 4660
4661 uint32_t StringHasher::GetHashField() { 4661 uint32_t StringHasher::GetHashField() {
4662 ASSERT(is_valid()); 4662 ASSERT(is_valid());
4663 if (length_ <= String::kMaxShortStringSize) { 4663 if (length_ <= String::kMaxShortSize) {
4664 uint32_t payload; 4664 uint32_t payload;
4665 if (is_array_index()) { 4665 if (is_array_index()) {
4666 payload = v8::internal::HashField(array_index(), true); 4666 payload = v8::internal::HashField(array_index(), true);
4667 } else { 4667 } else {
4668 payload = v8::internal::HashField(GetHash(), false); 4668 payload = v8::internal::HashField(GetHash(), false);
4669 } 4669 }
4670 return (payload & ((1 << String::kShortLengthShift) - 1)) | 4670 return (payload & ((1 << String::kShortLengthShift) - 1)) |
4671 (length_ << String::kShortLengthShift); 4671 (length_ << String::kShortLengthShift);
4672 } else if (length_ <= String::kMaxMediumStringSize) { 4672 } else if (length_ <= String::kMaxMediumSize) {
4673 uint32_t payload = v8::internal::HashField(GetHash(), false); 4673 uint32_t payload = v8::internal::HashField(GetHash(), false);
4674 return (payload & ((1 << String::kMediumLengthShift) - 1)) | 4674 return (payload & ((1 << String::kMediumLengthShift) - 1)) |
4675 (length_ << String::kMediumLengthShift); 4675 (length_ << String::kMediumLengthShift);
4676 } else { 4676 } else {
4677 return v8::internal::HashField(length_, false); 4677 return v8::internal::HashField(length_, false);
4678 } 4678 }
4679 } 4679 }
4680 4680
4681 4681
4682 uint32_t String::ComputeLengthAndHashField(unibrow::CharacterStream* buffer, 4682 uint32_t String::ComputeLengthAndHashField(unibrow::CharacterStream* buffer,
(...skipping 3624 matching lines...) Expand 10 before | Expand all | Expand 10 after
8307 if (break_point_objects()->IsUndefined()) return 0; 8307 if (break_point_objects()->IsUndefined()) return 0;
8308 // Single beak point. 8308 // Single beak point.
8309 if (!break_point_objects()->IsFixedArray()) return 1; 8309 if (!break_point_objects()->IsFixedArray()) return 1;
8310 // Multiple break points. 8310 // Multiple break points.
8311 return FixedArray::cast(break_point_objects())->length(); 8311 return FixedArray::cast(break_point_objects())->length();
8312 } 8312 }
8313 #endif 8313 #endif
8314 8314
8315 8315
8316 } } // namespace v8::internal 8316 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698