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

Side by Side Diff: src/objects.cc

Issue 2701003: Revert r4782. Fix issues 728, 732. (Closed)
Patch Set: fix review remarks, add static checks Created 10 years, 6 months 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
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 4832 matching lines...) Expand 10 before | Expand all | Expand 10 after
4843 4843
4844 *index = result; 4844 *index = result;
4845 return true; 4845 return true;
4846 } 4846 }
4847 4847
4848 4848
4849 bool String::SlowAsArrayIndex(uint32_t* index) { 4849 bool String::SlowAsArrayIndex(uint32_t* index) {
4850 if (length() <= kMaxCachedArrayIndexLength) { 4850 if (length() <= kMaxCachedArrayIndexLength) {
4851 Hash(); // force computation of hash code 4851 Hash(); // force computation of hash code
4852 uint32_t field = hash_field(); 4852 uint32_t field = hash_field();
4853 if ((field & kIsArrayIndexMask) == 0) return false; 4853 if ((field & kIsNotArrayIndexMask) != 0) return false;
4854 // Isolate the array index form the full hash field. 4854 // Isolate the array index form the full hash field.
4855 *index = (kArrayIndexHashMask & field) >> kHashShift; 4855 *index = (kArrayIndexHashMask & field) >> kHashShift;
4856 return true; 4856 return true;
4857 } else { 4857 } else {
4858 StringInputBuffer buffer(this); 4858 StringInputBuffer buffer(this);
4859 return ComputeArrayIndex(&buffer, index, length()); 4859 return ComputeArrayIndex(&buffer, index, length());
4860 } 4860 }
4861 } 4861 }
4862 4862
4863 4863
4864 static inline uint32_t HashField(uint32_t hash, 4864 static inline uint32_t HashField(uint32_t hash,
4865 bool is_array_index, 4865 bool is_array_index,
4866 int length = -1) { 4866 int length = -1) {
4867 uint32_t result = (hash << String::kHashShift); 4867 uint32_t result = (hash << String::kHashShift);
4868 if (is_array_index) { 4868 if (is_array_index) {
4869 // For array indexes mix the length into the hash as an array index could 4869 // For array indexes mix the length into the hash as an array index could
4870 // be zero. 4870 // be zero.
4871 ASSERT(length > 0); 4871 ASSERT(length > 0);
4872 ASSERT(length <= String::kMaxArrayIndexSize);
4872 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < 4873 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
4873 (1 << String::kArrayIndexValueBits)); 4874 (1 << String::kArrayIndexValueBits));
4874 result |= String::kIsArrayIndexMask; 4875 ASSERT(String::kMaxArrayIndexSize < (1 << String::kArrayIndexValueBits));
4876 result &= ~String::kIsNotArrayIndexMask;
4875 result |= length << String::kArrayIndexHashLengthShift; 4877 result |= length << String::kArrayIndexHashLengthShift;
4878 } else {
4879 result |= String::kIsNotArrayIndexMask;
4876 } 4880 }
4877 return result; 4881 return result;
4878 } 4882 }
4879 4883
4880 4884
4881 uint32_t StringHasher::GetHashField() { 4885 uint32_t StringHasher::GetHashField() {
4882 ASSERT(is_valid()); 4886 ASSERT(is_valid());
4883 if (length_ <= String::kMaxHashCalcLength) { 4887 if (length_ <= String::kMaxHashCalcLength) {
4884 if (is_array_index()) { 4888 if (is_array_index()) {
4885 return v8::internal::HashField(array_index(), true, length_); 4889 return v8::internal::HashField(array_index(), true, length_);
(...skipping 3828 matching lines...) Expand 10 before | Expand all | Expand 10 after
8714 if (break_point_objects()->IsUndefined()) return 0; 8718 if (break_point_objects()->IsUndefined()) return 0;
8715 // Single beak point. 8719 // Single beak point.
8716 if (!break_point_objects()->IsFixedArray()) return 1; 8720 if (!break_point_objects()->IsFixedArray()) return 1;
8717 // Multiple break points. 8721 // Multiple break points.
8718 return FixedArray::cast(break_point_objects())->length(); 8722 return FixedArray::cast(break_point_objects())->length();
8719 } 8723 }
8720 #endif 8724 #endif
8721 8725
8722 8726
8723 } } // namespace v8::internal 8727 } } // namespace v8::internal
OLDNEW
« src/objects.h ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698