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

Side by Side Diff: src/objects.cc

Issue 8187: Serendipitously arrange the tags so that String.length() becomes a branch-fre... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 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
OLDNEW
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 3950 matching lines...) Expand 10 before | Expand all | Expand 10 after
3961 3961
3962 uint32_t StringHasher::GetHashField() { 3962 uint32_t StringHasher::GetHashField() {
3963 ASSERT(is_valid()); 3963 ASSERT(is_valid());
3964 if (length_ <= String::kMaxShortStringSize) { 3964 if (length_ <= String::kMaxShortStringSize) {
3965 uint32_t payload; 3965 uint32_t payload;
3966 if (is_array_index()) { 3966 if (is_array_index()) {
3967 payload = v8::internal::HashField(array_index(), true); 3967 payload = v8::internal::HashField(array_index(), true);
3968 } else { 3968 } else {
3969 payload = v8::internal::HashField(GetHash(), false); 3969 payload = v8::internal::HashField(GetHash(), false);
3970 } 3970 }
3971 return (payload & 0x00FFFFFF) | (length_ << String::kShortLengthShift); 3971 return (payload & ((1 << String::kShortLengthShift) - 1)) |
3972 (length_ << String::kShortLengthShift);
3972 } else if (length_ <= String::kMaxMediumStringSize) { 3973 } else if (length_ <= String::kMaxMediumStringSize) {
3973 uint32_t payload = v8::internal::HashField(GetHash(), false); 3974 uint32_t payload = v8::internal::HashField(GetHash(), false);
3974 return (payload & 0x0000FFFF) | (length_ << String::kMediumLengthShift); 3975 return (payload & ((1 << String::kMediumLengthShift) - 1)) |
3976 (length_ << String::kMediumLengthShift);
3975 } else { 3977 } else {
3976 return v8::internal::HashField(length_, false); 3978 return v8::internal::HashField(length_, false);
3977 } 3979 }
3978 } 3980 }
3979 3981
3980 3982
3981 uint32_t String::ComputeLengthAndHashField(unibrow::CharacterStream* buffer, 3983 uint32_t String::ComputeLengthAndHashField(unibrow::CharacterStream* buffer,
3982 int length) { 3984 int length) {
3983 StringHasher hasher(length); 3985 StringHasher hasher(length);
3984 3986
(...skipping 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after
6722 // No break point. 6724 // No break point.
6723 if (break_point_objects()->IsUndefined()) return 0; 6725 if (break_point_objects()->IsUndefined()) return 0;
6724 // Single beak point. 6726 // Single beak point.
6725 if (!break_point_objects()->IsFixedArray()) return 1; 6727 if (!break_point_objects()->IsFixedArray()) return 1;
6726 // Multiple break points. 6728 // Multiple break points.
6727 return FixedArray::cast(break_point_objects())->length(); 6729 return FixedArray::cast(break_point_objects())->length();
6728 } 6730 }
6729 6731
6730 6732
6731 } } // namespace v8::internal 6733 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698